@behivetech/atoms.spinner 0.0.0-stage → 0.4.2
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 +54 -2
- package/dist/index.cjs +175 -0
- package/dist/index.css +34 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +161 -0
- package/docs.json +36 -0
- package/index.ts +2 -0
- package/package.json +56 -3
- package/spinner.example.tsx +17 -0
- package/spinner.module.scss +56 -0
- package/spinner.tsx +34 -0
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Spinner
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A loading spinner with size variants and accessible labeling.
|
|
4
|
+
|
|
5
|
+
A pure CSS animated loading indicator. Uses `role="status"` and `aria-label` so screen readers announce the loading state without visual output.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Spinner } from "@behivetech/atoms.spinner";
|
|
11
|
+
|
|
12
|
+
<Spinner size="md" label="Loading..." />;
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Small
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
<Spinner size="sm" />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Medium (default)
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
<Spinner size="md" />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Large
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
<Spinner size="lg" />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Custom Label
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
<Spinner size="md" label="Saving your changes..." />
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Props
|
|
42
|
+
|
|
43
|
+
| Prop | Type | Default | Description |
|
|
44
|
+
| --------- | ---------------------- | -------------- | ------------------------------------ |
|
|
45
|
+
| size | `'sm' \| 'md' \| 'lg'` | `'md'` | Controls the diameter |
|
|
46
|
+
| label | string | `'Loading...'` | `aria-label` text for screen readers |
|
|
47
|
+
| className | string | - | Additional CSS classes |
|
|
48
|
+
|
|
49
|
+
All other native `<span>` attributes are forwarded to the root element.
|
|
50
|
+
|
|
51
|
+
## Accessibility
|
|
52
|
+
|
|
53
|
+
- `role="status"` announces loading state to screen readers
|
|
54
|
+
- `aria-label` carries the human-readable label (defaults to "Loading...")
|
|
55
|
+
- The visible circle is `aria-hidden="true"` to avoid redundant announcements
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
34
|
+
var require_classnames = __commonJS({
|
|
35
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
(function() {
|
|
38
|
+
"use strict";
|
|
39
|
+
var hasOwn = {}.hasOwnProperty;
|
|
40
|
+
function classNames() {
|
|
41
|
+
var classes = "";
|
|
42
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
43
|
+
var arg = arguments[i];
|
|
44
|
+
if (arg) {
|
|
45
|
+
classes = appendClass(classes, parseValue(arg));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return classes;
|
|
49
|
+
}
|
|
50
|
+
function parseValue(arg) {
|
|
51
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
52
|
+
return arg;
|
|
53
|
+
}
|
|
54
|
+
if (typeof arg !== "object") {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(arg)) {
|
|
58
|
+
return classNames.apply(null, arg);
|
|
59
|
+
}
|
|
60
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
61
|
+
return arg.toString();
|
|
62
|
+
}
|
|
63
|
+
var classes = "";
|
|
64
|
+
for (var key in arg) {
|
|
65
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
66
|
+
classes = appendClass(classes, key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return classes;
|
|
70
|
+
}
|
|
71
|
+
function appendClass(value, newClass) {
|
|
72
|
+
if (!newClass) {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
if (value) {
|
|
76
|
+
return value + " " + newClass;
|
|
77
|
+
}
|
|
78
|
+
return value + newClass;
|
|
79
|
+
}
|
|
80
|
+
if (typeof module2 !== "undefined" && module2.exports) {
|
|
81
|
+
classNames.default = classNames;
|
|
82
|
+
module2.exports = classNames;
|
|
83
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
84
|
+
define("classnames", [], function() {
|
|
85
|
+
return classNames;
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
window.classNames = classNames;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// index.ts
|
|
95
|
+
var index_exports = {};
|
|
96
|
+
__export(index_exports, {
|
|
97
|
+
Spinner: () => Spinner
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(index_exports);
|
|
100
|
+
|
|
101
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
102
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
103
|
+
var getClassName = ({
|
|
104
|
+
className,
|
|
105
|
+
modifiers = {},
|
|
106
|
+
rootClass,
|
|
107
|
+
styles = {}
|
|
108
|
+
}) => {
|
|
109
|
+
function getModifiers() {
|
|
110
|
+
const updatedModifiers = {};
|
|
111
|
+
const modifierKeys = Object.keys(modifiers);
|
|
112
|
+
if (modifierKeys.length) {
|
|
113
|
+
modifierKeys.forEach((modKey) => {
|
|
114
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
115
|
+
const newClassName = styles[classKey] || classKey;
|
|
116
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return updatedModifiers;
|
|
120
|
+
}
|
|
121
|
+
function getChildClass(childClassName) {
|
|
122
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
123
|
+
return styles[classKey] || classKey;
|
|
124
|
+
}
|
|
125
|
+
function getRootStyles() {
|
|
126
|
+
return (0, import_classnames.default)(
|
|
127
|
+
className,
|
|
128
|
+
{
|
|
129
|
+
...getModifiers()
|
|
130
|
+
},
|
|
131
|
+
styles[rootClass] || rootClass
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return [getRootStyles(), getChildClass];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// spinner.module.scss
|
|
138
|
+
var spinner_module_default = {
|
|
139
|
+
"BHT__Spinner": "BHT__Spinner",
|
|
140
|
+
"BHT__Spinner__circle": "BHT__Spinner__circle",
|
|
141
|
+
"spinner-rotate": "spinner-rotate",
|
|
142
|
+
"BHT__Spinner--sm": "BHT__Spinner--sm",
|
|
143
|
+
"BHT__Spinner--md": "BHT__Spinner--md",
|
|
144
|
+
"BHT__Spinner--lg": "BHT__Spinner--lg"
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// spinner.tsx
|
|
148
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
149
|
+
var Spinner = ({
|
|
150
|
+
size = "md",
|
|
151
|
+
label = "Loading...",
|
|
152
|
+
className,
|
|
153
|
+
...rest
|
|
154
|
+
}) => {
|
|
155
|
+
const [rootClass, getChildClass] = getClassName({
|
|
156
|
+
className,
|
|
157
|
+
rootClass: "BHT__Spinner",
|
|
158
|
+
modifiers: { [size]: true },
|
|
159
|
+
styles: spinner_module_default
|
|
160
|
+
});
|
|
161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ...rest, className: rootClass, role: "status", "aria-label": label, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: getChildClass("circle"), "aria-hidden": "true" }) });
|
|
162
|
+
};
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
Spinner
|
|
166
|
+
});
|
|
167
|
+
/*! Bundled license information:
|
|
168
|
+
|
|
169
|
+
classnames/index.js:
|
|
170
|
+
(*!
|
|
171
|
+
Copyright (c) 2018 Jed Watson.
|
|
172
|
+
Licensed under the MIT License (MIT), see
|
|
173
|
+
http://jedwatson.github.io/classnames
|
|
174
|
+
*)
|
|
175
|
+
*/
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* esbuild-sass-plugin:css-chunkspinner.module.scss */
|
|
2
|
+
.BHT__Spinner {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
}
|
|
7
|
+
.BHT__Spinner__circle {
|
|
8
|
+
display: block;
|
|
9
|
+
border-style: solid;
|
|
10
|
+
border-color: var(--md-sys-color-secondary-container, var(--color-border-strong));
|
|
11
|
+
border-top-color: var(--md-sys-color-primary, var(--color-primary));
|
|
12
|
+
border-radius: var(--md-sys-shape-corner-full, 9999px);
|
|
13
|
+
animation: spinner-rotate 0.7s linear infinite;
|
|
14
|
+
}
|
|
15
|
+
.BHT__Spinner--sm .BHT__Spinner__circle {
|
|
16
|
+
width: 1rem;
|
|
17
|
+
height: 1rem;
|
|
18
|
+
border-width: 2px;
|
|
19
|
+
}
|
|
20
|
+
.BHT__Spinner--md .BHT__Spinner__circle {
|
|
21
|
+
width: 1.5rem;
|
|
22
|
+
height: 1.5rem;
|
|
23
|
+
border-width: 2px;
|
|
24
|
+
}
|
|
25
|
+
.BHT__Spinner--lg .BHT__Spinner__circle {
|
|
26
|
+
width: 2.5rem;
|
|
27
|
+
height: 2.5rem;
|
|
28
|
+
border-width: 3px;
|
|
29
|
+
}
|
|
30
|
+
@keyframes spinner-rotate {
|
|
31
|
+
to {
|
|
32
|
+
transform: rotate(360deg);
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type SpinnerSize = "sm" | "md" | "lg";
|
|
5
|
+
interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
6
|
+
/** Controls the size; defaults to md */
|
|
7
|
+
size?: SpinnerSize;
|
|
8
|
+
/** Accessible label announced to screen readers while loading */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Additional class names to merge with the component root element */
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const Spinner: ({ size, label, className, ...rest }: SpinnerProps) => react.JSX.Element;
|
|
14
|
+
|
|
15
|
+
export { Spinner, type SpinnerProps, type SpinnerSize };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
28
|
+
var require_classnames = __commonJS({
|
|
29
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
(function() {
|
|
32
|
+
"use strict";
|
|
33
|
+
var hasOwn = {}.hasOwnProperty;
|
|
34
|
+
function classNames() {
|
|
35
|
+
var classes = "";
|
|
36
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
37
|
+
var arg = arguments[i];
|
|
38
|
+
if (arg) {
|
|
39
|
+
classes = appendClass(classes, parseValue(arg));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return classes;
|
|
43
|
+
}
|
|
44
|
+
function parseValue(arg) {
|
|
45
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
46
|
+
return arg;
|
|
47
|
+
}
|
|
48
|
+
if (typeof arg !== "object") {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(arg)) {
|
|
52
|
+
return classNames.apply(null, arg);
|
|
53
|
+
}
|
|
54
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
55
|
+
return arg.toString();
|
|
56
|
+
}
|
|
57
|
+
var classes = "";
|
|
58
|
+
for (var key in arg) {
|
|
59
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
60
|
+
classes = appendClass(classes, key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return classes;
|
|
64
|
+
}
|
|
65
|
+
function appendClass(value, newClass) {
|
|
66
|
+
if (!newClass) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
if (value) {
|
|
70
|
+
return value + " " + newClass;
|
|
71
|
+
}
|
|
72
|
+
return value + newClass;
|
|
73
|
+
}
|
|
74
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
75
|
+
classNames.default = classNames;
|
|
76
|
+
module.exports = classNames;
|
|
77
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
78
|
+
define("classnames", [], function() {
|
|
79
|
+
return classNames;
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
window.classNames = classNames;
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
89
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
90
|
+
var getClassName = ({
|
|
91
|
+
className,
|
|
92
|
+
modifiers = {},
|
|
93
|
+
rootClass,
|
|
94
|
+
styles = {}
|
|
95
|
+
}) => {
|
|
96
|
+
function getModifiers() {
|
|
97
|
+
const updatedModifiers = {};
|
|
98
|
+
const modifierKeys = Object.keys(modifiers);
|
|
99
|
+
if (modifierKeys.length) {
|
|
100
|
+
modifierKeys.forEach((modKey) => {
|
|
101
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
102
|
+
const newClassName = styles[classKey] || classKey;
|
|
103
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return updatedModifiers;
|
|
107
|
+
}
|
|
108
|
+
function getChildClass(childClassName) {
|
|
109
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
110
|
+
return styles[classKey] || classKey;
|
|
111
|
+
}
|
|
112
|
+
function getRootStyles() {
|
|
113
|
+
return (0, import_classnames.default)(
|
|
114
|
+
className,
|
|
115
|
+
{
|
|
116
|
+
...getModifiers()
|
|
117
|
+
},
|
|
118
|
+
styles[rootClass] || rootClass
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return [getRootStyles(), getChildClass];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// spinner.module.scss
|
|
125
|
+
var spinner_module_default = {
|
|
126
|
+
"BHT__Spinner": "BHT__Spinner",
|
|
127
|
+
"BHT__Spinner__circle": "BHT__Spinner__circle",
|
|
128
|
+
"spinner-rotate": "spinner-rotate",
|
|
129
|
+
"BHT__Spinner--sm": "BHT__Spinner--sm",
|
|
130
|
+
"BHT__Spinner--md": "BHT__Spinner--md",
|
|
131
|
+
"BHT__Spinner--lg": "BHT__Spinner--lg"
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// spinner.tsx
|
|
135
|
+
import { jsx } from "react/jsx-runtime";
|
|
136
|
+
var Spinner = ({
|
|
137
|
+
size = "md",
|
|
138
|
+
label = "Loading...",
|
|
139
|
+
className,
|
|
140
|
+
...rest
|
|
141
|
+
}) => {
|
|
142
|
+
const [rootClass, getChildClass] = getClassName({
|
|
143
|
+
className,
|
|
144
|
+
rootClass: "BHT__Spinner",
|
|
145
|
+
modifiers: { [size]: true },
|
|
146
|
+
styles: spinner_module_default
|
|
147
|
+
});
|
|
148
|
+
return /* @__PURE__ */ jsx("span", { ...rest, className: rootClass, role: "status", "aria-label": label, children: /* @__PURE__ */ jsx("span", { className: getChildClass("circle"), "aria-hidden": "true" }) });
|
|
149
|
+
};
|
|
150
|
+
export {
|
|
151
|
+
Spinner
|
|
152
|
+
};
|
|
153
|
+
/*! Bundled license information:
|
|
154
|
+
|
|
155
|
+
classnames/index.js:
|
|
156
|
+
(*!
|
|
157
|
+
Copyright (c) 2018 Jed Watson.
|
|
158
|
+
Licensed under the MIT License (MIT), see
|
|
159
|
+
http://jedwatson.github.io/classnames
|
|
160
|
+
*)
|
|
161
|
+
*/
|
package/docs.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"generatedAt": "2026-10-20T05:49:42.844Z",
|
|
5
|
+
"docs": [
|
|
6
|
+
{
|
|
7
|
+
"displayName": "Spinner",
|
|
8
|
+
"description": "",
|
|
9
|
+
"extendsNative": true,
|
|
10
|
+
"props": [
|
|
11
|
+
{
|
|
12
|
+
"name": "className",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"required": false,
|
|
15
|
+
"defaultValue": null,
|
|
16
|
+
"description": "Additional class names to merge with the component root element"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "label",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"required": false,
|
|
22
|
+
"defaultValue": "Loading...",
|
|
23
|
+
"description": "Accessible label announced to screen readers while loading"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "size",
|
|
27
|
+
"type": "\"sm\" | \"md\" | \"lg\"",
|
|
28
|
+
"required": false,
|
|
29
|
+
"defaultValue": "md",
|
|
30
|
+
"description": "Controls the size; defaults to md"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"functions": []
|
|
36
|
+
}
|
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/atoms.spinner",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./styles.css": "./dist/index.css"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"index.ts",
|
|
19
|
+
"spinner.tsx",
|
|
20
|
+
"spinner.module.scss",
|
|
21
|
+
"*.example.tsx",
|
|
22
|
+
"docs.json"
|
|
23
|
+
],
|
|
24
|
+
"registry": {
|
|
25
|
+
"status": "stable",
|
|
26
|
+
"tags": []
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^19.2.7",
|
|
30
|
+
"react-dom": "^19.2.7"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "19.2.17",
|
|
34
|
+
"@types/react-dom": "19.2.3",
|
|
35
|
+
"eslint": "^9.39.5",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^6.0.3",
|
|
38
|
+
"vitest": "^4.1.10",
|
|
39
|
+
"@bht-component-registry/class-names": "0.0.6",
|
|
40
|
+
"@bht-component-registry/env": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
45
|
+
"directory": "registry/behivetech/atoms/spinner"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org",
|
|
49
|
+
"access": "public",
|
|
50
|
+
"provenance": true
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup && bht-registry-docgen",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"lint": "eslint . --max-warnings 0",
|
|
56
|
+
"check-types": "tsc --noEmit",
|
|
57
|
+
"test": "vitest run"
|
|
58
|
+
}
|
|
6
59
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Spinner } from "./spinner.js";
|
|
2
|
+
|
|
3
|
+
export const SmallSpinner = () => {
|
|
4
|
+
return <Spinner size="sm" />;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const MediumSpinner = () => {
|
|
8
|
+
return <Spinner size="md" />;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const LargeSpinner = () => {
|
|
12
|
+
return <Spinner size="lg" />;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const SpinnerWithCustomLabel = () => {
|
|
16
|
+
return <Spinner size="md" label="Saving changes" />;
|
|
17
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Material Design 3 circular progress indicator (indeterminate): a `primary`
|
|
2
|
+
// active indicator turning over a `secondary-container` track.
|
|
3
|
+
|
|
4
|
+
.BHT__Spinner {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
|
|
9
|
+
&__circle {
|
|
10
|
+
display: block;
|
|
11
|
+
border-style: solid;
|
|
12
|
+
border-color: var(
|
|
13
|
+
--md-sys-color-secondary-container,
|
|
14
|
+
var(--color-border-strong)
|
|
15
|
+
);
|
|
16
|
+
border-top-color: var(--md-sys-color-primary, var(--color-primary));
|
|
17
|
+
border-radius: var(--md-sys-shape-corner-full, 9999px);
|
|
18
|
+
animation: spinner-rotate 0.7s linear infinite;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&--sm {
|
|
22
|
+
.BHT__Spinner {
|
|
23
|
+
&__circle {
|
|
24
|
+
width: 1rem;
|
|
25
|
+
height: 1rem;
|
|
26
|
+
border-width: 2px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&--md {
|
|
32
|
+
.BHT__Spinner {
|
|
33
|
+
&__circle {
|
|
34
|
+
width: 1.5rem;
|
|
35
|
+
height: 1.5rem;
|
|
36
|
+
border-width: 2px;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&--lg {
|
|
42
|
+
.BHT__Spinner {
|
|
43
|
+
&__circle {
|
|
44
|
+
width: 2.5rem;
|
|
45
|
+
height: 2.5rem;
|
|
46
|
+
border-width: 3px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes spinner-rotate {
|
|
53
|
+
to {
|
|
54
|
+
transform: rotate(360deg);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/spinner.tsx
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
import { getClassName } from "@bht-component-registry/class-names";
|
|
3
|
+
import styles from "./spinner.module.scss";
|
|
4
|
+
|
|
5
|
+
export type SpinnerSize = "sm" | "md" | "lg";
|
|
6
|
+
|
|
7
|
+
export interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
8
|
+
/** Controls the size; defaults to md */
|
|
9
|
+
size?: SpinnerSize;
|
|
10
|
+
/** Accessible label announced to screen readers while loading */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Additional class names to merge with the component root element */
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Spinner = ({
|
|
17
|
+
size = "md",
|
|
18
|
+
label = "Loading...",
|
|
19
|
+
className,
|
|
20
|
+
...rest
|
|
21
|
+
}: SpinnerProps) => {
|
|
22
|
+
const [rootClass, getChildClass] = getClassName({
|
|
23
|
+
className,
|
|
24
|
+
rootClass: "BHT__Spinner",
|
|
25
|
+
modifiers: { [size]: true },
|
|
26
|
+
styles,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<span {...rest} className={rootClass} role="status" aria-label={label}>
|
|
31
|
+
<span className={getChildClass("circle")} aria-hidden="true" />
|
|
32
|
+
</span>
|
|
33
|
+
);
|
|
34
|
+
};
|