Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
albnunes committed Jan 9, 2025
1 parent 2c713a7 commit 233a780
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
6 changes: 4 additions & 2 deletions packages/ui/src/lib/components/icon-button/icon-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
>
{#if disableTooltip}
<slot />
{:else}
{:else if tooltipContent || $$props['aria-label']}
<Tooltip content={tooltipContent ?? $$props['aria-label']}>
<slot />
</Tooltip>
{:else}
<slot />
{/if}
</svelte:element>

Expand Down Expand Up @@ -85,7 +87,7 @@
fill: var(--figma-color-icon-disabled);
color: var(--figma-color-icon-disabled); // TODO: check if this is correct
}
}
}
}
.fps-IconButton:focus-visible {
Expand Down
46 changes: 31 additions & 15 deletions packages/ui/src/lib/components/layer-tree/layer-tree-node.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
export let expandedNodes: Set<string>;
export let singleSelect: boolean = false;
export let clickable: boolean = true;
export let collapsable: boolean = true;
export let collapsableRoot: boolean = true;
export let isRoot: boolean = false;
let selected: boolean = false;
if (singleSelect) {
Expand All @@ -22,6 +25,8 @@
});
}
$: showChevron = data.children?.length > 0 && (isRoot ? collapsableRoot : collapsable);
function toggleExpand(node: LayerTreeData) {
if (expandedNodes.has(node.id)) {
if (!node.matches && !node.children?.some((child) => child.matches)) {
Expand Down Expand Up @@ -57,18 +62,20 @@
style:opacity={data.opacity || 1}
>
{#if data.children?.length > 0}
<button
class="layerTree--caret"
on:click|stopPropagation={() => !data.disabled && toggleExpand(data)}
class:expanded={expandedNodes.has(data.id)}
class:searching={data.matches || data.children.some((child) => child.matches)}
>
{#if expandedNodes.has(data.id)}
<Icon icon="ChevronDownSvg_16" />
{:else}
<Icon icon="ChevronRightSvg_16" />
{/if}
</button>
{#if showChevron}
<button
class="layerTree--caret"
on:click|stopPropagation={() => !data.disabled && toggleExpand(data)}
class:expanded={expandedNodes.has(data.id)}
class:searching={data.matches || data.children.some((child) => child.matches)}
>
{#if expandedNodes.has(data.id)}
<Icon icon="ChevronDownSvg_16" />
{:else}
<Icon icon="ChevronRightSvg_16" />
{/if}
</button>
{/if}
{/if}

<Layer
Expand All @@ -79,14 +86,23 @@
{selected}
actions={data.actions}
disabled={!clickable}

/>
</div>

{#if expandedNodes.has(data.id) && data.children?.length}
<div class="layerTree--children">
{#each data.children as child}
<svelte:self {expandedNodes} data={child} {singleSelect} {clickable} on:select on:toggle />
<svelte:self
{expandedNodes}
data={child}
{singleSelect}
{clickable}
{collapsable}
{collapsableRoot}
isRoot={false}
on:select
on:toggle
/>
{/each}
</div>
{/if}
Expand Down Expand Up @@ -133,7 +149,7 @@
}
:global(svg) {
transform: rotate(-90deg);
transform: rotate(0deg);
transition: transform 0.2s ease;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/src/lib/components/layer-tree/layer-tree.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
export let initiallyExpanded: boolean = false;
export let singleSelect: boolean = false;
export let clickable: boolean = false;
export let collapsable: boolean = true;
export let collapsableRoot: boolean = true;
function expandAll(node: LayerTreeData) {
expandedNodes.add(node.id);
Expand Down Expand Up @@ -105,6 +107,9 @@
{expandedNodes}
{singleSelect}
{clickable}
{collapsable}
{collapsableRoot}
isRoot={true}
on:select
on:toggle
/>
Expand Down

0 comments on commit 233a780

Please sign in to comment.