Skip to content

Conversation

@k35o
Copy link
Contributor

@k35o k35o commented May 30, 2024

Close #54

@vercel
Copy link

vercel bot commented May 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pandabox-z5kx ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 3:14am
export interface StrictTokensScopeOptions {
categories?: TokenCategory[]
props?: Array<keyof CssProperties | (string & {})>
shouldExclude?: boolean
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the excludeCategories: ['colors', 'spacing'] made more sense here instead of a boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fix it.


const transformed =
content.code.replace(regex, (match, prop, value) => {
if (shouldExclude) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my mind, this feature could be done simply by re-using the current logic in transformPropTypes and filling the categories with every possible TokenCategory (when excludeCategories is not empty) then filtering the array using excludeCategories

something like:

const allCategories = ["zIndex", "opacity", "colors", "fonts", "fontSizes", "fontWeights", "lineHeights", "letterSpacings", "sizes", "shadows", "spacing", "radii", "borders", "durations", "easings", "animations", "blurs", "gradients", "assets", "borderWidths", "aspectRatios", "containerNames"] // excludeCategories: ['colors', spacing'] -> allCategories.filter((cat) => !excludeCategories.include(cat))
@k35o
Copy link
Contributor Author

k35o commented May 31, 2024

We noticed that the type of values not included in CssProperties, such as textStyle, is broken, although from existing.

The type below will be any.

{ textStyle?: ConditionalValue<UtilityValues["textStyle"] | CssProperties["textStyle"]> }

I had to fix it in a separate issue or pr.

And, incidentally, that did not happen with the first way it was implemented.

if (strictTokenProps.includes(prop)) { const longhand = ctx.utility.shorthands.get(prop); return `${prop}?: ConditionalValue<${value} | CssProperties["${longhand || prop}"]>`; }; return match;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants