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

feat: incorporate chakra type generation in the workflow #1207

Merged
merged 9 commits into from
Nov 15, 2024

Conversation

Averethel
Copy link
Contributor

@Averethel Averethel commented Nov 15, 2024

References: https://smg-au.atlassian.net/browse/FED-421

Chakra-ui provides type generation based on the tokens defined in the theme.

This PR integrates the typegen in our workflow and ensures that we have proper type definitions in our component library

@automotiveengineeringbot automotiveengineeringbot deployed to branch-components-pkg-chakra-v3-type-generation November 15, 2024 14:10 Active
@Averethel Averethel force-pushed the chakra-v3/type-generation branch from 8cf3f22 to d2b9dd5 Compare November 15, 2024 14:12
@automotiveengineeringbot automotiveengineeringbot deployed to branch-components-pkg-chakra-v3-type-generation November 15, 2024 14:17 Active
@automotiveengineeringbot automotiveengineeringbot deployed to branch-components-pkg-chakra-v3-type-generation November 15, 2024 14:24 Active
@@ -11,7 +11,7 @@ const meta: Meta<typeof VehicleReference> = {
component: VehicleReference,
decorators: [
(Story) => (
<Box maxW={{ '2xs': '100%', md: '600px' }}>
<Box maxW={{ '2xs': 'full', md: '7xl' }}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Strict tokens mean we need to use design tokens here

@@ -43,8 +43,11 @@
"format:i18n": "npx sort-phraseapp-locales src/locales/de/dict.json src/locales/en/dict.json src/locales/fr/dict.json src/locales/it/dict.json --fix",
"format": "npm run format:i18n && npm run lint -- --fix",
"typecheck": "tsc --noEmit",
"typegen": "npx chakra typegen src/themes/autoScout24.ts --clean",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to pass a single system; both shapes are the same.

Comment on lines 5 to 6
fill?: 'none';
stroke?: 'currentColor';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

extending props as these values are not supported and we need them for animations in listings

@@ -15,7 +15,7 @@ export const CompareIcon = createIcon({
),
defaultProps: {
boxSize: 'sm',
fill: 'currentColor',
fill: 'currentBg',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

currentColor is not supported, currentBg makes sense for fill

Comment on lines 22 to 23
fill: 'none',
stroke: 'currentColor',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't seem to pass these as props, moving them to the path definition

@@ -51,19 +51,19 @@ const meta: Meta<typeof ThemeProvider> = {
box: (
<Box
display="flex"
direction="row"
flexDirection="row"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

direction works on Stack, but css direction attribute has nothing with flex directions.

@@ -1,6 +1,7 @@
import { defineTokens } from '@chakra-ui/react';

export const sizes = defineTokens.sizes({
auto: { value: 'auto' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this as a utility

@@ -1,6 +1,7 @@
import { defineTokens } from '@chakra-ui/react';

export const spacing = defineTokens.spacing({
'0': { value: '0' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this as a utility

tokenPath: string;
renderValue?: boolean;
renderDemo?: (tokenValue: string) => React.ReactNode;
renderDemo?: (tokenName: Tokens[Token]) => React.ReactNode;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we pass string and want to use it as a token value, strict tokens would yell at us.
This is why we add type parameters so we can properly cast a token name to an expected token.

@@ -22,7 +22,7 @@ const conversionToPixels = {

export const BorderRadius: StoryType = {
render: () => (
<TokenShowcase
<TokenShowcase<'radii'>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passing token type

@Averethel Averethel requested review from talamcol, masone, a team, braopa-smg and marko-markovic-smg and removed request for a team November 15, 2024 14:34
@Averethel Averethel marked this pull request as ready for review November 15, 2024 14:35
Comment on lines +139 to +140
none: { value: 'none' },
currentColor: { value: 'currentColor' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding this two utilities to streamline svg icons

@automotiveengineeringbot automotiveengineeringbot deployed to branch-components-pkg-chakra-v3-type-generation November 15, 2024 15:07 Active
@Averethel Averethel merged commit 2b01e16 into chakra-v3/root Nov 15, 2024
10 checks passed
@Averethel Averethel deleted the chakra-v3/type-generation branch November 15, 2024 15:09
@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.12.0-chakra-v3-2b01e1695f18cd9d9904654a954403715816f889.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.12.0-chakra-v3-48faf66f285855f83fe067b3e1023b7d201e3356.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.12.0-chakra-v3-cd3fc71866ab1effc5e6b22bb42a02eb8dd830bd.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.12.0-chakra-v3-b007baa34b3042d13cb9ebf96bd863b4c5b0e151.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.15.0-chakra-v3-f0a29c4689b248124d11f182c1701bad4af03971.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.16.0-chakra-v3-1179149485ac09b9c262ae8648e855b1ce506b02.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.16.0-chakra-v3-7a58fab7dfb141d07161cc692ea467088dbf00b4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.17.0-chakra-v3-ed38805868813712826f68f9fd6cbcde5f1c3db6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@automotiveengineeringbot
Copy link
Collaborator

🎉 This PR is included in version 23.17.0-chakra-v3-a3e5a49230070338bd79966543c4f14023c39dab.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants