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

build: add Chakra CLI #1

Closed
wants to merge 2 commits into from
Closed

build: add Chakra CLI #1

wants to merge 2 commits into from

Conversation

TylerAPfledderer
Copy link
Owner

Description

This PR adds back in the Chakra CLI to generate typing based on the custom theme configuration. This is helpful for IDE auto-completion to be able to recognize the correct tokens.

  • Adds scripts to both run the command once, and to have a watcher to update changes on the go.
  • Runs the postinstall script to generate the theme typing once yarn install has run
  • Applied the concurrently command remotely to run next dev and yarn theme:watch at the same time.

Related Issue

N/A

Copy link
Owner Author

@TylerAPfledderer TylerAPfledderer left a comment

Choose a reason for hiding this comment

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

A couple of thoughts...

@@ -3,7 +3,8 @@
"version": "8.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"dev": "npx concurrently \"yarn next dev\" \"yarn theme:watch\"",
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is very much a personal preference. concurrently is not added to the project as a dev dependency, but run remotely. The only requirement that would be prompted in the console is for the user to install it to their local machine. (This package is used in Chakra projects)

This command ensures that the dev environment and the Chakra CLI run in parallel without the user needing to remember an extra step.

Can certainly revert this if this is too much.

Comment on lines +21 to +22
"theme": "chakra-cli tokens ./src/@chakra-ui/theme.ts --strict-token-types --strict-component-types",
"theme:watch": "chakra-cli tokens ./src/@chakra-ui/theme.ts --strict-token-types --strict-component-types --watch"
Copy link
Owner Author

@TylerAPfledderer TylerAPfledderer Jan 27, 2024

Choose a reason for hiding this comment

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

The strict-token-types and strict-component-types flags are used to constrain the typing, so that a combination of the string and {} primitives are not part of the type unions.

At the moment, this can aid in auto-completion. When talking with a member of the Chakra team, we recognized two issues (one kinda related):

  • If we have a component that is taking is props that are typed with a shape from Chakra (i.e. StackProps) and you spread them into a component (i.e. Stack), you lose typing if you also directly add props to the component
<Stack
  color="blue.500" // Typing lost here
  {...props}
/>
  • I would expect that with strict typing of the themes that TypeScript would throw an error if a typo or invalid token exists. This unfortunately does not seem to be the case.

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "ESNext",
Copy link
Owner Author

Choose a reason for hiding this comment

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

Otherwise an error throws with es5:
Transforming object literal extensions to the configured target environment ("es5") is not supported yet

TylerAPfledderer pushed a commit that referenced this pull request Mar 26, 2024
pettinarip pushed a commit that referenced this pull request Apr 24, 2024
feat: add year and banner to translathathon page
TylerAPfledderer pushed a commit that referenced this pull request Jun 22, 2024
TylerAPfledderer pushed a commit that referenced this pull request Jun 25, 2024
wackerow pushed a commit that referenced this pull request Oct 22, 2024
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.

1 participant