Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move separator to config #290

Merged
merged 2 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function getDefaultConfig() {

return {
cacheSize: 500,
separator: ':',
theme: {
colors: [isAny],
spacing: [isLength],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/modifier-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Config } from './types'
export const IMPORTANT_MODIFIER = '!'

export function createSplitModifiers(config: Config) {
const separator = config.separator || ':'
const separator = config.separator
const isSeparatorSingleCharacter = separator.length === 1
const firstSeparatorCharacter = separator[0]
const separatorLength = separator.length
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Config {
* Custom separator for modifiers in Tailwind classes
* @see https://tailwindcss.com/docs/configuration#separator
*/
separator?: string
separator: string
/**
* Theme scales used in classGroups.
* The keys are the same as in the Tailwind config but the values are sometimes defined more broadly.
Expand Down
2 changes: 2 additions & 0 deletions tests/create-tailwind-merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createTailwindMerge } from '../src'
test('createTailwindMerge works with single config function', () => {
const tailwindMerge = createTailwindMerge(() => ({
cacheSize: 20,
separator: ':',
theme: {},
classGroups: {
fooKey: [{ fooKey: ['bar', 'baz'] }],
Expand Down Expand Up @@ -42,6 +43,7 @@ test('createTailwindMerge works with multiple config functions', () => {
const tailwindMerge = createTailwindMerge(
() => ({
cacheSize: 20,
separator: ':',
theme: {},
classGroups: {
fooKey: [{ fooKey: ['bar', 'baz'] }],
Expand Down
2 changes: 2 additions & 0 deletions tests/merge-configs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test('mergeConfigs has correct behavior', () => {
mergeConfigs(
{
cacheSize: 50,
separator: ':',
theme: {
hi: ['ho'],
},
Expand All @@ -28,6 +29,7 @@ test('mergeConfigs has correct behavior', () => {
),
).toEqual({
cacheSize: 50,
separator: ':',
theme: {
hi: ['ho'],
},
Expand Down
1 change: 1 addition & 0 deletions tests/modifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test('conflicts across postfix modifiers', () => {

const customTwMerge = createTailwindMerge(() => ({
cacheSize: 10,
separator: ':',
theme: {},
classGroups: {
foo: ['foo-1/2', 'foo-2/3'],
Expand Down
3 changes: 3 additions & 0 deletions tests/public-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ test('createTailwindMerge() has correct inputs and outputs', () => {
expect(
createTailwindMerge(() => ({
cacheSize: 0,
separator: ':',
theme: {},
classGroups: {},
conflictingClassGroups: {},
Expand All @@ -92,6 +93,7 @@ test('createTailwindMerge() has correct inputs and outputs', () => {

const tailwindMerge = createTailwindMerge(() => ({
cacheSize: 20,
separator: ':',
theme: {},
classGroups: {
fooKey: [{ fooKey: ['bar', 'baz'] }],
Expand Down Expand Up @@ -156,6 +158,7 @@ test('mergeConfigs has correct inputs and outputs', () => {
mergeConfigs(
{
cacheSize: 50,
separator: ':',
theme: {},
classGroups: {
fooKey: [{ fooKey: ['one', 'two'] }],
Expand Down
Loading