Skip to content

Commit 390c5a2

Browse files
committed
refactor card components order
1 parent 5db974e commit 390c5a2

File tree

1 file changed

+37
-26
lines changed

1 file changed

+37
-26
lines changed

src/features/common/components/card/card.component.tsx

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import styles from "./card.module.scss";
33
import { clsx } from "clsx";
44
import { getLocalizedSecondaryFont, MonoFont } from "@/libs/theme/fonts";
55
import { CardMessageComponent } from "@/features/common/components/card-message/card-message.component";
6+
import { HeaderIcon } from "../icons/header/header-icon";
67

78
export interface CardComponentProps extends PropsWithChildren {
89
id: string;
910
languageCode: string;
1011
title: string;
1112
compactTitle: string;
13+
hasHeaderIcon?: boolean;
1214
options: Partial<{
1315
noPadding: boolean;
1416
fullWidth: boolean;
@@ -44,6 +46,7 @@ export const CardComponent: React.FC<CardComponentProps> = (props) => {
4446
},
4547
messages,
4648
slots,
49+
hasHeaderIcon = false,
4750
} = props;
4851

4952
const cardId = useId();
@@ -64,7 +67,7 @@ export const CardComponent: React.FC<CardComponentProps> = (props) => {
6467
MonoFont.className,
6568
styles.card,
6669
options && options.fullWidth && styles.card__hasFullWidth,
67-
options && options.fullHeight && styles.card__hasFullHeight,
70+
options && options.fullHeight && styles.card__hasFullHeight
6871
)}
6972
data-type={options && options.isOutput ? "output" : "input"}
7073
data-frameless={options && options.frameless}
@@ -74,21 +77,9 @@ export const CardComponent: React.FC<CardComponentProps> = (props) => {
7477
{titleKey && (
7578
<div className={styles.card__headline}>
7679
{titleKey && !compactTitle && (
77-
<h4 id={cardId}>
78-
<span className={styles.card__titleKey}>
79-
{titleKey}
80-
{titleValue && `: `}
81-
</span>
82-
{titleValue && (
83-
<span className={styles.card__titleValue}>
84-
{titleValue}
85-
</span>
86-
)}
87-
</h4>
88-
)}
89-
{titleKey && compactTitle && (
90-
<>
91-
<h4 id={cardId} className={styles.card__fullTitle}>
80+
<div className={styles.card__heading_title_container}>
81+
{hasHeaderIcon && <HeaderIcon />}
82+
<h4 id={cardId}>
9283
<span className={styles.card__titleKey}>
9384
{titleKey}
9485
{titleValue && `: `}
@@ -99,6 +90,24 @@ export const CardComponent: React.FC<CardComponentProps> = (props) => {
9990
</span>
10091
)}
10192
</h4>
93+
</div>
94+
)}
95+
{titleKey && compactTitle && (
96+
<>
97+
<div className={styles.card__heading_title_container}>
98+
{hasHeaderIcon && <HeaderIcon />}
99+
<h4 id={cardId} className={styles.card__fullTitle}>
100+
<span className={styles.card__titleKey}>
101+
{titleKey}
102+
{titleValue && `: `}
103+
</span>
104+
{titleValue && (
105+
<span className={styles.card__titleValue}>
106+
{titleValue}
107+
</span>
108+
)}
109+
</h4>
110+
</div>
102111
<h4 id={cardId} className={styles.card__compactTitle}>
103112
<span className={styles.card__titleKey}>
104113
{compactTitle}
@@ -111,6 +120,16 @@ export const CardComponent: React.FC<CardComponentProps> = (props) => {
111120
)}
112121
</>
113122
)}
123+
<div className={styles.card__content}>
124+
<div
125+
className={styles.card__body}
126+
data-no-padding={
127+
options && options.noPadding ? options.noPadding : undefined
128+
}
129+
>
130+
{children}
131+
</div>
132+
</div>
114133
{messages && messages.errors && messages.errors.length > 0 ? (
115134
<div
116135
data-testid={`${id}___statusBar__error`}
@@ -136,6 +155,7 @@ export const CardComponent: React.FC<CardComponentProps> = (props) => {
136155
})}
137156
</div>
138157
) : null}
158+
{slots?.notification}
139159
{messages && messages.warnings && messages.warnings.length > 0 && (
140160
<div
141161
data-testid={`${id}___statusBar__warning`}
@@ -149,15 +169,6 @@ export const CardComponent: React.FC<CardComponentProps> = (props) => {
149169
})}
150170
</div>
151171
)}
152-
{slots?.notification}
153-
<div
154-
className={styles.card__body}
155-
data-no-padding={
156-
options && options.noPadding ? options.noPadding : undefined
157-
}
158-
>
159-
{children}
160-
</div>
161172
{slots?.footer && (
162173
<div className={styles.card__action}>{slots.footer}</div>
163174
)}
@@ -192,7 +203,7 @@ export const CardWithHeadlineComponent: React.FC<
192203
id={regionId}
193204
className={clsx(
194205
styles.cardHeadline__title,
195-
getLocalizedSecondaryFont(languageCode),
206+
getLocalizedSecondaryFont(languageCode)
196207
)}
197208
>
198209
{sectionHeadline.title}

0 commit comments

Comments
 (0)