Skip to content

Commit e75eff6

Browse files
committed
added library section to the showcase page for Icon library
1 parent 861cfe7 commit e75eff6

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

showcase/app/components/page-components/icon/index.gts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
* Copyright IBM Corp. 2021, 2025
33
* SPDX-License-Identifier: MPL-2.0
44
*/
5+
56
import type { TemplateOnlyComponent } from '@ember/component/template-only';
7+
68
import { pageTitle } from 'ember-page-title';
79

810
import ShwTextH1 from 'showcase/components/shw/text/h1';
911

1012
import SubSectionSize from 'showcase/components/page-components/icon/sub-sections/size';
1113
import SubSectionColor from 'showcase/components/page-components/icon/sub-sections/color';
1214
import SubSectionDisplay from 'showcase/components/page-components/icon/sub-sections/display';
15+
import SubSectionLibrary from 'showcase/components/page-components/icon/sub-sections/library';
1316

1417
const IconIndex: TemplateOnlyComponent = <template>
1518
{{pageTitle "Icon Component"}}
@@ -20,6 +23,7 @@ const IconIndex: TemplateOnlyComponent = <template>
2023
<SubSectionSize />
2124
<SubSectionColor />
2225
<SubSectionDisplay />
26+
<SubSectionLibrary />
2327
</section>
2428
</template>;
2529

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { array } from '@ember/helper';
99
import ShwTextH2 from 'showcase/components/shw/text/h2';
1010
import ShwTextH4 from 'showcase/components/shw/text/h4';
1111
import ShwFlex from 'showcase/components/shw/flex';
12+
import ShwDivider from 'showcase/components/shw/divider';
1213

1314
import { HdsIcon } from '@hashicorp/design-system-components/components';
1415

@@ -76,6 +77,8 @@ const SubSectionDisplay: TemplateOnlyComponent = <template>
7677

7778
{{/each}}
7879
{{/let}}
80+
81+
<ShwDivider />
7982
</template>;
8083

8184
export default SubSectionDisplay;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Copyright IBM Corp. 2021, 2025
3+
* SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
import Component from '@glimmer/component';
7+
8+
import ShwTextH2 from 'showcase/components/shw/text/h2';
9+
import ShwTextH4 from 'showcase/components/shw/text/h4';
10+
import ShwGrid from 'showcase/components/shw/grid';
11+
import ShwLabel from 'showcase/components/shw/label';
12+
import ShwDivider from 'showcase/components/shw/divider';
13+
14+
import { HdsIcon } from '@hashicorp/design-system-components/components';
15+
import catalog from '@hashicorp/flight-icons/catalog.json';
16+
17+
import type { IconName } from '@hashicorp/flight-icons/svg';
18+
19+
export default class SubSectionIconLibrary extends Component {
20+
get groupedIcons() {
21+
const groupedIcons: Record<string, IconName[]> = {}; // icons grouped by category
22+
23+
catalog.assets
24+
.filter(({ size }) => size === '24')
25+
.forEach((icon) => {
26+
const category = icon.category;
27+
if (!groupedIcons[category]) {
28+
groupedIcons[category] = [];
29+
}
30+
groupedIcons[category].push(icon.iconName as IconName);
31+
});
32+
33+
// Sort the categories alphabetically
34+
const sortedGroupedIcons: Record<string, IconName[]> = {};
35+
Object.keys(groupedIcons)
36+
.sort()
37+
.forEach((category) => {
38+
sortedGroupedIcons[category] = groupedIcons[category] as IconName[];
39+
});
40+
41+
return sortedGroupedIcons;
42+
}
43+
44+
<template>
45+
<div class="shw-component-icon-library-header">
46+
<ShwTextH2>Library</ShwTextH2>
47+
</div>
48+
49+
{{#each-in this.groupedIcons as |categoryName categoryIcons|}}
50+
<ShwTextH4 @tag="h3">{{categoryName}}</ShwTextH4>
51+
52+
<ShwGrid @columns={{8}} @gap="1rem" as |SG|>
53+
{{#each categoryIcons as |iconName|}}
54+
<SG.Item class="shw-component-icon-library-item">
55+
<HdsIcon @name={{iconName}} @size="24" />
56+
<ShwLabel
57+
class="hds-typography-body-100 shw-icon-label"
58+
>{{iconName}}</ShwLabel>
59+
</SG.Item>
60+
{{/each}}
61+
</ShwGrid>
62+
63+
<ShwDivider @level={{2}} />
64+
65+
{{/each-in}}
66+
</template>
67+
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,18 @@ body.page-components-icon {
2929
background: #0c0c0e;
3030
outline: 2px solid #0c0c0e;
3131
}
32+
33+
// LIBRARY
34+
35+
.shw-component-icon-library-header {
36+
display: flex;
37+
align-items: center;
38+
justify-content: space-between;
39+
}
40+
41+
.shw-component-icon-library-item {
42+
display: flex;
43+
flex-direction: column;
44+
gap: 4px;
45+
}
3246
}

0 commit comments

Comments
 (0)