Skip to content

Commit 59bca4e

Browse files
committed
chore(docs): support shadow TokenLit
1 parent e4c0713 commit 59bca4e

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

docs/components/token-cell.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,39 @@ function renderGradientWithTokens(gradient: AST.GradientLit) {
3636
);
3737
}
3838

39+
function renderShadowWithTokens(shadow: AST.ShadowLit) {
40+
return (
41+
<span>
42+
{shadow.layers.map((layer, index) => (
43+
<Fragment key={index}>
44+
{layer.offsetX.value}
45+
{layer.offsetX.unit} {layer.offsetY.value}
46+
{layer.offsetY.unit} {layer.blur.value}
47+
{layer.blur.unit} {layer.spread.value}
48+
{layer.spread.unit}{" "}
49+
{layer.color.kind === "TokenLit" ? (
50+
<TokenLink id={layer.color.identifier} />
51+
) : (
52+
layer.color.value
53+
)}
54+
{index < shadow.layers.length - 1 ? ", " : ""}
55+
</Fragment>
56+
))}
57+
</span>
58+
);
59+
}
60+
3961
export function TokenCell(props: TokenCellProps) {
4062
const { isExpanded, values, resolvedValue } = props;
4163

4264
const isGradientWithTokens =
4365
resolvedValue.kind === "GradientLit" &&
4466
resolvedValue.stops.some((stop) => stop.color.kind === "TokenLit");
4567

68+
const isShadowWithTokens =
69+
resolvedValue.kind === "ShadowLit" &&
70+
resolvedValue.layers.some((layer) => layer.color.kind === "TokenLit");
71+
4672
return (
4773
<div className="flex justify-between" aria-expanded={isExpanded}>
4874
<div className="flex flex-col gap-1">
@@ -51,7 +77,9 @@ export function TokenCell(props: TokenCellProps) {
5177
<Fragment key={item.ref}>
5278
<div className="flex items-center gap-2">
5379
<TypeIndicator value={resolvedValue} />{" "}
54-
{index === values.length - 1 && isGradientWithTokens ? (
80+
{index === values.length - 1 && isShadowWithTokens ? (
81+
renderShadowWithTokens(resolvedValue as AST.ShadowLit)
82+
) : index === values.length - 1 && isGradientWithTokens ? (
5583
renderGradientWithTokens(resolvedValue as AST.GradientLit)
5684
) : item.ref.startsWith("$") ? (
5785
<TokenLink id={item.ref} description={item.description} />
@@ -69,7 +97,9 @@ export function TokenCell(props: TokenCellProps) {
6997
) : (
7098
<div className="flex items-center gap-2">
7199
<TypeIndicator value={resolvedValue} />{" "}
72-
{isGradientWithTokens ? (
100+
{isShadowWithTokens ? (
101+
renderShadowWithTokens(resolvedValue as AST.ShadowLit)
102+
) : isGradientWithTokens ? (
73103
renderGradientWithTokens(resolvedValue as AST.GradientLit)
74104
) : values[0].ref.startsWith("$") ? (
75105
<TokenLink id={values[0].ref} description={values[0].description} />

0 commit comments

Comments
 (0)