Skip to content

Commit

Permalink
fix(tag): fix icon sizes in the storybook default demo
Browse files Browse the repository at this point in the history
  • Loading branch information
masoudmanson committed Mar 14, 2024
1 parent df6e98a commit f06e554
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 10 additions & 8 deletions packages/components/src/core/Tag/__storybook__/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Icon from "src/core/Icon";
import { ExtraTagProps } from "../style";
import { WbSunny } from "@mui/icons-material";
import CustomSvgIcon from "src/common/storybook/customSvgIcon";

export const TAG_EXCLUDED_CONTROLS = [
"color",
Expand All @@ -14,21 +15,22 @@ export const TAG_EXCLUDED_CONTROLS = [

export const TAG_ICONS = [
undefined,
<Icon
sdsSize="xs"
sdsIcon="CheckCircle"
key="CheckCircle"
sdsType="button"
/>,
<Icon sdsSize="l" sdsIcon="Loading" key="loading" sdsType="button" />,
"CheckCircle",
"Loading",
"ExclamationMarkCircle",
"Person",
<WbSunny key="WBSunny" />,
<CustomSvgIcon key="CustomSvgIcon" />,
];

export const TAG_ICONS_LABELS = [
"No Icon",
"SDS Check Circle",
"SDS Loading",
"MUI WbSunny",
"SDS Exclamation Mark",
"SDS Person",
"MUI Wb Sunny",
"Custom SVG Icon",
];

export const TAG_SDS_STYLES: ExtraTagProps["sdsStyle"][] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { Args } from "@storybook/react";
import Callout from "src/core/Callout";
import CalloutTitle from "src/core/Callout/components/CalloutTitle";
import Icon, { IconNameToSizes } from "src/core/Icon";
import RawTag from "src/core/Tag";

export const Tag = (props: Args): JSX.Element => {
const { label, sdsSize, icon } = props;

const finalIcon =
typeof icon === "string" ? (
<Icon
sdsSize={sdsSize}
sdsIcon={icon as keyof IconNameToSizes}
sdsType="static"
/>
) : (
icon
);

if (sdsSize === "l" && !icon) {
return (
<Callout intent="negative">
Expand All @@ -18,5 +30,5 @@ export const Tag = (props: Args): JSX.Element => {
);
}

return <RawTag label={label} {...props} sdsSize={sdsSize} icon={icon} />;
return <RawTag label={label} {...props} sdsSize={sdsSize} icon={finalIcon} />;
};

0 comments on commit f06e554

Please sign in to comment.