From 1f1c85e2adc2e069b54d32ed2e03755a106fd9f1 Mon Sep 17 00:00:00 2001 From: raylotan Date: Wed, 14 Aug 2024 10:19:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(tag):=20=E5=AF=B9=E9=BD=90mobile-vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/mobile/mobile.config.js | 2 +- src/_util/parseTNode.ts | 4 +- src/tag/CheckTag.tsx | 106 +- src/tag/Tag.tsx | 159 ++- src/tag/__tests__/index.test.tsx | 266 ++++ src/tag/_example/checkable.jsx | 40 - src/tag/_example/checkable.tsx | 25 + src/tag/_example/closable.jsx | 38 - src/tag/_example/closable.tsx | 25 + src/tag/_example/ellipsis.jsx | 10 - src/tag/_example/icon.jsx | 13 - src/tag/_example/index.jsx | 65 - src/tag/_example/index.tsx | 31 + src/tag/_example/shape.jsx | 15 - src/tag/_example/size.jsx | 18 - src/tag/_example/size.tsx | 25 + src/tag/_example/style/index.less | 39 +- src/tag/_example/theme.jsx | 14 - src/tag/_example/theme.tsx | 42 + src/tag/_example/type.tsx | 38 + src/tag/_example/variant.jsx | 21 - src/tag/defaultProps.ts | 23 + src/tag/style/index.js | 2 +- src/tag/tag.md | 26 +- src/tag/type.ts | 41 +- test/snap/__snapshots__/csr.test.jsx.snap | 1567 +++++++++++++++++++++ test/snap/__snapshots__/ssr.test.jsx.snap | 12 + 27 files changed, 2284 insertions(+), 383 deletions(-) create mode 100644 src/tag/__tests__/index.test.tsx delete mode 100644 src/tag/_example/checkable.jsx create mode 100644 src/tag/_example/checkable.tsx delete mode 100644 src/tag/_example/closable.jsx create mode 100644 src/tag/_example/closable.tsx delete mode 100644 src/tag/_example/ellipsis.jsx delete mode 100644 src/tag/_example/icon.jsx delete mode 100644 src/tag/_example/index.jsx create mode 100644 src/tag/_example/index.tsx delete mode 100644 src/tag/_example/shape.jsx delete mode 100644 src/tag/_example/size.jsx create mode 100644 src/tag/_example/size.tsx delete mode 100644 src/tag/_example/theme.jsx create mode 100644 src/tag/_example/theme.tsx create mode 100644 src/tag/_example/type.tsx delete mode 100644 src/tag/_example/variant.jsx create mode 100644 src/tag/defaultProps.ts diff --git a/site/mobile/mobile.config.js b/site/mobile/mobile.config.js index 457941835..b50fbac08 100644 --- a/site/mobile/mobile.config.js +++ b/site/mobile/mobile.config.js @@ -150,7 +150,7 @@ export default { { title: 'Tag 标签', name: 'tag', - component: () => import('tdesign-mobile-react/tag/_example/index.jsx'), + component: () => import('tdesign-mobile-react/tag/_example/index.tsx'), }, { title: 'Toast 轻提示', diff --git a/src/_util/parseTNode.ts b/src/_util/parseTNode.ts index 468639ee2..6dbd30725 100644 --- a/src/_util/parseTNode.ts +++ b/src/_util/parseTNode.ts @@ -1,7 +1,7 @@ -import React, { ReactElement, ReactNode } from 'react'; import isFunction from 'lodash/isFunction'; -import { TNode } from '../common'; +import React, { ReactElement, ReactNode } from 'react'; import log from '../_common/js/log'; +import { TNode } from '../common'; // 解析 TNode 数据结构 export default function parseTNode( diff --git a/src/tag/CheckTag.tsx b/src/tag/CheckTag.tsx index 2127a57ec..0ce686633 100644 --- a/src/tag/CheckTag.tsx +++ b/src/tag/CheckTag.tsx @@ -1,33 +1,39 @@ -import React, { forwardRef, Ref } from 'react'; import classNames from 'classnames'; +import React, { + forwardRef, + memo +} from 'react'; import { Icon } from 'tdesign-icons-react'; +import parseTNode from 'tdesign-mobile-react/_util/parseTNode'; +import { StyledProps } from 'tdesign-mobile-react/common'; import useConfig from '../_util/useConfig'; -import { TdCheckTagProps } from './type'; import useDefault from '../_util/useDefault'; -import noop from '../_util/noop'; +import useDefaultProps from '../hooks/useDefaultProps'; +import { checkTagDefaultProps } from "./defaultProps"; +import { TdCheckTagProps } from './type'; -export interface TagCheckProps extends TdCheckTagProps { - className?: string; - style?: object; -} +export interface TagCheckProps extends TdCheckTagProps, StyledProps { } -const TagCheck: React.FC = React.memo( - forwardRef((props, ref: Ref) => { +const TagCheck = memo( + forwardRef((originProps, ref) => { + const props = useDefaultProps(originProps, checkTagDefaultProps) const { - checked = undefined, - defaultChecked = undefined, - content = '', + checked, + defaultChecked, + content, children, - style = {}, - className = '', - icon = '', - disabled = false, - closable = false, - size = 'medium', - shape = 'square', - onClick = noop, - onChange = noop, - ...other + style, + className, + icon, + disabled, + closable, + size, + shape, + variant, + onClick, + onChange, + onClose, + ...otherProps } = props; const { classPrefix } = useConfig(); @@ -38,46 +44,64 @@ const TagCheck: React.FC = React.memo( const checkTagClass = classNames( `${baseClass}`, - `${baseClass}--checkable`, - `${baseClass}--shape-${shape}`, - `${baseClass}--size-${size}`, + // `${baseClass}--checkable`, + `${baseClass}--${shape}`, + `${baseClass}--${innerChecked ? 'primary' : 'default'}`, + `${baseClass}--${size}`, + `${baseClass}--${variant}`, + { - [`${classPrefix}-is-closable ${baseClass}--closable`]: closable, - [`${classPrefix}-is-disabled ${baseClass}--disabled`]: disabled, - [`${classPrefix}-is-checked ${baseClass}--checked`]: innerChecked, + [`${baseClass}--closable`]: closable, + [`${baseClass}--disabled`]: disabled, + [`${baseClass}--checked`]: !disabled && innerChecked, }, className, ); + const renderText = () => { + if (Array.isArray(content) && content.length === 2) { + return innerChecked ? content[0] : content[1]; + } + return content; + } + + const childNode = parseTNode(renderText()) || parseTNode(children) + const tagStyle = { ...style, }; const handleClick = (e) => { - if (disabled || closable) { - return; + if (!props.disabled) { + onClick?.(e); + onInnerChecked(!innerChecked); } - onInnerChecked(!innerChecked); - onClick({ e }); }; const handleClose = (e) => { - if (disabled) { - return; - } e.stopPropagation(); - onClick({ e }); + if (!props.disabled) { + onClose?.({ e }); + } }; return ( - - {icon} - {content || children} - {closable ? ( + + {icon && {icon}} + {childNode} + {props.closable && ( - ) : null} + )} ); }), diff --git a/src/tag/Tag.tsx b/src/tag/Tag.tsx index fef075672..6b5c67b41 100644 --- a/src/tag/Tag.tsx +++ b/src/tag/Tag.tsx @@ -1,93 +1,92 @@ -import React, { useCallback, forwardRef } from 'react'; import classNames from 'classnames'; +import React, { forwardRef, memo } from 'react'; import { Icon } from 'tdesign-icons-react'; -import noop from '../_util/noop'; -import { TdTagProps } from './type'; +import parseTNode from 'tdesign-mobile-react/_util/parseTNode'; +import { StyledProps } from 'tdesign-mobile-react/common'; +import useDefaultProps from 'tdesign-mobile-react/hooks/useDefaultProps'; import useConfig from '../_util/useConfig'; +import { tagDefaultProps } from './defaultProps'; +import { TdTagProps } from './type'; -export interface TagProps extends TdTagProps { - className: string; - style: object; -} - -const Tag = forwardRef((props, ref) => { - const { - className = '', - style = {}, - closable = false, - content = null, - disabled = false, - icon = undefined, - maxWidth, - children = '', - shape = 'square', - size = 'medium', - theme = 'default', - variant = 'dark', - onClick = noop, - onClose = noop, - ...other - } = props; +export interface TagProps extends TdTagProps, StyledProps { } - const { classPrefix } = useConfig(); - const baseClass = `${classPrefix}-tag`; +const Tag = memo( + forwardRef((originProps, ref) => { + const props = useDefaultProps(originProps, tagDefaultProps) + const { + className, + style, + closable, + content, + disabled, + icon, + maxWidth, + children, + shape, + size, + theme, + variant, + onClick, + onClose, + ...otherProps + } = props; - const tagClassNames = classNames( - `${baseClass}`, - `${baseClass}--theme-${theme}`, - `${baseClass}--shape-${shape}`, - `${baseClass}--variant-${variant}`, - `${baseClass}--size-${size}`, - { - [`${classPrefix}-is-closable ${baseClass}--closable`]: closable, - [`${classPrefix}-is-disabled ${baseClass}--disabled`]: disabled, - }, - className, - ); + const { classPrefix } = useConfig(); + const baseClass = `${classPrefix}-tag`; - const tagStyle = { - ...style, - maxWidth: typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth, - }; + const tagClassNames = classNames( + `${baseClass}`, + `${baseClass}--${theme}`, + `${baseClass}--${shape}`, + `${baseClass}--${variant}`, + `${baseClass}--${size}`, + { + [`${classPrefix}-is-closable ${baseClass}--closable`]: closable, + [`${classPrefix}-is-disabled ${baseClass}--disabled`]: disabled, + }, + className, + ); - const getRenderContent = useCallback(() => { - const contentType = typeof content; - if (contentType === 'string' || contentType === 'number') { - return content; - } - // if (contentType === 'function') { - // return content(); - // } + const tagStyle = { + ...style, + maxWidth: typeof maxWidth === 'number' ? `${maxWidth}px` : maxWidth, + }; - return content; - }, [content]); + const handleClose = (e) => { + e.stopPropagation(); + if (!props.disabled) { + onClose?.({ e }); + } + }; - function onClickClose(e) { - if (disabled) { - return; - } - e.stopPropagation(); - onClose({ e }); - } + const handleClick = (e) => { + if (disabled) { + return; + } + onClick?.({ e }); + }; - const handleClick = (e) => { - if (disabled) { - return; - } - onClick({ e }); - }; + const ChildNode = parseTNode(content) || parseTNode(children); - return ( - - {icon} - {getRenderContent() || children} - {closable ? ( - - - - ) : null} - - ); -}); + return ( + + {icon && {icon}} + {ChildNode} + {props.closable && ( + + + + )} + + ) + })); -export default React.memo(Tag); +export default Tag; diff --git a/src/tag/__tests__/index.test.tsx b/src/tag/__tests__/index.test.tsx new file mode 100644 index 000000000..a57fd3f25 --- /dev/null +++ b/src/tag/__tests__/index.test.tsx @@ -0,0 +1,266 @@ +import { describe, vi } from "@test/utils"; +import { fireEvent, render } from '@testing-library/react'; +import React from "react"; +import { Icon } from "tdesign-icons-react"; +import { Tag, TagCheck } from "../index"; + +const prefix = "t"; +const baseClass = `.${prefix}-tag` + +describe("tag", () => { + describe("props", () => { + it(": content", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.textContent).toBe('tag') + }) + + it(": children", () => { + const { container } = render(tag) + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.textContent).toBe('tag') + }) + + it(": shape", () => { + const shape = ["square", "round", "mark"] as ("square" | "round" | "mark")[] + shape.forEach(s => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + if (s === "mark") { + expect($tagItem.classList.contains(`${baseClass}__${s}`)) + } else if (s === 'round') { + expect($tagItem.classList.contains(`${baseClass}__${s}`)) + } else if (s === "square") { + expect($tagItem.classList.contains(`${baseClass}__${s}`)) + } + }) + }) + + it(": theme", () => { + const theme = ["default", "primary", "warning", "danger", "success"] as ("default" | "primary" | "warning" | "danger" | "success")[] + theme.forEach(t => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}--${t}`)) + }) + }) + + it(": variant", () => { + const variant = ["light", "dark"] as ("light" | "dark")[] + variant.forEach(v => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}--${v}`)) + }) + }) + + it(": size", () => { + const size = ["small", "medium", "large", 'extra-large'] as ("small" | "medium" | "large" | 'extra-large')[] + size.forEach(s => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + if (s === "small") { + expect($tagItem.classList.contains(`${baseClass}--${s}`)) + } else if (s === "medium") { + expect($tagItem.classList.contains(`${baseClass}--${s}`)) + } else if (s === "large") { + expect($tagItem.classList.contains(`${baseClass}--${s}`)) + } else if (s === "extra-large") { + expect($tagItem.classList.contains(`${baseClass}--${s}`)) + } + }) + }) + + + it(": closable", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}__icon-close`)) + }) + + it(": disabled", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}--disabled`)) + }) + + it(": icon", () => { + const { container } = render(} />) + const $icon = container.querySelector(`${baseClass}__icon`) as HTMLElement + expect($icon).toBeTruthy(); + }) + + it(": maxWidth", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.style.maxWidth).toBe('100px') + }) + + it(": defaultChecked", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}--checked`)) + }) + + }) + + describe('event', () => { + it(': click', async () => { + const handleClick = vi.fn(); + const { container } = render(); + const tag = container.querySelector(`${baseClass}`); + fireEvent.click(tag); + expect(handleClick).toHaveBeenCalled(); + }); + + it(': click disabled', async () => { + const handleClick = vi.fn(); + const { container } = render(); + const tag = container.querySelector(`${baseClass}`); + fireEvent.click(tag); + expect(handleClick).not.toHaveBeenCalled() + }); + + it(': close', async () => { + const handleClose = vi.fn(); + const { container } = render(); + const closeBtn = container.querySelector(`${baseClass}__icon-close`); + fireEvent.click(closeBtn); + expect(handleClose).toHaveBeenCalled(); + }); + + it(': close disabled', async () => { + const handleClose = vi.fn(); + const { container } = render(); + const closeBtn = container.querySelector(`${baseClass}__icon-close`); + fireEvent.click(closeBtn); + expect(handleClose).not.toHaveBeenCalled(); + }); + }) +}) + +describe('TagCheck', () => { + describe('props', () => { + it(': content', () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.textContent).toBe('tag') + }); + + it(': children', () => { + const { container } = render(tag) + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.textContent).toBe('tag') + }) + + it(': checked', () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}--checked`)) + }); + + it(": closable", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}__icon-close`)) + }) + + it(": disabled", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}--disabled`)) + }) + + it(': icon', () => { + const { container } = render(} />) + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}__icon-check`)) + }) + + it(" defaultChecked", () => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + expect($tagItem.classList.contains(`${baseClass}--checked`)) + }) + + it(": shape", () => { + const shape = ['square', 'round', 'mark'] as ('square' | 'round' | 'mark')[] + shape.forEach(item => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + if (item === 'square') { + expect($tagItem.classList.contains(`${baseClass}--square`)) + } else if (item === 'round') { + expect($tagItem.classList.contains(`${baseClass}--round`)) + } else if (item === 'mark') { + expect($tagItem.classList.contains(`${baseClass}--mark`)) + } + }) + }) + + it(": size", () => { + const size = ['small', 'medium', 'large'] as ('small' | 'medium' | 'large')[] + size.forEach(item => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + if (item === 'small') { + expect($tagItem.classList.contains(`${baseClass}--small`)) + } else if (item === 'medium') { + expect($tagItem.classList.contains(`${baseClass}--medium`)) + } + }) + }) + + it(": variant", () => { + const variants = ['dark', 'light', 'outline', 'light-outline'] as ('dark' | 'light' | 'outline' | 'light-outline')[] + variants.forEach(item => { + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + if (item === 'dark') { + expect($tagItem.classList.contains(`${baseClass}--dark`)) + } else if (item === 'light') { + expect($tagItem.classList.contains(`${baseClass}--light`)) + } else if (item === 'outline') { + expect($tagItem.classList.contains(`${baseClass}--outline`)) + } else if (item === 'light-outline') { + expect($tagItem.classList.contains(`${baseClass}--light-outline`)) + } + }) + }) + }) + + describe('event', () => { + it(': click', () => { + const handleClick = vi.fn() + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + fireEvent.click($tagItem) + expect(handleClick).toHaveBeenCalled() + }) + + it(': click disabled', () => { + const handleClick = vi.fn() + const { container } = render() + const $tagItem = container.querySelector(baseClass) as HTMLElement + fireEvent.click($tagItem) + expect(handleClick).not.toHaveBeenCalled() + }) + + it(': close', () => { + const handleClose = vi.fn() + const { container } = render() + const closeBtn = container.querySelector(`${baseClass}__icon-close`); + fireEvent.click(closeBtn); + expect(handleClose).toHaveBeenCalled(); + }) + + it(': close disabled', () => { + const handleClose = vi.fn() + const { container } = render() + const closeBtn = container.querySelector(`${baseClass}__icon-close`); + fireEvent.click(closeBtn); + expect(handleClose).not.toHaveBeenCalled(); + }) + }) + +}) diff --git a/src/tag/_example/checkable.jsx b/src/tag/_example/checkable.jsx deleted file mode 100644 index cc2ffe891..000000000 --- a/src/tag/_example/checkable.jsx +++ /dev/null @@ -1,40 +0,0 @@ -import React, { useState } from 'react'; -import { TagCheck } from 'tdesign-mobile-react'; - -const TagChecksOptions = [ - { - name: '选中', - checked: true, - }, - { - name: '未选中', - checked: false, - }, - { - name: '不可选', - checked: false, - disabled: true, - }, -]; - -const CheckeableDemo = () => { - const [tagChecks, setTagChecks] = useState(TagChecksOptions); - - const onClick = (tagCheckIndex) => { - const shallowClone = [...tagChecks]; - shallowClone[tagCheckIndex].checked = !shallowClone[tagCheckIndex].checked; - setTagChecks([...shallowClone]); - }; - - return ( - <> - {tagChecks.map((item, index) => ( - onClick(index)}> - {item.name} - - ))} - - ); -}; - -export default CheckeableDemo; diff --git a/src/tag/_example/checkable.tsx b/src/tag/_example/checkable.tsx new file mode 100644 index 000000000..67f460ee9 --- /dev/null +++ b/src/tag/_example/checkable.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { TagCheck } from 'tdesign-mobile-react'; + +const CheckeableDemo = () => { + const variants = ['light', 'dark', 'outline', 'light-outline']; + + return ( + <> +
可选中的标签
+
+
+ {variants.map((item, index) => ( +
+
{item}
+ + +
+ ))} +
+
+ + ); +}; + +export default CheckeableDemo; diff --git a/src/tag/_example/closable.jsx b/src/tag/_example/closable.jsx deleted file mode 100644 index ea6fd0545..000000000 --- a/src/tag/_example/closable.jsx +++ /dev/null @@ -1,38 +0,0 @@ -import React, { useState } from 'react'; -import { Tag } from 'tdesign-mobile-react'; -import { Icon } from 'tdesign-icons-react'; - -const TagOptions = [ - { - size: 'medium', - name: '标签', - }, - { - name: '标签', - size: 'medium', - icon: , - }, -]; -const ClosableDemo = () => { - const [tags, setTags] = useState(TagOptions); - - const onClose = (dex) => { - setTags((pre) => { - const temp = [...pre]; - temp.splice(dex, 1); - return temp; - }); - }; - - return ( - <> - {tags.map((item, index) => ( - onClose(index)}> - 标签 - - ))} - - ); -}; - -export default ClosableDemo; diff --git a/src/tag/_example/closable.tsx b/src/tag/_example/closable.tsx new file mode 100644 index 000000000..8f9c887e3 --- /dev/null +++ b/src/tag/_example/closable.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Tag } from 'tdesign-mobile-react'; + +const ClosableDemo = () => { + const tagRef1 = React.useRef(); + const tagRef2 = React.useRef(); + const onClickClose = (e) => { + if (e === 1) { + tagRef1.current.remove(); + } else { + tagRef2.current.remove(); + } + } + return ( + <> +
可关闭标签
+
+ onClickClose(1)}>文字标签 + onClickClose(2)}>文字标签 +
+ + ) +} + +export default ClosableDemo diff --git a/src/tag/_example/ellipsis.jsx b/src/tag/_example/ellipsis.jsx deleted file mode 100644 index c8df1f85e..000000000 --- a/src/tag/_example/ellipsis.jsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import { Tag } from 'tdesign-mobile-react'; - -const EllipsisDemo = () => ( - <> - 听说超长可以省略听说超长 - -); - -export default EllipsisDemo; diff --git a/src/tag/_example/icon.jsx b/src/tag/_example/icon.jsx deleted file mode 100644 index fcc65940f..000000000 --- a/src/tag/_example/icon.jsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { Tag } from 'tdesign-mobile-react'; -import { Icon } from 'tdesign-icons-react'; - -const IconDemo = () => ( - <> - }> - 标签 - - -); - -export default IconDemo; diff --git a/src/tag/_example/index.jsx b/src/tag/_example/index.jsx deleted file mode 100644 index ed06428f3..000000000 --- a/src/tag/_example/index.jsx +++ /dev/null @@ -1,65 +0,0 @@ -import React from 'react'; -import { TagCheck } from 'tdesign-mobile-react'; -import TDemoBlock from '../../../site/mobile/components/DemoBlock'; -import TDemoHeader from '../../../site/mobile/components/DemoHeader'; -import CheckeableDemo from './checkable'; -import ShapeDemo from './shape'; -import ClosableDemo from './closable'; -import ThemeDemo from './theme'; -import VariantDemo from './variant'; -import SizeDemo from './size'; -import EllipsisDemo from './ellipsis'; - -import './style/index.less'; -import IconDemo from './icon'; - -export default function Base() { - return ( - <> - - -
- -
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
- -
- 点击标签30 - 点击标签24 -
-
- - ); -} diff --git a/src/tag/_example/index.tsx b/src/tag/_example/index.tsx new file mode 100644 index 000000000..811c713e3 --- /dev/null +++ b/src/tag/_example/index.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import TDemoBlock from '../../../site/mobile/components/DemoBlock'; +import CheckeableDemo from './checkable'; +import ClosableDemo from './closable'; +import SizeDemo from './size'; +import './style/index.less'; +import ThemeDemo from './theme'; +import TypeDemo from './type'; + +export default function Base() { + return ( +
+

Tag 标签

+

用于表明主体的类目,属性或状态。

+ + + + + + + + + +
+ +
+
+
+ + ); +} diff --git a/src/tag/_example/shape.jsx b/src/tag/_example/shape.jsx deleted file mode 100644 index cfbe243d0..000000000 --- a/src/tag/_example/shape.jsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { Tag } from 'tdesign-mobile-react'; - -const ShapeDemo = () => ( - <> - - 圆弧 - - - 半圆弧 - - -); - -export default ShapeDemo; diff --git a/src/tag/_example/size.jsx b/src/tag/_example/size.jsx deleted file mode 100644 index 164cc8fb3..000000000 --- a/src/tag/_example/size.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { Tag } from 'tdesign-mobile-react'; - -const SizeDemo = () => ( - <> - - 展示标签30 - - - 展示标签24 - - - 展示标签20 - - -); - -export default SizeDemo; diff --git a/src/tag/_example/size.tsx b/src/tag/_example/size.tsx new file mode 100644 index 000000000..a60a5ca35 --- /dev/null +++ b/src/tag/_example/size.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Tag } from 'tdesign-mobile-react'; + +const SizeDemo = () => ( + <> +
+
+
+ 加大尺寸 + 大尺寸 + 中尺寸 + 小尺寸 +
+
+ 加大尺寸 + 大尺寸 + 中尺寸 + 小尺寸 +
+
+
+ +); + +export default SizeDemo; diff --git a/src/tag/_example/style/index.less b/src/tag/_example/style/index.less index 3aa8c663c..0e62beda1 100644 --- a/src/tag/_example/style/index.less +++ b/src/tag/_example/style/index.less @@ -1,14 +1,34 @@ +.tdesign-mobile-demo { + background-color: var(--bg-color-demo, #fff) +} + .tag-demo { background-color: #fff; padding: 16px; display: flex; - .t-tag + .t-tag { + .t-tag+.t-tag { margin-left: 16px; } } -.tag-demo + .tag-demo { +.tag-block { + margin-bottom: 16px; +} + +.check-tag-block { + display: flex; + align-items: center; + + &__title { + color: var(--td-text-color-disabled, rgba(0, 0, 0, 0.4)); + font-size: 14px; + width: 80px; + margin-right: 16px; + } +} + +.tag-demo+.tag-demo { margin-top: 16px; } @@ -31,3 +51,18 @@ margin-right: 16px; } } + +.tag-container { + width: 100%; +} + +.tag-block1 { + display: flex; + justify-content: space-between; +} + +.tag-block1 { + >.t-tag { + margin: 0; + } +} diff --git a/src/tag/_example/theme.jsx b/src/tag/_example/theme.jsx deleted file mode 100644 index 441db18a3..000000000 --- a/src/tag/_example/theme.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import { Tag } from 'tdesign-mobile-react'; - -const ThemeDemo = () => ( - <> - 标签 - 标签 - 标签 - 标签 - 标签 - -); - -export default ThemeDemo; diff --git a/src/tag/_example/theme.tsx b/src/tag/_example/theme.tsx new file mode 100644 index 000000000..277cbf488 --- /dev/null +++ b/src/tag/_example/theme.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import { Tag } from 'tdesign-mobile-react'; + +const ThemeDemo = () => ( + <> +
展示型标签
+
+
+
+ 默认 + 主要 + 警告 + 危险 + 成功 +
+
+ 默认 + 主要 + 警告 + 危险 + 成功 +
+
+ 默认 + 主要 + 警告 + 危险 + 成功 +
+
+ 默认 + 主要 + 警告 + 危险 + 成功 +
+
+
+ +); + +export default ThemeDemo; diff --git a/src/tag/_example/type.tsx b/src/tag/_example/type.tsx new file mode 100644 index 000000000..2fce5361a --- /dev/null +++ b/src/tag/_example/type.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { Icon } from 'tdesign-icons-react'; +import { Tag } from "tdesign-mobile-react"; + +const TypeDemo = () => ( + <> +
基础标签
+
+ 标签文字 + 标签文字 +
+
圆弧标签
+
+ 标签文字 + 标签文字 + 标签文字 +
+
带图标的标签
+
+ }> + 标签文字 + + }> + 标签文字 + +
+
超长文本省略标签
+
+ 听说超长可以省略听说超长 +
+ +); + +export default TypeDemo; diff --git a/src/tag/_example/variant.jsx b/src/tag/_example/variant.jsx deleted file mode 100644 index 1731138a3..000000000 --- a/src/tag/_example/variant.jsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -import { Tag } from 'tdesign-mobile-react'; - -const VariantDemo = () => ( - <> - - 深色 - - - 浅色 - - - 描边 - - - 浅色描边 - - -); - -export default VariantDemo; diff --git a/src/tag/defaultProps.ts b/src/tag/defaultProps.ts new file mode 100644 index 000000000..fba81011f --- /dev/null +++ b/src/tag/defaultProps.ts @@ -0,0 +1,23 @@ +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdCheckTagProps, TdTagProps } from './type'; + +export const tagDefaultProps: TdTagProps = { + closable: false, + disabled: false, + icon: undefined, + shape: 'square', + size: 'medium', + theme: 'default', + variant: 'dark', +}; + +export const checkTagDefaultProps: TdCheckTagProps = { + closable: false, + disabled: false, + shape: 'square', + size: 'medium', + variant: 'dark', +}; diff --git a/src/tag/style/index.js b/src/tag/style/index.js index ba353af39..f67ee5024 100644 --- a/src/tag/style/index.js +++ b/src/tag/style/index.js @@ -1 +1 @@ -import '../../_common/style/mobile/components/tag/_index.less'; +import '../../_common/style/mobile/components/tag/v2/_index.less'; diff --git a/src/tag/tag.md b/src/tag/tag.md index ed8ef2a68..5a12c2a23 100644 --- a/src/tag/tag.md +++ b/src/tag/tag.md @@ -1,37 +1,43 @@ :: BASE_DOC :: ## API + ### Tag Props -名称 | 类型 | 默认值 | 说明 | 必传 +名称 | 类型 | 默认值 | 描述 | 必传 -- | -- | -- | -- | -- className | String | - | 类名 | N style | Object | - | 样式,TS 类型:`React.CSSProperties` | N +children | TNode | - | 组件子元素,同`content`。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N closable | Boolean | false | 标签是否可关闭 | N -content | TNode | - | 组件子元素。TS 类型:`string | number | TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +content | TNode | - | 组件子元素。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N disabled | Boolean | false | 标签禁用态,失效标签不能触发事件。默认风格(theme=default)才有禁用态 | N icon | TElement | undefined | 标签中的图标,可自定义图标呈现。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N -maxWidth | String / Number | - | 标签最大宽度,宽度超出后会出现省略号。示例:'50px' / 80。TS 类型:`CSSProperties['maxWidth'] | number` | N +maxWidth | String / Number | - | 标签最大宽度,宽度超出后会出现省略号。示例:'50px' / 80 | N shape | String | square | 标签类型,有三种:方形、圆角方形、标记型。可选项:square/round/mark | N -size | String | medium | 标签尺寸。可选项:small/medium/large。TS 类型:`SizeEnum`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +size | String | medium | 标签尺寸。可选项:small/medium/large/extra-large | N theme | String | default | 组件风格,用于描述组件不同的应用场景。可选项:default/primary/warning/danger/success | N variant | String | dark | 标签风格变体。可选项:dark/light/outline/light-outline | N onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
点击时触发 | N onClose | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
如果关闭按钮存在,点击关闭按钮时触发 | N + ### CheckTag Props -名称 | 类型 | 默认值 | 说明 | 必传 +名称 | 类型 | 默认值 | 描述 | 必传 -- | -- | -- | -- | -- className | String | - | 类名 | N style | Object | - | 样式,TS 类型:`React.CSSProperties` | N -checked | Boolean | undefined | 标签选中的状态,默认风格(theme=default)才有选中态 | N -defaultChecked | Boolean | undefined | 标签选中的状态,默认风格(theme=default)才有选中态。非受控属性 | N +checked | Boolean | - | 标签选中的状态,默认风格(theme=default)才有选中态 | N +children | TNode | - | 组件子元素。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N closable | Boolean | false | 标签是否可关闭 | N -content | TNode | - | 组件子元素。TS 类型:`string | number | TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +content | TNode | - | 组件子元素;传入数组时:[选中内容,非选中内容]。TS 类型:`string \| number \| array \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N +defaultChecked | Boolean | - | 标签选中的状态,默认风格(theme=default)才有选中态。非受控属性 | N disabled | Boolean | false | 标签禁用态,失效标签不能触发事件。默认风格(theme=default)才有禁用态 | N icon | TElement | - | 标签中的图标,可自定义图标呈现。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N -shape | String | square | 标签类型,有三种:方形、圆角方形、标记型。可选项:square/round/mark | N +shape | String | square | 标签类型,有三种:方形、圆角方形、标记型。。可选项:square/round/mark | N size | String | medium | 标签尺寸。可选项:small/medium/large。TS 类型:`SizeEnum`。[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N -onChange | Function | | TS 类型:`(checked: boolean) => void`
组件子元素 | N +variant | String | dark | 标签风格变体。可选项:dark/light/outline/light-outline | N +onChange | Function | | TS 类型:`(checked: boolean) => void`
状态切换时触发 | N onClick | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
点击标签时触发 | N +onClose | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
如果关闭按钮存在,点击关闭按钮时触发 | N diff --git a/src/tag/type.ts b/src/tag/type.ts index 13261f3d9..bf0fb60c0 100644 --- a/src/tag/type.ts +++ b/src/tag/type.ts @@ -4,10 +4,14 @@ * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC * */ -import { TNode, TElement, SizeEnum } from '../common'; -import { CSSProperties, MouseEvent } from 'react'; +import { MouseEvent } from 'react'; +import { SizeEnum, TElement, TNode } from '../common'; export interface TdTagProps { + /** + * 组件子元素,同`content` + */ + children?: TNode; /** * 标签是否可关闭 * @default false @@ -29,7 +33,7 @@ export interface TdTagProps { /** * 标签最大宽度,宽度超出后会出现省略号。示例:'50px' / 80 */ - maxWidth?: CSSProperties['maxWidth'] | number; + maxWidth?: string | number; /** * 标签类型,有三种:方形、圆角方形、标记型 * @default square @@ -39,7 +43,7 @@ export interface TdTagProps { * 标签尺寸 * @default medium */ - size?: SizeEnum; + size?: 'small' | 'medium' | 'large' | 'extra-large'; /** * 组件风格,用于描述组件不同的应用场景 * @default default @@ -53,11 +57,11 @@ export interface TdTagProps { /** * 点击时触发 */ - onClick?: (context: { e: MouseEvent }) => void; + onClick?: (context: { e: MouseEvent }) => void; /** * 如果关闭按钮存在,点击关闭按钮时触发 */ - onClose?: (context: { e: MouseEvent }) => void; + onClose?: (context: { e: MouseEvent }) => void; } export interface TdCheckTagProps { @@ -66,18 +70,22 @@ export interface TdCheckTagProps { */ checked?: boolean; /** - * 标签选中的状态,默认风格(theme=default)才有选中态,非受控属性 + * 组件子元素 */ - defaultChecked?: boolean; + children?: TNode; /** * 标签是否可关闭 * @default false */ closable?: boolean; /** - * 组件子元素 + * 组件子元素;传入数组时:[选中内容,非选中内容] */ content?: TNode; + /** + * 标签选中的状态,默认风格(theme=default)才有选中态。非受控属性 + */ + defaultChecked?: boolean; /** * 标签禁用态,失效标签不能触发事件。默认风格(theme=default)才有禁用态 * @default false @@ -88,7 +96,7 @@ export interface TdCheckTagProps { */ icon?: TElement; /** - * 标签类型,有三种:方形、圆角方形、标记型 + * 标签类型,有三种:方形、圆角方形、标记型。 * @default square */ shape?: 'square' | 'round' | 'mark'; @@ -98,11 +106,20 @@ export interface TdCheckTagProps { */ size?: SizeEnum; /** - * 组件子元素 + * 标签风格变体 + * @default dark + */ + variant?: 'dark' | 'light' | 'outline' | 'light-outline'; + /** + * 状态切换时触发 */ onChange?: (checked: boolean) => void; /** * 点击标签时触发 */ - onClick?: (context: { e: MouseEvent }) => void; + onClick?: (context: { e: MouseEvent }) => void; + /** + * 如果关闭按钮存在,点击关闭按钮时触发 + */ + onClose?: (context: { e: MouseEvent }) => void; } diff --git a/test/snap/__snapshots__/csr.test.jsx.snap b/test/snap/__snapshots__/csr.test.jsx.snap index 5a3922ae3..94f8f30f3 100644 --- a/test/snap/__snapshots__/csr.test.jsx.snap +++ b/test/snap/__snapshots__/csr.test.jsx.snap @@ -4718,6 +4718,1561 @@ exports[`csr snapshot test > csr test src/sticky/_example/offset.tsx 1`] = ` `; +exports[`csr snapshot test > csr test src/tag/_example/checkable.tsx 1`] = ` +
+
+ 可选中的标签 +
+
+
+
+
+ light +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+ dark +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+ outline +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+ light-outline +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/tag/_example/closable.tsx 1`] = ` +
+
+ 可关闭标签 +
+
+ + + 文字标签 + + + + + + + + + + 文字标签 + + + + + + + +
+
+`; + +exports[`csr snapshot test > csr test src/tag/_example/index.tsx 1`] = ` +
+
+

+ Tag 标签 +

+

+ 用于表明主体的类目,属性或状态。 +

+
+
+

+ 01 组件类型 +

+
+
+
+ 基础标签 +
+
+ + + 标签文字 + + + + + 标签文字 + + +
+
+ 圆弧标签 +
+
+ + + 标签文字 + + + + + 标签文字 + + + + + 标签文字 + + +
+
+ 带图标的标签 +
+
+ + + + + + + + 标签文字 + + + + + + + + + + 标签文字 + + +
+
+ 超长文本省略标签 +
+
+ + + 听说超长可以省略听说超长 + + +
+
+ 可关闭标签 +
+
+ + + 文字标签 + + + + + + + + + + 文字标签 + + + + + + + +
+
+ 可选中的标签 +
+
+
+
+
+ light +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+ dark +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+ outline +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+ light-outline +
+ + + 未选中态 + + + + + 已选中态 + + +
+
+
+
+
+
+
+

+ 02 组件状态 +

+
+
+
+ 展示型标签 +
+
+
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+
+
+
+
+
+

+ 03 组件尺寸 +

+
+
+
+
+
+
+ + + 加大尺寸 + + + + + 大尺寸 + + + + + 中尺寸 + + + + + 小尺寸 + + +
+
+ + + 加大尺寸 + + + + + + + + + + 大尺寸 + + + + + + + + + + 中尺寸 + + + + + + + + + + 小尺寸 + + + + + + + +
+
+
+
+
+
+
+
+`; + +exports[`csr snapshot test > csr test src/tag/_example/size.tsx 1`] = ` +
+
+
+
+ + + 加大尺寸 + + + + + 大尺寸 + + + + + 中尺寸 + + + + + 小尺寸 + + +
+
+ + + 加大尺寸 + + + + + + + + + + 大尺寸 + + + + + + + + + + 中尺寸 + + + + + + + + + + 小尺寸 + + + + + + + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/tag/_example/theme.tsx 1`] = ` +
+
+ 展示型标签 +
+
+
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+ + + 默认 + + + + + 主要 + + + + + 警告 + + + + + 危险 + + + + + 成功 + + +
+
+
+
+`; + +exports[`csr snapshot test > csr test src/tag/_example/type.tsx 1`] = ` +
+
+ 基础标签 +
+
+ + + 标签文字 + + + + + 标签文字 + + +
+
+ 圆弧标签 +
+
+ + + 标签文字 + + + + + 标签文字 + + + + + 标签文字 + + +
+
+ 带图标的标签 +
+
+ + + + + + + + 标签文字 + + + + + + + + + + 标签文字 + + +
+
+ 超长文本省略标签 +
+
+ + + 听说超长可以省略听说超长 + + +
+
+`; + exports[`ssr snapshot test > ssr test src/back-top/_example/base.tsx 1`] = `"
"`; exports[`ssr snapshot test > ssr test src/back-top/_example/index.tsx 1`] = `"

BackTop 返回顶部

当页面过长往下滑动是会出现返回顶部的便捷操作,帮助用户快速回到页面顶部

形状

"`; @@ -4769,3 +6324,15 @@ exports[`ssr snapshot test > ssr test src/sticky/_example/container.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/sticky/_example/index.tsx 1`] = `"

Sticky 吸顶

用于常驻页面顶部的信息,操作展示

基础吸顶

吸顶距离

指定容器

"`; exports[`ssr snapshot test > ssr test src/sticky/_example/offset.tsx 1`] = `"
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/checkable.tsx 1`] = `"
可选中的标签
light
未选中态已选中态
dark
未选中态已选中态
outline
未选中态已选中态
light-outline
未选中态已选中态
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/closable.tsx 1`] = `"
可关闭标签
文字标签文字标签
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/index.tsx 1`] = `"

Tag 标签

用于表明主体的类目,属性或状态。

01 组件类型

基础标签
标签文字标签文字
圆弧标签
标签文字标签文字标签文字
带图标的标签
标签文字标签文字
超长文本省略标签
听说超长可以省略听说超长
可关闭标签
文字标签文字标签
可选中的标签
light
未选中态已选中态
dark
未选中态已选中态
outline
未选中态已选中态
light-outline
未选中态已选中态

02 组件状态

展示型标签
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功

03 组件尺寸

加大尺寸大尺寸中尺寸小尺寸
加大尺寸大尺寸中尺寸小尺寸
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/size.tsx 1`] = `"
加大尺寸大尺寸中尺寸小尺寸
加大尺寸大尺寸中尺寸小尺寸
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/theme.tsx 1`] = `"
展示型标签
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/type.tsx 1`] = `"
基础标签
标签文字标签文字
圆弧标签
标签文字标签文字标签文字
带图标的标签
标签文字标签文字
超长文本省略标签
听说超长可以省略听说超长
"`; diff --git a/test/snap/__snapshots__/ssr.test.jsx.snap b/test/snap/__snapshots__/ssr.test.jsx.snap index 29a019ae5..28e86820e 100644 --- a/test/snap/__snapshots__/ssr.test.jsx.snap +++ b/test/snap/__snapshots__/ssr.test.jsx.snap @@ -51,3 +51,15 @@ exports[`ssr snapshot test > ssr test src/sticky/_example/container.tsx 1`] = `" exports[`ssr snapshot test > ssr test src/sticky/_example/index.tsx 1`] = `"

Sticky 吸顶

用于常驻页面顶部的信息,操作展示

基础吸顶

吸顶距离

指定容器

"`; exports[`ssr snapshot test > ssr test src/sticky/_example/offset.tsx 1`] = `"
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/checkable.tsx 1`] = `"
可选中的标签
light
未选中态已选中态
dark
未选中态已选中态
outline
未选中态已选中态
light-outline
未选中态已选中态
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/closable.tsx 1`] = `"
可关闭标签
文字标签文字标签
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/index.tsx 1`] = `"

Tag 标签

用于表明主体的类目,属性或状态。

01 组件类型

基础标签
标签文字标签文字
圆弧标签
标签文字标签文字标签文字
带图标的标签
标签文字标签文字
超长文本省略标签
听说超长可以省略听说超长
可关闭标签
文字标签文字标签
可选中的标签
light
未选中态已选中态
dark
未选中态已选中态
outline
未选中态已选中态
light-outline
未选中态已选中态

02 组件状态

展示型标签
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功

03 组件尺寸

加大尺寸大尺寸中尺寸小尺寸
加大尺寸大尺寸中尺寸小尺寸
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/size.tsx 1`] = `"
加大尺寸大尺寸中尺寸小尺寸
加大尺寸大尺寸中尺寸小尺寸
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/theme.tsx 1`] = `"
展示型标签
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功
默认主要警告危险成功
"`; + +exports[`ssr snapshot test > ssr test src/tag/_example/type.tsx 1`] = `"
基础标签
标签文字标签文字
圆弧标签
标签文字标签文字标签文字
带图标的标签
标签文字标签文字
超长文本省略标签
听说超长可以省略听说超长
"`;