Skip to content

Commit

Permalink
fix(Tag): hover & improve docs decorators/disable/delete
Browse files Browse the repository at this point in the history
  • Loading branch information
zettca committed Sep 26, 2023
1 parent 6d9eaf9 commit 9f3b225
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 56 deletions.
72 changes: 17 additions & 55 deletions packages/core/src/components/Tag/Tag.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const StyledListItem = styled(HvListItem)({
const meta: Meta<typeof HvTag> = {
title: "Components/Tag/Tag",
component: HvTag,
decorators: [
(Story) => <div style={{ display: "flex", gap: 20 }}>{Story()}</div>,
],
};
export default meta;

Expand Down Expand Up @@ -59,43 +62,31 @@ export const LongLabelText: StoryObj<HvTagProps> = {
const longText = "This is an example of a very long tag";

return (
<div style={{ display: "flex", gap: 20 }}>
<>
<HvTag label={<HvOverflowTooltip data={longText} />} />
<HvTag label={`${longText} with default overflow`} />
</div>
</>
);
},
};

export const Semantical: StoryObj<HvTagProps> = {
render: () => {
return (
<div
style={{
width: "600px",
display: "flex",
justifyContent: "space-between",
}}
>
<>
<HvTag label="Informational" />
<HvTag color="positive_20" label="Success" />
<HvTag color="negative_20" label="Warning" />
<HvTag color="warning_20" label="Error" />
</div>
</>
);
},
};

export const Categorial: StoryObj<HvTagProps> = {
export const Categorical: StoryObj<HvTagProps> = {
render: () => {
return (
<div
style={{
width: "600px",
display: "flex",
justifyContent: "space-between",
}}
>
<>
<HvTag label="Feat" onClick={() => alert("Hello")} type="categorical" />
<HvTag
label="Docs"
Expand All @@ -122,49 +113,32 @@ export const Categorial: StoryObj<HvTagProps> = {
color="cat5"
/>
<HvTag label="No Click" type="categorical" color="#22FF45" />
</div>
</>
);
},
};

export const DisabledTags: StoryObj<HvTagProps> = {
render: () => {
return (
<div
style={{
width: "350px",
display: "flex",
justifyContent: "space-between",
}}
>
<HvTag
label="Informational"
disabled
deleteButtonProps={{ "aria-label": "Disabled tag" }}
/>
<>
<HvTag label="Informational" disabled />
<HvTag
label="Success"
disabled
onDelete={() => {
alert("On Delete Action");
}}
deleteButtonProps={{ "aria-label": "Disabled tag" }}
/>
</div>
</>
);
},
};

export const WithDeleteAction: StoryObj<HvTagProps> = {
render: () => {
return (
<div
style={{
width: "600px",
display: "flex",
justifyContent: "space-between",
}}
>
<>
<HvTag
label="Informational"
onDelete={() => {
Expand All @@ -177,19 +151,13 @@ export const WithDeleteAction: StoryObj<HvTagProps> = {
onDelete={() => {
alert("On Delete Action");
}}
deleteButtonProps={{
tabIndex: -1, // tab navigation should skip this tag
}}
/>
<HvTag
label="Warning"
color="negative_20"
onDelete={() => {
alert("On Delete Action");
}}
deleteButtonProps={{
tabIndex: -1, // tab navigation should skip this tag
}}
/>
<HvTag
label="Error"
Expand All @@ -198,21 +166,15 @@ export const WithDeleteAction: StoryObj<HvTagProps> = {
alert("On Delete Action");
}}
/>
</div>
</>
);
},
};

export const CategoricalTagsDisabled: StoryObj<HvTagProps> = {
render: () => {
return (
<div
style={{
width: "350px",
display: "flex",
justifyContent: "space-between",
}}
>
<>
<HvTag
label="Feat"
onClick={() => alert("Hello")}
Expand Down Expand Up @@ -247,7 +209,7 @@ export const CategoricalTagsDisabled: StoryObj<HvTagProps> = {
color="cat5"
disabled
/>
</div>
</>
);
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const HvTag = (props: HvTagProps) => {
(type === "categorical" && `${categoricalBackgroundColor}30`) ||
undefined;

const isClickable = !!onClick && !disabled;
const isClickable = !!(onClick || onDelete) && !disabled;

const clickableClass = css({
"&:hover": {
Expand Down

0 comments on commit 9f3b225

Please sign in to comment.