@nattui/react-components 0.0.1
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/.prettierignore +2 -0
- package/.prettierrc +9 -0
- package/.turbo/turbo-build.log +29 -0
- package/LICENSE +21 -0
- package/dist/button-background.module-FK4ABTRO.module.css +38 -0
- package/dist/button-spinner.module-IRIJPNSF.module.css +95 -0
- package/dist/button.module-QR72PPSM.module.css +238 -0
- package/dist/index.d.mts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +124 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +115 -0
- package/dist/index.mjs.map +1 -0
- package/eslint.config.mjs +96 -0
- package/global.d.ts +4 -0
- package/package.json +59 -0
- package/src/button-background.module.css +38 -0
- package/src/button-background.tsx +40 -0
- package/src/button-spinner.module.css +95 -0
- package/src/button-spinner.tsx +21 -0
- package/src/button.module.css +238 -0
- package/src/button.tsx +97 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +13 -0
- package/tsup.config.ts +13 -0
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @nattui/react-components@0.0.1 build /Users/snowshift/Documents/3-github/react-components/packages/ui
|
|
4
|
+
> tsup
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.5.0
|
|
9
|
+
[34mCLI[39m Using tsup config: /Users/snowshift/Documents/3-github/react-components/packages/ui/tsup.config.ts
|
|
10
|
+
[34mCLI[39m Target: node16
|
|
11
|
+
[34mCLI[39m Cleaning output folder
|
|
12
|
+
[34mESM[39m Build start
|
|
13
|
+
[34mCJS[39m Build start
|
|
14
|
+
[32mESM[39m [1mdist/button-spinner.module-IRIJPNSF.module.css [22m[32m1.49 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/button.module-QR72PPSM.module.css [22m[32m5.60 KB[39m
|
|
16
|
+
[32mESM[39m [1mdist/button-background.module-FK4ABTRO.module.css [22m[32m667.00 B[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m3.42 KB[39m
|
|
18
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m7.61 KB[39m
|
|
19
|
+
[32mESM[39m ⚡️ Build success in 83ms
|
|
20
|
+
[32mCJS[39m [1mdist/button-spinner.module-IRIJPNSF.module.css [22m[32m1.49 KB[39m
|
|
21
|
+
[32mCJS[39m [1mdist/button.module-QR72PPSM.module.css [22m[32m5.60 KB[39m
|
|
22
|
+
[32mCJS[39m [1mdist/button-background.module-FK4ABTRO.module.css [22m[32m667.00 B[39m
|
|
23
|
+
[32mCJS[39m [1mdist/index.js [22m[32m4.14 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m7.66 KB[39m
|
|
25
|
+
[32mCJS[39m ⚡️ Build success in 83ms
|
|
26
|
+
DTS Build start
|
|
27
|
+
DTS ⚡️ Build success in 682ms
|
|
28
|
+
DTS dist/index.d.mts 1.31 KB
|
|
29
|
+
DTS dist/index.d.ts 1.31 KB
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Natt Nguyen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* Base */
|
|
2
|
+
.button_background {
|
|
3
|
+
position: absolute;
|
|
4
|
+
top: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
bottom: 50%;
|
|
7
|
+
left: 0;
|
|
8
|
+
opacity: 0.2;
|
|
9
|
+
z-index: -1;
|
|
10
|
+
filter: none !important;
|
|
11
|
+
transition: opacity 150ms;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Rounded */
|
|
15
|
+
.button_background__rounded_base {
|
|
16
|
+
border-radius: 7px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.button_background__rounded_full {
|
|
20
|
+
border-radius: 9999px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Variant */
|
|
24
|
+
.button_background__variant_accent {
|
|
25
|
+
background: linear-gradient(
|
|
26
|
+
to bottom,
|
|
27
|
+
var(--color-primary-7, #edadc8),
|
|
28
|
+
var(--color-primary-8, #e58fb1)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.button_background__variant_primary {
|
|
33
|
+
background: linear-gradient(
|
|
34
|
+
to bottom,
|
|
35
|
+
var(--color-gray-10, #86848d),
|
|
36
|
+
var(--color-gray-11, #6f6e77)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.button_spinner {
|
|
2
|
+
position: relative;
|
|
3
|
+
scale: -1 1;
|
|
4
|
+
animation: spinner 1000ms steps(12, end) infinite;
|
|
5
|
+
width: var(--size);
|
|
6
|
+
height: var(--size);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@keyframes spinner {
|
|
10
|
+
to {
|
|
11
|
+
rotate: 1turn;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.button_spinner > div {
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 50%;
|
|
18
|
+
right: 0;
|
|
19
|
+
transform-origin: center left;
|
|
20
|
+
translate: 0 -50%;
|
|
21
|
+
transition: all 150ms;
|
|
22
|
+
width: calc(var(--size) / 2);
|
|
23
|
+
height: calc(var(--size) / 12);
|
|
24
|
+
pointer-events: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.button_spinner > div::after {
|
|
28
|
+
position: absolute;
|
|
29
|
+
right: 0;
|
|
30
|
+
border-radius: 9999px;
|
|
31
|
+
background-color: currentColor;
|
|
32
|
+
width: 50%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
content: "";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.button_spinner > div:nth-child(1) {
|
|
38
|
+
rotate: 0deg;
|
|
39
|
+
opacity: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.button_spinner > div:nth-child(2) {
|
|
43
|
+
rotate: 30deg;
|
|
44
|
+
opacity: 0.925;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.button_spinner > div:nth-child(3) {
|
|
48
|
+
rotate: 60deg;
|
|
49
|
+
opacity: 0.85;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.button_spinner > div:nth-child(4) {
|
|
53
|
+
rotate: 90deg;
|
|
54
|
+
opacity: 0.775;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.button_spinner > div:nth-child(5) {
|
|
58
|
+
rotate: 120deg;
|
|
59
|
+
opacity: 0.7;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.button_spinner > div:nth-child(6) {
|
|
63
|
+
rotate: 150deg;
|
|
64
|
+
opacity: 0.625;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.button_spinner > div:nth-child(7) {
|
|
68
|
+
rotate: 180deg;
|
|
69
|
+
opacity: 0.55;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.button_spinner > div:nth-child(8) {
|
|
73
|
+
rotate: 210deg;
|
|
74
|
+
opacity: 0.475;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.button_spinner > div:nth-child(9) {
|
|
78
|
+
rotate: 240deg;
|
|
79
|
+
opacity: 0.4;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.button_spinner > div:nth-child(10) {
|
|
83
|
+
rotate: 270deg;
|
|
84
|
+
opacity: 0.325;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.button_spinner > div:nth-child(11) {
|
|
88
|
+
rotate: 300deg;
|
|
89
|
+
opacity: 0.25;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.button_spinner > div:nth-child(12) {
|
|
93
|
+
rotate: 330deg;
|
|
94
|
+
opacity: 0.15;
|
|
95
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/* ===================================================== */
|
|
2
|
+
/* Base */
|
|
3
|
+
/* ===================================================== */
|
|
4
|
+
.button {
|
|
5
|
+
display: flex;
|
|
6
|
+
position: relative;
|
|
7
|
+
column-gap: 8px;
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
justify-content: safe center;
|
|
10
|
+
align-items: safe center;
|
|
11
|
+
transition-duration: 150ms;
|
|
12
|
+
transition-property: all;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
outline-width: 0;
|
|
15
|
+
border-width: 1px;
|
|
16
|
+
border-style: solid;
|
|
17
|
+
border-color: transparent;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
font-weight: 500;
|
|
20
|
+
line-height: 1.5;
|
|
21
|
+
user-select: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.button:disabled {
|
|
25
|
+
opacity: 0.5;
|
|
26
|
+
cursor: not-allowed;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Active */
|
|
30
|
+
.button:enabled[aria-pressed="true"] > *,
|
|
31
|
+
.button:enabled:active > * {
|
|
32
|
+
transform: translateY(1px);
|
|
33
|
+
transition-duration: 150ms;
|
|
34
|
+
transition-property: transform;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Disable child shadow */
|
|
38
|
+
.button:enabled[aria-pressed="true"] > *,
|
|
39
|
+
.button:enabled:active > *,
|
|
40
|
+
.button:enabled:hover > * {
|
|
41
|
+
filter: none !important;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Hover */
|
|
45
|
+
.button:enabled[aria-pressed="true"],
|
|
46
|
+
.button:enabled:active,
|
|
47
|
+
.button:enabled:hover {
|
|
48
|
+
opacity: 0.85;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Button background */
|
|
52
|
+
.button:enabled[aria-pressed="true"] > [data-element="button-background"],
|
|
53
|
+
.button:enabled:active > [data-element="button-background"],
|
|
54
|
+
.button:enabled:hover > [data-element="button-background"] {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* ===================================================== */
|
|
59
|
+
/* Icon only */
|
|
60
|
+
/* ===================================================== */
|
|
61
|
+
.button__icon_only {
|
|
62
|
+
padding: 0 !important;
|
|
63
|
+
width: var(--size) !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* ===================================================== */
|
|
67
|
+
/* Rounded */
|
|
68
|
+
/* ===================================================== */
|
|
69
|
+
.button__rounded_base {
|
|
70
|
+
border-radius: 8px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.button__rounded_full {
|
|
74
|
+
border-radius: 9999px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* ===================================================== */
|
|
78
|
+
/* Size */
|
|
79
|
+
/* ===================================================== */
|
|
80
|
+
.button__size_32 {
|
|
81
|
+
--size: 32px;
|
|
82
|
+
padding: 0 8px;
|
|
83
|
+
height: var(--size);
|
|
84
|
+
font-size: 14px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.button__size_36 {
|
|
88
|
+
--size: 36px;
|
|
89
|
+
padding: 0 12px;
|
|
90
|
+
height: var(--size);
|
|
91
|
+
font-size: 14px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.button__size_40 {
|
|
95
|
+
--size: 40px;
|
|
96
|
+
padding: 0 16px;
|
|
97
|
+
height: var(--size);
|
|
98
|
+
font-size: 14px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.button__size_48 {
|
|
102
|
+
--size: 48px;
|
|
103
|
+
padding: 0 20px;
|
|
104
|
+
height: var(--size);
|
|
105
|
+
font-size: 16px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* ===================================================== */
|
|
109
|
+
/* Variant */
|
|
110
|
+
/* ===================================================== */
|
|
111
|
+
/* Accent */
|
|
112
|
+
.button__variant_accent {
|
|
113
|
+
box-shadow:
|
|
114
|
+
inset 0 1px 0 0 rgba(255, 255, 255, 0.25),
|
|
115
|
+
inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
|
|
116
|
+
border-color: var(--color-primary-9, #e93d82);
|
|
117
|
+
background-image: linear-gradient(
|
|
118
|
+
to bottom,
|
|
119
|
+
var(--color-primary-9, #e93d82),
|
|
120
|
+
var(--color-primary-10, #e03177)
|
|
121
|
+
);
|
|
122
|
+
color: var(--color-gray-1, #fdfcfd);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.button__variant_accent:enabled[aria-pressed="true"],
|
|
126
|
+
.button__variant_accent:enabled:active {
|
|
127
|
+
box-shadow:
|
|
128
|
+
inset 0 -1px 0 0 rgba(255, 255, 255, 0.25),
|
|
129
|
+
inset 0 1px 0 0 rgba(0, 0, 0, 0.1) !important;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Ghost */
|
|
133
|
+
.button__variant_ghost {
|
|
134
|
+
background-color: transparent;
|
|
135
|
+
color: var(--color-gray-11, #6f6e77);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.button__variant_ghost:enabled[aria-pressed="true"],
|
|
139
|
+
.button__variant_ghost:enabled:active {
|
|
140
|
+
background-color: var(--color-gray-5, #e9e8ea) !important;
|
|
141
|
+
color: var(--color-gray-12, #1a1523);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.button__variant_ghost:enabled:hover {
|
|
145
|
+
background-color: color-mix(
|
|
146
|
+
in oklab,
|
|
147
|
+
var(--color-gray-5, #e9e8ea) 75%,
|
|
148
|
+
transparent
|
|
149
|
+
);
|
|
150
|
+
color: var(--color-gray-12, #1a1523);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* Primary */
|
|
154
|
+
.button__variant_primary {
|
|
155
|
+
box-shadow:
|
|
156
|
+
inset 0 1px 0 0 rgba(255, 255, 255, 0.25),
|
|
157
|
+
inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
|
|
158
|
+
border-color: var(--color-gray-12, #1a1523);
|
|
159
|
+
background-image: linear-gradient(
|
|
160
|
+
to bottom,
|
|
161
|
+
color-mix(in oklab, var(--color-gray-12, #1a1523) 90%, transparent),
|
|
162
|
+
var(--color-gray-12, #1a1523)
|
|
163
|
+
);
|
|
164
|
+
color: var(--color-gray-1, #fdfcfd);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.button__variant_primary:enabled[aria-pressed="true"],
|
|
168
|
+
.button__variant_primary:enabled:active {
|
|
169
|
+
box-shadow:
|
|
170
|
+
inset 0 -1px 0 0 rgba(255, 255, 255, 0.25),
|
|
171
|
+
inset 0 1px 0 0 rgba(0, 0, 0, 0.5) !important;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* Secondary */
|
|
175
|
+
.button__variant_secondary {
|
|
176
|
+
box-shadow:
|
|
177
|
+
inset 0 1px 0 0 rgba(255, 255, 255, 0.25),
|
|
178
|
+
inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
|
|
179
|
+
border-color: var(--color-gray-6, #e4e2e4);
|
|
180
|
+
background-image: linear-gradient(
|
|
181
|
+
to bottom,
|
|
182
|
+
var(--color-gray-1, #fdfcfd),
|
|
183
|
+
var(--color-gray-3, #f4f2f4)
|
|
184
|
+
);
|
|
185
|
+
color: var(--color-gray-11, #6f6e77);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.button__variant_secondary:enabled[aria-pressed="true"],
|
|
189
|
+
.button__variant_secondary:enabled:active,
|
|
190
|
+
.button__variant_secondary:enabled:hover {
|
|
191
|
+
border-color: var(--color-gray-8, #c8c7cb);
|
|
192
|
+
color: var(--color-gray-12, #1a1523);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.button__variant_secondary:enabled[aria-pressed="true"],
|
|
196
|
+
.button__variant_secondary:enabled:active {
|
|
197
|
+
box-shadow:
|
|
198
|
+
inset 0 -1px 0 0 var(--color-gray-1, #fdfcfd),
|
|
199
|
+
inset 0 1px 0 0 rgba(0, 0, 0, 0.1) !important;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Group */
|
|
203
|
+
.button__variant_accent,
|
|
204
|
+
.button__variant_primary,
|
|
205
|
+
.button__variant_secondary {
|
|
206
|
+
filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.05));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.button__variant_accent > * {
|
|
210
|
+
filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.1));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.button__variant_primary > * {
|
|
214
|
+
filter: drop-shadow(0 1px 0 rgb(255 255 255 / 0.1));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.button__variant_accent:enabled:hover,
|
|
218
|
+
.button__variant_primary:enabled:hover,
|
|
219
|
+
.button__variant_secondary:enabled:hover {
|
|
220
|
+
filter: none;
|
|
221
|
+
box-shadow: inset 0 0 0 0 transparent;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.button__variant_ghost:enabled:hover,
|
|
225
|
+
.button__variant_secondary:enabled:hover {
|
|
226
|
+
color: var(--color-gray-12, #1a1523);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* ===================================================== */
|
|
230
|
+
/* Width */
|
|
231
|
+
/* ===================================================== */
|
|
232
|
+
.button__width_base {
|
|
233
|
+
width: max-content;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.button__width_full {
|
|
237
|
+
width: 100%;
|
|
238
|
+
}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode, JSX } from 'react';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps extends ComponentProps<"button"> {
|
|
4
|
+
fullWidth?: boolean;
|
|
5
|
+
iconEnd?: ReactNode;
|
|
6
|
+
iconOnly?: boolean;
|
|
7
|
+
iconStart?: ReactNode;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
rounded?: boolean;
|
|
10
|
+
size?: 32 | 36 | 40 | 48;
|
|
11
|
+
variant?: "accent" | "ghost" | "primary" | "secondary";
|
|
12
|
+
}
|
|
13
|
+
type ButtonPropsInternal = ButtonPropsWithIcon | ButtonPropsWithText;
|
|
14
|
+
interface ButtonPropsWithIcon extends ButtonProps {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
iconOnly: true;
|
|
17
|
+
}
|
|
18
|
+
interface ButtonPropsWithText extends ButtonProps {
|
|
19
|
+
children?: string;
|
|
20
|
+
iconOnly?: false;
|
|
21
|
+
}
|
|
22
|
+
declare function Button(props: ButtonPropsInternal): JSX.Element;
|
|
23
|
+
declare const BUTTON_CLASS_NAME: {
|
|
24
|
+
readonly BASE: string;
|
|
25
|
+
readonly ICON_ONLY: string;
|
|
26
|
+
readonly ROUNDED: {
|
|
27
|
+
readonly BASE: string;
|
|
28
|
+
readonly FULL: string;
|
|
29
|
+
};
|
|
30
|
+
readonly SIZE: {
|
|
31
|
+
readonly 32: string;
|
|
32
|
+
readonly 36: string;
|
|
33
|
+
readonly 40: string;
|
|
34
|
+
readonly 48: string;
|
|
35
|
+
};
|
|
36
|
+
readonly VARIANT: {
|
|
37
|
+
readonly ACCENT: string;
|
|
38
|
+
readonly GHOST: string;
|
|
39
|
+
readonly PRIMARY: string;
|
|
40
|
+
readonly SECONDARY: string;
|
|
41
|
+
};
|
|
42
|
+
readonly WIDTH: {
|
|
43
|
+
readonly BASE: string;
|
|
44
|
+
readonly FULL: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { BUTTON_CLASS_NAME, Button, type ButtonProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode, JSX } from 'react';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps extends ComponentProps<"button"> {
|
|
4
|
+
fullWidth?: boolean;
|
|
5
|
+
iconEnd?: ReactNode;
|
|
6
|
+
iconOnly?: boolean;
|
|
7
|
+
iconStart?: ReactNode;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
rounded?: boolean;
|
|
10
|
+
size?: 32 | 36 | 40 | 48;
|
|
11
|
+
variant?: "accent" | "ghost" | "primary" | "secondary";
|
|
12
|
+
}
|
|
13
|
+
type ButtonPropsInternal = ButtonPropsWithIcon | ButtonPropsWithText;
|
|
14
|
+
interface ButtonPropsWithIcon extends ButtonProps {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
iconOnly: true;
|
|
17
|
+
}
|
|
18
|
+
interface ButtonPropsWithText extends ButtonProps {
|
|
19
|
+
children?: string;
|
|
20
|
+
iconOnly?: false;
|
|
21
|
+
}
|
|
22
|
+
declare function Button(props: ButtonPropsInternal): JSX.Element;
|
|
23
|
+
declare const BUTTON_CLASS_NAME: {
|
|
24
|
+
readonly BASE: string;
|
|
25
|
+
readonly ICON_ONLY: string;
|
|
26
|
+
readonly ROUNDED: {
|
|
27
|
+
readonly BASE: string;
|
|
28
|
+
readonly FULL: string;
|
|
29
|
+
};
|
|
30
|
+
readonly SIZE: {
|
|
31
|
+
readonly 32: string;
|
|
32
|
+
readonly 36: string;
|
|
33
|
+
readonly 40: string;
|
|
34
|
+
readonly 48: string;
|
|
35
|
+
};
|
|
36
|
+
readonly VARIANT: {
|
|
37
|
+
readonly ACCENT: string;
|
|
38
|
+
readonly GHOST: string;
|
|
39
|
+
readonly PRIMARY: string;
|
|
40
|
+
readonly SECONDARY: string;
|
|
41
|
+
};
|
|
42
|
+
readonly WIDTH: {
|
|
43
|
+
readonly BASE: string;
|
|
44
|
+
readonly FULL: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { BUTTON_CLASS_NAME, Button, type ButtonProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styles = require('./button-background.module-FK4ABTRO.module.css');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var styles2 = require('./button-spinner.module-IRIJPNSF.module.css');
|
|
6
|
+
var styles3 = require('./button.module-QR72PPSM.module.css');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
11
|
+
var styles2__default = /*#__PURE__*/_interopDefault(styles2);
|
|
12
|
+
var styles3__default = /*#__PURE__*/_interopDefault(styles3);
|
|
13
|
+
|
|
14
|
+
// src/button-background.tsx
|
|
15
|
+
function ButtonBackground(props) {
|
|
16
|
+
const { rounded = false, variant = "primary" } = props;
|
|
17
|
+
const combinedBackgroundStyles = `
|
|
18
|
+
${BUTTON_BACKGROUND_CLASS_NAME.BASE}
|
|
19
|
+
${rounded ? BUTTON_BACKGROUND_CLASS_NAME.ROUNDED.FULL : BUTTON_BACKGROUND_CLASS_NAME.ROUNDED.BASE}
|
|
20
|
+
${variant === "accent" ? BUTTON_BACKGROUND_CLASS_NAME.VARIANT.ACCENT : ""}
|
|
21
|
+
${variant === "primary" ? BUTTON_BACKGROUND_CLASS_NAME.VARIANT.PRIMARY : ""}
|
|
22
|
+
`.replaceAll(/\s+/g, " ").trim();
|
|
23
|
+
if (!(variant === "accent" || variant === "primary")) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
className: combinedBackgroundStyles,
|
|
28
|
+
"data-element": "button-background"
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
var BUTTON_BACKGROUND_CLASS_NAME = {
|
|
33
|
+
BASE: styles__default.default.button_background,
|
|
34
|
+
ROUNDED: {
|
|
35
|
+
BASE: styles__default.default.button_background__rounded_base,
|
|
36
|
+
FULL: styles__default.default.button_background__rounded_full
|
|
37
|
+
},
|
|
38
|
+
VARIANT: {
|
|
39
|
+
ACCENT: styles__default.default.button_background__variant_accent,
|
|
40
|
+
PRIMARY: styles__default.default.button_background__variant_primary
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function ButtonSpinner(props) {
|
|
44
|
+
const { size = 16 } = props;
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: styles2__default.default.button_spinner,
|
|
49
|
+
style: { "--size": `${size}px` },
|
|
50
|
+
children: Array.from({ length: 12 }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx("div", {}, index))
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function Button(props) {
|
|
55
|
+
const {
|
|
56
|
+
children = "",
|
|
57
|
+
className: customClassName = "",
|
|
58
|
+
disabled = false,
|
|
59
|
+
fullWidth = false,
|
|
60
|
+
iconEnd = "",
|
|
61
|
+
iconOnly = false,
|
|
62
|
+
iconStart = "",
|
|
63
|
+
isLoading = false,
|
|
64
|
+
rounded = false,
|
|
65
|
+
size = 36,
|
|
66
|
+
type = "button",
|
|
67
|
+
variant = "primary",
|
|
68
|
+
...rest
|
|
69
|
+
} = props;
|
|
70
|
+
const combinedClassName = `
|
|
71
|
+
${BUTTON_CLASS_NAME.BASE}
|
|
72
|
+
${BUTTON_CLASS_NAME.SIZE[size]}
|
|
73
|
+
${BUTTON_CLASS_NAME.VARIANT[variant.toUpperCase()]}
|
|
74
|
+
${fullWidth ? BUTTON_CLASS_NAME.WIDTH.FULL : BUTTON_CLASS_NAME.WIDTH.BASE}
|
|
75
|
+
${iconOnly ? BUTTON_CLASS_NAME.ICON_ONLY : ""}
|
|
76
|
+
${rounded ? BUTTON_CLASS_NAME.ROUNDED.FULL : BUTTON_CLASS_NAME.ROUNDED.BASE}
|
|
77
|
+
${customClassName}
|
|
78
|
+
`.replaceAll(/\s+/g, " ").trim();
|
|
79
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
className: combinedClassName,
|
|
83
|
+
disabled: disabled || isLoading,
|
|
84
|
+
type,
|
|
85
|
+
...rest,
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx(ButtonBackground, { rounded, variant }),
|
|
88
|
+
isLoading && /* @__PURE__ */ jsxRuntime.jsx(ButtonSpinner, {}),
|
|
89
|
+
!isLoading && iconStart,
|
|
90
|
+
children,
|
|
91
|
+
!isLoading && iconEnd
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
var BUTTON_CLASS_NAME = {
|
|
97
|
+
BASE: styles3__default.default.button,
|
|
98
|
+
ICON_ONLY: styles3__default.default.button__icon_only,
|
|
99
|
+
ROUNDED: {
|
|
100
|
+
BASE: styles3__default.default.button__rounded_base,
|
|
101
|
+
FULL: styles3__default.default.button__rounded_full
|
|
102
|
+
},
|
|
103
|
+
SIZE: {
|
|
104
|
+
32: styles3__default.default.button__size_32,
|
|
105
|
+
36: styles3__default.default.button__size_36,
|
|
106
|
+
40: styles3__default.default.button__size_40,
|
|
107
|
+
48: styles3__default.default.button__size_48
|
|
108
|
+
},
|
|
109
|
+
VARIANT: {
|
|
110
|
+
ACCENT: styles3__default.default.button__variant_accent,
|
|
111
|
+
GHOST: styles3__default.default.button__variant_ghost,
|
|
112
|
+
PRIMARY: styles3__default.default.button__variant_primary,
|
|
113
|
+
SECONDARY: styles3__default.default.button__variant_secondary
|
|
114
|
+
},
|
|
115
|
+
WIDTH: {
|
|
116
|
+
BASE: styles3__default.default.button__width_base,
|
|
117
|
+
FULL: styles3__default.default.button__width_full
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
exports.BUTTON_CLASS_NAME = BUTTON_CLASS_NAME;
|
|
122
|
+
exports.Button = Button;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/button-background.tsx","../src/button-spinner.tsx","../src/button.tsx"],"names":["jsx","Fragment","styles","jsxs"],"mappings":";;;;;;;;;;;;;;AAOO,SAAS,iBAAiB,KAA2C,EAAA;AAC1E,EAAA,MAAM,EAAE,OAAA,GAAU,KAAO,EAAA,OAAA,GAAU,WAAc,GAAA,KAAA;AAEjD,EAAA,MAAM,wBAA2B,GAAA;AAAA,IAAA,EAC7B,6BAA6B,IAAI;AAAA,IAAA,EACjC,UAAU,4BAA6B,CAAA,OAA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,MAEJ,QAAA,EAAA;AAAA,wBAAAH,cAAAA,CAAC,gBAAiB,EAAA,EAAA,OAAA,EAAkB,OAAkB,EAAA,CAAA;AAAA,QACrD,SAAA,oBAAaA,cAAAA,CAAC,aAAc,EAAA,EAAA,CAAA;AAAA,QAC5B,CAAC,SAAa,IAAA,SAAA;AAAA,QACd,QAAA;AAAA,QACA,CAAC,SAAa,IAAA;AAAA;AAAA;AAAA,GACjB;AAEJ;AAEO,IAAM,iBAAoB,GAAA;AAAA,EAC/B,MAAME,wBAAO,CAAA,MAAA;AAAA,EACb,WAAWA,wBAAO,CAAA,iBAAA;AAAA,EAClB,OAAS,EAAA;AAAA,IACP,MAAMA,wBAAO,CAAA,oBAAA;AAAA,IACb,MAAMA,wBAAO,CAAA;AAAA,GACf;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,IAAIA,wBAAO,CAAA,eAAA;AAAA,IACX,IAAIA,wBAAO,CAAA,eAAA;AAAA,IACX,IAAIA,wBAAO,CAAA,eAAA;AAAA,IACX,IAAIA,wBAAO,CAAA;AAAA,GACb;AAAA,EACA,OAAS,EAAA;AAAA,IACP,QAAQA,wBAAO,CAAA,sBAAA;AAAA,IACf,OAAOA,wBAAO,CAAA,qBAAA;AAAA,IACd,SAASA,wBAAO,CAAA,uBAAA;AAAA,IAChB,WAAWA,wBAAO,CAAA;AAAA,GACpB;AAAA,EACA,KAAO,EAAA;AAAA,IACL,MAAMA,wBAAO,CAAA,kBAAA;AAAA,IACb,MAAMA,wBAAO,CAAA;AAAA;AAEjB","file":"index.js","sourcesContent":["import type { JSX } from \"react\"\nimport type { ButtonProps } from \"@/button\"\nimport styles from \"@/button-background.module.css\"\n\nexport interface ButtonBackgroundProps\n extends Pick<ButtonProps, \"rounded\" | \"variant\"> {}\n\nexport function ButtonBackground(props: ButtonBackgroundProps): JSX.Element {\n const { rounded = false, variant = \"primary\" } = props\n\n const combinedBackgroundStyles = `\n ${BUTTON_BACKGROUND_CLASS_NAME.BASE}\n ${rounded ? BUTTON_BACKGROUND_CLASS_NAME.ROUNDED.FULL : BUTTON_BACKGROUND_CLASS_NAME.ROUNDED.BASE}\n ${variant === \"accent\" ? BUTTON_BACKGROUND_CLASS_NAME.VARIANT.ACCENT : \"\"}\n ${variant === \"primary\" ? BUTTON_BACKGROUND_CLASS_NAME.VARIANT.PRIMARY : \"\"}\n `\n .replaceAll(/\\s+/g, \" \")\n .trim()\n\n if (!(variant === \"accent\" || variant === \"primary\")) return <></>\n\n return (\n <div\n className={combinedBackgroundStyles}\n data-element=\"button-background\"\n />\n )\n}\n\nexport const BUTTON_BACKGROUND_CLASS_NAME = {\n BASE: styles.button_background,\n ROUNDED: {\n BASE: styles.button_background__rounded_base,\n FULL: styles.button_background__rounded_full,\n },\n VARIANT: {\n ACCENT: styles.button_background__variant_accent,\n PRIMARY: styles.button_background__variant_primary,\n },\n} as const\n","import type { CSSProperties, JSX } from \"react\"\nimport styles from \"@/button-spinner.module.css\"\n\nexport interface ButtonSpinnerProps {\n size?: number\n}\n\nexport function ButtonSpinner(props: ButtonSpinnerProps): JSX.Element {\n const { size = 16 } = props\n\n return (\n <div\n className={styles.button_spinner}\n style={{ \"--size\": `${size}px` } as CSSProperties}\n >\n {Array.from({ length: 12 }).map((_, index) => (\n <div key={index} />\n ))}\n </div>\n )\n}\n","import type { ComponentProps, JSX, ReactNode } from \"react\"\nimport { ButtonBackground } from \"@/button-background\"\nimport { ButtonSpinner } from \"@/button-spinner\"\nimport styles from \"@/button.module.css\"\n\nexport interface ButtonProps extends ComponentProps<\"button\"> {\n fullWidth?: boolean\n iconEnd?: ReactNode\n iconOnly?: boolean\n iconStart?: ReactNode\n isLoading?: boolean\n rounded?: boolean\n size?: 32 | 36 | 40 | 48\n variant?: \"accent\" | \"ghost\" | \"primary\" | \"secondary\"\n}\n\ntype ButtonPropsInternal = ButtonPropsWithIcon | ButtonPropsWithText\n\ninterface ButtonPropsWithIcon extends ButtonProps {\n children?: ReactNode\n iconOnly: true\n}\n\ninterface ButtonPropsWithText extends ButtonProps {\n children?: string\n iconOnly?: false\n}\n\nexport function Button(props: ButtonPropsInternal): JSX.Element {\n const {\n children = \"\",\n className: customClassName = \"\",\n disabled = false,\n fullWidth = false,\n iconEnd = \"\",\n iconOnly = false,\n iconStart = \"\",\n isLoading = false,\n rounded = false,\n size = 36,\n type = \"button\",\n variant = \"primary\",\n ...rest\n } = props\n\n const combinedClassName = `\n ${BUTTON_CLASS_NAME.BASE}\n ${BUTTON_CLASS_NAME.SIZE[size]}\n ${BUTTON_CLASS_NAME.VARIANT[variant.toUpperCase() as keyof typeof BUTTON_CLASS_NAME.VARIANT]}\n ${fullWidth ? BUTTON_CLASS_NAME.WIDTH.FULL : BUTTON_CLASS_NAME.WIDTH.BASE}\n ${iconOnly ? BUTTON_CLASS_NAME.ICON_ONLY : \"\"}\n ${rounded ? BUTTON_CLASS_NAME.ROUNDED.FULL : BUTTON_CLASS_NAME.ROUNDED.BASE}\n ${customClassName}\n `\n .replaceAll(/\\s+/g, \" \")\n .trim()\n\n return (\n <button\n className={combinedClassName}\n disabled={disabled || isLoading}\n type={type}\n {...rest}\n >\n <ButtonBackground rounded={rounded} variant={variant} />\n {isLoading && <ButtonSpinner />}\n {!isLoading && iconStart}\n {children}\n {!isLoading && iconEnd}\n </button>\n )\n}\n\nexport const BUTTON_CLASS_NAME = {\n BASE: styles.button,\n ICON_ONLY: styles.button__icon_only,\n ROUNDED: {\n BASE: styles.button__rounded_base,\n FULL: styles.button__rounded_full,\n },\n SIZE: {\n 32: styles.button__size_32,\n 36: styles.button__size_36,\n 40: styles.button__size_40,\n 48: styles.button__size_48,\n },\n VARIANT: {\n ACCENT: styles.button__variant_accent,\n GHOST: styles.button__variant_ghost,\n PRIMARY: styles.button__variant_primary,\n SECONDARY: styles.button__variant_secondary,\n },\n WIDTH: {\n BASE: styles.button__width_base,\n FULL: styles.button__width_full,\n },\n} as const\n"]}
|