Skip to content

Commit fb0fb2d

Browse files
authored
feat: add link animation for cards without shadow (#513)
1 parent 0ce69f0 commit fb0fb2d

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

src/sub-blocks/BackgroundCard/BackgroundCard.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ const BackgroundCard = (props: BackgroundCardProps) => {
2727

2828
const theme = useTheme();
2929
const hasBackgroundColor = backgroundColor || cardTheme !== 'default';
30-
const link = hasBackgroundColor || border === 'line' ? undefined : url;
3130
const borderType = hasBackgroundColor ? 'none' : border;
3231

3332
return (
3433
<CardBase
3534
className={b({padding: paddingBottom, theme: cardTheme})}
36-
url={link}
35+
url={url}
3736
border={borderType}
3837
>
3938
<CardBase.Content>

src/sub-blocks/BackgroundCard/__stories__/BackgroundCard.stories.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,23 @@ const BackgroundColorTemplate: StoryFn<BackgroundCardProps> = (args) => (
8585
</div>
8686
);
8787

88+
const WithUrlTemplate: StoryFn<{items: BackgroundCardProps[]}> = (args) => (
89+
<div style={{display: 'flex'}}>
90+
{args.items.map((item, i) => (
91+
<div style={{maxWidth: '400px', padding: '0 8px'}} key={i}>
92+
<BackgroundCard {...item} />
93+
</div>
94+
))}
95+
</div>
96+
);
97+
8898
export const Default = DefaultTemplate.bind({});
8999
export const WithBackgroundImage = DefaultTemplate.bind({});
90100
export const Paddings = PaddingsTemplate.bind({});
91101
export const CardThemes = CardThemesTemplate.bind([]);
92102
export const BorderLine = DefaultTemplate.bind({});
93103
export const BackgroundColor = BackgroundColorTemplate.bind({});
104+
export const WithUrl = WithUrlTemplate.bind({});
94105

95106
const DefaultArgs = {
96107
title: data.common.title,
@@ -128,3 +139,17 @@ BackgroundColor.args = {
128139
...DefaultArgs,
129140
...data.backgroundColor.content,
130141
} as BackgroundCardProps;
142+
143+
WithUrl.args = {
144+
items: [
145+
data.cardThemes.content[1],
146+
data.withBackgroundImage.content,
147+
data.borderLine.content,
148+
data.backgroundColor.content,
149+
data.borderNone.content,
150+
].map((item) => ({
151+
...DefaultArgs,
152+
...item,
153+
url: data.url,
154+
})) as BackgroundCardProps[],
155+
};

src/sub-blocks/BackgroundCard/__stories__/data.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
"border": "line"
5656
}
5757
},
58+
"borderNone": {
59+
"content": {
60+
"border": "none"
61+
}
62+
},
63+
"url": "https://example.com",
5864
"paddings": {
5965
"title": "Padding Bottom = {{padding}}"
6066
},

src/sub-blocks/BasicCard/__stories__/BasicCard.stories.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,24 @@ const WithBorderTemplate: StoryFn<BasicCardProps> = (args) => (
6060
</div>
6161
);
6262

63+
const WithUrlTemplate: StoryFn<BasicCardProps> = (args) => (
64+
<div style={{display: 'flex', padding: '40px 0'}}>
65+
<div style={{maxWidth: '400px', padding: '0 8px'}}>
66+
<BasicCard {...args} title={getCardWithBorderTitle('shadow')} />
67+
</div>
68+
<div style={{maxWidth: '400px', padding: '0 8px'}}>
69+
<BasicCard {...args} border="line" title={getCardWithBorderTitle('line')} />
70+
</div>
71+
<div style={{maxWidth: '400px', padding: '0 8px'}}>
72+
<BasicCard {...args} border="none" title={getCardWithBorderTitle('none')} />
73+
</div>
74+
</div>
75+
);
76+
6377
export const Default = DefaultTemplate.bind({});
6478
export const WithIcon = WithIconTemplate.bind({});
6579
export const WithBorder = WithBorderTemplate.bind({});
80+
export const WithUrl = WithUrlTemplate.bind({});
6681

6782
const DefaultArgs = {
6883
...data.default.content,
@@ -75,3 +90,7 @@ Default.args = {
7590
} as BasicCardProps;
7691
WithIcon.args = DefaultArgs as BasicCardProps;
7792
WithBorder.args = DefaultArgs as BasicCardProps;
93+
WithUrl.args = {
94+
url: data.url,
95+
...DefaultArgs,
96+
} as BasicCardProps;

src/sub-blocks/BasicCard/__stories__/data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"withBorder": {
1111
"title": "Card with border {{border}}"
1212
},
13+
"url": "https://example.com",
1314
"default": {
1415
"content": {
15-
"url": "https://example.com",
1616
"title": "Lorem ipsum",
1717
"text": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
1818
}

styles/mixins.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@
246246

247247
&_border_line,
248248
&_border_none {
249-
cursor: default;
249+
@if $hover {
250+
@include card-hover();
251+
}
250252
}
251253

252254
&_border_shadow {

0 commit comments

Comments
 (0)