mirror of
https://github.com/snowball-tools/snowballtools-base
synced 2024-11-17 20:49:18 +00:00
♻️ refactor: rename tags to tag
This commit is contained in:
parent
596889b5e2
commit
55848b1dd1
@ -1,7 +1,7 @@
|
|||||||
import { tv } from 'tailwind-variants';
|
import { tv } from 'tailwind-variants';
|
||||||
import type { VariantProps } from 'tailwind-variants';
|
import type { VariantProps } from 'tailwind-variants';
|
||||||
|
|
||||||
export const tagsTheme = tv(
|
export const tagTheme = tv(
|
||||||
{
|
{
|
||||||
slots: {
|
slots: {
|
||||||
wrapper: ['flex', 'gap-1.5', 'rounded-lg', 'border'],
|
wrapper: ['flex', 'gap-1.5', 'rounded-lg', 'border'],
|
||||||
@ -90,4 +90,4 @@ export const tagsTheme = tv(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export type TagsTheme = VariantProps<typeof tagsTheme>;
|
export type TagTheme = VariantProps<typeof tagTheme>;
|
@ -3,11 +3,11 @@ import React, {
|
|||||||
type ComponentPropsWithoutRef,
|
type ComponentPropsWithoutRef,
|
||||||
useMemo,
|
useMemo,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { TagsTheme, tagsTheme } from './Tags.theme';
|
import { tagTheme, type TagTheme } from './Tag.theme';
|
||||||
import { cloneIcon } from 'utils/cloneIcon';
|
import { cloneIcon } from 'utils/cloneIcon';
|
||||||
|
|
||||||
type TagsProps = ComponentPropsWithoutRef<'div'> &
|
type TagProps = ComponentPropsWithoutRef<'div'> &
|
||||||
TagsTheme & {
|
TagTheme & {
|
||||||
/**
|
/**
|
||||||
* The optional left icon element for a component.
|
* The optional left icon element for a component.
|
||||||
* @type {ReactNode}
|
* @type {ReactNode}
|
||||||
@ -18,36 +18,21 @@ type TagsProps = ComponentPropsWithoutRef<'div'> &
|
|||||||
* @type {ReactNode}
|
* @type {ReactNode}
|
||||||
*/
|
*/
|
||||||
rightIcon?: ReactNode;
|
rightIcon?: ReactNode;
|
||||||
/**
|
|
||||||
* The optional type of the tags component.
|
|
||||||
* @type {TagsTheme['type']}
|
|
||||||
**/
|
|
||||||
type?: TagsTheme['type'];
|
|
||||||
/**
|
|
||||||
* The optional style of the tags component.
|
|
||||||
* @type {TagsTheme['style']}
|
|
||||||
*/
|
|
||||||
style?: TagsTheme['style'];
|
|
||||||
/**
|
|
||||||
* The optional size of the tags component.
|
|
||||||
* @type {TagsTheme['size']}
|
|
||||||
*/
|
|
||||||
size?: TagsTheme['size'];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Tags = ({
|
export const Tag = ({
|
||||||
children,
|
children,
|
||||||
leftIcon,
|
leftIcon,
|
||||||
rightIcon,
|
rightIcon,
|
||||||
type = 'attention',
|
type = 'attention',
|
||||||
style = 'default',
|
style = 'default',
|
||||||
size = 'sm',
|
size = 'sm',
|
||||||
}: TagsProps) => {
|
}: TagProps) => {
|
||||||
const {
|
const {
|
||||||
wrapper: wrapperCls,
|
wrapper: wrapperCls,
|
||||||
icon: iconCls,
|
icon: iconCls,
|
||||||
label: labelCls,
|
label: labelCls,
|
||||||
} = tagsTheme({
|
} = tagTheme({
|
||||||
type,
|
type,
|
||||||
style,
|
style,
|
||||||
size,
|
size,
|
2
packages/frontend/src/components/shared/Tag/index.ts
Normal file
2
packages/frontend/src/components/shared/Tag/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './Tag';
|
||||||
|
export * from './Tag.theme';
|
@ -1,2 +0,0 @@
|
|||||||
export * from './Tags';
|
|
||||||
export * from './Tags.theme';
|
|
@ -23,7 +23,7 @@ import {
|
|||||||
renderInlineNotifications,
|
renderInlineNotifications,
|
||||||
} from './renders/inlineNotifications';
|
} from './renders/inlineNotifications';
|
||||||
import { renderInputs } from './renders/input';
|
import { renderInputs } from './renders/input';
|
||||||
import { renderDefaultTags, renderMinimalTags } from './renders/tags';
|
import { renderDefaultTag, renderMinimalTag } from './renders/Tag';
|
||||||
|
|
||||||
const Page = () => {
|
const Page = () => {
|
||||||
const [singleDate, setSingleDate] = useState<Value>();
|
const [singleDate, setSingleDate] = useState<Value>();
|
||||||
@ -42,13 +42,13 @@ const Page = () => {
|
|||||||
|
|
||||||
<div className="w-full h border border-gray-200 px-20 my-10" />
|
<div className="w-full h border border-gray-200 px-20 my-10" />
|
||||||
|
|
||||||
{/* Tags */}
|
{/* Tag */}
|
||||||
<div className="flex flex-col gap-10 items-center justify-between">
|
<div className="flex flex-col gap-10 items-center justify-between">
|
||||||
<div className="flex flex-col gap-10 items-center justify-between">
|
<div className="flex flex-col gap-10 items-center justify-between">
|
||||||
<h1 className="text-2xl font-bold">Tags</h1>
|
<h1 className="text-2xl font-bold">Tag</h1>
|
||||||
<div className="flex flex-col gap-10 items-center justify-center">
|
<div className="flex flex-col gap-10 items-center justify-center">
|
||||||
{renderDefaultTags()}
|
{renderDefaultTag()}
|
||||||
{renderMinimalTags()}
|
{renderMinimalTag()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Tags } from 'components/shared/Tags';
|
import { Tag } from 'components/shared/Tag';
|
||||||
import { PlusIcon } from 'components/shared/CustomIcon';
|
import { PlusIcon } from 'components/shared/CustomIcon';
|
||||||
|
|
||||||
export const renderDefaultTags = () =>
|
export const renderDefaultTag = () =>
|
||||||
(['default'] as const).map((style) => (
|
(['default'] as const).map((style) => (
|
||||||
<div key={style} className="flex gap-4 items-center">
|
<div key={style} className="flex gap-4 items-center">
|
||||||
{(
|
{(
|
||||||
['attention', 'negative', 'positive', 'emphasized', 'neutral'] as const
|
['attention', 'negative', 'positive', 'emphasized', 'neutral'] as const
|
||||||
).map((type) => (
|
).map((type) => (
|
||||||
<div key={type} className="flex flex-col gap-4">
|
<div key={type} className="flex flex-col gap-4">
|
||||||
<Tags
|
<Tag
|
||||||
leftIcon={<PlusIcon />}
|
leftIcon={<PlusIcon />}
|
||||||
rightIcon={<PlusIcon />}
|
rightIcon={<PlusIcon />}
|
||||||
style={style}
|
style={style}
|
||||||
@ -17,8 +17,8 @@ export const renderDefaultTags = () =>
|
|||||||
size="sm"
|
size="sm"
|
||||||
>
|
>
|
||||||
Label
|
Label
|
||||||
</Tags>
|
</Tag>
|
||||||
<Tags
|
<Tag
|
||||||
leftIcon={<PlusIcon />}
|
leftIcon={<PlusIcon />}
|
||||||
rightIcon={<PlusIcon />}
|
rightIcon={<PlusIcon />}
|
||||||
size="xs"
|
size="xs"
|
||||||
@ -26,20 +26,20 @@ export const renderDefaultTags = () =>
|
|||||||
type={type}
|
type={type}
|
||||||
>
|
>
|
||||||
Label
|
Label
|
||||||
</Tags>
|
</Tag>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
|
|
||||||
export const renderMinimalTags = () =>
|
export const renderMinimalTag = () =>
|
||||||
(['minimal'] as const).map((style) => (
|
(['minimal'] as const).map((style) => (
|
||||||
<div key={style} className="flex gap-4 items-center">
|
<div key={style} className="flex gap-4 items-center">
|
||||||
{(
|
{(
|
||||||
['attention', 'negative', 'positive', 'emphasized', 'neutral'] as const
|
['attention', 'negative', 'positive', 'emphasized', 'neutral'] as const
|
||||||
).map((type) => (
|
).map((type) => (
|
||||||
<div key={type} className="flex flex-col gap-4">
|
<div key={type} className="flex flex-col gap-4">
|
||||||
<Tags
|
<Tag
|
||||||
leftIcon={<PlusIcon />}
|
leftIcon={<PlusIcon />}
|
||||||
rightIcon={<PlusIcon />}
|
rightIcon={<PlusIcon />}
|
||||||
style={style}
|
style={style}
|
||||||
@ -47,8 +47,8 @@ export const renderMinimalTags = () =>
|
|||||||
size="sm"
|
size="sm"
|
||||||
>
|
>
|
||||||
Label
|
Label
|
||||||
</Tags>
|
</Tag>
|
||||||
<Tags
|
<Tag
|
||||||
leftIcon={<PlusIcon />}
|
leftIcon={<PlusIcon />}
|
||||||
rightIcon={<PlusIcon />}
|
rightIcon={<PlusIcon />}
|
||||||
size="xs"
|
size="xs"
|
||||||
@ -56,7 +56,7 @@ export const renderMinimalTags = () =>
|
|||||||
type={type}
|
type={type}
|
||||||
>
|
>
|
||||||
Label
|
Label
|
||||||
</Tags>
|
</Tag>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user