Skip to content

Commit dc32125

Browse files
authored
Merge pull request #733 from db-ui/feat-added-missing-components-react
feat: added card to react showcase
2 parents c5ef163 + 4722e6b commit dc32125

16 files changed

+271
-61
lines changed
1.23 KB
Loading
1.59 KB
Loading
1.17 KB
Loading
1.23 KB
Loading
1.59 KB
Loading
1.17 KB
Loading

packages/components/src/components/card/card.lite.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ useMetadata({
1414
key: 'Interactive',
1515
name: 'Interactive',
1616
value: 'interactive'
17-
},
18-
{
19-
key: 'Full Width',
20-
name: 'Full Width',
21-
value: 'full-width'
2217
}
2318
]
2419
}
@@ -49,8 +44,8 @@ export default function DBCard(props: DBCardProps) {
4944
class={'db-card' + (props.className ? ' ' + props.className : '')}
5045
data-variant={props.variant}
5146
data-color-variant={props.colorVariant}
52-
data-direction={props.direction}
5347
data-elevation={props.elevation}
48+
data-spacing={props.spacing}
5449
onClick={(event) => state.handleClick(event)}>
5550
<Show when={state.stylePath}>
5651
<link rel="stylesheet" href={state.stylePath} />

packages/components/src/components/card/card.scss

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,25 @@
1818
display: flex;
1919
flex-direction: column;
2020

21-
&[data-direction="row"] {
22-
@media only screen and (min-width: #{$db-screens-s}) {
23-
display: grid;
24-
grid-template-columns: repeat(2, minmax(0, 1fr));
25-
gap: $db-spacing-fixed-md;
26-
27-
& > .db-card-image {
28-
height: 100%;
29-
}
30-
}
31-
}
32-
3321
& > a {
3422
text-decoration: none;
3523
}
3624

37-
&[data-variant="full-width"] {
38-
width: 100vw;
39-
border-radius: 0;
25+
&[data-spacing="medium"] {
26+
padding: $db-spacing-fixed-lg;
27+
}
28+
29+
&[data-spacing="small"] {
30+
padding: $db-spacing-fixed-md;
4031
}
4132

4233
&[data-variant="interactive"] {
34+
// TODO use transition duration as variable
35+
transition: box-shadow 0.15s $db-transition-functional-timing;
36+
4337
&:hover:not([data-elevation="none"]) {
4438
cursor: pointer;
45-
box-shadow: $db-elevation-4;
39+
box-shadow: $db-elevation-8;
4640
}
4741

4842
&:active:not([data-elevation="none"]) {

packages/components/src/components/card/card.spec.tsx

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,6 @@ const testCardColorVariants = () => {
4848
}
4949
};
5050

51-
const testCardRow = () => {
52-
for (const direction of directions) {
53-
test(`DBCard should match screenshot for direction ${direction}`, async ({
54-
mount
55-
}) => {
56-
const component = await mount(
57-
<div>
58-
<DBCard direction={direction}>
59-
<span>Test 1</span>
60-
<span>Test 2</span>
61-
</DBCard>
62-
</div>
63-
);
64-
await expect(component).toHaveScreenshot();
65-
});
66-
}
67-
};
68-
6951
const testCardVariants = () => {
7052
for (const variant of variants) {
7153
test(`DBCard should match screenshot for variant ${variant}`, async ({
@@ -109,25 +91,11 @@ test.describe('DBCard component on mobile: Color Variants', () => {
10991
testCardColorVariants();
11092
});
11193

112-
test.describe('DBCard component on desktop: Row', () => {
113-
// Old-school CRT monitor screensize
114-
test.use({ viewport: { width: 1024, height: 768 } });
115-
116-
testCardRow();
117-
});
118-
119-
test.describe('DBCard component on mobile: Row', () => {
120-
// iPhone 13 / portrait screen size
121-
test.use({ viewport: { width: 390, height: 884 } });
122-
123-
testCardRow();
124-
});
125-
12694
test.describe('DBCard component on desktop: Variants', () => {
12795
// Old-school CRT monitor screensize
12896
test.use({ viewport: { width: 1024, height: 768 } });
12997

130-
testCardRow();
98+
testCardVariants();
13199
});
132100

133101
test.describe('DBCard component on mobile: Variants', () => {

packages/components/src/components/card/model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99

1010
export type DBCardDefaultProps = {
1111
colorVariant?: string;
12-
direction?: 'column' | 'row';
13-
variant?: 'full-width' | 'interactive';
12+
variant?: 'interactive';
13+
spacing?: 'medium' | 'small';
1414
};
1515

1616
export type DBCardProps = DBCardDefaultProps &

0 commit comments

Comments
 (0)