Skip to content

Commit 3bf6b71

Browse files
authored
Add "library section" to the showcase page for Icon library to improve Percy coverage (#3723)
1 parent 7fb232d commit 3bf6b71

File tree

8 files changed

+116
-22
lines changed

8 files changed

+116
-22
lines changed

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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/color.gts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ const SubSectionColor: TemplateOnlyComponent = <template>
2323
<SF.Item as |SFI|>
2424
<SFI.Label>unspecified color (<code>currentColor</code>)</SFI.Label>
2525
<div>
26-
<HdsIcon @name="lock-fill" @size="24" />
26+
<HdsIcon @name="plus-circle-fill" @size="24" />
2727
</div>
2828
</SF.Item>
2929
<SF.Item as |SGI|>
3030
<SGI.Label>parent with <code>#e12568</code> color</SGI.Label>
3131
<div {{style color="#e12568"}}>
32-
<HdsIcon @name="lock-fill" @size="24" />
32+
<HdsIcon @name="plus-circle-fill" @size="24" />
3333
</div>
3434
</SF.Item>
3535
</ShwFlex>
@@ -41,7 +41,7 @@ const SubSectionColor: TemplateOnlyComponent = <template>
4141
{{#each COLORS as |color|}}
4242
<SG.Item @label={{color}}>
4343
<div class="shw-component-icon-sample-color--{{color}}">
44-
<HdsIcon @name="lock-fill" @color={{color}} @size="24" />
44+
<HdsIcon @name="plus-circle-fill" @color={{color}} @size="24" />
4545
</div>
4646
</SG.Item>
4747
{{/each}}
@@ -53,12 +53,12 @@ const SubSectionColor: TemplateOnlyComponent = <template>
5353
<ShwFlex @direction="column" as |SF|>
5454
<SF.Item as |SGI|>
5555
<SGI.Label><code>#e91e63</code></SGI.Label>
56-
<HdsIcon @name="lock-fill" @color="#e91e63" @size="24" />
56+
<HdsIcon @name="plus-circle-fill" @color="#e91e63" @size="24" />
5757
</SF.Item>
5858
<SF.Item as |SGI|>
5959
<SGI.Label><code>--token-color-palette-purple-400</code></SGI.Label>
6060
<HdsIcon
61-
@name="lock-fill"
61+
@name="plus-circle-fill"
6262
@color="var(--token-color-palette-purple-400)"
6363
@size="24"
6464
/>
@@ -69,7 +69,7 @@ const SubSectionColor: TemplateOnlyComponent = <template>
6969
<code>green !important</code>
7070
</SGI.Label>
7171
<div {{style color="green !important"}}>
72-
<HdsIcon @name="lock-fill" @color="orange" @size="24" />
72+
<HdsIcon @name="plus-circle-fill" @color="orange" @size="24" />
7373
</div>
7474
</SF.Item>
7575
</ShwFlex>

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

Lines changed: 14 additions & 11 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

@@ -23,9 +24,9 @@ const SubSectionDisplay: TemplateOnlyComponent = <template>
2324
"Block (default)"
2425
}}</ShwTextH4>
2526

26-
<ShwFlex class="shw-foundation-outline-icons" as |SF|>
27+
<ShwFlex class="shw-component-outline-icons" as |SF|>
2728
<SF.Item @label="single icon">
28-
<HdsIcon @name="bookmark" @isInline={{isInline}} />
29+
<HdsIcon @name="bookmark-fill" @isInline={{isInline}} />
2930
</SF.Item>
3031
<SF.Item @label="multiple icons">
3132
<HdsIcon @name="alert-circle-fill" @isInline={{isInline}} />
@@ -34,29 +35,29 @@ const SubSectionDisplay: TemplateOnlyComponent = <template>
3435
</SF.Item>
3536
</ShwFlex>
3637

37-
<ShwFlex class="shw-foundation-outline-icons" @gap="4rem" as |SG|>
38+
<ShwFlex class="shw-component-outline-icons" @gap="4rem" as |SG|>
3839
<SG.Item @label="icon + inline text">
39-
<HdsIcon @name="bookmark" @isInline={{isInline}} />
40+
<HdsIcon @name="bookmark-fill" @isInline={{isInline}} />
4041
<span class="hds-typography-body-200">Lorem ipsum dolor</span>
4142
</SG.Item>
4243
<SG.Item @label="icon + inline text (inside flexbox)">
43-
<div class="shw-foundation-icon-container-flex">
44-
<HdsIcon @name="bookmark" @isInline={{isInline}} />
44+
<div class="shw-component-icon-container-flex">
45+
<HdsIcon @name="bookmark-fill" @isInline={{isInline}} />
4546
<span class="hds-typography-body-200">Lorem ipsum dolor</span>
4647
</div>
4748
</SG.Item>
4849
<SG.Item @label="icon + inline text (inside grid)">
49-
<div class="shw-foundation-icon-container-grid">
50-
<HdsIcon @name="bookmark" @isInline={{isInline}} />
50+
<div class="shw-component-icon-container-grid">
51+
<HdsIcon @name="bookmark-fill" @isInline={{isInline}} />
5152
<span class="hds-typography-body-200">Lorem ipsum dolor</span>
5253
</div>
5354
</SG.Item>
5455
</ShwFlex>
5556

56-
<ShwFlex class="shw-foundation-outline-icons" @gap="4rem" as |SF|>
57+
<ShwFlex class="shw-component-outline-icons" @gap="4rem" as |SF|>
5758
<SF.Item @label="icons interleaved with inline text">
5859
<span class="hds-typography-body-200">Lorem ipsum dolor</span>
59-
<HdsIcon @name="bookmark" @isInline={{isInline}} />
60+
<HdsIcon @name="bookmark-fill" @isInline={{isInline}} />
6061
<span class="hds-typography-body-200">Sit amet consectetur</span>
6162
<HdsIcon @name="alert-circle-fill" @isInline={{isInline}} />
6263
<HdsIcon @name="alert-diamond-fill" @isInline={{isInline}} />
@@ -65,7 +66,7 @@ const SubSectionDisplay: TemplateOnlyComponent = <template>
6566
</SF.Item>
6667
<SF.Item @label="icons interleaved with block text">
6768
<p class="hds-typography-body-200">Lorem ipsum dolor</p>
68-
<HdsIcon @name="bookmark" @isInline={{isInline}} />
69+
<HdsIcon @name="bookmark-fill" @isInline={{isInline}} />
6970
<p class="hds-typography-body-200">Sit amet consectetur</p>
7071
<HdsIcon @name="alert-circle-fill" @isInline={{isInline}} />
7172
<HdsIcon @name="alert-diamond-fill" @isInline={{isInline}} />
@@ -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/_globals.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,8 @@ body {
236236
main section:not([data-test-percy]) {
237237
display: none !important;
238238
}
239+
// disable icons animations when Percy is taking screenshots
240+
.hds-icon--animation-loading {
241+
animation: none !important;
242+
}
239243
}

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@
44
*/
55

66
// ICON
7-
// The icon page is currently displayed in 2 places,
8-
// foundations for FlightIcon and components for Hds::icon
97
body.page-components-icon {
10-
.shw-foundation-outline-icons {
8+
.shw-component-outline-icons {
119
.hds-icon {
1210
outline: 1px dotted #CCC;
1311
}
1412
}
1513

16-
.shw-foundation-icon-container-flex {
14+
.shw-component-icon-container-flex {
1715
display: flex;
1816
gap: 4px;
1917
align-items: center;
2018
}
2119

22-
.shw-foundation-icon-container-grid {
20+
.shw-component-icon-container-grid {
2321
display: grid;
2422
grid-template-columns: auto 1fr;
2523
gap: 4px;
@@ -31,4 +29,18 @@ body.page-components-icon {
3129
background: #0c0c0e;
3230
outline: 2px solid #0c0c0e;
3331
}
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+
}
3446
}

showcase/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@glint/template": "^1.5.2",
6060
"@hashicorp/design-system-components": "workspace:*",
6161
"@hashicorp/design-system-tokens": "workspace:*",
62+
"@hashicorp/flight-icons": "workspace:*",
6263
"@nullvoxpopuli/ember-composable-helpers": "^5.2.11",
6364
"@percy/cli": "^1.30.5",
6465
"@percy/ember": "^4.2.0",

0 commit comments

Comments
 (0)