Skip to content

Commit eb8bcdd

Browse files
committed
Add aliases for composite token components
Now every composite token has alias on components - transition (duration, delay, timing function) - typography (font size, font weight, etc.) - border (width, color, style) - shadow (x, y, blur, spread) - gradient (color)
1 parent df8e3f0 commit eb8bcdd

File tree

6 files changed

+1111
-403
lines changed

6 files changed

+1111
-403
lines changed

src/alias-token.svelte

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@
55
resolveTokenValue,
66
isAliasCircular,
77
} from "./state.svelte";
8-
import type { NodeRef, Value } from "./schema";
8+
import { isNodeRef, type NodeRef, type RawValue, type Value } from "./schema";
99
1010
let {
1111
nodeId,
1212
type,
13-
nodeRef,
13+
value,
1414
onChange,
1515
}: {
16-
/** makes sure alias is not circular */
17-
nodeId: string;
16+
/** makes sure alias is not circular, optional for composite components */
17+
nodeId?: string;
1818
/** shows tokens only for specified type */
1919
type: Value["type"];
20-
nodeRef: undefined | NodeRef;
20+
value: NodeRef | RawValue["value"];
2121
onChange: (newNodeRef: undefined | NodeRef) => void;
2222
} = $props();
2323
const key = $props.id();
2424
25+
const nodeRef = $derived(isNodeRef(value) ? value : undefined);
26+
2527
let aliasSearchInput = $state("");
2628
let highlightedIndex = $state(0);
2729
let popoverElement: undefined | HTMLDivElement;
@@ -49,7 +51,8 @@
4951
// Filter by type compatibility and check for circular dependencies
5052
return (
5153
otherTokenType === type &&
52-
!isAliasCircular(nodeId, item.nodeId, nodes)
54+
// composites can safely avoid circular check
55+
(!nodeId || !isAliasCircular(nodeId, item.nodeId, nodes))
5356
);
5457
}
5558
return false;

0 commit comments

Comments
 (0)