Skip to content

Commit

Permalink
feat(icons): add all icons in story
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelB committed Oct 9, 2024
1 parent d7e3bfd commit 435c183
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import '../app/styles/global.css';

const preview = {
parameters: {
layout: 'centered',
Expand Down Expand Up @@ -33,11 +35,11 @@ const preview = {
'Breaking changes',
'Faire une release',
'Architecture',
'Storybook'
'Storybook',
],
],
},
},
}
},
};
export default preview;
4 changes: 2 additions & 2 deletions app/stories/pix-icon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import * as ComponentStories from './pix-icon.stories';

> Permet d'utiliser les icônes disponible du Design System.
<Story of={ComponentStories.icon} height={60} />
<Story of={ComponentStories.allIcons} height={1050} />

## Usage

```html
<PixIcon @name="powerSettings", @plainIcon={{true}} />
<PixIcon @name="powerSettings" @plainIcon="{{true}}" />
```

## Arguments
Expand Down
31 changes: 31 additions & 0 deletions app/stories/pix-icon.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,34 @@ export const icon = (args) => ({
/>`,
context: args,
});

const icons = Object.entries(ICONS).flatMap(([name, icon]) =>
icon.plainIcon
? [
{ iconName: name, variant: false },
{ iconName: name, variant: true },
]
: { iconName: name, variant: false },
);

export const allIcons = (args) => {
return {
template: hbs`<ul class='icon-list'>
{{#each this.icons as |icon|}}
<li class='icon-list__cell'>
<PixIcon
@name={{icon.iconName}}
@plainIcon={{icon.variant}}
@alternativeText={{icon.iconName}}
@ariaHidden={{true}}
/>
<p class='icon-name'>{{icon.iconName}}&nbsp;{{if icon.variant '(plain)'}}</p>
</li>
{{/each}}
</ul>`,
context: args,
};
};

allIcons.bind({});
allIcons.args = { icons };
24 changes: 24 additions & 0 deletions app/styles/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* on utilise un fichier css car on a pas de loader scss */
.icon-list {
display: grid;
grid-template-columns: repeat(9, 1fr);
gap: .4rem;
}

.icon-list__cell {
display: flex;
flex-direction: column;
align-items: center;
height:60px;
padding-bottom: .3rem;
}

.icon-list__cell svg {
width: 2rem;
height: 2rem;
}

.icon-name {
color:var(--pix-neutral-800);
font-size: .75rem
}

0 comments on commit 435c183

Please sign in to comment.