@memori.ai/ui 1.0.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -0
- package/dist/components/Alert/Alert.d.ts +18 -0
- package/dist/components/Alert/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +27 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/ButtonBase/ButtonBase.d.ts +28 -0
- package/dist/components/ButtonBase/index.d.ts +3 -0
- package/dist/components/Card/Card.d.ts +13 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +11 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +12 -0
- package/dist/components/ConfirmDialog/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.d.ts +32 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/Dropdown/Dropdown.d.ts +11 -0
- package/dist/components/Dropdown/index.d.ts +2 -0
- package/dist/components/Expandable/Expandable.d.ts +15 -0
- package/dist/components/Expandable/helpers.d.ts +3 -0
- package/dist/components/Expandable/index.d.ts +2 -0
- package/dist/components/InputBase/InputBase.d.ts +49 -0
- package/dist/components/InputBase/index.d.ts +3 -0
- package/dist/components/Modal/Modal.d.ts +16 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +16 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Slider/Slider.d.ts +12 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Spin/Spin.d.ts +9 -0
- package/dist/components/Spin/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/i18n/I18nWrapper.d.ts +6 -0
- package/dist/icons/AI.d.ts +5 -0
- package/dist/icons/Alert.d.ts +5 -0
- package/dist/icons/ArrowUp.d.ts +5 -0
- package/dist/icons/Bug.d.ts +5 -0
- package/dist/icons/Chat.d.ts +5 -0
- package/dist/icons/ChevronDown.d.ts +5 -0
- package/dist/icons/ChevronLeft.d.ts +5 -0
- package/dist/icons/ChevronRight.d.ts +5 -0
- package/dist/icons/ChevronUp.d.ts +5 -0
- package/dist/icons/Clear.d.ts +5 -0
- package/dist/icons/Close.d.ts +6 -0
- package/dist/icons/Code.d.ts +5 -0
- package/dist/icons/Copy.d.ts +5 -0
- package/dist/icons/DeepThought.d.ts +5 -0
- package/dist/icons/Delete.d.ts +5 -0
- package/dist/icons/Document.d.ts +5 -0
- package/dist/icons/Download.d.ts +5 -0
- package/dist/icons/Edit.d.ts +5 -0
- package/dist/icons/Expand.d.ts +5 -0
- package/dist/icons/Eye.d.ts +5 -0
- package/dist/icons/EyeInvisible.d.ts +5 -0
- package/dist/icons/Facebook.d.ts +5 -0
- package/dist/icons/Feedback.d.ts +5 -0
- package/dist/icons/File.d.ts +5 -0
- package/dist/icons/FileExcel.d.ts +5 -0
- package/dist/icons/FilePdf.d.ts +5 -0
- package/dist/icons/FileWord.d.ts +5 -0
- package/dist/icons/Fullscreen.d.ts +5 -0
- package/dist/icons/FullscreenExit.d.ts +5 -0
- package/dist/icons/Group.d.ts +5 -0
- package/dist/icons/History.d.ts +6 -0
- package/dist/icons/Image.d.ts +4 -0
- package/dist/icons/Info.d.ts +5 -0
- package/dist/icons/Link.d.ts +5 -0
- package/dist/icons/Linkedin.d.ts +5 -0
- package/dist/icons/Loading.d.ts +6 -0
- package/dist/icons/Logout.d.ts +5 -0
- package/dist/icons/Mail.d.ts +5 -0
- package/dist/icons/MapMarker.d.ts +5 -0
- package/dist/icons/MenuHorizontal.d.ts +6 -0
- package/dist/icons/MenuVertical.d.ts +6 -0
- package/dist/icons/Message.d.ts +5 -0
- package/dist/icons/Microphone.d.ts +5 -0
- package/dist/icons/Minus.d.ts +5 -0
- package/dist/icons/MinusCircle.d.ts +5 -0
- package/dist/icons/PaperClip.d.ts +5 -0
- package/dist/icons/Picture.d.ts +5 -0
- package/dist/icons/Plus.d.ts +5 -0
- package/dist/icons/Preview.d.ts +4 -0
- package/dist/icons/Print.d.ts +6 -0
- package/dist/icons/QuestionHelp.d.ts +5 -0
- package/dist/icons/Refresh.d.ts +5 -0
- package/dist/icons/SelectIcon.d.ts +5 -0
- package/dist/icons/Send.d.ts +5 -0
- package/dist/icons/Setting.d.ts +5 -0
- package/dist/icons/Share.d.ts +5 -0
- package/dist/icons/Sound.d.ts +5 -0
- package/dist/icons/SoundDeactivated.d.ts +5 -0
- package/dist/icons/Telegram.d.ts +5 -0
- package/dist/icons/ThumbDown.d.ts +5 -0
- package/dist/icons/ThumbUp.d.ts +5 -0
- package/dist/icons/Translation.d.ts +5 -0
- package/dist/icons/Twitter.d.ts +5 -0
- package/dist/icons/Upload.d.ts +4 -0
- package/dist/icons/User.d.ts +5 -0
- package/dist/icons/Warning.d.ts +5 -0
- package/dist/icons/WhatsApp.d.ts +5 -0
- package/dist/index.d.ts +13 -0
- package/dist/memori-ai-ui.css +2 -0
- package/dist/memori-ai-ui.es.js +6400 -0
- package/dist/memori-ai-ui.umd.js +23 -0
- package/package.json +97 -0
- package/src/components/Alert/Alert.css +95 -0
- package/src/components/Alert/Alert.stories.tsx +156 -0
- package/src/components/Alert/Alert.test.tsx +122 -0
- package/src/components/Alert/Alert.tsx +124 -0
- package/src/components/Alert/__snapshots__/Alert.test.tsx.snap +67 -0
- package/src/components/Alert/index.tsx +2 -0
- package/src/components/Button/Button.css +173 -0
- package/src/components/Button/Button.stories.tsx +173 -0
- package/src/components/Button/Button.test.tsx +80 -0
- package/src/components/Button/Button.tsx +104 -0
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +204 -0
- package/src/components/Button/index.tsx +2 -0
- package/src/components/ButtonBase/ButtonBase.stories.tsx +194 -0
- package/src/components/ButtonBase/ButtonBase.tsx +84 -0
- package/src/components/ButtonBase/index.tsx +3 -0
- package/src/components/ButtonBase/styles.module.css +135 -0
- package/src/components/Card/Card.css +67 -0
- package/src/components/Card/Card.stories.tsx +104 -0
- package/src/components/Card/Card.test.tsx +67 -0
- package/src/components/Card/Card.tsx +58 -0
- package/src/components/Card/__snapshots__/Card.test.tsx.snap +321 -0
- package/src/components/Card/index.tsx +2 -0
- package/src/components/Checkbox/Checkbox.css +114 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +77 -0
- package/src/components/Checkbox/Checkbox.test.tsx +50 -0
- package/src/components/Checkbox/Checkbox.tsx +61 -0
- package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +131 -0
- package/src/components/Checkbox/index.tsx +2 -0
- package/src/components/ConfirmDialog/ConfirmDialog.css +44 -0
- package/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +235 -0
- package/src/components/ConfirmDialog/ConfirmDialog.test.tsx +129 -0
- package/src/components/ConfirmDialog/ConfirmDialog.tsx +73 -0
- package/src/components/ConfirmDialog/__snapshots__/ConfirmDialog.test.tsx.snap +11 -0
- package/src/components/ConfirmDialog/index.tsx +2 -0
- package/src/components/Details/Details.css +66 -0
- package/src/components/Details/Details.stories.tsx +67 -0
- package/src/components/Drawer/Drawer.css +210 -0
- package/src/components/Drawer/Drawer.stories.tsx +275 -0
- package/src/components/Drawer/Drawer.test.tsx +158 -0
- package/src/components/Drawer/Drawer.tsx +242 -0
- package/src/components/Drawer/__snapshots__/Drawer.test.tsx.snap +21 -0
- package/src/components/Drawer/index.tsx +2 -0
- package/src/components/Dropdown/Dropdown.css +177 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +73 -0
- package/src/components/Dropdown/Dropdown.test.tsx +88 -0
- package/src/components/Dropdown/Dropdown.tsx +88 -0
- package/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap +141 -0
- package/src/components/Dropdown/index.tsx +2 -0
- package/src/components/Expandable/Expandable.css +15 -0
- package/src/components/Expandable/Expandable.stories.tsx +196 -0
- package/src/components/Expandable/Expandable.test.tsx +143 -0
- package/src/components/Expandable/Expandable.tsx +122 -0
- package/src/components/Expandable/__snapshots__/Expandable.test.tsx.snap +199 -0
- package/src/components/Expandable/helpers.ts +16 -0
- package/src/components/Expandable/index.tsx +2 -0
- package/src/components/InputBase/InputBase.stories.tsx +237 -0
- package/src/components/InputBase/InputBase.tsx +105 -0
- package/src/components/InputBase/index.tsx +3 -0
- package/src/components/InputBase/styles.module.css +96 -0
- package/src/components/Modal/Modal.css +95 -0
- package/src/components/Modal/Modal.stories.tsx +184 -0
- package/src/components/Modal/Modal.test.tsx +129 -0
- package/src/components/Modal/Modal.tsx +124 -0
- package/src/components/Modal/__snapshots__/Modal.test.tsx.snap +17 -0
- package/src/components/Modal/index.tsx +2 -0
- package/src/components/Select/Select.css +134 -0
- package/src/components/Select/Select.stories.tsx +85 -0
- package/src/components/Select/Select.test.tsx +85 -0
- package/src/components/Select/Select.tsx +84 -0
- package/src/components/Select/__snapshots__/Select.test.tsx.snap +261 -0
- package/src/components/Select/index.tsx +2 -0
- package/src/components/Slider/Slider.css +194 -0
- package/src/components/Slider/Slider.stories.tsx +85 -0
- package/src/components/Slider/Slider.test.tsx +55 -0
- package/src/components/Slider/Slider.tsx +157 -0
- package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +419 -0
- package/src/components/Slider/index.tsx +2 -0
- package/src/components/Spin/Spin.css +31 -0
- package/src/components/Spin/Spin.stories.tsx +65 -0
- package/src/components/Spin/Spin.test.tsx +47 -0
- package/src/components/Spin/Spin.tsx +34 -0
- package/src/components/Spin/__snapshots__/Spin.test.tsx.snap +193 -0
- package/src/components/Spin/index.tsx +2 -0
- package/src/components/Table/Table.css +130 -0
- package/src/components/Table/Table.stories.tsx +274 -0
- package/src/components/Tooltip/Tooltip.css +160 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +136 -0
- package/src/components/Tooltip/Tooltip.test.tsx +110 -0
- package/src/components/Tooltip/Tooltip.tsx +46 -0
- package/src/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap +163 -0
- package/src/components/Tooltip/index.tsx +2 -0
- package/src/components/definitions.stories.tsx +150 -0
- package/src/i18n/I18nWrapper.tsx +13 -0
- package/src/i18n/i18n.ts +34 -0
- package/src/icons/AI.tsx +38 -0
- package/src/icons/Alert.tsx +31 -0
- package/src/icons/ArrowUp.tsx +28 -0
- package/src/icons/Bug.tsx +81 -0
- package/src/icons/Chat.tsx +30 -0
- package/src/icons/ChevronDown.tsx +26 -0
- package/src/icons/ChevronLeft.tsx +28 -0
- package/src/icons/ChevronRight.tsx +28 -0
- package/src/icons/ChevronUp.tsx +24 -0
- package/src/icons/Clear.tsx +23 -0
- package/src/icons/Close.tsx +30 -0
- package/src/icons/Code.tsx +30 -0
- package/src/icons/Copy.tsx +30 -0
- package/src/icons/DeepThought.tsx +38 -0
- package/src/icons/Delete.tsx +23 -0
- package/src/icons/Document.tsx +52 -0
- package/src/icons/Download.tsx +23 -0
- package/src/icons/Edit.tsx +17 -0
- package/src/icons/Expand.tsx +23 -0
- package/src/icons/Eye.tsx +17 -0
- package/src/icons/EyeInvisible.tsx +24 -0
- package/src/icons/Facebook.tsx +23 -0
- package/src/icons/Feedback.tsx +27 -0
- package/src/icons/File.tsx +17 -0
- package/src/icons/FileExcel.tsx +23 -0
- package/src/icons/FilePdf.tsx +23 -0
- package/src/icons/FileWord.tsx +23 -0
- package/src/icons/Fullscreen.tsx +23 -0
- package/src/icons/FullscreenExit.tsx +23 -0
- package/src/icons/Group.tsx +30 -0
- package/src/icons/History.tsx +33 -0
- package/src/icons/Image.tsx +37 -0
- package/src/icons/Info.tsx +37 -0
- package/src/icons/Link.tsx +17 -0
- package/src/icons/Linkedin.tsx +23 -0
- package/src/icons/Loading.tsx +28 -0
- package/src/icons/Logout.tsx +33 -0
- package/src/icons/Mail.tsx +17 -0
- package/src/icons/MapMarker.tsx +26 -0
- package/src/icons/MenuHorizontal.tsx +29 -0
- package/src/icons/MenuVertical.tsx +29 -0
- package/src/icons/Message.tsx +23 -0
- package/src/icons/Microphone.tsx +23 -0
- package/src/icons/Minus.tsx +23 -0
- package/src/icons/MinusCircle.tsx +24 -0
- package/src/icons/PaperClip.tsx +23 -0
- package/src/icons/Picture.tsx +23 -0
- package/src/icons/Plus.tsx +18 -0
- package/src/icons/Preview.tsx +31 -0
- package/src/icons/Print.tsx +37 -0
- package/src/icons/QuestionHelp.tsx +34 -0
- package/src/icons/Refresh.tsx +30 -0
- package/src/icons/SelectIcon.tsx +28 -0
- package/src/icons/Send.tsx +17 -0
- package/src/icons/Setting.tsx +23 -0
- package/src/icons/Share.tsx +23 -0
- package/src/icons/Sound.tsx +23 -0
- package/src/icons/SoundDeactivated.tsx +27 -0
- package/src/icons/Telegram.tsx +26 -0
- package/src/icons/ThumbDown.tsx +29 -0
- package/src/icons/ThumbUp.tsx +29 -0
- package/src/icons/Translation.tsx +24 -0
- package/src/icons/Twitter.tsx +23 -0
- package/src/icons/Upload.tsx +34 -0
- package/src/icons/User.tsx +17 -0
- package/src/icons/Warning.tsx +27 -0
- package/src/icons/WhatsApp.tsx +24 -0
- package/src/icons/icons.stories.css +5 -0
- package/src/icons/icons.stories.tsx +110 -0
- package/src/icons/loading.css +14 -0
- package/src/index.ts +15 -0
- package/src/styles/utils.css +17 -0
- package/src/styles.css +4 -0
- package/src/theme/variables.css +110 -0
- package/src/vite-env.d.ts +6 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
3
|
+
import Button from './Button'
|
|
4
|
+
import Eye from '../../icons/Eye'
|
|
5
|
+
|
|
6
|
+
import { fn } from 'storybook/test'
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'UI/Button',
|
|
10
|
+
component: Button,
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
argTypes: {
|
|
13
|
+
children: {
|
|
14
|
+
control: {
|
|
15
|
+
type: 'text',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
className: {
|
|
19
|
+
control: {
|
|
20
|
+
type: 'text',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
htmlType: {
|
|
24
|
+
control: {
|
|
25
|
+
type: 'select',
|
|
26
|
+
options: ['button', 'submit', 'reset'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
primary: {
|
|
30
|
+
control: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
outlined: {
|
|
35
|
+
control: {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
ghost: {
|
|
40
|
+
control: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
padded: {
|
|
45
|
+
control: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
block: {
|
|
50
|
+
control: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
danger: {
|
|
55
|
+
control: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
loading: {
|
|
60
|
+
control: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
disabled: {
|
|
65
|
+
control: {
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
parameters: {
|
|
71
|
+
controls: { expanded: true },
|
|
72
|
+
},
|
|
73
|
+
args: {
|
|
74
|
+
onClick: fn(),
|
|
75
|
+
},
|
|
76
|
+
} satisfies Meta<typeof Button>
|
|
77
|
+
|
|
78
|
+
export default meta
|
|
79
|
+
|
|
80
|
+
type Story = StoryObj<typeof meta>
|
|
81
|
+
|
|
82
|
+
export const Default: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
children: 'Click me',
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const Primary: Story = {
|
|
89
|
+
args: {
|
|
90
|
+
children: 'Click me',
|
|
91
|
+
primary: true,
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const Outlined: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
children: 'Click me',
|
|
98
|
+
outlined: true,
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const Ghost: Story = {
|
|
103
|
+
args: {
|
|
104
|
+
children: 'Click me',
|
|
105
|
+
ghost: true,
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const PrimaryOutlined: Story = {
|
|
110
|
+
args: {
|
|
111
|
+
children: 'Click me',
|
|
112
|
+
primary: true,
|
|
113
|
+
outlined: true,
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const Square: Story = {
|
|
118
|
+
args: {
|
|
119
|
+
children: 'Click me',
|
|
120
|
+
shape: 'square',
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export const Padded: Story = {
|
|
125
|
+
args: {
|
|
126
|
+
children: 'Click me',
|
|
127
|
+
padded: true,
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const Block: Story = {
|
|
132
|
+
args: {
|
|
133
|
+
children: 'Click me',
|
|
134
|
+
block: true,
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export const Circle: Story = {
|
|
139
|
+
args: {
|
|
140
|
+
children: 'Click me',
|
|
141
|
+
shape: 'circle',
|
|
142
|
+
icon: <Eye />,
|
|
143
|
+
padded: false,
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export const WithIcon: Story = {
|
|
148
|
+
args: {
|
|
149
|
+
children: 'Click me',
|
|
150
|
+
icon: <Eye />,
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const Danger: Story = {
|
|
155
|
+
args: {
|
|
156
|
+
children: 'Click me',
|
|
157
|
+
danger: true,
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const Loading: Story = {
|
|
162
|
+
args: {
|
|
163
|
+
children: 'Click me',
|
|
164
|
+
loading: true,
|
|
165
|
+
},
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const Disabled: Story = {
|
|
169
|
+
args: {
|
|
170
|
+
children: 'Click me',
|
|
171
|
+
disabled: true,
|
|
172
|
+
},
|
|
173
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { expect, it } from 'vitest'
|
|
3
|
+
import { render } from '@testing-library/react'
|
|
4
|
+
import Button from './Button'
|
|
5
|
+
import Loading from '../../icons/Loading'
|
|
6
|
+
|
|
7
|
+
it('renders empty Button unchanged', () => {
|
|
8
|
+
const { container } = render(<Button />)
|
|
9
|
+
expect(container).toMatchSnapshot()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('renders Button unchanged', () => {
|
|
13
|
+
const { container } = render(<Button>Click me</Button>)
|
|
14
|
+
expect(container).toMatchSnapshot()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('renders Button primary unchanged', () => {
|
|
18
|
+
const { container } = render(<Button primary>Click me</Button>)
|
|
19
|
+
expect(container).toMatchSnapshot()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('renders Button outlined unchanged', () => {
|
|
23
|
+
const { container } = render(<Button outlined>Click me</Button>)
|
|
24
|
+
expect(container).toMatchSnapshot()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('renders Button padded unchanged', () => {
|
|
28
|
+
const { container } = render(<Button padded>Click me</Button>)
|
|
29
|
+
expect(container).toMatchSnapshot()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('renders Button block unchanged', () => {
|
|
33
|
+
const { container } = render(<Button block>Click me</Button>)
|
|
34
|
+
expect(container).toMatchSnapshot()
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('renders Button with icon unchanged', () => {
|
|
38
|
+
const { container } = render(<Button icon={<Loading />}>Click me</Button>)
|
|
39
|
+
expect(container).toMatchSnapshot()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('renders Button with icon only unchanged', () => {
|
|
43
|
+
const { container } = render(<Button icon={<Loading />} />)
|
|
44
|
+
expect(container).toMatchSnapshot()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('renders Button danger unchanged', () => {
|
|
48
|
+
const { container } = render(<Button danger>Click me</Button>)
|
|
49
|
+
expect(container).toMatchSnapshot()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('renders Button loading unchanged', () => {
|
|
53
|
+
const { container } = render(<Button loading>Click me</Button>)
|
|
54
|
+
expect(container).toMatchSnapshot()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('renders Button disabled unchanged', () => {
|
|
58
|
+
const { container } = render(<Button disabled>Click me</Button>)
|
|
59
|
+
expect(container).toMatchSnapshot()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('renders Button with title unchanged', () => {
|
|
63
|
+
const { container } = render(<Button title="Button title">Click me</Button>)
|
|
64
|
+
expect(container).toMatchSnapshot()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('renders Button square unchanged', () => {
|
|
68
|
+
const { container } = render(<Button shape="square">Click me</Button>)
|
|
69
|
+
expect(container).toMatchSnapshot()
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('renders Button circle unchanged', () => {
|
|
73
|
+
const { container } = render(
|
|
74
|
+
<Button
|
|
75
|
+
shape="circle"
|
|
76
|
+
icon={<Loading />}
|
|
77
|
+
/>,
|
|
78
|
+
)
|
|
79
|
+
expect(container).toMatchSnapshot()
|
|
80
|
+
})
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { FC } from 'react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import cx from 'classnames'
|
|
4
|
+
import Loading from '../../icons/Loading'
|
|
5
|
+
|
|
6
|
+
import './Button.css'
|
|
7
|
+
|
|
8
|
+
export interface Props {
|
|
9
|
+
children?: React.ReactNode
|
|
10
|
+
primary?: boolean
|
|
11
|
+
outlined?: boolean
|
|
12
|
+
ghost?: boolean
|
|
13
|
+
padded?: boolean
|
|
14
|
+
block?: boolean
|
|
15
|
+
icon?: React.ReactNode
|
|
16
|
+
shape?: 'square' | 'rounded' | 'circle'
|
|
17
|
+
danger?: boolean
|
|
18
|
+
loading?: boolean
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
className?: string
|
|
21
|
+
title?: string
|
|
22
|
+
id?: string
|
|
23
|
+
isActive?: boolean
|
|
24
|
+
htmlType?: 'button' | 'submit' | 'reset'
|
|
25
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
26
|
+
onMouseDown?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
27
|
+
onMouseUp?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
28
|
+
onMouseLeave?: (
|
|
29
|
+
event: React.MouseEvent<HTMLButtonElement, MouseEvent>,
|
|
30
|
+
) => void
|
|
31
|
+
onTouchStart?: (
|
|
32
|
+
event: React.TouchEvent<HTMLButtonElement> | React.MouseEvent,
|
|
33
|
+
) => void
|
|
34
|
+
onTouchEnd?: (
|
|
35
|
+
event: React.TouchEvent<HTMLButtonElement> | React.MouseEvent,
|
|
36
|
+
) => void
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const Button: FC<Props> = ({
|
|
40
|
+
primary = false,
|
|
41
|
+
outlined = false,
|
|
42
|
+
ghost = false,
|
|
43
|
+
padded = true,
|
|
44
|
+
shape = 'rounded',
|
|
45
|
+
danger = false,
|
|
46
|
+
loading = false,
|
|
47
|
+
disabled = false,
|
|
48
|
+
block = false,
|
|
49
|
+
icon,
|
|
50
|
+
className,
|
|
51
|
+
title,
|
|
52
|
+
id,
|
|
53
|
+
htmlType,
|
|
54
|
+
onClick,
|
|
55
|
+
onMouseDown,
|
|
56
|
+
onMouseUp,
|
|
57
|
+
onMouseLeave,
|
|
58
|
+
onTouchStart,
|
|
59
|
+
onTouchEnd,
|
|
60
|
+
children,
|
|
61
|
+
isActive,
|
|
62
|
+
}) => (
|
|
63
|
+
<button
|
|
64
|
+
id={id}
|
|
65
|
+
type={htmlType}
|
|
66
|
+
onClick={onClick}
|
|
67
|
+
onMouseDown={onMouseDown}
|
|
68
|
+
onMouseUp={onMouseUp}
|
|
69
|
+
onMouseLeave={onMouseLeave}
|
|
70
|
+
onTouchStart={onTouchStart}
|
|
71
|
+
onTouchEnd={onTouchEnd}
|
|
72
|
+
title={title}
|
|
73
|
+
disabled={loading || disabled}
|
|
74
|
+
className={cx(
|
|
75
|
+
'memori-button',
|
|
76
|
+
{
|
|
77
|
+
'memori-button--primary': primary,
|
|
78
|
+
'memori-button--outlined': outlined,
|
|
79
|
+
'memori-button--ghost': ghost,
|
|
80
|
+
'memori-button--square': shape === 'square',
|
|
81
|
+
'memori-button--rounded': shape === 'rounded',
|
|
82
|
+
'memori-button--circle': shape === 'circle',
|
|
83
|
+
'memori-button--padded': padded,
|
|
84
|
+
'memori-button--block': block,
|
|
85
|
+
'memori-button--with-icon': (icon || loading) && children,
|
|
86
|
+
'memori-button--icon-only': (icon || loading) && !children,
|
|
87
|
+
'memori-button--danger': danger,
|
|
88
|
+
'memori-button--loading': loading,
|
|
89
|
+
'memori-button--active': isActive,
|
|
90
|
+
},
|
|
91
|
+
className,
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
{icon && !loading && <span className="memori-button--icon">{icon}</span>}
|
|
95
|
+
{loading && (
|
|
96
|
+
<span className="memori-button--icon loading-icon">
|
|
97
|
+
<Loading loading />
|
|
98
|
+
</span>
|
|
99
|
+
)}
|
|
100
|
+
{children}
|
|
101
|
+
</button>
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
export default Button
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`renders Button block unchanged 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<button
|
|
6
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--block"
|
|
7
|
+
>
|
|
8
|
+
Click me
|
|
9
|
+
</button>
|
|
10
|
+
</div>
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`renders Button circle unchanged 1`] = `
|
|
14
|
+
<div>
|
|
15
|
+
<button
|
|
16
|
+
class="memori-button memori-button--circle memori-button--padded memori-button--icon-only"
|
|
17
|
+
>
|
|
18
|
+
<span
|
|
19
|
+
class="memori-button--icon"
|
|
20
|
+
>
|
|
21
|
+
<svg
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
class="memori-loading-icon"
|
|
24
|
+
focusable="false"
|
|
25
|
+
role="img"
|
|
26
|
+
viewBox="0 0 1024 1024"
|
|
27
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
|
|
31
|
+
/>
|
|
32
|
+
</svg>
|
|
33
|
+
</span>
|
|
34
|
+
</button>
|
|
35
|
+
</div>
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
exports[`renders Button danger unchanged 1`] = `
|
|
39
|
+
<div>
|
|
40
|
+
<button
|
|
41
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--danger"
|
|
42
|
+
>
|
|
43
|
+
Click me
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
exports[`renders Button disabled unchanged 1`] = `
|
|
49
|
+
<div>
|
|
50
|
+
<button
|
|
51
|
+
class="memori-button memori-button--rounded memori-button--padded"
|
|
52
|
+
disabled=""
|
|
53
|
+
>
|
|
54
|
+
Click me
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
exports[`renders Button loading unchanged 1`] = `
|
|
60
|
+
<div>
|
|
61
|
+
<button
|
|
62
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--with-icon memori-button--loading"
|
|
63
|
+
disabled=""
|
|
64
|
+
>
|
|
65
|
+
<span
|
|
66
|
+
class="memori-button--icon loading-icon"
|
|
67
|
+
>
|
|
68
|
+
<svg
|
|
69
|
+
aria-hidden="true"
|
|
70
|
+
class="memori-loading-icon"
|
|
71
|
+
focusable="false"
|
|
72
|
+
role="img"
|
|
73
|
+
viewBox="0 0 1024 1024"
|
|
74
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
75
|
+
>
|
|
76
|
+
<path
|
|
77
|
+
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
|
|
78
|
+
/>
|
|
79
|
+
</svg>
|
|
80
|
+
</span>
|
|
81
|
+
Click me
|
|
82
|
+
</button>
|
|
83
|
+
</div>
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`renders Button outlined unchanged 1`] = `
|
|
87
|
+
<div>
|
|
88
|
+
<button
|
|
89
|
+
class="memori-button memori-button--outlined memori-button--rounded memori-button--padded"
|
|
90
|
+
>
|
|
91
|
+
Click me
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
exports[`renders Button padded unchanged 1`] = `
|
|
97
|
+
<div>
|
|
98
|
+
<button
|
|
99
|
+
class="memori-button memori-button--rounded memori-button--padded"
|
|
100
|
+
>
|
|
101
|
+
Click me
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
exports[`renders Button primary unchanged 1`] = `
|
|
107
|
+
<div>
|
|
108
|
+
<button
|
|
109
|
+
class="memori-button memori-button--primary memori-button--rounded memori-button--padded"
|
|
110
|
+
>
|
|
111
|
+
Click me
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
`;
|
|
115
|
+
|
|
116
|
+
exports[`renders Button square unchanged 1`] = `
|
|
117
|
+
<div>
|
|
118
|
+
<button
|
|
119
|
+
class="memori-button memori-button--square memori-button--padded"
|
|
120
|
+
>
|
|
121
|
+
Click me
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
exports[`renders Button unchanged 1`] = `
|
|
127
|
+
<div>
|
|
128
|
+
<button
|
|
129
|
+
class="memori-button memori-button--rounded memori-button--padded"
|
|
130
|
+
>
|
|
131
|
+
Click me
|
|
132
|
+
</button>
|
|
133
|
+
</div>
|
|
134
|
+
`;
|
|
135
|
+
|
|
136
|
+
exports[`renders Button with icon only unchanged 1`] = `
|
|
137
|
+
<div>
|
|
138
|
+
<button
|
|
139
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--icon-only"
|
|
140
|
+
>
|
|
141
|
+
<span
|
|
142
|
+
class="memori-button--icon"
|
|
143
|
+
>
|
|
144
|
+
<svg
|
|
145
|
+
aria-hidden="true"
|
|
146
|
+
class="memori-loading-icon"
|
|
147
|
+
focusable="false"
|
|
148
|
+
role="img"
|
|
149
|
+
viewBox="0 0 1024 1024"
|
|
150
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
151
|
+
>
|
|
152
|
+
<path
|
|
153
|
+
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
|
|
154
|
+
/>
|
|
155
|
+
</svg>
|
|
156
|
+
</span>
|
|
157
|
+
</button>
|
|
158
|
+
</div>
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
exports[`renders Button with icon unchanged 1`] = `
|
|
162
|
+
<div>
|
|
163
|
+
<button
|
|
164
|
+
class="memori-button memori-button--rounded memori-button--padded memori-button--with-icon"
|
|
165
|
+
>
|
|
166
|
+
<span
|
|
167
|
+
class="memori-button--icon"
|
|
168
|
+
>
|
|
169
|
+
<svg
|
|
170
|
+
aria-hidden="true"
|
|
171
|
+
class="memori-loading-icon"
|
|
172
|
+
focusable="false"
|
|
173
|
+
role="img"
|
|
174
|
+
viewBox="0 0 1024 1024"
|
|
175
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
176
|
+
>
|
|
177
|
+
<path
|
|
178
|
+
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
|
|
179
|
+
/>
|
|
180
|
+
</svg>
|
|
181
|
+
</span>
|
|
182
|
+
Click me
|
|
183
|
+
</button>
|
|
184
|
+
</div>
|
|
185
|
+
`;
|
|
186
|
+
|
|
187
|
+
exports[`renders Button with title unchanged 1`] = `
|
|
188
|
+
<div>
|
|
189
|
+
<button
|
|
190
|
+
class="memori-button memori-button--rounded memori-button--padded"
|
|
191
|
+
title="Button title"
|
|
192
|
+
>
|
|
193
|
+
Click me
|
|
194
|
+
</button>
|
|
195
|
+
</div>
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
exports[`renders empty Button unchanged 1`] = `
|
|
199
|
+
<div>
|
|
200
|
+
<button
|
|
201
|
+
class="memori-button memori-button--rounded memori-button--padded"
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
204
|
+
`;
|