diff --git a/packages/doc/content/components/components/tag/default-web.mdx b/packages/doc/content/components/components/tag/default-web.mdx index b4290cbe26..122aa30714 100644 --- a/packages/doc/content/components/components/tag/default-web.mdx +++ b/packages/doc/content/components/components/tag/default-web.mdx @@ -13,6 +13,15 @@ render( ); ``` +### Ellipsis +The tag component can receive an ellipsis prop that will add "..." if is a large text. + +``` + + default with large text + +``` + ### Props The Tag component also has support for margins props as you can see more details our system diff --git a/packages/doc/content/components/components/tag/informative-web.mdx b/packages/doc/content/components/components/tag/informative-web.mdx index 14daaaa7db..50fb33ffc4 100644 --- a/packages/doc/content/components/components/tag/informative-web.mdx +++ b/packages/doc/content/components/components/tag/informative-web.mdx @@ -45,6 +45,17 @@ Use the prop `small` to control its size ``` +### Ellipsis +Use the prop `ellipsis` with `maxWidth` to cut large texts + +``` + + + I'm a ellipsis tag + + +``` + ### Adornments Use the prop `icon` to add an icon. Refer to icons to check the library. diff --git a/packages/yoga/src/Tag/web/Informative.jsx b/packages/yoga/src/Tag/web/Informative.jsx index 771a1f7541..a238696c09 100644 --- a/packages/yoga/src/Tag/web/Informative.jsx +++ b/packages/yoga/src/Tag/web/Informative.jsx @@ -45,9 +45,10 @@ const TagInformative = ({ }, }, small, + ellipsis, ...props }) => ( - + {icon && ( ', () => { expect(container).toMatchSnapshot(); }); + + it('should match snapshot with ellipsis prop', () => { + const { container } = render( + + + Default with ellipsis + + , + ); + + expect(container).toMatchSnapshot(); + }); + + it('should match snapshot with variant, informative type and ellipsis prop', () => { + const { container } = render( + + + Success with ellipsis + + + Attention with ellipsis + + + Informative with ellipsis + + , + ); + + expect(container).toMatchSnapshot(); + }); }); diff --git a/packages/yoga/src/Tag/web/__snapshots__/Tag.test.jsx.snap b/packages/yoga/src/Tag/web/__snapshots__/Tag.test.jsx.snap index 9620336e4d..d673709326 100644 --- a/packages/yoga/src/Tag/web/__snapshots__/Tag.test.jsx.snap +++ b/packages/yoga/src/Tag/web/__snapshots__/Tag.test.jsx.snap @@ -98,6 +98,45 @@ exports[` should match snapshot with custom icon and informative type 1`] `; +exports[` should match snapshot with ellipsis prop 1`] = ` +.c0 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + border-style: solid; + padding: 4px 8px 4px 8px; + display: block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #6B6B78; + border-radius: 4px; + border-width: 1px; + border-color: #9898A6; + font-size: 12px; + line-height: 16px; + font-weight: 500; + max-width: 10px; +} + + + + Default with ellipsis + + +`; + exports[` should match snapshot with variant and margin prop 1`] = ` .c0 { display: -webkit-inline-box; @@ -574,6 +613,164 @@ exports[` should match snapshot with variant prop and informative type wi `; +exports[` should match snapshot with variant, informative type and ellipsis prop 1`] = ` +.c0 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + border-style: solid; + padding: 4px 8px 4px 8px; + display: block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #1D856C; + border-radius: 4px; + border-width: 1px; + border-color: #1D856C; + font-size: 12px; + line-height: 16px; + font-weight: 500; + max-width: 10px; +} + +.c2 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + border-style: solid; + padding: 4px 8px 4px 8px; + display: block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #CA4808; + border-radius: 4px; + border-width: 1px; + border-color: #CA4808; + font-size: 12px; + line-height: 16px; + font-weight: 500; + max-width: 10px; +} + +.c4 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + border-style: solid; + padding: 4px 8px 4px 8px; + display: block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #5340C9; + border-radius: 4px; + border-width: 1px; + border-color: #5340C9; + font-size: 12px; + line-height: 16px; + font-weight: 500; + max-width: 10px; +} + +.c1 { + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + background-color: #C1EEDB; + color: #231B22; + border-radius: 4px; + border-color: #C1EEDB; + font-size: 12px; + font-weight: 500; +} + +.c5 { + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + background-color: #E0DFFF; + color: #231B22; + border-radius: 4px; + border-color: #E0DFFF; + font-size: 12px; + font-weight: 500; +} + +.c3 { + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + background-color: #FCD6C3; + color: #231B22; + border-radius: 4px; + border-color: #FCD6C3; + font-size: 12px; + font-weight: 500; +} + + + + Success with ellipsis + + + Attention with ellipsis + + + Informative with ellipsis + + +`; + exports[` should match snapshot with without icon and informative type 1`] = ` .c0 { display: -webkit-inline-box;