Skip to content

Commit

Permalink
Docs(web-react): Add Icons demo #DS-900
Browse files Browse the repository at this point in the history
- Add Components and Icons tabs
- Create demo page for icons
  • Loading branch information
pavelklibani committed Sep 13, 2023
1 parent 8b0255f commit d9782f0
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/web-react/config/vite/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default defineConfig({
plugins: [
react(),
handlebars({
helpers: {
eq: (variable, value) => variable === value,
},
partialDirectory: resolve(__dirname, '../../partials'),
runtimeOptions: {
data: {
Expand All @@ -18,6 +21,9 @@ export default defineConfig({
.filter((item) => item.isDirectory())
.map((item) => item.name),
],
icons: [
...readdirSync('../../../icons/src/svg', { withFileTypes: true }).map((item) => item.name.slice(0, -4)),
],
},
},
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/web-react/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#> layout/default }}
{{#> layout/default page="components" }}

<section class="docs-Section">

Expand Down
12 changes: 12 additions & 0 deletions packages/web-react/partials/icons.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{#> layout/default page="icons"}}

<section class="docs-Section">

<h2 class="typography-heading-medium-text text-secondary-disabled mb-700 mb-tablet-900">Icons</h2>

<div id="root"></div>
<script type="module" src="./index.tsx"></script>

</section>

{{/layout/default }}
2 changes: 2 additions & 0 deletions packages/web-react/partials/layout/default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<main class="py-900 py-tablet-1200">
<div class="Container">

{{> tabs }}

{{> @partial-block }}

</div>
Expand Down
8 changes: 8 additions & 0 deletions packages/web-react/partials/tabs.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ul class="Tabs mb-1100" role="tablist">
<li class="Tabs__item">
<a href="/" class="Tabs__link{{#if (eq page 'components')}} is-selected" aria-selected="true{{/if}}">Components</a>
</li>
<li class="Tabs__item">
<a href="/src/icons/" class="Tabs__link{{#if (eq page 'icons')}} is-selected" aria-selected="true{{/if}}">Icons</a>
</li>
</ul>
47 changes: 47 additions & 0 deletions packages/web-react/src/icons/demo/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import { Grid, Text, Icon } from '../../components';

const Icons = () => {
// TODO: Get this list from folder like in other demos?
const icons = [
'add',
'check-plain',
'chevron-down',
'chevron-left',
'chevron-right',
'chevron-up',
'close',
'download',
'edit',
'file',
'hamburger',
'help',
'info',
'link',
'more',
'profile',
'reload',
'search',
'spinner',
'upload',
'visibility-off',
'visibility-on',
'warning',
];

return (
<Grid cols={2} tablet={4} desktop={6} UNSAFE_className="text-center my-1000">
{icons.map((icon) => (
<div key={icon} className="mb-600">
<Icon name={icon} />
{/* TODO: emphsasis="bold" made it too much 'bold' */}
<Text UNSAFE_className="mt-500" UNSAFE_style={{ fontWeight: 'bold' }}>
{icon}
</Text>
</div>
))}
</Grid>
);
};

export default Icons;
1 change: 1 addition & 0 deletions packages/web-react/src/icons/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{> icons }}
17 changes: 17 additions & 0 deletions packages/web-react/src/icons/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Because there is no `dist` directory during the CI run
/* eslint-disable import/no-extraneous-dependencies, import/extensions, import/no-unresolved */
import React from 'react';
import ReactDOM from 'react-dom/client';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, import/extensions, import/no-unresolved
// @ts-ignore: No declaration file
import icons from '@lmc-eu/spirit-icons/dist/icons';
import { IconsProvider } from '../context';
import Icons from './demo/icons';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<IconsProvider value={icons}>
<Icons />
</IconsProvider>
</React.StrictMode>,
);

0 comments on commit d9782f0

Please sign in to comment.