-
Notifications
You must be signed in to change notification settings - Fork 17
Extended Type Functionality and Adapted for newer DTCG format #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
Open
terynk
wants to merge
4
commits into
main
Choose a base branch
from
user/terynkum/bebop-web-tokens-exploration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d40d8a9
updated tool to accept $type and type entries for new dtcg format
terynkum d8b2016
added fontFamily, lineHeight, lineWeight, borderRadius types
terynkum 8be46db
updated extensions handling for codeSyntax
terynkum 8517dfd
addressed PR comments and removed duplicate logic
terynkum 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,19 @@ | ||
| /** Extract the first font family name from a CSS font-family string. */ | ||
| export function extractFirstFontFamily(value: any): string { | ||
| if (typeof value !== "string") { | ||
| return String(value) | ||
| } | ||
|
|
||
| // Check if split method exists | ||
| if (typeof value.split !== "function") { | ||
| return value.replace(/^['"]|['"]$/g, "") | ||
| } | ||
|
|
||
| // Split by comma to get the first font in the stack | ||
| const firstFont = value.split(",")[0].trim() | ||
|
|
||
| // Remove surrounding quotes (single or double) | ||
| const withoutQuotes = firstFont.replace(/^['"]|['"]$/g, "") | ||
|
|
||
| return withoutQuotes | ||
| } | ||
This file contains hidden or 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,8 @@ | ||
| /** Convert line height percentage values to multipliers. */ | ||
| export function convertLineHeightPercentageToMultiplier(value: any): number { | ||
| if (typeof value === "number") { | ||
| return value / 100 | ||
| } else { | ||
| return parseFloat(value) / 100 | ||
| } | ||
| } |
This file contains hidden or 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,25 @@ | ||
| /** Map numeric font weight values to their string equivalents. | ||
| * This mapping is for Segoe Sans font weights (our default font). Figma has its own terminology for font weights and not numeric values. Mapping the value to a word helps designers accurately predict what font is going to have what weight. | ||
| */ | ||
| export function mapFontWeight(value: any): string | number { | ||
| const fontWeightMap: Record<number, string> = { | ||
| 100: "hairline", | ||
| 200: "thin", | ||
| 300: "light", | ||
| 400: "semilight", | ||
| 500: "regular", | ||
| 600: "semibold", | ||
| 700: "bold", | ||
| 800: "extrabold", | ||
| 900: "black", | ||
| } | ||
|
|
||
| const numericValue = typeof value === "number" ? value : parseFloat(value) | ||
|
|
||
| if (!isNaN(numericValue) && fontWeightMap[numericValue]) { | ||
| return fontWeightMap[numericValue] | ||
| } | ||
|
|
||
| // Return original value if no mapping found | ||
| return value | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Is there a possibility that value.split doesn't have a valid return, which would cause this to crash?