Skip to content

Commit 9017c58

Browse files
committed
added filter to the showcase icon library to highlight mapped/unmapped icons
1 parent fa9e68c commit 9017c58

File tree

3 files changed

+99
-4
lines changed

3 files changed

+99
-4
lines changed

showcase/app/components/page-components/icon/sub-sections/library.gts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
*/
55

66
import Component from '@glimmer/component';
7+
import { tracked } from '@glimmer/tracking';
8+
import { on } from '@ember/modifier';
79

810
import ShwTextH2 from 'showcase/components/shw/text/h2';
911
import ShwTextH4 from 'showcase/components/shw/text/h4';
12+
import ShwTextBody from 'showcase/components/shw/text/body';
1013
import ShwGrid from 'showcase/components/shw/grid';
1114
import ShwLabel from 'showcase/components/shw/label';
1215
import ShwDivider from 'showcase/components/shw/divider';
@@ -25,6 +28,19 @@ import catalog from '@hashicorp/flight-icons/catalog.json';
2528
// ).sort();
2629

2730
export default class SubSectionIconLibrary extends Component {
31+
@tracked filterBy = '';
32+
33+
setLibraryFilter = (event: Event) => {
34+
const { value } = event.target as HTMLSelectElement;
35+
this.filterBy = value;
36+
};
37+
38+
get filterByClass() {
39+
return this.filterBy !== ''
40+
? `shw-component-icon-library-filter-${this.filterBy}`
41+
: '';
42+
}
43+
2844
get groupedIcons() {
2945
const groupedIcons: Record<string, string[]> = {}; // icons grouped by category
3046

@@ -50,12 +66,29 @@ export default class SubSectionIconLibrary extends Component {
5066
}
5167

5268
<template>
53-
<ShwTextH2>Library</ShwTextH2>
69+
<div class="shw-component-icon-library-header">
70+
<ShwTextH2>Library</ShwTextH2>
71+
<div class="shw-component-icon-library-filter">
72+
<label
73+
for="shw-component-icon-library-filter-control"
74+
class="shw-component-icon-library-filter-label"
75+
>Filter:</label>
76+
<select
77+
id="shw-component-icon-library-filter-control"
78+
class="shw-component-icon-library-filter-control"
79+
{{on "change" this.setLibraryFilter}}
80+
>
81+
<option value="">Show all</option>
82+
<option value="carbonized">With mapping</option>
83+
<option value="non-carbonized">Without mapping</option>
84+
</select>
85+
</div>
86+
</div>
5487

5588
{{#each-in this.groupedIcons as |categoryName categoryIcons|}}
5689
<ShwTextH4 @tag="h3">{{categoryName}}</ShwTextH4>
5790

58-
<ShwGrid @columns={{8}} @gap="1rem" as |SG|>
91+
<ShwGrid @columns={{8}} @gap="1rem" class={{this.filterByClass}} as |SG|>
5992
{{#each categoryIcons as |iconName|}}
6093
<SG.Item class="shw-component-icon-library-item">
6194
<HdsIcon @name={{iconName}} @size="24" />

showcase/app/components/shw/text/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export enum TextTagValues {
1313
P = 'p',
1414
Span = 'span',
1515
Div = 'div',
16+
Label = 'label',
1617
}
1718

1819
export type TextTags = `${TextTagValues}`;

showcase/app/styles/showcase-pages/icon.scss

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*/
55

66
// ICON
7-
// The icon page is currently displayed in 2 places,
8-
// foundations for FlightIcon and components for Hds::icon
7+
8+
@use "../typography" as *;
9+
910
body.page-components-icon {
1011
.shw-component-icon-theme-toggle-container {
1112
position: sticky;
@@ -39,9 +40,69 @@ body.page-components-icon {
3940
outline: 2px solid #0c0c0e;
4041
}
4142

43+
// LIBRARY
44+
45+
.shw-component-icon-library-header {
46+
display: flex;
47+
align-items: center;
48+
justify-content: space-between;
49+
}
50+
51+
.shw-component-icon-library-filter {
52+
display: flex;
53+
gap: 8px;
54+
align-items: center;
55+
}
56+
57+
.shw-component-icon-library-filter-label {
58+
@include shw-font-family('gilmer');
59+
60+
margin: 0;
61+
color: var(--shw-color-black);
62+
font-size: 0.9rem;
63+
line-height: 20px;
64+
}
65+
66+
.shw-component-icon-library-filter-control {
67+
@include shw-font-family('gilmer');
68+
69+
height: 24px;
70+
padding: 2px 24px 2px 8px;
71+
color: var(--shw-color-gray-100);
72+
font-size: 0.8rem;
73+
background-color: var(--shw-color-gray-600);
74+
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.34572 7H20.6543C21.8517 7 22.4504 8.4463 21.6028 9.29391L12.9519 17.9515C12.4272 18.4763 11.5728 18.4763 11.0481 17.9515L2.39722 9.29391C1.54961 8.4463 2.14832 7 3.34572 7Z' fill='%23808080'/%3E%3C/svg%3E"); // notice: the 'caret' color is hardcoded here!
75+
background-repeat: no-repeat;
76+
background-position: right 6px top 4px;
77+
background-size: 12px 12px;
78+
border: 1px solid var(--shw-color-gray-400);
79+
border-radius: 3px;
80+
appearance: none;
81+
82+
&:hover {
83+
background-color: var(--shw-color-gray-500);
84+
}
85+
86+
&:where(:focus-visible) {
87+
outline: 2px dashed var(--shw-color-action-active-foreground);
88+
}
89+
}
90+
4291
.shw-component-icon-library-item {
4392
display: flex;
4493
flex-direction: column;
4594
gap: 4px;
4695
}
96+
97+
.shw-component-icon-library-filter-carbonized {
98+
.shw-component-icon-library-item:has(.hds-icon:not([data-has-carbon-equivalent])) {
99+
opacity: 0.1;
100+
}
101+
}
102+
103+
.shw-component-icon-library-filter-non-carbonized {
104+
.shw-component-icon-library-item:has(.hds-icon[data-has-carbon-equivalent]) {
105+
opacity: 0.1;
106+
}
107+
}
47108
}

0 commit comments

Comments
 (0)