From 57add5163ca2052c10baec1a2f6cd776c39c8e90 Mon Sep 17 00:00:00 2001 From: Paul Naszalyi Date: Wed, 13 Nov 2024 17:36:35 +0100 Subject: [PATCH] Add ButtonListDirectionEnum --- examples/react-template/screens/Button.tsx | 25 +++++++++++++------ .../components/button/list/ButtonListEnum.ts | 6 +++++ .../components/button/list/ButtonListProps.ts | 3 ++- .../react/components/price/Price.native.tsx | 24 +++--------------- packages/react/components/price/Price.tsx | 23 +++++------------ packages/react/components/price/PriceProps.ts | 1 - 6 files changed, 36 insertions(+), 46 deletions(-) create mode 100644 packages/react/components/button/list/ButtonListEnum.ts diff --git a/examples/react-template/screens/Button.tsx b/examples/react-template/screens/Button.tsx index 8cbb2951..c5e2a75b 100644 --- a/examples/react-template/screens/Button.tsx +++ b/examples/react-template/screens/Button.tsx @@ -8,18 +8,20 @@ import { Spacer, Title, TitleLevels, -} from "@trilogy-ds/react/components"; -import React from "react"; +} from '@trilogy-ds/react/components' +import * as React from 'react' +import { ButtonListDirectionEnum } from '@trilogy-ds/react/lib/components/button/list/ButtonListEnum' +import { Alignable } from '@trilogy-ds/react' const Separator = () => { return ( <> - - - + + + - ); -}; + ) +} export const ButtonScreen = (): JSX.Element => { return ( @@ -33,6 +35,15 @@ export const ButtonScreen = (): JSX.Element => { })} + {/* ======== list column ======== */} + List column + + + {Object.values(ButtonVariant).map((variant, index) => { + return ; + })} + + {/* ======== loading & variant ======== */} loading + variant diff --git a/packages/react/components/button/list/ButtonListEnum.ts b/packages/react/components/button/list/ButtonListEnum.ts new file mode 100644 index 00000000..08cff74a --- /dev/null +++ b/packages/react/components/button/list/ButtonListEnum.ts @@ -0,0 +1,6 @@ +export enum ButtonListDirectionEnum { + ROW = 'row', + COLUMN = 'column', +} + +export type ButtonListDirectionEnumValues = `${ButtonListDirectionEnum}` diff --git a/packages/react/components/button/list/ButtonListProps.ts b/packages/react/components/button/list/ButtonListProps.ts index 5e92d0eb..a68d0620 100644 --- a/packages/react/components/button/list/ButtonListProps.ts +++ b/packages/react/components/button/list/ButtonListProps.ts @@ -2,6 +2,7 @@ import { Alignable, AlignableValues } from '../../../objects' import type { DividerProps } from '../../../components/divider/DividerProps' import type { ButtonProps } from '../../../components/button/ButtonProps' import { CommonProps } from '../../../objects/facets/CommonProps' +import { ButtonListDirectionEnum, ButtonListDirectionEnumValues } from '@/components/button/list/ButtonListEnum' type ButtonListChildrenTypes = React.ReactElement | undefined @@ -16,6 +17,6 @@ export interface ButtonListProps { * Button List Web Interface */ export interface ButtonListWebProps extends ButtonListProps, CommonProps { - direction?: 'row' | 'column' + direction?: ButtonListDirectionEnum | ButtonListDirectionEnumValues align?: Alignable | AlignableValues } diff --git a/packages/react/components/price/Price.native.tsx b/packages/react/components/price/Price.native.tsx index 8d813fee..83b50858 100644 --- a/packages/react/components/price/Price.native.tsx +++ b/packages/react/components/price/Price.native.tsx @@ -40,7 +40,6 @@ const Price = ({ level, inverted, align, - inline, testId, accessibilityLabel, oldAmount, @@ -156,11 +155,7 @@ const Price = ({ priceContainer: { padding: 0, paddingLeft: - (inline && 0) || - (level == PriceLevel.FIVE && 2) || - (level == PriceLevel.SIX && 2) || - (level == PriceLevel.SEVEN && 2) || - 4, + (level == PriceLevel.FIVE && 2) || (level == PriceLevel.SIX && 2) || (level == PriceLevel.SEVEN && 2) || 4, flexDirection: 'column', justifyContent: 'center', width: 'auto', @@ -213,7 +208,7 @@ const Price = ({ height: 1, backgroundColor: (inverted && invertedColor) || primaryColor, width: period ? '96%' : '100%', - transform: [{ rotate: inline ? '-10deg' : strikedRotateByLevel() }], + transform: [{ rotate: strikedRotateByLevel() }], bottom: strikedBottomByLevel(), left: 1, zIndex: 20, @@ -281,18 +276,7 @@ const Price = ({ testID={priceTestId} {...others} > - {inline ? ( - - {oldAmount && } - - {whole}€{hideCents && cents} - - - {mention} - {period && ` / ${period}`} - - - ) : ( + { <> {oldAmount && ( @@ -331,7 +315,7 @@ const Price = ({ )} - )} + } {tagValue && ( diff --git a/packages/react/components/price/Price.tsx b/packages/react/components/price/Price.tsx index 156f8404..443227a2 100644 --- a/packages/react/components/price/Price.tsx +++ b/packages/react/components/price/Price.tsx @@ -36,7 +36,6 @@ const Price = ({ level, inverted, align, - inline, accessibilityLabel, oldAmount, overline, @@ -46,21 +45,11 @@ const Price = ({ }: PriceProps): JSX.Element => { const { styled } = useTrilogyContext() - const classes = hashClass( - styled, - clsx('price', inverted && is('inverted'), inline && is('inlined'), overline && has('suptitle'), className), - ) + const classes = hashClass(styled, clsx('price', inverted && is('inverted'), overline && has('suptitle'), className)) const classesStrike = hashClass( styled, - clsx( - 'price', - inverted && is('inverted'), - inline && is('inlined'), - oldAmount && 'strike', - overline && has('suptitle'), - className, - ), + clsx('price', inverted && is('inverted'), oldAmount && 'strike', overline && has('suptitle'), className), ) let amountComponent = null @@ -75,14 +64,14 @@ const Price = ({ let cents = checkCents(absoluteAmountStrike.toString().split(/[.,]/)[1]?.substring(0, 2) || '') cents = (cents && cents.length === 1 && `${cents}0`) || cents - const centsDisplayed = (inline && !hideCents && `,${cents || '00'} €`) || (!hideCents && `€${cents || '00'}`) || '€' + const centsDisplayed = (!hideCents && `,${cents || '00'} €`) || (!hideCents && `€${cents || '00'}`) || '€' oldAmountComponent = (