Skip to content

Commit

Permalink
Update card designs type
Browse files Browse the repository at this point in the history
Update all card styles to match the old
  • Loading branch information
AadneRo committed May 29, 2024
1 parent 3e3b869 commit ef394c1
Show file tree
Hide file tree
Showing 5 changed files with 583 additions and 614 deletions.
79 changes: 33 additions & 46 deletions packages/dnb-eufemia/src/extensions/payment-card/PaymentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
BankLogo,
ProductLogo,
BankAxeptLogo,
TypeLogo,
StatusIcon,
CardProviderLogo,
} from './icons'
Expand All @@ -26,6 +25,7 @@ import {
PaymentCardProps,
PaymentCardRawData,
} from './types'
import { getTranslation } from '../../shared/Translation'

Check failure on line 28 in packages/dnb-eufemia/src/extensions/payment-card/PaymentCard.tsx

View workflow job for this annotation

GitHub Actions / Run tests and checks

'getTranslation' is defined but never used

Check failure on line 28 in packages/dnb-eufemia/src/extensions/payment-card/PaymentCard.tsx

View workflow job for this annotation

GitHub Actions / Run tests and checks

'getTranslation' is defined but never used

const defaultCard: (productCode: string) => PaymentCardRawData = (
productCode
Expand Down Expand Up @@ -65,7 +65,8 @@ const defaultProps = {
}

export function PaymentCard(props: PaymentCardProps) {
const context = useContext(Context).PaymentCard
const context = useContext(Context)

// const translations = context.getTranslation(props)

const {
Expand All @@ -82,40 +83,33 @@ export function PaymentCard(props: PaymentCardProps) {
class: _className,
children, //eslint-disable-line

// text_card_number,
// text_expired,
// text_blocked,
// text_not_active,
// text_order_in_process,
// text_renewed,
// text_replaced,
// text_unknown,
text_card_number,
text_expired,
text_blocked,
text_not_active,
text_order_in_process,
text_renewed,
text_replaced,
text_unknown,

...attributes
} = extendPropsWithContext(
props,
defaultProps,
// { translations },
{
skeleton: context?.skeleton,
}
)
} = extendPropsWithContext(props, defaultProps, context?.PaymentCard, {
skeleton: context?.skeleton,
})

const cardData: PaymentCardRawData =
raw_data || getCardData(product_code)

console.log('cardData', cardData)

// const translations = {
// text_card_number,
// text_expired,
// text_blocked,
// text_not_active,
// text_order_in_process,
// text_renewed,
// text_replaced,
// text_unknown,
// }
const translations = {
text_card_number,
text_expired,
text_blocked,
text_not_active,
text_order_in_process,
text_renewed,
text_replaced,
text_unknown,
}

const params = {
className: classnames(
Expand All @@ -135,13 +129,13 @@ export function PaymentCard(props: PaymentCardProps) {
validateDOMAttributes(props, params)

const cardStatusMap = {
not_active: 'not_active', // 'translations.text_not_active',
order_in_process: 'order_in_process', // 'translations.text_order_in_process',
renewed: 'renewed', // 'translations.text_renewed',
replaced: 'replaced', // 'translations.text_replaced',
blocked: 'blocked', // 'translations.text_blocked',
expired: 'expired', // 'translations.text_expired',
unknown: 'unknown', // 'translations.text_unknown',
not_active: translations.text_not_active,
order_in_process: translations.text_order_in_process,
renewed: translations.text_renewed,
replaced: translations.text_replaced,
blocked: translations.text_blocked,
expired: translations.text_expired,
unknown: translations.text_unknown,
}

return (
Expand All @@ -167,21 +161,14 @@ export function PaymentCard(props: PaymentCardProps) {
<div className="dnb-payment-card__card__top">
<BankLogo
logoType={cardData.cardDesign.bankLogo}
height={undefined}
color={cardData.cardDesign.bankLogoColors}
/>
<ProductLogo
productType={cardData.productType}
cardDesign={cardData.cardDesign.cardDesign}
/>

{/*
productType: ProductType
cardDesign: CardDesign
*/}
<BankAxeptLogo
bankAxept={cardData.bankAxept}
// cardDesign={cardData.cardDesign}
/>
<BankAxeptLogo bankAxept={cardData.bankAxept} />
</div>
<div className="dnb-payment-card__card__bottom">
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import '../style/themes/ui'
import { PaymentCard, getCardData } from './../PaymentCard' // BankAxeptType, // ProductType, // getCardData,
import H3 from '../../../elements/H3'
import cardData from '../utils/cardProducts'
import { PaymentCardRawData } from '../types'

export default {
title: 'Eufemia/Extensions/PaymentCard',
Expand All @@ -23,15 +24,16 @@ const CustomWrapper = styled(Wrapper)`
/* empty */
`

// const customData = {
// productCode: 'UNDEFINED',
// productName: 'DNB Custom Card',
// displayName: 'Custom card', // Only showed in compact variant
// cardDesign: 'gold',
// cardType: 'Visa',
// productType: 'Business',
// bankAxept: 'BankAxept',
// }
const customData: PaymentCardRawData = {
productCode: 'UNDEFINED',
productName: 'DNB Custom Card',
displayName: 'Custom card', // Only showed in compact variant
// cardDesign: 'gold',
cardDesign: { cardDesign: 'SagaGold' },
cardType: 'VisaColored',
productType: 'Business',
bankAxept: 'BankAxeptBlack',
}

export const PaymentCards = () => (
<CustomWrapper className="dnb-spacing">
Expand All @@ -48,9 +50,9 @@ export const PaymentCards = () => (
/>
</Box>

{/* <Box>
<Box>
<PaymentCard
locale="en-GB"
// locale="en-GB"
product_code="DNB"
card_number="************1337"
card_status="expired"
Expand All @@ -71,7 +73,7 @@ export const PaymentCards = () => (
variant="compact"
card_number="************1337"
/>
</Box> */}
</Box>

<Box>
{cards.map((product_code) => {
Expand Down
10 changes: 5 additions & 5 deletions packages/dnb-eufemia/src/extensions/payment-card/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export type PaymentCardRawData = {
}

export type CardDesignData = {
name: string
cardStyle: string
bankLogo: LogoType
cardType: CardTypeDesign
bankAxept: BankAxeptType
name?: string
cardStyle?: string
bankLogo?: LogoType
cardType?: CardTypeDesign
bankAxept?: BankAxeptType
cardStatus?: CardStatus
productType?: ProductType
cardDesign?: CardDesign
Expand Down
Loading

0 comments on commit ef394c1

Please sign in to comment.