Skip to content

Commit

Permalink
added tag component
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadgaz committed Sep 26, 2024
1 parent 8e6cea1 commit 265bd33
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './horizontal-line';
export * from './vertical-line';
export * from './link-btn';
export * from './card';
export * from './tag';
27 changes: 27 additions & 0 deletions components/atoms/tag/component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use client';

import { cn } from '@/lib/cn';
import React from 'react';

interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
children?: React.ReactNode;
}

export const Tag: React.FC<Props> = ({ children, className, ...props }) => {
const [id, setId] = React.useState('');
React.useEffect(() => setId(Math.random().toString(36).substring(7)), []);
return (
<span>
<input {...props} className="peer sr-only" id={id} />
<label
className={cn(
'bg-border animation peer-checked:!text-background flex cursor-pointer items-center gap-xs rounded-lg px-md py-sm peer-checked:!bg-light-primary peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-light-primary peer-focus:ring-offset-2 peer-enabled:hover:opacity-50 peer-enabled:active:opacity-25 peer-disabled:text-light-neutral-gray',
className,
)}
htmlFor={id}
>
{children}
</label>
</span>
);
};
2 changes: 2 additions & 0 deletions components/atoms/tag/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Tag as default } from './component';
export * from './component';

0 comments on commit 265bd33

Please sign in to comment.