-
Notifications
You must be signed in to change notification settings - Fork 31
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
Allow JS plugin to nest token output #79
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@cobalt-ui/plugin-js': minor | ||
'@cobalt-ui/utils': minor | ||
--- | ||
|
||
Allow JS plugin output to be nested |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"color": { | ||
"$type": "color", | ||
"$description": "Brand blue", | ||
"black": {"$value": "#00193f"}, | ||
"blue": { | ||
"00": {"$value": "{color.black}"}, | ||
"10": {"$value": "#062053"}, | ||
"20": {"$value": "#0f2868"}, | ||
"30": {"$value": "#192f7d"}, | ||
"40": {"$value": "#223793"}, | ||
"50": { | ||
"$description": "Medium blue", | ||
"$value": "#2b3faa" | ||
}, | ||
"60": {"$value": "#3764ba"}, | ||
"70": {"$value": "#4887c9"}, | ||
"80": {"$value": "#5ca9d7"}, | ||
"90": {"$value": "#72cce5"}, | ||
"100": {"$value": "#89eff1"} | ||
}, | ||
"white": {"$value": "#ffffff"} | ||
}, | ||
"ui": { | ||
"fg": { | ||
"$type": "color", | ||
"$value": "{color.black}", | ||
"$extensions": { | ||
"mode": { | ||
"light": "{color.black}", | ||
"dark": "{color.white}" | ||
} | ||
} | ||
}, | ||
"bg": { | ||
"$type": "color", | ||
"$value": "{color.white}", | ||
"$extensions": { | ||
"mode": { | ||
"light": "{color.white}", | ||
"dark": "{color.black}" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Design Tokens | ||
* Autogenerated from tokens.json. | ||
* DO NOT EDIT! | ||
*/ | ||
|
||
import { | ||
ColorToken, | ||
ParsedColorToken, | ||
} from '@cobalt-ui/core'; | ||
|
||
export declare const tokens: { | ||
color: { | ||
black: ColorToken['$value']; | ||
blue: { | ||
10: ColorToken['$value']; | ||
20: ColorToken['$value']; | ||
30: ColorToken['$value']; | ||
40: ColorToken['$value']; | ||
50: ColorToken['$value']; | ||
60: ColorToken['$value']; | ||
70: ColorToken['$value']; | ||
80: ColorToken['$value']; | ||
90: ColorToken['$value']; | ||
100: ColorToken['$value']; | ||
'00': ColorToken['$value']; | ||
}; | ||
white: ColorToken['$value']; | ||
}; | ||
ui: { | ||
fg: ColorToken['$value']; | ||
bg: ColorToken['$value']; | ||
}; | ||
}; | ||
|
||
export declare const meta: { | ||
color: { | ||
black: ParsedColorToken; | ||
blue: { | ||
10: ParsedColorToken; | ||
20: ParsedColorToken; | ||
30: ParsedColorToken; | ||
40: ParsedColorToken; | ||
50: ParsedColorToken; | ||
60: ParsedColorToken; | ||
70: ParsedColorToken; | ||
80: ParsedColorToken; | ||
90: ParsedColorToken; | ||
100: ParsedColorToken; | ||
'00': ParsedColorToken; | ||
}; | ||
white: ParsedColorToken; | ||
}; | ||
ui: { | ||
fg: ParsedColorToken & { $extensions: { mode: typeof modes['ui']['fg'] } }; | ||
bg: ParsedColorToken & { $extensions: { mode: typeof modes['ui']['bg'] } }; | ||
}; | ||
}; | ||
|
||
export declare const modes: { | ||
ui: { | ||
fg: { | ||
light: ColorToken['$value']; | ||
dark: ColorToken['$value']; | ||
}; | ||
bg: { | ||
light: ColorToken['$value']; | ||
dark: ColorToken['$value']; | ||
}; | ||
}; | ||
}; | ||
|
||
export declare function token<K extends keyof typeof tokens>(tokenID: K, modeName?: never): typeof tokens[K]; | ||
export declare function token<K extends keyof typeof modes, M extends keyof typeof modes[K]>(tokenID: K, modeName: M): typeof modes[K][M]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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’m so sorry you had to wade through the manual
.d.ts
file generation. I don’t think a lot of this code was written as well as I’d like to be easy to refactor / work on.But this all looks fantastic 🙂
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.
Honestly it wasn’t that bad, it was just very specific! You did most of the work with the serializer function 😄
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.
For a lot of codegen stuff, taking a more AST approach is “cleaner” in some ways. But you pay for it in other ways in terms of upfront timesink / wading through the land of obscure bugs, not to mention when you set it down for a while, the confusion of “wait how does this thing work again?”
String mashing is sloppy but it’s real easy to compare “output good” vs “output bad” and know exactly where to make the adjustment