Skip to content

Commit 9cb92c4

Browse files
committed
put px value into spacing scale
1 parent d862881 commit 9cb92c4

File tree

1 file changed

+22
-41
lines changed

1 file changed

+22
-41
lines changed

src/lib/default-config.ts

+22-41
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,9 @@ export const getDefaultConfig = () => {
7474
] as const
7575
const scaleOverflow = () => ['auto', 'hidden', 'clip', 'visible', 'scroll'] as const
7676
const scaleOverscroll = () => ['auto', 'contain', 'none'] as const
77-
const scaleInset = () =>
78-
[
79-
isFraction,
80-
'px',
81-
'full',
82-
'auto',
83-
isArbitraryVariable,
84-
isArbitraryValue,
85-
themeSpacing,
86-
] as const
77+
const scaleUnambiguousSpacing = () =>
78+
[isArbitraryVariable, isArbitraryValue, themeSpacing] as const
79+
const scaleInset = () => [isFraction, 'full', 'auto', ...scaleUnambiguousSpacing()] as const
8780
const scaleGridTemplateColsRows = () =>
8881
[isInteger, 'none', 'subgrid', isArbitraryVariable, isArbitraryValue] as const
8982
const scaleGridColRowStartAndEnd = () =>
@@ -97,19 +90,14 @@ export const getDefaultConfig = () => {
9790
[isInteger, 'auto', isArbitraryVariable, isArbitraryValue] as const
9891
const scaleGridAutoColsRows = () =>
9992
['auto', 'min', 'max', 'fr', isArbitraryVariable, isArbitraryValue] as const
100-
const scaleGap = () => [isArbitraryVariable, isArbitraryValue, themeSpacing] as const
10193
const scaleAlignPrimaryAxis = () =>
10294
['start', 'end', 'center', 'between', 'around', 'evenly', 'stretch', 'baseline'] as const
10395
const scaleAlignSecondaryAxis = () => ['start', 'end', 'center', 'stretch'] as const
104-
const scaleUnambiguousSpacing = () =>
105-
[isArbitraryVariable, isArbitraryValue, themeSpacing] as const
106-
const scalePadding = () => ['px', ...scaleUnambiguousSpacing()]
107-
const scaleMargin = () => ['px', 'auto', ...scaleUnambiguousSpacing()] as const
96+
const scaleMargin = () => ['auto', ...scaleUnambiguousSpacing()] as const
10897
const scaleSizing = () =>
10998
[
11099
isFraction,
111100
'auto',
112-
'px',
113101
'full',
114102
'dvw',
115103
'dvh',
@@ -120,9 +108,7 @@ export const getDefaultConfig = () => {
120108
'min',
121109
'max',
122110
'fit',
123-
isArbitraryVariable,
124-
isArbitraryValue,
125-
themeSpacing,
111+
...scaleUnambiguousSpacing(),
126112
] as const
127113
const scaleColor = () => [themeColor, isArbitraryVariable, isArbitraryValue] as const
128114
const scaleGradientStopPosition = () => [isPercent, isArbitraryLength] as const
@@ -184,8 +170,7 @@ export const getDefaultConfig = () => {
184170
const scaleRotate = () => ['none', isNumber, isArbitraryVariable, isArbitraryValue] as const
185171
const scaleScale = () => ['none', isNumber, isArbitraryVariable, isArbitraryValue] as const
186172
const scaleSkew = () => [isNumber, isArbitraryVariable, isArbitraryValue] as const
187-
const scaleTranslate = () =>
188-
[isFraction, 'full', 'px', isArbitraryVariable, isArbitraryValue, themeSpacing] as const
173+
const scaleTranslate = () => [isFraction, 'full', ...scaleUnambiguousSpacing()] as const
189174

190175
return {
191176
cacheSize: 500,
@@ -215,7 +200,7 @@ export const getDefaultConfig = () => {
215200
perspective: ['dramatic', 'near', 'normal', 'midrange', 'distant', 'none'],
216201
radius: [isTshirtSize],
217202
shadow: [isTshirtSize],
218-
spacing: [isNumber],
203+
spacing: ['px', isNumber],
219204
text: [isTshirtSize],
220205
tracking: ['tighter', 'tight', 'normal', 'wide', 'wider', 'widest'],
221206
},
@@ -442,10 +427,8 @@ export const getDefaultConfig = () => {
442427
isFraction,
443428
'full',
444429
'auto',
445-
isArbitraryVariable,
446-
isArbitraryValue,
447430
themeContainer,
448-
themeSpacing,
431+
...scaleUnambiguousSpacing(),
449432
],
450433
},
451434
],
@@ -549,17 +532,17 @@ export const getDefaultConfig = () => {
549532
* Gap
550533
* @see https://tailwindcss.com/docs/gap
551534
*/
552-
gap: [{ gap: scaleGap() }],
535+
gap: [{ gap: scaleUnambiguousSpacing() }],
553536
/**
554537
* Gap X
555538
* @see https://tailwindcss.com/docs/gap
556539
*/
557-
'gap-x': [{ 'gap-x': scaleGap() }],
540+
'gap-x': [{ 'gap-x': scaleUnambiguousSpacing() }],
558541
/**
559542
* Gap Y
560543
* @see https://tailwindcss.com/docs/gap
561544
*/
562-
'gap-y': [{ 'gap-y': scaleGap() }],
545+
'gap-y': [{ 'gap-y': scaleUnambiguousSpacing() }],
563546
/**
564547
* Justify Content
565548
* @see https://tailwindcss.com/docs/justify-content
@@ -610,47 +593,47 @@ export const getDefaultConfig = () => {
610593
* Padding
611594
* @see https://tailwindcss.com/docs/padding
612595
*/
613-
p: [{ p: scalePadding() }],
596+
p: [{ p: scaleUnambiguousSpacing() }],
614597
/**
615598
* Padding X
616599
* @see https://tailwindcss.com/docs/padding
617600
*/
618-
px: [{ px: scalePadding() }],
601+
px: [{ px: scaleUnambiguousSpacing() }],
619602
/**
620603
* Padding Y
621604
* @see https://tailwindcss.com/docs/padding
622605
*/
623-
py: [{ py: scalePadding() }],
606+
py: [{ py: scaleUnambiguousSpacing() }],
624607
/**
625608
* Padding Start
626609
* @see https://tailwindcss.com/docs/padding
627610
*/
628-
ps: [{ ps: scalePadding() }],
611+
ps: [{ ps: scaleUnambiguousSpacing() }],
629612
/**
630613
* Padding End
631614
* @see https://tailwindcss.com/docs/padding
632615
*/
633-
pe: [{ pe: scalePadding() }],
616+
pe: [{ pe: scaleUnambiguousSpacing() }],
634617
/**
635618
* Padding Top
636619
* @see https://tailwindcss.com/docs/padding
637620
*/
638-
pt: [{ pt: scalePadding() }],
621+
pt: [{ pt: scaleUnambiguousSpacing() }],
639622
/**
640623
* Padding Right
641624
* @see https://tailwindcss.com/docs/padding
642625
*/
643-
pr: [{ pr: scalePadding() }],
626+
pr: [{ pr: scaleUnambiguousSpacing() }],
644627
/**
645628
* Padding Bottom
646629
* @see https://tailwindcss.com/docs/padding
647630
*/
648-
pb: [{ pb: scalePadding() }],
631+
pb: [{ pb: scaleUnambiguousSpacing() }],
649632
/**
650633
* Padding Left
651634
* @see https://tailwindcss.com/docs/padding
652635
*/
653-
pl: [{ pl: scalePadding() }],
636+
pl: [{ pl: scaleUnambiguousSpacing() }],
654637
/**
655638
* Margin
656639
* @see https://tailwindcss.com/docs/margin
@@ -881,11 +864,9 @@ export const getDefaultConfig = () => {
881864
leading: [
882865
{
883866
leading: [
884-
isArbitraryVariable,
885-
isArbitraryValue,
886867
/** Deprecated since Tailwind CSS v4.0.0. @see https://github.com/tailwindlabs/tailwindcss.com/issues/2027#issuecomment-2620152757 */
887868
themeLeading,
888-
themeSpacing,
869+
...scaleUnambiguousSpacing(),
889870
],
890871
},
891872
],
@@ -978,7 +959,7 @@ export const getDefaultConfig = () => {
978959
* Text Indent
979960
* @see https://tailwindcss.com/docs/text-indent
980961
*/
981-
indent: [{ indent: ['px', ...scaleUnambiguousSpacing()] }],
962+
indent: [{ indent: scaleUnambiguousSpacing() }],
982963
/**
983964
* Vertical Alignment
984965
* @see https://tailwindcss.com/docs/vertical-align

0 commit comments

Comments
 (0)