-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathCardAction.stories.tsx
103 lines (97 loc) · 2.79 KB
/
CardAction.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { Heading4, Paragraph } from '@sb1/ffe-core-react';
import { Icon } from '@sb1/ffe-icons-react';
import type { Meta, StoryObj } from '@storybook/react';
import React from 'react';
import { CardBase } from '../CardBase';
import { IconCard } from '../IconCard/IconCard';
import { CardActionRenderProps, CardRenderProps } from '../types';
import { CardAction as CardActionComponent } from './CardAction';
const Custom: React.FC<React.ComponentProps<'a'>> = props => (
<a {...props}>
{`Custom `}
{props.children}
</a>
);
const meta: Meta<typeof CardActionComponent<any>> = {
title: 'Komponenter/Cards/CardAction',
component: CardActionComponent,
argTypes: {
as: {
options: ['a', 'button', 'custom'],
mapping: {
'': 'a',
a: 'a',
button: 'button',
custom: Custom,
},
},
},
};
export default meta;
type Story = StoryObj<typeof CardActionComponent<any>>;
export const Standard: Story = {
args: {
as: 'a',
href: 'https://design.sparebank1.no',
},
render: args => (
<CardBase>
{({ CardAction }: CardActionRenderProps) => (
<>
<Heading4>
<CardAction {...args}>Lenke</CardAction>
</Heading4>
<Paragraph>Hele kortet er klikkbart</Paragraph>
</>
)}
</CardBase>
),
};
export const AsButton: Story = {
args: {
as: 'button',
type: 'button',
},
render: args => (
<CardBase>
{({ CardAction }: CardActionRenderProps) => (
<>
<Heading4>
<CardAction {...args}>Knapp</CardAction>
</Heading4>
<Paragraph>Hele kortet er klikkbart</Paragraph>
</>
)}
</CardBase>
),
};
export const WithinTitle: Story = {
args: {
as: 'a',
href: 'https://design.sparebank1.no',
},
render: args => (
<IconCard
icon={<Icon fileUrl="icons/open/300/xl/savings.svg" size="xl" />}
>
{({
CardAction,
CardName,
Title,
Subtext,
Text,
}: CardRenderProps) => (
<>
<CardName>Kortnavn</CardName>
<Title>
<CardAction {...args}>
Lenke men hele kortet er klikkbart
</CardAction>
</Title>
<Subtext>En liten undertekst</Subtext>
<Text>Her kan man ha tekst</Text>
</>
)}
</IconCard>
),
};