Skip to content

Commit

Permalink
Add ButtonListDirectionEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Naszalyi committed Nov 13, 2024
1 parent d2e9318 commit 57add51
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 46 deletions.
25 changes: 18 additions & 7 deletions examples/react-template/screens/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<Spacer size={10}/>
<Divider/>
<Spacer size={50}/>
<Spacer size={10} />
<Divider />
<Spacer size={50} />
</>
);
};
)
}

export const ButtonScreen = (): JSX.Element => {
return (
Expand All @@ -33,6 +35,15 @@ export const ButtonScreen = (): JSX.Element => {
})}
</ButtonList>
<Separator/>
{/* ======== list column ======== */}
<Title level={TitleLevels.TWO}>List column</Title>
<Spacer size={10}/>
<ButtonList direction={ButtonListDirectionEnum.COLUMN} align={Alignable.ALIGNED_START}>
{Object.values(ButtonVariant).map((variant, index) => {
return <Button variant={variant} key={index}>{variant}</Button>;
})}
</ButtonList>
<Separator/>

{/* ======== loading & variant ======== */}
<Title level={TitleLevels.TWO}>loading + variant </Title>
Expand Down
6 changes: 6 additions & 0 deletions packages/react/components/button/list/ButtonListEnum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum ButtonListDirectionEnum {
ROW = 'row',
COLUMN = 'column',
}

export type ButtonListDirectionEnumValues = `${ButtonListDirectionEnum}`
3 changes: 2 additions & 1 deletion packages/react/components/button/list/ButtonListProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ButtonProps | DividerProps> | undefined

Expand All @@ -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
}
24 changes: 4 additions & 20 deletions packages/react/components/price/Price.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const Price = ({
level,
inverted,
align,
inline,
testId,
accessibilityLabel,
oldAmount,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -281,18 +276,7 @@ const Price = ({
testID={priceTestId}
{...others}
>
{inline ? (
<View style={[styles.priceContainer, { flexDirection: 'row' }]}>
{oldAmount && <Text style={[styles.striked]}></Text>}
<Text style={[styles.price, styles.priceFontSize, styles.priceColor]}>
{whole}{hideCents && cents}
</Text>
<Text style={[styles.inlinePeriod, styles.priceColor]}>
{mention}
{period && ` / ${period}`}
</Text>
</View>
) : (
{
<>
{oldAmount && (
<View style={[{ flexDirection: 'row' }]}>
Expand Down Expand Up @@ -331,7 +315,7 @@ const Price = ({
</View>
)}
</>
)}
}
</View>
{tagValue && (
<View style={{ flexDirection: 'row', alignItems: 'center', marginLeft: 5 }}>
Expand Down
23 changes: 6 additions & 17 deletions packages/react/components/price/Price.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const Price = ({
level,
inverted,
align,
inline,
accessibilityLabel,
oldAmount,
overline,
Expand All @@ -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
Expand All @@ -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 = (
<span aria-hidden='true' className={classesStrike} {...others}>
<Text markup={TextMarkup.SPAN}>{`${wholeStrike}`}</Text>
<span className={hashClass(styled, clsx('price-details'))}>
<span className={hashClass(styled, clsx('cents'))}>
{inline && centsDisplayed === '€' ? <>&nbsp;{centsDisplayed}</> : centsDisplayed}
{centsDisplayed === '€' ? <>&nbsp;{centsDisplayed}</> : centsDisplayed}
{mention && <sup>{mention}</sup>}
</span>
{period && <span className={hashClass(styled, clsx('period'))}>/{period}</span>}
Expand All @@ -99,14 +88,14 @@ const Price = ({

let cents = checkCents(absoluteAmount.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'}`) || '€'

amountComponent = (
<span aria-hidden='true' aria-label={accessibilityLabel} className={classes} {...others}>
<Text markup={TextMarkup.SPAN}>{`${whole}`}</Text>
<span className={hashClass(styled, clsx('price-details'))}>
<span className={hashClass(styled, clsx('cents'))}>
{inline && centsDisplayed === '€' ? <>&nbsp;{centsDisplayed}</> : centsDisplayed}
{centsDisplayed === '€' ? <>&nbsp;{centsDisplayed}</> : centsDisplayed}
{mention && <sup>{mention}</sup>}
</span>
{period && <span className={hashClass(styled, clsx('period'))}>/{period}</span>}
Expand Down
1 change: 0 additions & 1 deletion packages/react/components/price/PriceProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface PriceProps extends Invertable, Accessibility, AlignableProps, D
mention?: string
period?: string
hideCents?: boolean
inline?: boolean
level?: PriceLevel | PriceLevelValues
oldAmount?: number
overline?: string
Expand Down

0 comments on commit 57add51

Please sign in to comment.