Skip to content

Commit 7b66ff3

Browse files
committed
refactor: extract inline styles from CardTeaser into dedicated CSS file
1 parent 9648f84 commit 7b66ff3

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.card-teaser {
2+
flex: 1 1 calc(50% - var(--db-spacing-fixed-md));
3+
min-inline-size: 280px;
4+
text-decoration: none;
5+
color: inherit;
6+
}
7+
8+
.card-teaser-content {
9+
display: flex;
10+
align-items: center;
11+
gap: var(--db-spacing-fixed-md);
12+
}
13+
14+
.card-teaser-body {
15+
flex: 1;
16+
}
17+
18+
.card-teaser-title {
19+
display: block;
20+
margin-block-end: var(--db-spacing-fixed-xs);
21+
}
22+
23+
.card-teaser-description {
24+
color: var(--db-adaptive-on-bg-basic-emphasis-70-default);
25+
}
26+
27+
.card-teaser-label {
28+
display: block;
29+
margin-block-start: var(--db-spacing-fixed-sm);
30+
}
31+
32+
.card-teaser-image {
33+
block-size: 80px;
34+
object-fit: contain;
35+
opacity: 0.8;
36+
}
37+

template/components/CardTeaser/CardTeaser.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DBCard } from '@db-ux/react-core-components';
2+
import './CardTeaser.css';
23

34
export interface CardTeaserProps {
45
title: string;
@@ -23,33 +24,24 @@ const CardTeaser = ({
2324
<a
2425
href={url}
2526
{...(external ? { target: '_blank', rel: 'noopener noreferrer' } : {})}
26-
style={{
27-
flex: '1 1 calc(50% - var(--db-spacing-fixed-md))',
28-
minInlineSize: '280px',
29-
textDecoration: 'none',
30-
color: 'inherit',
31-
}}
27+
className="card-teaser"
3228
>
3329
<DBCard behavior="interactive" spacing="medium">
34-
<div style={{ display: 'flex', alignItems: 'center', gap: 'var(--db-spacing-fixed-md)' }}>
35-
<div style={{ flex: 1 }}>
36-
<strong style={{ display: 'block', marginBlockEnd: 'var(--db-spacing-fixed-xs)' }}>
37-
{title}
38-
</strong>
39-
<span style={{ color: 'var(--db-adaptive-on-bg-basic-emphasis-70-default)' }}>
40-
{description}
41-
</span>
30+
<div className="card-teaser-content">
31+
<div className="card-teaser-body">
32+
<strong className="card-teaser-title">{title}</strong>
33+
<span className="card-teaser-description">{description}</span>
4234
<strong
35+
className="card-teaser-label"
4336
data-icon-trailing={external ? 'arrow_up_right' : 'arrow_right'}
44-
style={{ display: 'block', marginBlockStart: 'var(--db-spacing-fixed-sm)' }}
4537
>
4638
{label}
4739
</strong>
4840
</div>
4941
<img
5042
src={image}
5143
alt={imageAlt}
52-
style={{ blockSize: '80px', objectFit: 'contain', opacity: 0.8 }}
44+
className="card-teaser-image"
5345
loading="lazy"
5446
/>
5547
</div>

template/components/CardTeaser/CardTeaserRow.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
gap: var(--db-spacing-fixed-md);
55
}
66

7-
.card-teaser-row > a {
7+
.card-teaser-row > .card-teaser {
88
display: flex;
99
}
1010

11-
.card-teaser-row > a > .db-card {
11+
.card-teaser-row > .card-teaser > .db-card {
1212
inline-size: 100%;
1313
}

template/styles/global.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
@import url('./table.css');
99
@import url('../components/GuidelineExample/GuidelineExample.css');
1010
@import url('../components/YourAction/YourAction.css');
11+
@import url('../components/CardTeaser/CardTeaser.css');
1112
@import url('../components/CardTeaser/CardTeaserRow.css');
1213
@import url('./db-ux-overrides.css');
1314

0 commit comments

Comments
 (0)