Skip to content

Commit b7de86c

Browse files
committed
[FEATURE] Add version filter
1 parent 5f8ffaf commit b7de86c

6 files changed

Lines changed: 66 additions & 3 deletions

File tree

assets/js/main.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ document.addEventListener("DOMContentLoaded", () => {
3737
}
3838
}
3939

40+
document.querySelectorAll('.btn-check[data-version]').forEach(el => {
41+
el.addEventListener('change', () => {
42+
const activeVersions = Array.from(
43+
document.querySelectorAll('.btn-check[data-version]:checked')
44+
).map(e => e.dataset.version);
45+
46+
const items = document.querySelectorAll('[data-versions]');
47+
48+
items.forEach((item) => {
49+
const versions = item.dataset.versions
50+
.trim()
51+
.split(/\s+/);
52+
53+
const match =
54+
activeVersions.length === 0
55+
? true
56+
: activeVersions.some(v => versions.includes(v));
57+
58+
item.classList.toggle('d-none', !match);
59+
});
60+
61+
});
62+
});
63+
4064
document.querySelectorAll('.code-copy-btn').forEach((button) => {
4165
button.addEventListener('click', () => {
4266
const codeBlock = button.nextElementSibling?.querySelector('code');

assets/scss/docs.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
@import 'docs/iconstage';
66
@import 'docs/preview';
77
@import 'docs/misc';
8+
@import "docs/version-filter";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.version-badge {
2+
cursor: pointer;
3+
user-select: none;
4+
transition: all .2s ease;
5+
opacity: .6;
6+
}
7+
8+
/* checked state */
9+
.btn-check:checked + .version-badge {
10+
opacity: 1;
11+
}
12+
13+
/* hover */
14+
.version-badge:hover {
15+
opacity: .85;
16+
}

tmpl/html/docs/_filters.html.twig

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,26 @@
77
</label>
88
</div>
99
{%- endif -%}
10-
<input class="form-control search mb-0" id="search" placeholder="Start typing to filter..." autocomplete="off">
10+
{%- if showVersionFilter is not defined or showVersionFilter -%}
11+
<div class="d-flex flex-wrap gap-2">
12+
<span class="me-2">Available in TYPO3</span>
13+
{%- for typo3version, version in typo3.versions -%}
14+
<input
15+
type="checkbox"
16+
class="btn-check"
17+
id="version-{{ typo3version }}"
18+
autocomplete="off"
19+
data-version="{{ typo3version }}"
20+
>
21+
22+
<label
23+
class="badge bg-primary version-badge"
24+
for="version-{{ typo3version }}"
25+
>
26+
{{ typo3version }}
27+
</label>
28+
{%- endfor -%}
29+
</div>
30+
{%- endif -%}
31+
<input class="form-control search mb-0 flex-shrink-0 w-auto" style="min-width: 220px;" id="search" placeholder="Start typing to filter..." autocomplete="off">
1132
</div>

tmpl/html/docs/index.html.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<h2 class="mb-0">Icons</h2>
1313
{%- include '_filters.html.twig' -%}
1414
</div>
15-
15+
1616
<div class="icongrid" id="iconlist">
1717
{%- for category in categories -%}
1818
{%- for iconIdentifier in category.icons -%}
@@ -22,6 +22,7 @@
2222
data-type="icon"
2323
data-identifier="{{ icon.identifier }}"
2424
data-search="{{ icon.identifier }} {{ icon._meta.tags|join(' ') }}"
25+
data-versions="{%- for typo3version, version in typo3.versions -%}{%- if version in icon._meta.changes %}{{ typo3version }} {% endif -%}{%- endfor -%}"
2526
{% if icon._meta.bidi %}data-bidi="true"{% endif %}
2627
href="{{ pathPrefix }}icons/{{ category.identifier }}/{{ icon.identifier }}.html"
2728
title="{{ icon.identifier }}"

tmpl/html/docs/section.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<div class="d-flex mb-4 align-items-center">
1313
<h2 class="mb-0">{{ category.title }}</h2>
14-
{%- include '_filters.html.twig' with { showBidiFilter: not category.rendering.menuview } -%}
14+
{%- include '_filters.html.twig' with { showBidiFilter: not category.rendering.menuview, showVersionFilter: not category.rendering.menuview } -%}
1515
</div>
1616

1717
{%- if category.rendering.menuview -%}

0 commit comments

Comments
 (0)