Skip to content

Commit

Permalink
feat: add svg icon default import to copy (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaevAlexandr authored May 26, 2023
1 parent e246bde commit 9c07bac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions .storybook/src/IconTooltip/IconTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import './IconTooltip.scss';

export interface IconTooltipProps {
componentName: string;
svgPath: string;
importLine: string;
importSvg: string;
importComponent: string;
children: React.ReactElement;
forceOpen?: boolean;
}
Expand All @@ -16,8 +16,8 @@ const b = block('icon-tooltip');

export function IconTooltip({
componentName,
svgPath,
importLine,
importSvg,
importComponent,
forceOpen,
children,
}: IconTooltipProps) {
Expand All @@ -31,16 +31,16 @@ export function IconTooltip({
{componentName}
</Label>
</div>
<div className={b('label')}>Path</div>
<div className={b('label')}>Svg</div>
<div className={b('value')}>
<Label type="copy" copyText={svgPath}>
{svgPath}
<Label type="copy" copyText={importSvg}>
{importSvg}
</Label>
</div>
<div className={b('label')}>Import</div>
<div className={b('label')}>Component</div>
<div className={b('value')}>
<Label type="copy" copyText={importLine}>
{importLine}
<Label type="copy" copyText={importComponent}>
{importComponent}
</Label>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions .storybook/src/Showcase.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export const Showcase: Story = () => {
<IconTooltip
key={meta.svgName}
componentName={meta.componentName}
svgPath={buildIconSvgPath(meta.svgName)}
importLine={buildIconImportLine(meta.componentName)}
importSvg={buildIconSvgPath(meta.svgName, meta.componentName)}
importComponent={buildIconImportLine(meta.componentName)}
forceOpen={filteredItems.length === 1}
>
<Button view="flat" size="xl">
Expand All @@ -92,8 +92,8 @@ export const Showcase: Story = () => {
};
Showcase.storyName = 'Showcase';

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

function buildIconImportLine(componentName: string) {
Expand Down

0 comments on commit 9c07bac

Please sign in to comment.