-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1522 when applying border tokens we always apply color as a hex inste…
…ad of style when available (#1531)
- Loading branch information
Showing
3 changed files
with
72 additions
and
9 deletions.
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,16 @@ | ||
import { MapValuesToTokensResult } from '@/types'; | ||
import { NodeTokenRefMap } from '@/types/NodeTokenRefMap'; | ||
import { AnyTokenList } from '@/types/tokens'; | ||
|
||
export function extractColorInBorderTokenForAlias(tokens: Map<string, AnyTokenList[number]>, values: NodeTokenRefMap, borderToken: string): MapValuesToTokensResult { | ||
const resolvedToken = tokens.get(borderToken); | ||
if (resolvedToken?.rawValue && typeof resolvedToken.rawValue === 'object' && 'color' in resolvedToken.rawValue && resolvedToken.rawValue.color) { | ||
const { color } = resolvedToken.rawValue; | ||
const { borderColor } = values; | ||
let colorTokenName = color; | ||
if (String(color).startsWith('$')) colorTokenName = String(color).slice(1, String(color).length); | ||
if (String(color).startsWith('{')) colorTokenName = String(color).slice(1, String(color).length - 1); | ||
values = { ...values, ...(borderColor ? { } : { borderColor: String(colorTokenName) }) }; | ||
} | ||
return values; | ||
} |
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