-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- ✨ 新增 `LinkTag` 和 `SelectTag` 组件 - ✨ 新增 `size` 属性,支持调整组件尺寸 - 📚 `彩色标签`和`可关闭标签`新版设计已不再使用,文档中加了对应说明 ## break change - 默认 theme 调整为 `grey` 以适配新版设计语言
- Loading branch information
Showing
15 changed files
with
316 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { forwardRef } from 'react'; | ||
import Icon from '../icon'; | ||
import Tag, { ITagProps } from './Tag'; | ||
|
||
export interface ILinkTagProps | ||
extends Omit< | ||
ITagProps, | ||
'closable' | 'closeButtonStyle' | 'size' | 'theme' | 'outline' | ||
> { | ||
linkIconStyle?: React.CSSProperties; | ||
} | ||
|
||
export const LinkTag = forwardRef<HTMLDivElement, ILinkTagProps>( | ||
({ className, children, linkIconStyle, ...rest }, ref) => { | ||
return ( | ||
<Tag className={`zent-link-tag ${className}`} ref={ref} outline {...rest}> | ||
<div className="zent-link-tag-content">{children}</div> | ||
<Icon | ||
type="right" | ||
className="zent-link-tag-right-icon" | ||
style={linkIconStyle} | ||
/> | ||
</Tag> | ||
); | ||
} | ||
); | ||
|
||
LinkTag.displayName = 'ZentLinkTag'; | ||
|
||
export default LinkTag; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,63 @@ | ||
--- | ||
title: Tag | ||
path: component/tag | ||
group: Data Display | ||
group: Basics | ||
scatter: true | ||
--- | ||
|
||
## Tag | ||
|
||
Tag is suitable for marking and sorting。 | ||
Often used to mark object attributes, classification, usually a rounded rectangle. | ||
|
||
### Guides | ||
|
||
- Tag is usually used as special marks or sorting marks. | ||
- You can add multiple tags for one item. | ||
- The text in tag should not more than four words. | ||
- Use when you need to mark the attributes and dimensions of the content, or supplement the description | ||
- Use tags for cross-level search | ||
- It is recommended that the label text should not exceed 7 characters, and the size of the display label can be configured as required | ||
|
||
### Demos | ||
|
||
<!-- demo-slot-1 --> | ||
<!-- demo-slot-2 --> | ||
<!-- demo-slot-3 --> | ||
|
||
#### The following functions is obsolete in the new design system and is only used as a reference for the old version | ||
|
||
<!-- demo-slot-4 --> | ||
<!-- demo-slot-5 --> | ||
<!-- demo-slot-6 --> | ||
|
||
### API | ||
|
||
| Property | Description | Type | Default | Alternative | | ||
| ---------------- | ------------------------------------------------------------ | ------------------- | ------- | ---------------------------------------------------------- | | ||
| ---------------- | ------------------------------------------------------------ | ------------------- | ------- | ---------------------------------------------------------- | --- | | ||
| theme | The preset color of tag | string | `'red'` | `'red'` \| `'green'` \| `'yellow'` \| `'blue'` \| `'grey'` | | ||
| outline | The style with colorful border and transparent backgound. | bool | `false` | `true` \| `false` | | ||
| rounded | Whether the tag is rounded or not | bool | `true` | `true` \| `false` | | ||
| closable | Whether the tag can be closed | bool | `false` | `true` \| `false` | | ||
| onClose | The callback function that is trigged when the tag is closed | func | `noop` | | ||
| visible | Tag is visible | bool | `true` | `false` | | | ||
| visible | Tag is visible | bool | `true` | `false` | | | ||
| closeButtonStyle | Style of close button | React.CSSProperties | | | | ||
| className | The custom classname | string | | | | ||
| style | The custom style | React.CSSProperties | | | | ||
|
||
> All props are optional, a tag can be closed by using `visible` and `onClose` together. | ||
#### LinkTag | ||
|
||
| Property | Description | Type | Default | Alternative | | ||
| ------------- | -------------------------- | ------------------- | ------- | ----------- | | ||
| className | The custom classname | string | | | | ||
| style | The custom style | React.CSSProperties | | | | ||
| linkIconStyle | The custom link icon style | React.CSSProperties | | | | ||
|
||
#### SelectTag | ||
|
||
| Property | Description | Type | Default | Alternative | | ||
| --------- | --------------------------------------------------------------- | ------------------- | ------- | ----------------- | | ||
| className | The custom classname | string | | | | ||
| style | The custom style | React.CSSProperties | | | | ||
| selected | selected state | boolean | `false` | `true` \| `false` | | ||
| onChange | The callback function that is triggered when the tag is clicked | func | `noop` | | | ||
|
||
> the selected state of SelectTag is fully controlled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import cx from 'classnames'; | ||
import { forwardRef } from 'react'; | ||
import Tag, { ITagProps } from './Tag'; | ||
|
||
export interface ISelectTagProps | ||
extends Omit< | ||
ITagProps, | ||
'closable' | 'closeButtonStyle' | 'onChange' | 'size' | 'theme' | 'outline' | ||
> { | ||
selected?: boolean; | ||
onChange?: (selected: boolean) => void; | ||
} | ||
|
||
export const SelectTag = forwardRef<HTMLDivElement, ISelectTagProps>( | ||
({ className, children, selected, onChange, ...rest }, ref) => { | ||
const handleClick = (_e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { | ||
onChange?.(!selected); | ||
}; | ||
return ( | ||
<Tag | ||
className={cx('zent-select-tag', className, { | ||
'zent-select-tag-selected': selected, | ||
})} | ||
ref={ref} | ||
onClick={handleClick} | ||
outline | ||
{...rest} | ||
> | ||
{children} | ||
</Tag> | ||
); | ||
} | ||
); | ||
|
||
SelectTag.displayName = 'ZentSelectTag'; | ||
|
||
export default SelectTag; |
Oops, something went wrong.