Skip to content

Commit c57b2b0

Browse files
authored
fix(editor): replace hidden layer badge with eye-off icon (#149)
1 parent 13f7502 commit c57b2b0

3 files changed

Lines changed: 39 additions & 11 deletions

File tree

src/__tests__/panels/domPanel.test.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { join } from 'path'
2525
import React from 'react'
2626
import { render, screen, cleanup, fireEvent, act, waitFor } from '@testing-library/react'
2727
import { DomPanel } from '@site/panels/DomPanel/DomPanel'
28+
import { LayerTreeNodeContent } from '@site/panels/DomPanel/LayerTreeNodeContent'
2829
import { useEditorStore } from '@site/store/store'
2930
import { makeSite, makePage, makeNode, makeVC, makeVCNode, makeVCTree } from '../fixtures'
3031

@@ -424,6 +425,32 @@ describe('DomPanel — tree accessibility', () => {
424425
expect(source).toContain('treeDropStyles.dropInvalid')
425426
})
426427

428+
it('hidden layer rows render a muted eye-off icon instead of a text badge', () => {
429+
const { container } = render(
430+
<LayerTreeNodeContent
431+
moduleId="base.container"
432+
displayName="Container"
433+
htmlTag="div"
434+
classSelectorChip={null}
435+
hasChildren={false}
436+
expanded={false}
437+
showIcon={false}
438+
showTag={false}
439+
showClasses={false}
440+
hidden
441+
/>,
442+
)
443+
444+
const hiddenIndicator = container.querySelector('[title="Hidden"]')
445+
expect(hiddenIndicator?.querySelector('svg')).not.toBeNull()
446+
expect(hiddenIndicator?.textContent).toBe('')
447+
448+
const css = readFileSync(TREE_NODE_CSS_PATH, 'utf8')
449+
const hiddenIndicatorBlock = css.match(/\.hiddenIndicator\s*\{[^}]*\}/s)?.[0] ?? ''
450+
expect(hiddenIndicatorBlock).toContain('color: var(--text-muted)')
451+
expect(css).not.toContain('.hiddenBadge')
452+
})
453+
427454
it('drag overlay is portaled outside the transformed panel to keep pointer alignment', () => {
428455
const source = readFileSync(DOM_PANEL_SOURCE_PATH, 'utf8')
429456

@@ -661,7 +688,7 @@ describe('DomPanel — tree keyboard navigation', () => {
661688
})).toBeDefined()
662689
})
663690

664-
it('keeps hidden nodes in the tree and marks them with a hidden badge', () => {
691+
it('keeps hidden nodes in the tree and marks them with a hidden icon', () => {
665692
loadContainerSite()
666693
act(() => {
667694
useEditorStore.getState().toggleNodeHidden('container-1')
@@ -670,6 +697,7 @@ describe('DomPanel — tree keyboard navigation', () => {
670697
render(<DomPanel />)
671698

672699
expect(screen.getByRole('treeitem', { name: /container, hidden/i })).toBeDefined()
673-
expect(screen.getByText('hidden')).toBeDefined()
700+
const hiddenIndicator = document.querySelector('[title="Hidden"]')
701+
expect(hiddenIndicator?.querySelector('svg')).not.toBeNull()
674702
})
675703
})

src/admin/pages/site/panels/DomPanel/LayerTreeNodeContent.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { MouseEventHandler, ReactNode } from 'react'
2+
import { EyeOffSolidIcon } from 'pixel-art-icons/icons/eye-off-solid'
23
import { TreeChevron, TreeIconSlot, TreeLabel, TreeLabelGroup } from '@site/ui/Tree'
34
import { ModuleIcon } from '@site/ui/ModuleIcon'
45
import { TagPill } from '@ui/components/TagPill'
@@ -87,8 +88,8 @@ export function LayerTreeNodeContent({
8788
</span>
8889
)}
8990
{hidden && (
90-
<span aria-hidden="true" className={styles.hiddenBadge}>
91-
hidden
91+
<span title="Hidden" aria-hidden="true" className={styles.hiddenIndicator}>
92+
<EyeOffSolidIcon size={13} color="currentColor" />
9293
</span>
9394
)}
9495
</>

src/admin/pages/site/panels/DomPanel/TreeNode.module.css

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
line-height: 1;
2424
}
2525

26-
.hiddenBadge {
26+
.hiddenIndicator {
2727
flex-shrink: 0;
28-
border-radius: var(--radius-sm);
29-
background: var(--bg-surface-3);
30-
color: var(--text-disabled);
31-
padding: var(--space-px) var(--space-2xs);
32-
font-size: var(--text-2xs);
33-
line-height: 1.3;
28+
display: inline-flex;
29+
align-items: center;
30+
justify-content: center;
31+
color: var(--text-muted);
32+
line-height: 0;
3433
}
3534

3635
/* ── Slot-instance row — dimmer chrome to distinguish structural nodes ───── */

0 commit comments

Comments
 (0)