Skip to content

Commit ff501b5

Browse files
stribnyjonadeline
andauthored
Add RadioCard to storybook (baserow#4305)
Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
1 parent 1bee4ce commit ff501b5

File tree

4 files changed

+113
-4
lines changed

4 files changed

+113
-4
lines changed

web-frontend/modules/core/assets/scss/components/radio_card.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
display: flex;
2222
flex-direction: column;
2323
gap: 8px;
24+
min-width: 0;
2425
}
2526

2627
.radio-card__labels {
@@ -37,8 +38,13 @@
3738
font-weight: 500;
3839
}
3940

41+
.radio-card__badge {
42+
min-width: 0;
43+
}
44+
4045
.radio-card__description {
4146
color: $palette-neutral-900;
4247
line-height: 20px;
4348
font-size: 12px;
49+
word-break: break-word;
4450
}

web-frontend/modules/core/components/RadioCard.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<div class="radio-card__content">
77
<div class="radio-card__labels">
88
<label class="radio-card__label">{{ label }}</label>
9-
<div v-if="sideLabel">
10-
<Badge :rounded="true" :small="true">{{ sideLabel }}</Badge>
9+
<div v-if="badgeLabel" class="radio-card__badge">
10+
<Badge :rounded="true" :small="true">{{ badgeLabel }}</Badge>
1111
</div>
1212
</div>
1313
<div v-if="hasSlot" class="radio-card__description">
@@ -39,7 +39,7 @@ export default {
3939
type: String,
4040
required: true,
4141
},
42-
sideLabel: {
42+
badgeLabel: {
4343
type: String,
4444
required: false,
4545
default: undefined,

web-frontend/modules/core/components/settings/twoFactorAuth/EnableTwoFactorOptions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
:value="option.type"
77
:model-value="values.twoFaChoice"
88
:label="option.name"
9-
:side-label="option.sideLabel"
9+
:badge-label="option.sideLabel"
1010
@input="updateValue"
1111
>
1212
<div>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { Meta, Story, Props, Canvas } from '@storybook/addon-docs/blocks'
2+
import { config, withDesign } from 'storybook-addon-designs'
3+
import { action } from '@storybook/addon-actions'
4+
import { useArgs } from '@storybook/client-api'
5+
6+
import RadioCard from '@baserow/modules/core/components/RadioCard'
7+
8+
<Meta
9+
title="Baserow/Form Elements/Radio/RadioCard"
10+
component={RadioCard}
11+
parameters={{
12+
backgrounds: {
13+
default: 'white',
14+
values: [
15+
{ name: 'white', value: '#ffffff' },
16+
{ name: 'light', value: '#eeeeee' },
17+
{ name: 'dark', value: '#222222' },
18+
],
19+
},
20+
}}
21+
decorators={[
22+
withDesign,
23+
(story, context) => {
24+
const [_, updateArgs] = useArgs()
25+
return story({ ...context, updateArgs })
26+
},
27+
]}
28+
argTypes={{
29+
default: {
30+
control: 'text',
31+
description: 'Slot content',
32+
defaultValue: 'Label',
33+
},
34+
modelValue: {
35+
control: {
36+
type: 'text',
37+
},
38+
defaultValue: '',
39+
},
40+
value: {
41+
control: {
42+
type: 'text',
43+
},
44+
defaultValue: 'option1',
45+
},
46+
label: {
47+
control: {
48+
type: 'text',
49+
},
50+
defaultValue: 'Label',
51+
},
52+
badgeLabel: {
53+
control: {
54+
type: 'text',
55+
},
56+
defaultValue: 'Badge label',
57+
},
58+
}}
59+
/>
60+
61+
# RadioCard
62+
63+
The RadioCard component behaves like the Radio component but instead of the native circle button, it uses a custom card design.
64+
65+
export const Template = (args, { argTypes, updateArgs }) => ({
66+
methods: {
67+
action,
68+
handleInput(value) {
69+
const modelValue = value
70+
updateArgs({ ...args, modelValue })
71+
action('handleInput')(modelValue)
72+
},
73+
},
74+
components: { RadioCard },
75+
props: Object.keys(argTypes),
76+
template: `<RadioCard v-bind="$props" @input="handleInput">${args.default}</RadioCard>`,
77+
})
78+
79+
export const designConfig = {
80+
type: 'figma',
81+
url: 'https://www.figma.com/file/W7R2rQW7ohsZMeHRfEcPFW/Design-Library?node-id=53%3A1852&mode=dev',
82+
}
83+
84+
<Canvas>
85+
<Story
86+
name="RadioCard"
87+
parameters={{
88+
design: config(designConfig),
89+
}}
90+
>
91+
{Template.bind({})}
92+
</Story>
93+
</Canvas>
94+
95+
## Example
96+
97+
```javascript
98+
<RadioCard></RadioCard>
99+
```
100+
101+
## Props
102+
103+
<Props of={RadioCard} />

0 commit comments

Comments
 (0)