Skip to content

Commit

Permalink
feat: add svg icon default import to copy
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaevAlexandr committed May 26, 2023
1 parent e246bde commit 9700af6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .storybook/src/IconTooltip/IconTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface IconTooltipProps {
componentName: string;
svgPath: string;
importLine: string;
importSvg: string;
children: React.ReactElement;
forceOpen?: boolean;
}
Expand All @@ -17,6 +18,7 @@ const b = block('icon-tooltip');
export function IconTooltip({
componentName,
svgPath,
importSvg,
importLine,
forceOpen,
children,
Expand All @@ -37,7 +39,13 @@ export function IconTooltip({
{svgPath}
</Label>
</div>
<div className={b('label')}>Import</div>
<div className={b('label')}>Import Svg</div>
<div className={b('value')}>
<Label type="copy" copyText={importSvg}>
{importSvg}
</Label>
</div>
<div className={b('label')}>Import Component</div>
<div className={b('value')}>
<Label type="copy" copyText={importLine}>
{importLine}
Expand Down
5 changes: 5 additions & 0 deletions .storybook/src/Showcase.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const Showcase: Story = () => {
key={meta.svgName}
componentName={meta.componentName}
svgPath={buildIconSvgPath(meta.svgName)}
importSvg={buildImportSvgPath(meta.svgName, meta.componentName)}
importLine={buildIconImportLine(meta.componentName)}
forceOpen={filteredItems.length === 1}
>
Expand All @@ -92,6 +93,10 @@ export const Showcase: Story = () => {
};
Showcase.storyName = 'Showcase';

function buildImportSvgPath(svgName: string, componentName: string) {
return `import ${componentName}Icon '@gravity-ui/icons/svgs/${svgName}.svg'`;
}

function buildIconSvgPath(svgName: string) {
return `@gravity-ui/icons/svgs/${svgName}.svg`;
}
Expand Down

0 comments on commit 9700af6

Please sign in to comment.