Skip to content

Commit

Permalink
feat: add custom example
Browse files Browse the repository at this point in the history
  • Loading branch information
Niznikr committed Sep 24, 2024
1 parent 15485a9 commit 3f3a2e7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .storybook/custom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { withThemeByDataAttribute } from '@storybook/addon-themes';
import { themes } from '@storybook/theming';
import { BrowserRouter, useNavigate } from 'react-router-dom';

import custom from './custom.svg';
import { allModes } from './modes';

import '../packages/components/src/styles/themes.css';
Expand All @@ -30,6 +31,19 @@ fetch(sprite)
console.log('Failed to fetch sprite', err);
});

fetch(custom)
.then(async (response) => response.text())
.then((data) => {
const parser = new DOMParser();
const content = parser.parseFromString(data, 'image/svg+xml').documentElement;
content.id = 'app-icons-sprite';
content.style.display = 'none';
document.body.appendChild(content);
})
.catch((err) => {
console.log('Failed to fetch sprite', err);
});

const RouterProvider = ({ children }: { children: ReactNode }) => {
const navigate = useNavigate();
return (
Expand Down
7 changes: 6 additions & 1 deletion packages/components/stories/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ const renderModal = (args: Story['args'], destructive = false) => (
<>
<div slot="header">
{destructive && (
<Icon name="warning" size="medium" fill="var(--lp-color-fill-feedback-warning)" />
<Icon
name="warning"
size="medium"
variant={null}
fill="var(--lp-color-fill-feedback-warning)"
/>
)}
<Heading slot="title">Title</Heading>
<IconButton
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/src/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const Icon = ({
aria-hidden={props['aria-hidden'] ?? (!props['aria-labelledby'] && !props['aria-label'])}
focusable={focusable}
role={role}
className={icon({ size, variant: props.fill ? null : variant, className })}
className={icon({ size, variant, className })}
{...props}
{...labelProps}
>
Expand Down
17 changes: 13 additions & 4 deletions packages/icons/stories/Icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import type { Meta, ReactRenderer } from '@storybook/react';
import type { Meta, ReactRenderer, StoryObj } from '@storybook/react';
import type { ArgsStoryFn } from '@storybook/types';

import { CopyToClipboard } from '@launchpad-ui/clipboard';

import { Icon } from '../src';
import { icons } from '../src/types';

export default {
const meta: Meta<typeof Icon> = {
component: Icon,
title: 'Foundations/Icons',
description: 'Icons supplement content and represent an action or feature within LaunchDarkly.',
parameters: {
status: {
type: import.meta.env.STORYBOOK_PACKAGE_STATUS__ICONS,
},
},
} as Meta;
};

export default meta;

type Story = StoryObj<typeof Icon>;

const render: ArgsStoryFn<ReactRenderer> = () => (
<div
Expand Down Expand Up @@ -61,3 +64,9 @@ const render: ArgsStoryFn<ReactRenderer> = () => (
export const Sprites = {
render,
};

export const Custom: Story = {
args: {
children: <use href="#app-icon-smile" />,
},
};

0 comments on commit 3f3a2e7

Please sign in to comment.