Skip to content

Commit

Permalink
Merge pull request #43 from BouyguesTelecom/add/style-price-props
Browse files Browse the repository at this point in the history
💅 Add style price props
  • Loading branch information
sara-picoud authored May 15, 2024
2 parents 6816076 + 3728897 commit 988ac58
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 20 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/assets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trilogy-ds/assets",
"version": "0.0.1-beta.21",
"version": "0.0.1-beta.22",
"description": "Trilogy assets include all Open Source Fonts & Icons",
"author": "Bouygues Telecom",
"type": "module",
Expand Down
28 changes: 17 additions & 11 deletions packages/react/components/price/Price.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { StatesContext } from "../../context/providerStates"
* @param period {string} Period for Price (mois)
* @param showCents {boolean} Display cents
* @param level {PriceLevel} Price custom size
* @param style {Object} Additional style
* @param inverted {boolean} Inverted Price Color
* @param children {React.ReactNode}
* @param align {Alignable} Price alignement
Expand All @@ -37,6 +38,7 @@ const Price = ({
accessibilityLabel,
striked,
suptitle,
style,
...others
}: PriceProps): JSX.Element => {
const statesContext = useContext(StatesContext)
Expand Down Expand Up @@ -150,19 +152,23 @@ const Price = ({
(level == PriceLevel.LEVEL7 && "normal") ||
"bold",
color: color,
fontFamily: "poppins-semibold"
},
cents: {
fontWeight: "bold",
color: color,
fontSize: centsLevel,
fontFamily: "poppins-semibold"
},
period: {
color: color,
fontSize: centsLevel,
fontFamily: "poppins-semibold"
},
inlinePeriod: {
color: color,
fontSize: priceLevel,
fontFamily: "poppins-semibold"
},
striked: {
position: "absolute",
Expand Down Expand Up @@ -198,37 +204,37 @@ const Price = ({

return (
<>
{suptitle && <Text style={styles.suptitle}>{suptitle}</Text>}
{suptitle && <Text style={[styles.suptitle, style?.suptitle]}>{suptitle}</Text>}
<View
style={styles.container}
style={[styles.container, style?.container]}
accessible={!!priceAccessibilityLabel}
accessibilityLabel={priceAccessibilityLabel}
testID={priceTestId}
{...others}
>
{inline ? (
<View style={[styles.priceContainer, { flexDirection: "row" }]}>
{striked && <Text style={styles.striked}></Text>}
<Text style={styles.price}>
{striked && <Text style={[styles.striked, style?.striked]}></Text>}
<Text style={[styles.price, style?.price]}>
{whole}{showCents && cents}
</Text>
<Text style={styles.inlinePeriod}>
<Text style={[styles.inlinePeriod, style?.inlinePeriod]}>
{mention}
{period && ` / ${period}`}
</Text>
</View>
) : (
<View style={[{ flexDirection: "row" }]}>
{striked && <Text style={styles.striked}></Text>}
<View style={styles.priceContainer}>
<Text style={styles.price}>{`${whole}`}</Text>
{striked && <Text style={[styles.striked, style?.striked]}></Text>}
<View style={[styles.priceContainer, style?.priceContainer]}>
<Text style={[styles.price, style?.price]}>{`${whole}`}</Text>
</View>
<View style={styles.priceContainer}>
<Text style={styles.cents}>
<View style={[styles.priceContainer, style?.priceContainer]}>
<Text style={[styles.cents, style?.cents]}>
{showCents && (cents || "00")}
{mention && mention}
</Text>
<Text style={styles.period}>{period && `/${period}`}</Text>
<Text style={[styles.period, style?.period]}>{period && `/${period}`}</Text>
</View>
</View>
)}
Expand Down
4 changes: 4 additions & 0 deletions packages/react/components/price/PriceProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { PriceLevel, PriceLevelValues } from "./PriceEnum"
import { Invertable } from "../../objects/facets/Invertable"
import { Accessibility, AlertProps, AlignableProps } from "../../objects"

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Styles = { [key: string]: any }

/**
* Price Interface
*/
Expand All @@ -20,4 +23,5 @@ export interface PriceProps
className?: string;
striked?: boolean;
suptitle?: string;
style?: Styles
}
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trilogy-ds/react",
"version": "0.0.1-beta.21",
"version": "0.0.1-beta.22",
"type": "module",
"author": "Bouygues Telecom",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/react/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "0.0.1-beta.21"
export const version = "0.0.1-beta.22"
2 changes: 1 addition & 1 deletion packages/styles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trilogy-ds/styles",
"version": "0.0.1-beta.21",
"version": "0.0.1-beta.22"
"author": "Bouygues Telecom",
"license": "UNLICENSED",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trilogy-ds/vanilla",
"version": "0.0.1-beta.21",
"version": "0.0.1-beta.22",
"author": "Bouygues Telecom",
"main": "lib/trilogy-ds-vanilla.js",
"scripts": {
Expand Down

0 comments on commit 988ac58

Please sign in to comment.