diff --git a/.changeset/gorgeous-falcons-peel.md b/.changeset/gorgeous-falcons-peel.md new file mode 100644 index 0000000000..b2f563d725 --- /dev/null +++ b/.changeset/gorgeous-falcons-peel.md @@ -0,0 +1,4 @@ +--- +"@ultraviolet/ui": patch +--- +``: new prop `whiteSpace` \ No newline at end of file diff --git a/packages/plus/src/components/Navigation/components/Item.tsx b/packages/plus/src/components/Navigation/components/Item.tsx index 14c8a17eb0..fdd42774b9 100644 --- a/packages/plus/src/components/Navigation/components/Item.tsx +++ b/packages/plus/src/components/Navigation/components/Item.tsx @@ -133,7 +133,6 @@ const WrapText = styled(Text, { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; - white-space: pre-wrap; ` const StyledStack = styled(Stack)` @@ -602,6 +601,7 @@ export const Item = memo( animation={animation} disabled={disabled} subLabel + whiteSpace="pre-wrap" > {subLabel} diff --git a/packages/ui/src/__stories__/Properties/Properties.tsx b/packages/ui/src/__stories__/Properties/Properties.tsx index e93dd4e485..7d6a156907 100644 --- a/packages/ui/src/__stories__/Properties/Properties.tsx +++ b/packages/ui/src/__stories__/Properties/Properties.tsx @@ -5,10 +5,6 @@ import { Stack } from '../../components/Stack' import { Table } from '../../components/Table' import { Text } from '../../components/Text' -const StyledText = styled(Text)` - white-space: break-spaces; -` - const StyledTableRow = styled(Table.Row)` vertical-align: top; ` @@ -253,21 +249,21 @@ const Properties = () => { - + {propertyValues.join(', ')} - + - + {findSimilarProperty.join(', ')} - + - + {sortedPropertiesUsagesCountAndComponentsName[ property ].components.join(', ')} - + ) diff --git a/packages/ui/src/components/Badge/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Badge/__tests__/__snapshots__/index.test.tsx.snap index 98e27bd4cb..7cfb48c4d4 100644 --- a/packages/ui/src/components/Badge/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Badge/__tests__/__snapshots__/index.test.tsx.snap @@ -11,6 +11,7 @@ exports[`Badge > renders correctly prominence default 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -23,7 +24,6 @@ exports[`Badge > renders correctly prominence default 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -60,6 +60,7 @@ exports[`Badge > renders correctly prominence strong 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -72,7 +73,6 @@ exports[`Badge > renders correctly prominence strong 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -109,6 +109,7 @@ exports[`Badge > renders correctly sentiment danger 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -121,7 +122,6 @@ exports[`Badge > renders correctly sentiment danger 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -158,6 +158,7 @@ exports[`Badge > renders correctly sentiment info 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -170,7 +171,6 @@ exports[`Badge > renders correctly sentiment info 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -207,6 +207,7 @@ exports[`Badge > renders correctly sentiment neutral 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -219,7 +220,6 @@ exports[`Badge > renders correctly sentiment neutral 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -256,6 +256,7 @@ exports[`Badge > renders correctly sentiment primary 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -268,7 +269,6 @@ exports[`Badge > renders correctly sentiment primary 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -305,6 +305,7 @@ exports[`Badge > renders correctly sentiment secondary 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -317,7 +318,6 @@ exports[`Badge > renders correctly sentiment secondary 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -354,6 +354,7 @@ exports[`Badge > renders correctly sentiment success 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -366,7 +367,6 @@ exports[`Badge > renders correctly sentiment success 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -403,6 +403,7 @@ exports[`Badge > renders correctly sentiment warning 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -415,7 +416,6 @@ exports[`Badge > renders correctly sentiment warning 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -452,6 +452,7 @@ exports[`Badge > renders correctly size large 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -464,7 +465,6 @@ exports[`Badge > renders correctly size large 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 1rem; gap: 0.5rem; @@ -501,6 +501,7 @@ exports[`Badge > renders correctly size medium 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -513,7 +514,6 @@ exports[`Badge > renders correctly size medium 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -550,6 +550,7 @@ exports[`Badge > renders correctly size small 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -562,7 +563,6 @@ exports[`Badge > renders correctly size small 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.5rem; gap: 0.25rem; @@ -599,6 +599,7 @@ exports[`Badge > renders correctly when disabled 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -611,7 +612,6 @@ exports[`Badge > renders correctly when disabled 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -648,6 +648,7 @@ exports[`Badge > renders correctly with default values 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -660,7 +661,6 @@ exports[`Badge > renders correctly with default values 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -697,6 +697,7 @@ exports[`Badge > renders correctly with icon 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -709,7 +710,6 @@ exports[`Badge > renders correctly with icon 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; diff --git a/packages/ui/src/components/Badge/index.tsx b/packages/ui/src/components/Badge/index.tsx index be70c3a72f..b9bad16b0d 100644 --- a/packages/ui/src/components/Badge/index.tsx +++ b/packages/ui/src/components/Badge/index.tsx @@ -97,7 +97,6 @@ const StyledSpan = styled(Text, { display: inline-flex; align-items: center; justify-content: center; - white-space: nowrap; border-radius: ${({ theme }) => theme.radii.xlarge}; padding: 0 ${({ theme, size }) => { @@ -171,6 +170,7 @@ export const Badge = ({ prominence={disabled ? 'weak' : 'default'} className={className} data-testid={dataTestId} + whiteSpace="nowrap" > {icon && size !== 'small' ? : null} {children} diff --git a/packages/ui/src/components/Snippet/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Snippet/__tests__/__snapshots__/index.test.tsx.snap index baf7318dba..6b0634ab4f 100644 --- a/packages/ui/src/components/Snippet/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Snippet/__tests__/__snapshots__/index.test.tsx.snap @@ -50,11 +50,11 @@ exports[`Snippet > renders correctly 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; margin: 0; padding: 1rem; padding-right: 4.5rem; overflow-x: auto; - white-space: nowrap; height: auto; counter-reset: section; overflow-y: hidden; @@ -1312,11 +1312,11 @@ exports[`Snippet > renders correctly with copiedText 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; margin: 0; padding: 1rem; padding-right: 4.5rem; overflow-x: auto; - white-space: nowrap; height: auto; counter-reset: section; overflow-y: hidden; @@ -1526,11 +1526,11 @@ exports[`Snippet > renders correctly with copyText 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; margin: 0; padding: 1rem; padding-right: 4.5rem; overflow-x: auto; - white-space: nowrap; height: auto; counter-reset: section; overflow-y: hidden; @@ -3944,11 +3944,11 @@ exports[`Snippet > renders correctly with single line with prefix command 1`] = text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; margin: 0; padding: 1rem; padding-right: 4.5rem; overflow-x: auto; - white-space: nowrap; height: auto; counter-reset: section; overflow-y: hidden; @@ -4173,11 +4173,11 @@ exports[`Snippet > renders correctly with single line with prefix lines number 1 text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; margin: 0; padding: 1rem; padding-right: 4.5rem; overflow-x: auto; - white-space: nowrap; height: auto; counter-reset: section; overflow-y: hidden; diff --git a/packages/ui/src/components/Snippet/index.tsx b/packages/ui/src/components/Snippet/index.tsx index e9b582c4bc..fb7406618a 100644 --- a/packages/ui/src/components/Snippet/index.tsx +++ b/packages/ui/src/components/Snippet/index.tsx @@ -14,15 +14,8 @@ type Prefixes = 'lines' | 'command' const PreText = styled(Text, { shouldForwardProp: prop => - ![ - 'multiline', - 'hasShowMoreButton', - 'showMore', - 'rows', - 'noExpandable', - ].includes(prop), + !['hasShowMoreButton', 'showMore', 'rows', 'noExpandable'].includes(prop), })<{ - multiline?: boolean hasShowMoreButton?: boolean showMore?: boolean rows: number @@ -33,7 +26,6 @@ const PreText = styled(Text, { padding-right: ${({ theme }) => theme.space['9']}; overflow-x: ${({ hasShowMoreButton, showMore }) => hasShowMoreButton && !showMore ? 'hidden' : 'auto'}; - ${({ multiline }) => (!multiline ? 'white-space: nowrap;' : '')} height: auto; counter-reset: section; @@ -169,11 +161,11 @@ const CodeContent = ({ {multiline ? ( Children.map(lines, child => ( diff --git a/packages/ui/src/components/Stepper/Step.tsx b/packages/ui/src/components/Stepper/Step.tsx index 3adda2489f..aa70e41248 100644 --- a/packages/ui/src/components/Stepper/Step.tsx +++ b/packages/ui/src/components/Stepper/Step.tsx @@ -67,7 +67,6 @@ const StyledText = styled(Text)` text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; ` const StyledStepContainer = styled(Stack)<{ @@ -259,6 +258,7 @@ export const Step = ({ variant={textVariant} prominence={isDone || isActive ? 'default' : 'weak'} sentiment={isActive ? 'primary' : 'neutral'} + whiteSpace="normal" > {title} diff --git a/packages/ui/src/components/Stepper/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Stepper/__tests__/__snapshots__/index.test.tsx.snap index 3667a94c19..51dc6a5612 100644 --- a/packages/ui/src/components/Stepper/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Stepper/__tests__/__snapshots__/index.test.tsx.snap @@ -424,12 +424,12 @@ exports[`Stepper > handles clicks when interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-10 { @@ -442,12 +442,12 @@ exports[`Stepper > handles clicks when interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -516,12 +516,12 @@ exports[`Stepper > handles clicks when interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-18 { @@ -534,12 +534,12 @@ exports[`Stepper > handles clicks when interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -604,12 +604,12 @@ exports[`Stepper > handles clicks when interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-26 { @@ -622,12 +622,12 @@ exports[`Stepper > handles clicks when interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
handles clicks when interactive and small 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-10 { @@ -1149,12 +1149,12 @@ exports[`Stepper > handles clicks when interactive and small 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -1223,12 +1223,12 @@ exports[`Stepper > handles clicks when interactive and small 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-18 { @@ -1241,12 +1241,12 @@ exports[`Stepper > handles clicks when interactive and small 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -1311,12 +1311,12 @@ exports[`Stepper > handles clicks when interactive and small 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-26 { @@ -1329,12 +1329,12 @@ exports[`Stepper > handles clicks when interactive and small 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
handles clicks when not interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-10 { @@ -1856,12 +1856,12 @@ exports[`Stepper > handles clicks when not interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -1930,12 +1930,12 @@ exports[`Stepper > handles clicks when not interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-18 { @@ -1948,12 +1948,12 @@ exports[`Stepper > handles clicks when not interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -2018,12 +2018,12 @@ exports[`Stepper > handles clicks when not interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-26 { @@ -2036,12 +2036,12 @@ exports[`Stepper > handles clicks when not interactive 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with all selected 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -2390,12 +2390,12 @@ exports[`Stepper > renders correctly with all selected 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -2434,12 +2434,12 @@ exports[`Stepper > renders correctly with all selected 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with animation 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -2788,12 +2788,12 @@ exports[`Stepper > renders correctly with animation 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -2832,12 +2832,12 @@ exports[`Stepper > renders correctly with animation 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with children 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -3186,12 +3186,12 @@ exports[`Stepper > renders correctly with children 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -3230,12 +3230,12 @@ exports[`Stepper > renders correctly with children 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with default props 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -3585,12 +3585,12 @@ exports[`Stepper > renders correctly with default props 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -3629,12 +3629,12 @@ exports[`Stepper > renders correctly with default props 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with disabled steps 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-13 { @@ -3979,12 +3979,12 @@ exports[`Stepper > renders correctly with disabled steps 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with selected prop 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-25 { @@ -4323,12 +4323,12 @@ exports[`Stepper > renders correctly with selected prop 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with small size 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -4687,12 +4687,12 @@ exports[`Stepper > renders correctly with small size 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -4731,12 +4731,12 @@ exports[`Stepper > renders correctly with small size 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with step number in row 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-12 { @@ -5124,12 +5124,12 @@ exports[`Stepper > renders correctly with step number in row 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-22 { @@ -5196,12 +5196,12 @@ exports[`Stepper > renders correctly with step number in row 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly without separator 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -6155,12 +6155,12 @@ exports[`Stepper > renders correctly without separator 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -6199,12 +6199,12 @@ exports[`Stepper > renders correctly without separator 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly without separator with label on the right 1 text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-15 { @@ -6563,12 +6563,12 @@ exports[`Stepper > renders correctly without separator with label on the right 1 text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; } .emotion-23 { @@ -6607,12 +6607,12 @@ exports[`Stepper > renders correctly without separator with label on the right 1 text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: normal; -webkit-transition: text-decoration-color 250ms ease-out; transition: text-decoration-color 250ms ease-out; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: transparent; - white-space: normal; }
renders correctly with counter, badge and subtitle 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -324,7 +325,6 @@ exports[`Tab > renders correctly with counter, badge and subtitle 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; diff --git a/packages/ui/src/components/Tabs/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Tabs/__tests__/__snapshots__/index.test.tsx.snap index cd5d25fe22..d89efca1de 100644 --- a/packages/ui/src/components/Tabs/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Tabs/__tests__/__snapshots__/index.test.tsx.snap @@ -1487,6 +1487,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -1499,7 +1500,6 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -1524,6 +1524,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -1536,7 +1537,6 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -2763,6 +2763,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -2775,7 +2776,6 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; @@ -2800,6 +2800,7 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` text-transform: none; -webkit-text-decoration: none; text-decoration: none; + white-space: nowrap; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; @@ -2812,7 +2813,6 @@ exports[`Tabs > renders correctly with Tabs with prop 1`] = ` -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; - white-space: nowrap; border-radius: 1rem; padding: 0 0.75rem; gap: 0.5rem; diff --git a/packages/ui/src/components/Text/__tests__/__snapshots__/index.test.tsx.snap b/packages/ui/src/components/Text/__tests__/__snapshots__/index.test.tsx.snap index a3ec6f5557..0105f16fc5 100644 --- a/packages/ui/src/components/Text/__tests__/__snapshots__/index.test.tsx.snap +++ b/packages/ui/src/components/Text/__tests__/__snapshots__/index.test.tsx.snap @@ -725,6 +725,32 @@ exports[`Text > renders correctly with type="headingStronger" 1`] = ` `; +exports[`Text > renders correctly with whiteSpace 1`] = ` + + .emotion-0 { + font-size: 1rem; + font-family: Inter,Asap,sans-serif; + font-weight: 400; + letter-spacing: 0; + line-height: 1.5rem; + text-transform: none; + -webkit-text-decoration: none; + text-decoration: none; + white-space: nowrap; +} + +
+
+ This text is quite long. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +
+
+
+`; + exports[`Text > with disabled 1`] = ` .emotion-0 { @@ -776,6 +802,32 @@ exports[`Text > with italic 1`] = ` `; +exports[`Text > with monochrome 1`] = ` + + .emotion-0 { + color: #151a2d; + font-size: 1rem; + font-family: Inter,Asap,sans-serif; + font-weight: 400; + letter-spacing: 0; + line-height: 1.5rem; + text-transform: none; + -webkit-text-decoration: none; + text-decoration: none; +} + +
+
+ Lorem Ipsum +
+
+
+`; + exports[`Text > with multiple nested children renders correctly 1`] = ` .emotion-0 { diff --git a/packages/ui/src/components/Text/__tests__/index.test.tsx b/packages/ui/src/components/Text/__tests__/index.test.tsx index 6757bdee88..1b40bf4c79 100644 --- a/packages/ui/src/components/Text/__tests__/index.test.tsx +++ b/packages/ui/src/components/Text/__tests__/index.test.tsx @@ -92,4 +92,20 @@ describe('Text', () => { Lorem Ipsum , )) + + test(`with monochrome `, () => + shouldMatchEmotionSnapshot( + + Lorem Ipsum + , + )) + + test(`renders correctly with whiteSpace`, () => + shouldMatchEmotionSnapshot( + + This text is quite long. Lorem ipsum dolor sit amet, consectetur + adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore + magna aliqua. + , + )) }) diff --git a/packages/ui/src/components/Text/index.tsx b/packages/ui/src/components/Text/index.tsx index b9d00e7d32..c10eae888b 100644 --- a/packages/ui/src/components/Text/index.tsx +++ b/packages/ui/src/components/Text/index.tsx @@ -19,6 +19,7 @@ const PROMINENCES = { type ProminenceProps = keyof typeof PROMINENCES type PlacementProps = React.CSSProperties['textAlign'] +type WhiteSpaceProps = React.CSSProperties['whiteSpace'] type TextVariant = keyof typeof typography export const textVariants = Object.keys(typography) as TextVariant[] @@ -35,6 +36,7 @@ const generateStyles = ({ disabled, italic, underline, + whiteSpace, }: { placement?: PlacementProps prominence: ProminenceProps @@ -45,6 +47,7 @@ const generateStyles = ({ disabled: boolean italic: boolean underline: boolean + whiteSpace?: WhiteSpaceProps }): string => { // stronger is available only for neutral sentiment const definedProminence = @@ -77,6 +80,7 @@ const generateStyles = ({ text-transform: ${theme.typography[variant].textCase}; text-decoration: ${theme.typography[variant].textDecoration}; ${placement ? ` text-align: ${placement};` : ''} + ${whiteSpace ? `white-space: ${whiteSpace};` : ''} ${ oneLine @@ -87,6 +91,7 @@ const generateStyles = ({ } ${italic ? `font-style: italic;` : ''} ${underline ? `text-decoration: underline;` : ''} + ` } @@ -110,6 +115,7 @@ type TextProps = { dir?: 'ltr' | 'rtl' | 'auto' htmlFor?: string 'data-testid'?: string + whiteSpace?: WhiteSpaceProps } const StyledText = styled('div', { @@ -124,6 +130,7 @@ const StyledText = styled('div', { 'disabled', 'italic', 'underline', + 'whiteSpace', ].includes(prop), })<{ placement?: PlacementProps @@ -135,6 +142,7 @@ const StyledText = styled('div', { italic: boolean underline: boolean htmlFor?: string + whiteSpace?: WhiteSpaceProps }>(generateStyles) /** @@ -155,6 +163,7 @@ export const Text = ({ underline = false, id, dir, + whiteSpace, htmlFor, 'data-testid': dataTestId, }: TextProps) => { @@ -182,6 +191,7 @@ export const Text = ({ dir={dir} htmlFor={htmlFor} data-testid={dataTestId} + whiteSpace={whiteSpace} > {children}