Skip to content

Commit 497f046

Browse files
committed
Docs: Add docs for toggle/show/hide and examples. Move other visibility helpers to dedicated docs
1 parent d84dfd8 commit 497f046

File tree

20 files changed

+790
-337
lines changed

20 files changed

+790
-337
lines changed

docs/src/content/examples/query-clippingparent.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ shortTitle: '.clippingParent()'
44
id: 'query-clippingparent'
55
exampleType: 'component'
66
category: 'Query'
7-
subcategory: 'DOM Traversal'
7+
subcategory: 'Visibility'
88
tags: ['query', 'clipping', 'parent', 'overflow']
99
description: 'Finds nearest clipping parent element'
1010
tip: 'Essential for positioning dropdowns and tooltips that respect overflow boundaries'

docs/src/content/examples/query-containingparent.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ shortTitle: '.containingParent()'
44
id: 'query-containingparent'
55
exampleType: 'component'
66
category: 'Query'
7-
subcategory: 'DOM Traversal'
7+
subcategory: 'Visibility'
88
tags: ['query', 'containing', 'parent', 'position']
99
description: 'Finds nearest containing parent element'
1010
tip: 'Used for positioning elements relative to their containing block context'

docs/src/content/examples/query-is-visible.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ shortTitle: '.isVisible()'
44
id: 'query-is-visible'
55
exampleType: 'component'
66
category: 'Query'
7-
subcategory: 'Logical Operators'
7+
subcategory: 'Visibility'
88
tags: ['query', 'dom', 'is', 'visible', 'test', 'selector', 'traverse']
99
description: 'Tests if element is visible in the page'
1010
selectedFile: 'page.js'

docs/src/content/examples/query-naturaldisplay.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ shortTitle: '.naturalDisplay()'
44
id: 'query-naturaldisplay'
55
exampleType: 'component'
66
category: 'Query'
7-
subcategory: 'Dimensions'
7+
subcategory: 'Visibility'
88
tags: ['query', 'dimensions', 'display', 'natural', 'css']
99
description: 'Gets element natural display value ignoring display:none rules'
1010
tip: 'Useful for determining original display value before visibility changes'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: 'Query .hide()'
3+
shortTitle: '.hide()'
4+
id: 'query-visibility-hide'
5+
exampleType: 'component'
6+
category: 'Query'
7+
subcategory: 'Visibility'
8+
tags: ['query', 'visibility', 'display', 'hide']
9+
description: 'Hides elements by setting display to none'
10+
tip: 'hide() works on any element regardless of current display value'
11+
selectedFile: 'page.js'
12+
---
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: 'Query .show()'
3+
shortTitle: '.show()'
4+
id: 'query-visibility-show'
5+
exampleType: 'component'
6+
category: 'Query'
7+
subcategory: 'Visibility'
8+
tags: ['query', 'visibility', 'display', 'show']
9+
description: 'Shows hidden elements using their natural display value'
10+
tip: 'Use calculate: false for better performance with simple elements'
11+
selectedFile: 'page.js'
12+
---
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: 'Query .toggle()'
3+
shortTitle: '.toggle()'
4+
id: 'query-visibility-toggle'
5+
exampleType: 'component'
6+
category: 'Query'
7+
subcategory: 'Visibility'
8+
tags: ['query', 'visibility', 'display', 'toggle']
9+
description: 'Toggles element visibility between hidden and shown states'
10+
tip: 'toggle() intelligently shows or hides based on current display state'
11+
selectedFile: 'page.js'
12+
---
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.elements {
2+
padding: 15px;
3+
background: var(--standard-5);
4+
border-radius: var(--border-radius);
5+
margin-bottom: 20px;
6+
display: flex;
7+
flex-direction: column;
8+
gap: 10px;
9+
}
10+
11+
.item {
12+
padding: 10px;
13+
border-radius: var(--border-radius);
14+
font-weight: bold;
15+
}
16+
17+
.block-item {
18+
background: var(--blue-background-color);
19+
color: var(--blue-text-color);
20+
border: var(--blue-border);
21+
}
22+
23+
.inline-item {
24+
background: var(--green-background-color);
25+
color: var(--green-text-color);
26+
border: var(--green-border);
27+
display: inline-block;
28+
align-self: flex-start;
29+
}
30+
31+
.flex-container {
32+
background: var(--purple-background-color);
33+
color: var(--purple-text-color);
34+
border: var(--purple-border);
35+
display: flex;
36+
gap: 10px;
37+
38+
span {
39+
background: var(--orange-background-color);
40+
color: var(--orange-text-color);
41+
border: var(--orange-border);
42+
padding: 8px 12px;
43+
border-radius: var(--border-radius);
44+
}
45+
}
46+
47+
.controls {
48+
display: flex;
49+
gap: 10px;
50+
flex-wrap: wrap;
51+
margin-bottom: 20px;
52+
}
53+
54+
.status {
55+
padding: 10px;
56+
background: var(--standard-10);
57+
border-radius: var(--border-radius);
58+
font-family: monospace;
59+
60+
.count {
61+
font-weight: bold;
62+
}
63+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<p>Click buttons to hide visible elements</p>
2+
3+
<div class="elements">
4+
<div class="item block-item">Block Item 1</div>
5+
<div class="item block-item">Block Item 2</div>
6+
<span class="item inline-item">Inline 1</span>
7+
<span class="item inline-item">Inline 2</span>
8+
<div class="item flex-container">
9+
<span>Flex Item 1</span>
10+
<span>Flex Item 2</span>
11+
</div>
12+
</div>
13+
14+
<div class="controls">
15+
<ui-button class="hide-blocks">Hide Blocks</ui-button>
16+
<ui-button class="hide-inlines">Hide Inlines</ui-button>
17+
<ui-button class="hide-flex">Hide Flex</ui-button>
18+
<ui-button class="hide-all">Hide All</ui-button>
19+
<ui-button class="show-all">Show All</ui-button>
20+
</div>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { $ } from '@semantic-ui/query';
2+
3+
// Hide block elements
4+
$('.hide-blocks').on('click', () => {
5+
$('.block-item').hide();
6+
});
7+
8+
// Hide inline elements
9+
$('.hide-inlines').on('click', () => {
10+
$('.inline-item').hide();
11+
});
12+
13+
// Hide flex container
14+
$('.hide-flex').on('click', () => {
15+
$('.flex-container').hide();
16+
});
17+
18+
// Hide all elements
19+
$('.hide-all').on('click', () => {
20+
$('.item').hide();
21+
});
22+
23+
// Show all elements to reset
24+
$('.show-all').on('click', () => {
25+
$('.item').show();
26+
});

0 commit comments

Comments
 (0)