Skip to content

Commit

Permalink
Handle close on Tag cross click (#633)
Browse files Browse the repository at this point in the history
ievavizg authored Aug 4, 2023
1 parent 8351a7c commit 647498f
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nordcloud/gnui",
"description": "Nordcloud Design System - a collection of reusable React components used in Nordcloud's SaaS products",
"version": "8.13.3",
"version": "8.13.4",
"license": "MIT",
"repository": {
"type": "git",
1 change: 1 addition & 0 deletions src/components/tag/Tag.stories.mdx
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ import { Breadcrumbs } from "../breadcrumbs";
text="Help"
showClose
onClick={() => alert("clicked")}
onCloseClick={() => alert("clicked close")}
/>
<Tag
color="purple"
6 changes: 4 additions & 2 deletions src/components/tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ type TagProps = {
text?: string;
icon?: SVGIconProps["name"];
onClick?: () => void;
onCloseClick?: () => void;
showClose?: boolean;
isTransparent?: boolean;
};
@@ -125,16 +126,17 @@ export function Tag({
onClick,
showClose,
isTransparent,
onCloseClick,
...props
}: TagProps) {
return (
<StyledTag
color={color}
colorText={colorText}
icon={icon}
onClick={onClick}
showClose={showClose}
isTransparent={isTransparent}
onClick={onCloseClick ? undefined : onClick}
{...props}
>
{icon && (
@@ -145,7 +147,7 @@ export function Tag({
{text && <div className="tag-text">{text}</div>}
{showClose && (
<div className="tag-close-button">
<SVGIcon name="close" size="sm" />
<SVGIcon name="close" size="sm" onClick={onCloseClick} />
</div>
)}
</StyledTag>

0 comments on commit 647498f

Please sign in to comment.