Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adapt Tag to design #693

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/experimental/Layouts/Utils/Tag/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ const meta: Meta = {
alt: "I",
},
},
decorators: [
(Story) => (
<div className="w-64">
<Story />
</div>
),
],
}

export default meta
Expand Down
16 changes: 12 additions & 4 deletions lib/experimental/Layouts/Utils/Tag/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Icon } from "@/components/Utilities/Icon"
import { Avatar } from "@/experimental/Information/Avatar"
import { ChevronRight } from "@/icons"
import { cn } from "@/lib/utils"
import { ComponentProps, forwardRef } from "react"
import { getColorFromText } from "../helper"
Expand All @@ -23,21 +25,27 @@ export const Tag = forwardRef<HTMLDivElement, TagProps>(
return (
<div
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we make it a button or an a? this will help us dropping the !!onClick check in favor of disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that if doesn't have an onClick action then it's not really a button or an a so then it would be semantically wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should probably change the HTML element conditionally for accessibility purposes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see you're changing the role instead. It's probably ok then!

ref={ref}
role={onClick ? "button" : undefined}
className={cn(
"flex flex-row items-center justify-start gap-1.5 rounded-md border border-solid border-f1-border py-1 pl-1 pr-2 font-medium text-f1-foreground",
onClick && "cursor-pointer"
"group flex w-full flex-row items-center justify-between gap-1.5 rounded-sm py-1.5 pl-1.5 pr-2 font-medium text-f1-foreground",
!!onClick && "cursor-pointer hover:bg-f1-background-secondary"
)}
onClick={onClick}
>
<span>
<span className="flex flex-row items-center gap-1.5">
<Avatar
alt={short}
src={avatar?.src}
size="xsmall"
color={getColorFromText(text)}
/>
<p>{text}</p>
RamProg marked this conversation as resolved.
Show resolved Hide resolved
</span>
<p>{text}</p>
{!!onClick && (
<span className="hidden items-center text-f1-foreground-secondary group-hover:flex">
<Icon icon={ChevronRight} size="md" />
</span>
)}
</div>
)
}
Expand Down
Loading