@ladder-ui/button 0.2.0
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/dist/button.css +228 -0
- package/dist/button.d.ts +14 -0
- package/dist/button.vars.css +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -0
- package/dist/index.mjs +10 -0
- package/package.json +65 -0
package/dist/button.css
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.lui-button {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
position: relative;
|
|
7
|
+
font-family: var(--lui-font-family);
|
|
8
|
+
font-weight: var(--lui-font-weight);
|
|
9
|
+
border-radius: var(--lui-radius-sm);
|
|
10
|
+
border: var(--lui-border-width) solid;
|
|
11
|
+
transition: var(--lui-transition);
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
text-decoration: none;
|
|
14
|
+
outline: none;
|
|
15
|
+
}
|
|
16
|
+
.lui-button:focus-visible {
|
|
17
|
+
outline: none;
|
|
18
|
+
box-shadow: 0 0 0 2px var(--lui-button-focus-ring-color);
|
|
19
|
+
}
|
|
20
|
+
.lui-button:disabled {
|
|
21
|
+
opacity: var(--lui-disabled-opacity);
|
|
22
|
+
cursor: var(--lui-disabled-cursor);
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
}
|
|
25
|
+
.lui-button--xs {
|
|
26
|
+
padding: var(--lui-padding-size-xs);
|
|
27
|
+
font-size: var(--lui-font-size-xs);
|
|
28
|
+
}
|
|
29
|
+
.lui-button--sm {
|
|
30
|
+
padding: var(--lui-padding-size-sm);
|
|
31
|
+
font-size: var(--lui-font-size-sm);
|
|
32
|
+
}
|
|
33
|
+
.lui-button--md {
|
|
34
|
+
padding: var(--lui-padding-size-md);
|
|
35
|
+
font-size: var(--lui-font-size-md);
|
|
36
|
+
}
|
|
37
|
+
.lui-button--lg {
|
|
38
|
+
padding: var(--lui-padding-size-lg);
|
|
39
|
+
font-size: var(--lui-font-size-lg);
|
|
40
|
+
}
|
|
41
|
+
.lui-button--xl {
|
|
42
|
+
padding: var(--lui-padding-size-xl);
|
|
43
|
+
font-size: var(--lui-font-size-xl);
|
|
44
|
+
}
|
|
45
|
+
.lui-button--primary {
|
|
46
|
+
background-color: var(--lui-primary);
|
|
47
|
+
color: var(--lui-primary-text);
|
|
48
|
+
border-color: var(--lui-primary);
|
|
49
|
+
}
|
|
50
|
+
.lui-button--primary:hover:not(:disabled) {
|
|
51
|
+
background-color: var(--lui-primary-hover);
|
|
52
|
+
border-color: var(--lui-primary-hover);
|
|
53
|
+
}
|
|
54
|
+
.lui-button--secondary {
|
|
55
|
+
background-color: var(--lui-secondary);
|
|
56
|
+
color: var(--lui-secondary-text);
|
|
57
|
+
border-color: var(--lui-secondary);
|
|
58
|
+
}
|
|
59
|
+
.lui-button--secondary:hover:not(:disabled) {
|
|
60
|
+
background-color: var(--lui-secondary-hover);
|
|
61
|
+
border-color: var(--lui-secondary-hover);
|
|
62
|
+
}
|
|
63
|
+
.lui-button--outline {
|
|
64
|
+
background-color: transparent;
|
|
65
|
+
color: var(--lui-surface-text);
|
|
66
|
+
border-color: var(--lui-surface-border);
|
|
67
|
+
}
|
|
68
|
+
.lui-button--outline:hover:not(:disabled) {
|
|
69
|
+
background-color: var(--lui-surface-raised);
|
|
70
|
+
border-color: var(--lui-surface-border);
|
|
71
|
+
}
|
|
72
|
+
.lui-button--info {
|
|
73
|
+
background-color: var(--lui-info);
|
|
74
|
+
color: var(--lui-info-text);
|
|
75
|
+
border-color: var(--lui-info);
|
|
76
|
+
}
|
|
77
|
+
.lui-button--info:hover:not(:disabled) {
|
|
78
|
+
filter: brightness(0.9);
|
|
79
|
+
}
|
|
80
|
+
.lui-button--success {
|
|
81
|
+
background-color: var(--lui-success);
|
|
82
|
+
color: var(--lui-success-text);
|
|
83
|
+
border-color: var(--lui-success);
|
|
84
|
+
}
|
|
85
|
+
.lui-button--success:hover:not(:disabled) {
|
|
86
|
+
filter: brightness(0.9);
|
|
87
|
+
}
|
|
88
|
+
.lui-button--warning {
|
|
89
|
+
background-color: var(--lui-warning);
|
|
90
|
+
color: var(--lui-warning-text);
|
|
91
|
+
border-color: var(--lui-warning);
|
|
92
|
+
}
|
|
93
|
+
.lui-button--warning:hover:not(:disabled) {
|
|
94
|
+
filter: brightness(0.9);
|
|
95
|
+
}
|
|
96
|
+
.lui-button--ghost {
|
|
97
|
+
background-color: transparent;
|
|
98
|
+
color: var(--lui-surface-text);
|
|
99
|
+
border-color: transparent;
|
|
100
|
+
}
|
|
101
|
+
.lui-button--ghost:hover:not(:disabled) {
|
|
102
|
+
background-color: var(--lui-surface-raised);
|
|
103
|
+
border-color: transparent;
|
|
104
|
+
}
|
|
105
|
+
.lui-button--link {
|
|
106
|
+
background-color: transparent;
|
|
107
|
+
color: var(--lui-surface-text);
|
|
108
|
+
border-color: transparent;
|
|
109
|
+
text-decoration: underline;
|
|
110
|
+
text-underline-offset: 4px;
|
|
111
|
+
text-decoration-color: transparent;
|
|
112
|
+
}
|
|
113
|
+
.lui-button--link:hover:not(:disabled) {
|
|
114
|
+
background-color: transparent;
|
|
115
|
+
border-color: transparent;
|
|
116
|
+
text-decoration-color: var(--lui-surface-text);
|
|
117
|
+
}
|
|
118
|
+
.lui-button--destructive {
|
|
119
|
+
background-color: var(--lui-error);
|
|
120
|
+
color: var(--lui-error-text);
|
|
121
|
+
border-color: var(--lui-error);
|
|
122
|
+
}
|
|
123
|
+
.lui-button--destructive:hover:not(:disabled) {
|
|
124
|
+
filter: brightness(0.9);
|
|
125
|
+
}
|
|
126
|
+
.lui-button--soft.lui-button--primary {
|
|
127
|
+
background-color: var(--lui-primary-soft);
|
|
128
|
+
color: var(--lui-primary-soft-text);
|
|
129
|
+
border-color: transparent;
|
|
130
|
+
}
|
|
131
|
+
.lui-button--soft.lui-button--primary:hover:not(:disabled) {
|
|
132
|
+
filter: brightness(0.97);
|
|
133
|
+
border-color: transparent;
|
|
134
|
+
}
|
|
135
|
+
.lui-button--soft.lui-button--secondary {
|
|
136
|
+
background-color: var(--lui-secondary-soft);
|
|
137
|
+
color: var(--lui-secondary-soft-text);
|
|
138
|
+
border-color: transparent;
|
|
139
|
+
}
|
|
140
|
+
.lui-button--soft.lui-button--secondary:hover:not(:disabled) {
|
|
141
|
+
filter: brightness(0.97);
|
|
142
|
+
border-color: transparent;
|
|
143
|
+
}
|
|
144
|
+
.lui-button--soft.lui-button--outline {
|
|
145
|
+
background-color: var(--lui-neutral-soft);
|
|
146
|
+
color: var(--lui-neutral-soft-text);
|
|
147
|
+
border-color: transparent;
|
|
148
|
+
}
|
|
149
|
+
.lui-button--soft.lui-button--outline:hover:not(:disabled) {
|
|
150
|
+
filter: brightness(0.97);
|
|
151
|
+
border-color: transparent;
|
|
152
|
+
}
|
|
153
|
+
.lui-button--soft.lui-button--ghost {
|
|
154
|
+
background-color: var(--lui-neutral-soft);
|
|
155
|
+
color: var(--lui-neutral-soft-text);
|
|
156
|
+
border-color: transparent;
|
|
157
|
+
}
|
|
158
|
+
.lui-button--soft.lui-button--ghost:hover:not(:disabled) {
|
|
159
|
+
filter: brightness(0.97);
|
|
160
|
+
border-color: transparent;
|
|
161
|
+
}
|
|
162
|
+
.lui-button--soft.lui-button--destructive {
|
|
163
|
+
background-color: var(--lui-error-soft);
|
|
164
|
+
color: var(--lui-error-soft-text);
|
|
165
|
+
border-color: transparent;
|
|
166
|
+
}
|
|
167
|
+
.lui-button--soft.lui-button--destructive:hover:not(:disabled) {
|
|
168
|
+
filter: brightness(0.97);
|
|
169
|
+
border-color: transparent;
|
|
170
|
+
}
|
|
171
|
+
.lui-button--soft.lui-button--info {
|
|
172
|
+
background-color: var(--lui-info-soft);
|
|
173
|
+
color: var(--lui-info-soft-text);
|
|
174
|
+
border-color: transparent;
|
|
175
|
+
}
|
|
176
|
+
.lui-button--soft.lui-button--info:hover:not(:disabled) {
|
|
177
|
+
filter: brightness(0.97);
|
|
178
|
+
border-color: transparent;
|
|
179
|
+
}
|
|
180
|
+
.lui-button--soft.lui-button--success {
|
|
181
|
+
background-color: var(--lui-success-soft);
|
|
182
|
+
color: var(--lui-success-soft-text);
|
|
183
|
+
border-color: transparent;
|
|
184
|
+
}
|
|
185
|
+
.lui-button--soft.lui-button--success:hover:not(:disabled) {
|
|
186
|
+
filter: brightness(0.97);
|
|
187
|
+
border-color: transparent;
|
|
188
|
+
}
|
|
189
|
+
.lui-button--soft.lui-button--warning {
|
|
190
|
+
background-color: var(--lui-warning-soft);
|
|
191
|
+
color: var(--lui-warning-soft-text);
|
|
192
|
+
border-color: transparent;
|
|
193
|
+
}
|
|
194
|
+
.lui-button--soft.lui-button--warning:hover:not(:disabled) {
|
|
195
|
+
filter: brightness(0.97);
|
|
196
|
+
border-color: transparent;
|
|
197
|
+
}
|
|
198
|
+
.lui-button--full-width {
|
|
199
|
+
width: 100%;
|
|
200
|
+
display: flex;
|
|
201
|
+
}
|
|
202
|
+
.lui-button--loading .lui-button__content {
|
|
203
|
+
visibility: hidden;
|
|
204
|
+
}
|
|
205
|
+
.lui-button__content {
|
|
206
|
+
display: flex;
|
|
207
|
+
align-items: center;
|
|
208
|
+
justify-content: center;
|
|
209
|
+
gap: 0.5rem;
|
|
210
|
+
}
|
|
211
|
+
.lui-button__content--hidden {
|
|
212
|
+
visibility: hidden;
|
|
213
|
+
}
|
|
214
|
+
.lui-button__spinner {
|
|
215
|
+
position: absolute;
|
|
216
|
+
width: var(--lui-button-spinner-size);
|
|
217
|
+
height: var(--lui-button-spinner-size);
|
|
218
|
+
border: var(--lui-button-spinner-border-width) solid transparent;
|
|
219
|
+
border-top-color: var(--lui-button-spinner-color);
|
|
220
|
+
border-radius: 50%;
|
|
221
|
+
animation: lui-button-spin 1s linear infinite;
|
|
222
|
+
}
|
|
223
|
+
@keyframes lui-button-spin {
|
|
224
|
+
to {
|
|
225
|
+
transform: rotate(360deg);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Ref } from "react";
|
|
2
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
ref?: Ref<HTMLButtonElement>;
|
|
4
|
+
variant?: "primary" | "secondary" | "outline" | "ghost" | "link" | "destructive" | "info" | "success" | "warning";
|
|
5
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
6
|
+
soft?: boolean;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
/** Stretch the button to fill its container's full width. @default false */
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function Button({ ref, className, variant, size, soft, loading, fullWidth, children, disabled, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare namespace Button {
|
|
13
|
+
var displayName: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@layer button {
|
|
2
|
+
:root {
|
|
3
|
+
/* Focus ring */
|
|
4
|
+
--lui-button-focus-ring-color: color-mix(in srgb, var(--lui-primary) 40%, transparent);
|
|
5
|
+
/* Loading spinner */
|
|
6
|
+
--lui-button-spinner-size: 1rem;
|
|
7
|
+
--lui-button-spinner-border-width: 2px;
|
|
8
|
+
--lui-button-spinner-color: currentColor;
|
|
9
|
+
}
|
|
10
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var concatClassNames = require('@ladder-ui/core/concatClassNames');
|
|
7
|
+
|
|
8
|
+
function Button({ ref, className, variant = "primary", size = "md", soft, loading, fullWidth, children, disabled, ...props }) {
|
|
9
|
+
const buttonClasses = concatClassNames("lui-button", `lui-button--${variant}`, `lui-button--${size}`, soft && "lui-button--soft", loading && "lui-button--loading", fullWidth && "lui-button--full-width", className);
|
|
10
|
+
return (jsxRuntime.jsxs("button", { ref: ref, className: buttonClasses, disabled: disabled || loading, ...props, children: [loading ? jsxRuntime.jsx("span", { className: "lui-button__spinner" }) : null, jsxRuntime.jsx("span", { className: concatClassNames("lui-button__content", loading && "lui-button__content--hidden"), children: children })] }));
|
|
11
|
+
}
|
|
12
|
+
Button.displayName = "Button";
|
|
13
|
+
|
|
14
|
+
exports.Button = Button;
|
|
15
|
+
exports.default = Button;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import concatClassNames from '@ladder-ui/core/concatClassNames';
|
|
3
|
+
|
|
4
|
+
function Button({ ref, className, variant = "primary", size = "md", soft, loading, fullWidth, children, disabled, ...props }) {
|
|
5
|
+
const buttonClasses = concatClassNames("lui-button", `lui-button--${variant}`, `lui-button--${size}`, soft && "lui-button--soft", loading && "lui-button--loading", fullWidth && "lui-button--full-width", className);
|
|
6
|
+
return (jsxs("button", { ref: ref, className: buttonClasses, disabled: disabled || loading, ...props, children: [loading ? jsx("span", { className: "lui-button__spinner" }) : null, jsx("span", { className: concatClassNames("lui-button__content", loading && "lui-button__content--hidden"), children: children })] }));
|
|
7
|
+
}
|
|
8
|
+
Button.displayName = "Button";
|
|
9
|
+
|
|
10
|
+
export { Button, Button as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ladder-ui/button",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./*.css": "./dist/*.css",
|
|
15
|
+
"./styles/*.css": "./dist/*.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"nodejs",
|
|
22
|
+
"react",
|
|
23
|
+
"ui",
|
|
24
|
+
"components",
|
|
25
|
+
"library"
|
|
26
|
+
],
|
|
27
|
+
"author": "Ivan Avila <ivelaval@gmail.com> - https://www.vennet.dev",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+ssh://git@github.com/ivelaval/ladder-ui.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/ivelaval/ladder-ui/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/ivelaval/ladder-ui#readme",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
42
|
+
"@types/react": "^18.2.48",
|
|
43
|
+
"rollup": "^4.59.0",
|
|
44
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
45
|
+
"sass": "^1.90.0",
|
|
46
|
+
"typescript": "^5.3.3",
|
|
47
|
+
"tslib": "^2.6.2",
|
|
48
|
+
"@ladder-ui/core": "0.2.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@ladder-ui/core": ">=0.0.0",
|
|
52
|
+
"react": ">=18.0.0"
|
|
53
|
+
},
|
|
54
|
+
"sideEffects": [
|
|
55
|
+
"**/*.css"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "pnpm clean && rollup -c",
|
|
59
|
+
"dev": "rollup -c -w",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"test:watch": "vitest",
|
|
62
|
+
"type-check": "tsc --noEmit",
|
|
63
|
+
"clean": "rm -rf dist"
|
|
64
|
+
}
|
|
65
|
+
}
|