@skel-ui/react 1.0.0-alpha.248d1fb

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Augustin Joseph
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.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # 🚧 This package is highly under development. 🛠️
2
+
3
+ ```JSX
4
+ const { user, isLoading } = useProfile();
5
+
6
+ // Legacy Way
7
+ if(isLoading){
8
+ return <ProfileSkeleton/>
9
+ }
10
+
11
+ // Current Way
12
+ {isLoading ? (
13
+ <Skeleton circle />
14
+ ) : (
15
+ <Avatar src={user.image} name={user.name} />
16
+ )}
17
+ <h1>{user.name || <Skeleton />}</h1>
18
+
19
+
20
+ // Skel's Way ✨
21
+ <Skel.Root isLoading={isLoading}>
22
+ <Skel.Item as={Avatar} src={user.image} />
23
+ <Skel.Item as="h1">{user.name}</Skel.Item>
24
+ </Skel.Root>
25
+ ```
@@ -0,0 +1,53 @@
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => src_default
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ var import_react = __toESM(require("react"));
35
+ const IsLoadingContext = import_react.default.createContext(false);
36
+ function Root({ isLoading = true, children }) {
37
+ return <IsLoadingContext.Provider value={isLoading}>{children}</IsLoadingContext.Provider>;
38
+ }
39
+ function Item({ as, color, radius, children, ...props }) {
40
+ const isLoading = import_react.default.useContext(IsLoadingContext);
41
+ const Component = as || "p";
42
+ return <Component
43
+ {...props}
44
+ style={{
45
+ // @ts-ignore
46
+ ...props.style,
47
+ "--skel-ui-color": color,
48
+ "--skel-ui-radius": radius
49
+ }}
50
+ data-loading={isLoading}
51
+ >{isLoading ? null : typeof children === "function" ? children() : children}</Component>;
52
+ }
53
+ var src_default = { Root, Item };
@@ -0,0 +1,47 @@
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var tailwind_exports = {};
30
+ __export(tailwind_exports, {
31
+ default: () => tailwindcssPlugin
32
+ });
33
+ module.exports = __toCommonJS(tailwind_exports);
34
+ var import_plugin = __toESM(require("tailwindcss/plugin"));
35
+ function tailwindcssPlugin() {
36
+ const variants = [
37
+ { name: "loaded", value: false },
38
+ { name: "loading", value: true }
39
+ ];
40
+ return (0, import_plugin.default)(({ addVariant }) => {
41
+ variants.forEach(({ name, value }) => {
42
+ addVariant(name, `&[data-loading='${value}']`);
43
+ addVariant(`peer-${name}`, `:merge(.peer)[data-loading='${value}'] ~ &`);
44
+ addVariant(`group-${name}`, `:merge(.group)[data-loading='${value}'] &`);
45
+ });
46
+ });
47
+ }
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ const IsLoadingContext = React.createContext(false);
3
+ function Root({ isLoading = true, children }) {
4
+ return <IsLoadingContext.Provider value={isLoading}>{children}</IsLoadingContext.Provider>;
5
+ }
6
+ function Item({ as, color, radius, children, ...props }) {
7
+ const isLoading = React.useContext(IsLoadingContext);
8
+ const Component = as || "p";
9
+ return <Component
10
+ {...props}
11
+ style={{
12
+ // @ts-ignore
13
+ ...props.style,
14
+ "--skel-ui-color": color,
15
+ "--skel-ui-radius": radius
16
+ }}
17
+ data-loading={isLoading}
18
+ >{isLoading ? null : typeof children === "function" ? children() : children}</Component>;
19
+ }
20
+ var src_default = { Root, Item };
21
+ export {
22
+ src_default as default
23
+ };
@@ -0,0 +1,17 @@
1
+ import plugin from "tailwindcss/plugin";
2
+ function tailwindcssPlugin() {
3
+ const variants = [
4
+ { name: "loaded", value: false },
5
+ { name: "loading", value: true }
6
+ ];
7
+ return plugin(({ addVariant }) => {
8
+ variants.forEach(({ name, value }) => {
9
+ addVariant(name, `&[data-loading='${value}']`);
10
+ addVariant(`peer-${name}`, `:merge(.peer)[data-loading='${value}'] ~ &`);
11
+ addVariant(`group-${name}`, `:merge(.group)[data-loading='${value}'] &`);
12
+ });
13
+ });
14
+ }
15
+ export {
16
+ tailwindcssPlugin as default
17
+ };
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ type As<T> = React.ElementType | React.JSXElementConstructor<T>;
3
+ type RootProps = {
4
+ children: React.ReactNode;
5
+ isLoading: boolean;
6
+ };
7
+ type ItemProps<T extends As<T>> = {
8
+ as?: T;
9
+ children?: React.ReactNode | (() => React.ReactNode);
10
+ color?: string;
11
+ radius?: string;
12
+ } & (T extends React.ElementType ? Omit<React.ComponentPropsWithoutRef<T>, "children"> : {});
13
+ declare function Root({ isLoading, children }: RootProps): React.JSX.Element;
14
+ declare function Item<T extends As<T>>({ as, color, radius, children, ...props }: ItemProps<T>): React.JSX.Element;
15
+ declare const _default: {
16
+ Root: typeof Root;
17
+ Item: typeof Item;
18
+ };
19
+ export default _default;
@@ -0,0 +1,21 @@
1
+ :root {
2
+ --skel-ui-color: #f0f0f0;
3
+ --skel-ui-radius: 0.25rem;
4
+ }
5
+ [data-loading=true] {
6
+ animation: skel-ui-pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite alternate-reverse !important;
7
+ border-radius: var(--skel-ui-radius) !important;
8
+ background-color: var(--skel-ui-color) !important;
9
+ color: transparent !important;
10
+ cursor: default !important;
11
+ user-select: none !important;
12
+ pointer-events: none !important;
13
+ }
14
+ @keyframes skel-ui-pulse {
15
+ 0% {
16
+ opacity: 1;
17
+ }
18
+ 100% {
19
+ opacity: 0.5;
20
+ }
21
+ }
@@ -0,0 +1,4 @@
1
+ export default function tailwindcssPlugin(): {
2
+ handler: import("tailwindcss/types/config").PluginCreator;
3
+ config?: Partial<import("tailwindcss/types/config").Config>;
4
+ };
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@skel-ui/react",
3
+ "author": "https://github.com/sudoaugustin",
4
+ "version": "1.0.0-alpha.248d1fb",
5
+ "license": "MIT",
6
+ "description": "Next era of skeleton loading for react",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "main": "dist/cjs/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "module": "dist/esm/index.js",
13
+ "keywords": [
14
+ "react",
15
+ "skeleton",
16
+ "loading",
17
+ "placeholder"
18
+ ],
19
+ "exports": {
20
+ "types": {
21
+ "/": "./dist/index.d.ts",
22
+ "/tailwind": "./dist/tailwind.d.ts"
23
+ },
24
+ "import": {
25
+ "/": "./dist/esm/index.js",
26
+ "/tailwind": "./dist/esm/tailwind.js"
27
+ },
28
+ "require": {
29
+ "/": "./dist/cjs/index.js",
30
+ "/tailwind": "./dist/cjs/tailwind.js"
31
+ },
32
+ "/styles.css": "./dist/styles.css"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/sudoaugustin/react-sleleto/issues"
36
+ },
37
+ "homepage": "https://skel-ui.augustin.zip",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/sudoaugustin/react-sleleto"
41
+ },
42
+ "devDependencies": {
43
+ "@chromatic-com/storybook": "^1.9.0",
44
+ "@storybook/addon-essentials": "^8.3.3",
45
+ "@storybook/addon-interactions": "^8.3.3",
46
+ "@storybook/addon-links": "^8.3.3",
47
+ "@storybook/addon-onboarding": "^8.3.3",
48
+ "@storybook/blocks": "^8.3.3",
49
+ "@storybook/react": "^8.3.3",
50
+ "@storybook/react-vite": "^8.3.3",
51
+ "@storybook/test": "^8.3.3",
52
+ "@types/react": "^18.3.9",
53
+ "@types/react-dom": "^18.0.10",
54
+ "esbuild": "^0.17.5",
55
+ "react": "^18.2.0",
56
+ "react-dom": "^18.2.0",
57
+ "storybook": "^8.3.3",
58
+ "swr": "^2.2.5",
59
+ "tailwindcss": "^3.4.13",
60
+ "typescript": "^5.6.2"
61
+ },
62
+ "peerDependencies": {
63
+ "react": "^16.0.0 || ^17.0.0 || ^18.0.0",
64
+ "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
65
+ },
66
+ "scripts": {
67
+ "dev": "storybook dev -p 6006 --no-open",
68
+ "build": "rm -rf dist && pnpm build:dts && pnpm build:css && pnpm build:esm && pnpm build:cjs",
69
+ "build:dts": "tsc -p tsconfig.build.json --outDir dist",
70
+ "build:css": "esbuild src/styles.css --outdir=dist",
71
+ "build:esm": "esbuild src/*.ts* --format=esm --outdir=dist/esm",
72
+ "build:cjs": "esbuild src/*.ts* --format=cjs --outdir=dist/cjs"
73
+ }
74
+ }