From 190e2a28a79b99d8b4f2736d160ac64863a43cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Tue, 28 Apr 2020 14:33:39 +0800 Subject: [PATCH] :clapper: improve tag demo (#23703) --- .../__tests__/__snapshots__/demo.test.js.snap | 32 +++++++++---------- components/tag/demo/checkable.md | 24 +++----------- components/tag/demo/hot-tags.md | 10 +++--- components/tag/style/index.less | 1 + 4 files changed, 27 insertions(+), 40 deletions(-) diff --git a/components/tag/__tests__/__snapshots__/demo.test.js.snap b/components/tag/__tests__/__snapshots__/demo.test.js.snap index bfbc8259ac..677735d68c 100644 --- a/components/tag/__tests__/__snapshots__/demo.test.js.snap +++ b/components/tag/__tests__/__snapshots__/demo.test.js.snap @@ -202,23 +202,23 @@ exports[`renders ./components/tag/demo/basic.md correctly 1`] = ` `; exports[`renders ./components/tag/demo/checkable.md correctly 1`] = ` -
+Array [ Tag1 - + , Tag2 - + , Tag3 - -
+ , +] `; exports[`renders ./components/tag/demo/colorful.md correctly 1`] = ` @@ -457,33 +457,33 @@ exports[`renders ./components/tag/demo/controlled.md correctly 1`] = ` `; exports[`renders ./components/tag/demo/hot-tags.md correctly 1`] = ` -
+Array [ Categories: - + , Movies - + , Books - + , Music - + , Sports - -
+ , +] `; exports[`renders ./components/tag/demo/icon.md correctly 1`] = ` diff --git a/components/tag/demo/checkable.md b/components/tag/demo/checkable.md index 1d722f116b..7b2a68d817 100644 --- a/components/tag/demo/checkable.md +++ b/components/tag/demo/checkable.md @@ -22,26 +22,12 @@ import { Tag } from 'antd'; const { CheckableTag } = Tag; -class MyTag extends React.Component { - state = { checked: true }; - - handleChange = checked => { - this.setState({ checked }); - }; - - render() { - return ( - - ); - } -} - ReactDOM.render( -
- Tag1 - Tag2 - Tag3 -
, + <> + Tag1 + Tag2 + Tag3 + , mountNode, ); ``` diff --git a/components/tag/demo/hot-tags.md b/components/tag/demo/hot-tags.md index 8f4a802d5a..d263c02ddb 100644 --- a/components/tag/demo/hot-tags.md +++ b/components/tag/demo/hot-tags.md @@ -18,11 +18,11 @@ import { Tag } from 'antd'; const { CheckableTag } = Tag; -const tagsFromServer = ['Movies', 'Books', 'Music', 'Sports']; +const tagsData = ['Movies', 'Books', 'Music', 'Sports']; class HotTags extends React.Component { state = { - selectedTags: [], + selectedTags: ['Books'], }; handleChange(tag, checked) { @@ -35,9 +35,9 @@ class HotTags extends React.Component { render() { const { selectedTags } = this.state; return ( -
+ <> Categories: - {tagsFromServer.map(tag => ( + {tagsData.map(tag => ( -1} @@ -46,7 +46,7 @@ class HotTags extends React.Component { {tag} ))} -
+ ); } } diff --git a/components/tag/style/index.less b/components/tag/style/index.less index c7ded3f6dd..36f113e099 100644 --- a/components/tag/style/index.less +++ b/components/tag/style/index.less @@ -64,6 +64,7 @@ &-checkable { background-color: transparent; border-color: transparent; + cursor: pointer; &:not(&-checked):hover { color: @primary-color; }