Skip to content

Commit

Permalink
Merge pull request #12 from BrahimS/shared-ui/icones
Browse files Browse the repository at this point in the history
Shared UI/icones
  • Loading branch information
BrahimS authored Oct 15, 2024
2 parents 476d4d4 + cd4114c commit 91f8cc9
Show file tree
Hide file tree
Showing 15 changed files with 1,487 additions and 10 deletions.
90 changes: 88 additions & 2 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"dependencies": {
"react": "18.3.1",
"react-dom": "18.3.1",
"react-is": "18.3.1",
"styled-components": "5.3.6"
"react-is": "18.3.1"
},
"devDependencies": {
"@babel/core": "^7.25.7",
Expand Down Expand Up @@ -54,6 +53,7 @@
"@radix-ui/themes": "^3.1.4",
"@storybook/addon-essentials": "8.3.4",
"@storybook/addon-interactions": "^8.2.8",
"@storybook/addon-storysource": "^8.3.5",
"@storybook/core-server": "8.3.4",
"@storybook/jest": "^0.2.3",
"@storybook/react-vite": "8.3.4",
Expand Down Expand Up @@ -95,6 +95,7 @@
"react-router-dom": "^6.26.2",
"remove": "^0.1.5",
"storybook": "8.3.4",
"styled-components": "5.3.6",
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"tslib": "^2.3.0",
Expand Down
9 changes: 8 additions & 1 deletion shared-ui/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ['../src/lib/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-storysource',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/react-vite',
options: {
Expand All @@ -11,6 +15,9 @@ const config: StorybookConfig = {
},
},
},
docs: {
autodocs: true,
},
};

export default config;
Expand Down
Empty file removed shared-ui/.storybook/preview.ts
Empty file.
33 changes: 33 additions & 0 deletions shared-ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import type { Preview } from '@storybook/react';
import { GlobalStyle } from '../src/lib/styles/GlobalStyle';

const withGlobalStyle = (storyFn: () => JSX.Element) => (
<>
<GlobalStyle />
{storyFn()}
</>
);

const preview: Preview = {
globalTypes: {
theme: {
description: 'Global theme for components',
toolbar: {
// The label to show for this toolbar item
title: 'Theme',
icon: 'circlehollow',
// Array of plain string values or MenuItem shape (see below)
items: ['light', 'dark'],
// Change title based on selected value
dynamicTitle: true,
},
},
},
initialGlobals: {
theme: 'light',
},
decorators: [withGlobalStyle],
};

export default preview;
1 change: 1 addition & 0 deletions shared-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './lib/Main/MainContent';
export * from './lib/Menu/index';
export * from './lib/Navigation/MenuItem/index';
export * from './lib/styles';
export * from './lib/styles/utiles/index';
export * from './lib/Text/index';
export * from './lib/styles/styled.d';
export * from './lib/styles/GlobalStyle';
Expand Down
6 changes: 2 additions & 4 deletions shared-ui/src/lib/Head/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Helmet } from 'react-helmet';
import { fontUrl } from '../styles';
interface HeadProps {
title: string;
description: string;
Expand All @@ -11,10 +12,7 @@ export const Head = ({ title, description, keywords }: HeadProps) => {
<title>{title}</title>
<meta name="description" content={description} />
<meta name="keywords" content={keywords} />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
/>
<link rel="stylesheet" href={fontUrl} />
</Helmet>
);
};
88 changes: 88 additions & 0 deletions shared-ui/src/lib/Icones/Icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import styled, { css } from 'styled-components';
import { Icon, IconProps } from './Icon';
import { icons } from './paths';

const Meta = styled.div`
color: #666;
font-size: 12px;
`;

const Item = styled.li<{ minimal?: boolean }>`
display: inline-flex;
flex-direction: row;
align-items: center;
flex: 0 1 16%;
min-width: 120px;
margin: 16px;
svg {
margin-right: 6px;
width: 14px;
height: 14px;
}
${(props) =>
props.minimal &&
css`
flex: none;
min-width: auto;
padding: 0;
background: #fff;
margin: 16px;
svg {
display: block;
margin-right: 0;
width: 14px;
height: 14px;
}
`};
`;

const List = styled.ul`
display: flex;
flex-flow: row wrap;
list-style: none;
padding: 0;
margin: 0;
`;

const Header = styled.h2`
font-size: 16px;
margin: 16px;
`;

export default {
title: 'Icon',
component: Icon,
};

export const Basic = (args: IconProps) => <Icon {...args} />;
Basic.args = { icon: 'watch' };

export const Labels = () => (
<>
<Header>{Object.keys(icons).length} icons</Header>
<List>
{Object.keys(icons).map((key) => (
<Item key={key}>
<Icon icon={key as keyof typeof icons} aria-hidden />
<Meta>{key}</Meta>
</Item>
))}
</List>
</>
);

export const NoLabels = () => (
<>
<Header>{Object.keys(icons).length} icons</Header>
<List>
{Object.keys(icons).map((key) => (
<Item minimal key={key}>
<Icon icon={key as keyof typeof icons} aria-label={key} />
</Item>
))}
</List>
</>
);
27 changes: 27 additions & 0 deletions shared-ui/src/lib/Icones/Icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import styled from 'styled-components';
import { icons } from './paths';
export type IconType = keyof typeof icons;

export interface IconProps {
icon: IconType;
}

const Svg = styled.svg`
display: inline-block;
shape-rendering: inherit;
transform: translate3d(0, 0, 0);
vertical-align: middle;
path {
fill: currentColor;
}
`;

export const Icon: React.FC<IconProps> = ({ icon, ...props }: IconProps) => {
return (
<Svg viewBox="0 0 16 16" width="16px" height="16px" {...props}>
{icons[icon]}
</Svg>
);
};
Loading

0 comments on commit 91f8cc9

Please sign in to comment.