-
Notifications
You must be signed in to change notification settings - Fork 12
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
Set all type style properties explicitly #294
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@tailwind-toucan-base": major | ||
--- | ||
|
||
possibly breaking change that sets all type style properties explicitly, | ||
which could cause subtle, but unexpected, changes in the weight of rendered | ||
text if inherited parent styles are no longer applied. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,6 @@ | |
"packageManager": "[email protected]", | ||
"volta": { | ||
"node": "18.17.0", | ||
"yarn": "1.22.19", | ||
"npm": "9.8.1" | ||
"pnpm": "7.32.5" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,11 @@ module.exports = (fontSizes) => | |
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment explaining why certain properties are set to Also, not a big deal, but why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went with |
||
function addTextStyles({ addComponents, theme }, fontSize) { | ||
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-rendering | ||
let geometricPrecision = { textRendering: 'geometricPrecision' }; | ||
let underline = { textDecoration: 'underline' }; | ||
|
||
// geometricPrecision text rendering makes it appear slightly | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation! Do we want a "this is what we want for Toucan" at the end? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel that's implicit since we've included it, so not sure it needs that addition. |
||
// lighter than the standard font-weight | ||
let text = { | ||
'.geometric-precision-text': { | ||
...geometricPrecision, | ||
textRendering: 'geometricPrecision', | ||
}, | ||
}; | ||
|
||
|
@@ -24,114 +22,200 @@ function addTextStyles({ addComponents, theme }, fontSize) { | |
* fontSize and lineHeight when used in this type of object, every usage | ||
* provides *two* fontSizes (one desired, one is supposed to be the lineHeight, | ||
* but is interpreted as a fontSize here). | ||
* | ||
* We use the `initial` value to unset values that might be otherwise | ||
* inherited from parent elements eg. textRendering, textDecoration | ||
*/ | ||
let textStyles = { | ||
'.type-4xl': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize['4xl'], | ||
lineHeight: theme('lineHeight.13'), | ||
fontWeight: theme('fontWeight.medium'), | ||
letterSpacing: theme('letterSpacing.tight'), | ||
lineHeight: theme('lineHeight.13'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-3xl': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize['3xl'], | ||
lineHeight: theme('lineHeight.12'), | ||
fontWeight: theme('fontWeight.medium'), | ||
letterSpacing: theme('letterSpacing.tight'), | ||
lineHeight: theme('lineHeight.12'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-2xl': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize['2xl'], | ||
lineHeight: theme('lineHeight.10'), | ||
fontWeight: theme('fontWeight.medium'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.10'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-xl': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.xl, | ||
lineHeight: theme('lineHeight.8'), | ||
fontWeight: theme('fontWeight.medium'), | ||
...geometricPrecision, | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.8'), | ||
textDecoration: 'initial', | ||
textRendering: 'geometricPrecision', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are some of these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh nevermind I see that this was there from before. |
||
}, | ||
'.type-lg': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.lg, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.8'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-lg-medium': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.lg, | ||
lineHeight: theme('lineHeight.8'), | ||
fontWeight: theme('fontWeight.medium'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.8'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-lg-tight-medium': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.lg, | ||
lineHeight: theme('lineHeight.6'), | ||
fontWeight: theme('fontWeight.medium'), | ||
...geometricPrecision, | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.6'), | ||
textDecoration: 'initial', | ||
textRendering: 'geometricPrecision', | ||
}, | ||
'.type-md': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.md, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.6'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
// deprecated? md-medium? | ||
'.type-md-medium': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.md, | ||
lineHeight: theme('lineHeight.6'), | ||
fontWeight: theme('fontWeight.medium'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.6'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-md-underline': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.md, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.6'), | ||
...underline, | ||
textDecoration: 'underline', | ||
textRendering: 'initial', | ||
}, | ||
'.type-md-tight': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.md, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.5'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-md-tight-medium': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.md, | ||
lineHeight: theme('lineHeight.5'), | ||
fontWeight: theme('fontWeight.medium'), | ||
...geometricPrecision, | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.5'), | ||
textDecoration: 'initial', | ||
textRendering: 'geometricPrecision', | ||
}, | ||
'.type-md-tight-underline': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.md, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.5'), | ||
...underline, | ||
textDecoration: 'underline', | ||
textRendering: 'initial', | ||
}, | ||
'.type-sm-mono': { | ||
fontFamily: theme('fontFamily.mono'), | ||
fontSize: fontSize.sm, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.6'), | ||
fontFamily: theme('fontFamily.mono'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-sm-mono-tight': { | ||
fontSize: fontSize.sm, | ||
fontFamily: theme('fontFamily.mono'), | ||
fontSize: fontSize.sm, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.5'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-sm-mono-underline': { | ||
fontFamily: theme('fontFamily.mono'), | ||
fontSize: fontSize.sm, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.6'), | ||
fontFamily: theme('fontFamily.mono'), | ||
...underline, | ||
textDecoration: 'underline', | ||
textRendering: 'initial', | ||
}, | ||
'.type-xs': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.xs, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.5'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-xs-tight': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.xs, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.4'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-xs-tight-underline': { | ||
fontFamily: theme('fontFamily.sans'), | ||
fontSize: fontSize.xs, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.4'), | ||
...underline, | ||
textDecoration: 'underline', | ||
textRendering: 'initial', | ||
}, | ||
'.type-xs-mono': { | ||
fontFamily: theme('fontFamily.mono'), | ||
fontSize: fontSize.xs, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.6'), | ||
fontFamily: theme('fontFamily.mono'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
'.type-xxs-mono': { | ||
fontFamily: theme('fontFamily.mono'), | ||
fontSize: fontSize.xxs, | ||
fontWeight: theme('fontWeight.normal'), | ||
letterSpacing: theme('letterSpacing.normal'), | ||
lineHeight: theme('lineHeight.4'), | ||
fontFamily: theme('fontFamily.mono'), | ||
textDecoration: 'initial', | ||
textRendering: 'initial', | ||
}, | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can probably have only
node
andpnpm
under here, as it looks like we aren't usingyarn
ornpm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated