From baf4db0ddd6cd0a529d677326ca2ab9c7f9b2b7a Mon Sep 17 00:00:00 2001 From: Alisa Bayanova Date: Wed, 19 Jul 2023 16:28:35 +0200 Subject: [PATCH] feat(components/atom/tag/demo): tagGroup demo --- .../tag/demo/articles/ArticleTagGroup1.js | 64 +++++++++++++++++++ .../tag/demo/articles/ArticleTagGroup2.js | 61 ++++++++++++++++++ components/atom/tag/demo/index.js | 6 ++ 3 files changed, 131 insertions(+) create mode 100644 components/atom/tag/demo/articles/ArticleTagGroup1.js create mode 100644 components/atom/tag/demo/articles/ArticleTagGroup2.js diff --git a/components/atom/tag/demo/articles/ArticleTagGroup1.js b/components/atom/tag/demo/articles/ArticleTagGroup1.js new file mode 100644 index 0000000000..6a289e0ecc --- /dev/null +++ b/components/atom/tag/demo/articles/ArticleTagGroup1.js @@ -0,0 +1,64 @@ +import {useState} from 'react' + +import AtomTag, {atomTagDesigns} from 'components/atom/tag/src/index.js' +import PropTypes from 'prop-types' + +import {Article, H2, Paragraph} from '@s-ui/documentation-library' + +const options = [ + {id: 0, value: 'Autónomo'}, + {id: 1, value: 'De duración determinada'}, + {id: 2, value: 'De relevo'}, + {id: 3, value: 'Fijo discontinuo'}, + {id: 4, value: 'Formativo'}, + {id: 5, value: 'Indefinido'}, + {id: 6, value: 'A tiempo parcial'}, + {id: 7, value: 'Otros contratos'} +] + +const ArticleTagGroup1 = ({className}) => { + const [values, setValues] = useState([]) + const handleClick = (ev, {value}) => { + const selectedValues = new Set(values) + selectedValues.has(value) + ? selectedValues.delete(value) + : selectedValues.add(value) + setValues(Array.from(selectedValues)) + } + return ( +
+

TagGroup 1

+ Actionable tags can be used as selectable tags. +
+ + Substitutes OUTLINE design for SOLID design to mark a tag as selected + and vice versa to unselect a tag. + +
+
+ {options?.map((opt, pos) => ( + handleClick(ev, {value})} + /> + ))} +
+ ––––– +
+ ) +} + +ArticleTagGroup1.displayName = 'ArticleTagGroup' + +ArticleTagGroup1.propTypes = { + className: PropTypes.string +} + +export default ArticleTagGroup1 diff --git a/components/atom/tag/demo/articles/ArticleTagGroup2.js b/components/atom/tag/demo/articles/ArticleTagGroup2.js new file mode 100644 index 0000000000..d5ed771fe0 --- /dev/null +++ b/components/atom/tag/demo/articles/ArticleTagGroup2.js @@ -0,0 +1,61 @@ +import {useState} from 'react' + +import AtomTag, {atomTagDesigns} from 'components/atom/tag/src/index.js' +import PropTypes from 'prop-types' + +import {Article, H2, Paragraph} from '@s-ui/documentation-library' + +const options = [ + {id: 0, value: 'Autónomo'}, + {id: 1, value: 'De duración determinada'}, + {id: 2, value: 'De relevo'}, + {id: 3, value: 'Fijo discontinuo'}, + {id: 4, value: 'Formativo'}, + {id: 5, value: 'Indefinido'}, + {id: 6, value: 'A tiempo parcial'}, + {id: 7, value: 'Otros contratos'} +] + +const ArticleTagGroup2 = ({className}) => { + const [values, setValues] = useState([]) + const handleClick = (ev, {value}) => { + const selectedValues = new Set(values) + selectedValues.has(value) + ? selectedValues.delete(value) + : selectedValues.add(value) + setValues(Array.from(selectedValues)) + } + return ( +
+

TagGroup 2

+ Actionable tags can be used as selectable tags. +
+ + Substitutes SOLID design for 'special' tag type to mark a tag as + selected and vice versa to unselect a tag. + +
+
+ {options?.map((opt, pos) => ( + handleClick(ev, {value})} + /> + ))} +
+ ––––– +
+ ) +} + +ArticleTagGroup2.displayName = 'ArticleTagGroup' + +ArticleTagGroup2.propTypes = { + className: PropTypes.string +} + +export default ArticleTagGroup2 diff --git a/components/atom/tag/demo/index.js b/components/atom/tag/demo/index.js index 1de1a36293..ea48d148db 100644 --- a/components/atom/tag/demo/index.js +++ b/components/atom/tag/demo/index.js @@ -5,6 +5,8 @@ import ArticleDesign from './articles/ArticleDesign.js' import ArticleIcons from './articles/ArticleIcons.js' import ArticleIsFitted from './articles/ArticleIsFitted.js' import ArticleSize from './articles/ArticleSize.js' +import ArticleTagGroup1 from './articles/ArticleTagGroup1.js' +import ArticleTagGroup2 from './articles/ArticleTagGroup2.js' import ArticleTypes from './articles/ArticleTypes.js' import {CLASS_SECTION, closeIcon, icon} from './settings.js' @@ -30,5 +32,9 @@ export default () => (
+
+ +
+ )