From b92cf106f6f168c8401bf547345f9cc622bc4170 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 17 Dec 2024 15:20:49 +0100 Subject: [PATCH] fix(Text): add strike through on text --- .changeset/dry-fishes-allow.md | 5 ++++ .../EstimateCost/Components/Item.tsx | 6 ++++ .../__stories__/NewPrice.stories.tsx | 30 +++++++++++++++++++ .../__stories__/index.stories.tsx | 1 + packages/ui/src/components/Text/index.tsx | 8 +++++ 5 files changed, 50 insertions(+) create mode 100644 .changeset/dry-fishes-allow.md create mode 100644 packages/plus/src/components/EstimateCost/__stories__/NewPrice.stories.tsx diff --git a/.changeset/dry-fishes-allow.md b/.changeset/dry-fishes-allow.md new file mode 100644 index 0000000000..3aaff6445e --- /dev/null +++ b/.changeset/dry-fishes-allow.md @@ -0,0 +1,5 @@ +--- +"@ultraviolet/ui": patch +--- + +Add `strikethrough` prop on `` component diff --git a/packages/plus/src/components/EstimateCost/Components/Item.tsx b/packages/plus/src/components/EstimateCost/Components/Item.tsx index 981ce7d458..62a3e213fa 100644 --- a/packages/plus/src/components/EstimateCost/Components/Item.tsx +++ b/packages/plus/src/components/EstimateCost/Components/Item.tsx @@ -218,6 +218,10 @@ type ItemProps = { | 'years' // Allow a string for unit but keep autocomplete for the above values | (string & NonNullable) + /* + * To strike through the price + */ + strikeThrough?: boolean } const StyleNoPriceItem = styled(Text)` @@ -259,6 +263,7 @@ export const Item = memo( labelTextVariant, // To change left cell typography variant labelTextProminence, // To change left cell typography prominence notice, // To display a gray text below the label + strikeThrough, // To strike through the price }: ItemProps) => { const { locales, formatNumber } = useEstimateCost() @@ -458,6 +463,7 @@ export const Item = memo( <> > = props => ( + + + + + + + + + +) + +NewPrice.parameters = { + docs: { + description: { + story: '', + }, + }, +} diff --git a/packages/plus/src/components/EstimateCost/__stories__/index.stories.tsx b/packages/plus/src/components/EstimateCost/__stories__/index.stories.tsx index 6cb3f0228f..cf91926e46 100644 --- a/packages/plus/src/components/EstimateCost/__stories__/index.stories.tsx +++ b/packages/plus/src/components/EstimateCost/__stories__/index.stories.tsx @@ -32,3 +32,4 @@ export { GlobalDiscount } from './GlobalDiscount.stories' export { LocalDiscount } from './LocalDiscount.stories' export { NegativeValues } from './NegativeValues.stories' export { Design } from './Design.stories' +export { NewPrice } from './NewPrice.stories' diff --git a/packages/ui/src/components/Text/index.tsx b/packages/ui/src/components/Text/index.tsx index b9d00e7d32..c2ef5c147a 100644 --- a/packages/ui/src/components/Text/index.tsx +++ b/packages/ui/src/components/Text/index.tsx @@ -35,6 +35,7 @@ const generateStyles = ({ disabled, italic, underline, + strikeThrough, }: { placement?: PlacementProps prominence: ProminenceProps @@ -45,6 +46,7 @@ const generateStyles = ({ disabled: boolean italic: boolean underline: boolean + strikeThrough?: boolean }): string => { // stronger is available only for neutral sentiment const definedProminence = @@ -87,6 +89,7 @@ const generateStyles = ({ } ${italic ? `font-style: italic;` : ''} ${underline ? `text-decoration: underline;` : ''} + ${strikeThrough ? `text-decoration: line-through;` : ''} ` } @@ -110,6 +113,7 @@ type TextProps = { dir?: 'ltr' | 'rtl' | 'auto' htmlFor?: string 'data-testid'?: string + strikeThrough?: boolean } const StyledText = styled('div', { @@ -124,6 +128,7 @@ const StyledText = styled('div', { 'disabled', 'italic', 'underline', + 'strikeThrough', ].includes(prop), })<{ placement?: PlacementProps @@ -135,6 +140,7 @@ const StyledText = styled('div', { italic: boolean underline: boolean htmlFor?: string + strikeThrough?: boolean }>(generateStyles) /** @@ -153,6 +159,7 @@ export const Text = ({ disabled = false, italic = false, underline = false, + strikeThrough = false, id, dir, htmlFor, @@ -178,6 +185,7 @@ export const Text = ({ disabled={disabled} italic={italic} underline={underline} + strikeThrough={strikeThrough} id={id} dir={dir} htmlFor={htmlFor}