Skip to content

Commit

Permalink
Merge pull request #290 from dcastil/breaking-feature/170/move-separa…
Browse files Browse the repository at this point in the history
…tor-to-default-config

Move separator to config
  • Loading branch information
dcastil authored Aug 19, 2023
2 parents 18e2c71 + 1c41660 commit cf4cd80
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 2 deletions.
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

0 comments on commit cf4cd80

Please sign in to comment.