-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathAvatar.stories.tsx
129 lines (116 loc) · 3.15 KB
/
Avatar.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import cat1 from '@assets/img/cats/Cat 3.jpg';
import type { Meta, StoryFn } from '@storybook/react';
import { BriefcaseIcon } from '@navikt/aksel-icons';
import { Avatar } from '.';
import { Badge, DropdownMenu } from '../';
type Story = StoryFn<typeof Avatar>;
const meta: Meta = {
title: 'Komponenter/Avatar',
component: Avatar,
parameters: {
layout: 'padded',
},
decorators: [
(Story) => (
<div
style={{
display: 'flex',
gap: 'var(--ds-spacing-2)',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Story />
</div>
),
],
};
export default meta;
export const Preview: Story = (args) => <Avatar {...args} />;
Preview.args = {
'aria-label': 'Ola Nordmann',
color: 'accent',
size: 'md',
variant: 'circle',
children: '',
};
export const NoName: Story = () => <Avatar aria-label='Ola' />;
export const Sizes: Story = () => (
<>
<Avatar size='xs' aria-label='extra small'>
xs
</Avatar>
<Avatar size='xs' aria-label='extra small' />
<Avatar size='sm' aria-label='small'>
sm
</Avatar>
<Avatar size='sm' aria-label='small' />
<Avatar size='md' aria-label='medium'>
md
</Avatar>
<Avatar size='md' aria-label='medium' />
<Avatar size='lg' aria-label='large'>
lg
</Avatar>
<Avatar size='lg' aria-label='large' />
</>
);
export const ColorVariants: Story = () => (
<>
<Avatar color='accent' aria-label='color accent' />
<Avatar color='neutral' aria-label='color neutral' />
<Avatar color='brand1' aria-label='color brand1' />
<Avatar color='brand2' aria-label='color brand2' />
<Avatar color='brand3' aria-label='color brand3' />
</>
);
export const ShapeVariants: Story = () => (
<>
<Avatar variant='circle' aria-label='variant circle' />
<Avatar variant='square' aria-label='variant square' />
<Avatar variant='circle' aria-label='Ola Nordman'>
ON
</Avatar>
<Avatar variant='square' aria-label='Ola Nordman'>
ON
</Avatar>
</>
);
export const WithImage: Story = () => (
<Avatar aria-label='Ola Nordman'>
<img src={cat1} alt='' />
</Avatar>
);
export const InDropdownMenu: Story = () => (
<DropdownMenu.Root placement='bottom-end' size='md' portal>
<DropdownMenu.Trigger variant='tertiary'>
<Avatar aria-label='Ola Nordmann' size='sm'>
ON
</Avatar>
Velg Profil
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group heading='Alle kontoer'>
<DropdownMenu.Item>
<Badge overlap='circle' color='danger' size='sm'>
<Avatar aria-label='Ola Nordmann' size='xs'>
ON
</Avatar>
</Badge>
Ola Nordmann
</DropdownMenu.Item>
<DropdownMenu.Item>
<Avatar size='xs' color='brand1' aria-label='Sogndal Kommune'>
<BriefcaseIcon fontSize='5em' />
</Avatar>
Sogndal kommune
</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu.Root>
);
export const AsLink: Story = () => (
<a href='#'>
<Avatar aria-label='Ola Nordmann' />
</a>
);