@skel-ui/react 1.0.0-alpha.fa3737d → 1.0.0-alpha.fc281bd

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 CHANGED
@@ -1,42 +1,39 @@
1
- # Getting Started
1
+ Skel UI resolves the challenges of implementing skeletons by eliminating the need to create dedicated loading screens and providing an easier way to manage skeleton states using React Context.
2
2
 
3
- Skel UI resolves the challenges of implementing skeletons by eliminating the need to create dedicated loading screens and providing an easier way to manage skeleton states using react-context.
3
+ See the comparision [here](https://skel-ui.augustin.zip/#comparision).
4
4
 
5
- ## Installation
5
+ ## Get Started
6
6
 
7
- Install the package into your project via command line.
8
-
9
- ```bash
10
- npm install @skel-ui/react
11
- ```
12
-
13
- ## Importing CSS
7
+ ### Import CSS
14
8
 
15
9
  Import the CSS file into the root of your application.
16
10
 
17
- ```js
11
+ ```ts
18
12
  import "@skel-ui/react/styles.css";
19
13
  ```
20
14
 
21
- ## Start crafting UI
15
+ ### Implement Skel UI
22
16
 
23
17
  Now it's time for you to craft your user interface to life!
24
18
 
25
- ```jsx
19
+ ```tsx
26
20
  import * as Skel from "@skel-ui/react";
27
- import Image from "next/image";
21
+ import Image from "@ui/image";
28
22
 
29
- function Profile() {
30
- const { user, isLoading } = useProfile();
23
+ export default function PostCard() {
24
+ const { post, isLoading } = usePost();
31
25
 
32
26
  return (
33
27
  <Skel.Root isLoading={isLoading}>
34
- <Skel.Item className="user-avatar">
35
- <Image src={user.profile} />
36
- </Skel.Item>
37
- <Skel.Item as="h1" className="user-email">
38
- {user.email}
39
- </Skel.Item>
28
+ <div className="group w-full max-w-80 p-2.5 bg-white border border-slate-200 rounded-lg overflow-hidden duration-300">
29
+ <Skel.Item
30
+ as={Image}
31
+ src={post?.image}
32
+ className="rounded aspect-[800/530] duration-150 loaded:group-hover:scale-110"
33
+ />
34
+ <Skel.h1 className="text-xl font-bold mt-4 loading:max-w-48">{post?.title}</Skel.h1>
35
+ <Skel.p className="text-sm my-2 loading:h-[3.75rem]">{post?.description}</Skel.p>
36
+ </div>
40
37
  </Skel.Root>
41
38
  );
42
39
  }
@@ -44,28 +41,6 @@ function Profile() {
44
41
 
45
42
  Now, not only have you designed the skeleton, but you have also done the actual UI. Additionally, the skeleton state for the entire UI is handled in a single place at the `<Skel.Root>` .
46
43
 
47
- ## Customization
48
44
 
49
- Customize the default color and border-radius of skeleton using css variables.
50
-
51
- ```css title="global.css"
52
- :root {
53
- --skel-ui-color1: #a1a1aa;
54
- --skel-ui-color2: #e4e4e7;
55
- --skel-ui-radius: 0.25rem;
56
- }
57
- ```
58
45
 
59
- Each `Skel.Item` will have a `data-loading` attribute that is set to `"true"` when the item is in a loading state, and `"false"` otherwise. You can use this attribute in your CSS to create styles based on the loading state.
60
-
61
- ```css
62
- /* This style will be applied during loading. */
63
- .user-email[data-loading="true"] {
64
- width: 5rem;
65
- }
66
-
67
- /* This style will be applied after loading is done. */
68
- .user-email[data-loading="false"]:hover {
69
- background: #f97316;
70
- }
71
- ```
46
+ For full documentation, visit [skel-ui.augustin.zip](https://skel-ui.augustin.zip/)
package/dist/cjs/index.js CHANGED
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var src_exports = {};
31
- __export(src_exports, {
32
- Custom: () => Custom,
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ Item: () => Item,
33
33
  Root: () => Root,
34
34
  a: () => a,
35
35
  address: () => address,
@@ -130,7 +130,7 @@ __export(src_exports, {
130
130
  wbr: () => wbr,
131
131
  webview: () => webview
132
132
  });
133
- module.exports = __toCommonJS(src_exports);
133
+ module.exports = __toCommonJS(index_exports);
134
134
  var import_core = require("@skel-ui/core");
135
135
  var import_react = __toESM(require("react"));
136
136
  function createSkelComponent(type, isVoidTag = false) {
@@ -139,7 +139,7 @@ function createSkelComponent(type, isVoidTag = false) {
139
139
  const loadingStyle = isLoading ? {
140
140
  width: sw,
141
141
  height: sh,
142
- borderRadius: sr || "var(--skel-ui-radius)",
142
+ borderRadius: sr,
143
143
  color: "transparent",
144
144
  cursor: "default",
145
145
  userSelect: "none",
@@ -152,8 +152,8 @@ function createSkelComponent(type, isVoidTag = false) {
152
152
  style: { ...style, ...loadingStyle },
153
153
  "aria-hidden": isLoading,
154
154
  "data-loading": isLoading,
155
- // Use base64 transparent image while loading to avoid broken image ui. This doesn't trigger error on other media tags.
156
- ...isLoading && "src" in props && props.src === void 0 ? {
155
+ // Use base64 transparent image while loading to avoid broken image ui for falsy src. This doesn't trigger error on other media tags.
156
+ ...isLoading && "src" in props ? {
157
157
  src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAgEB/6mZBQAAAABJRU5ErkJggg=="
158
158
  } : {}
159
159
  },
@@ -161,11 +161,11 @@ function createSkelComponent(type, isVoidTag = false) {
161
161
  );
162
162
  };
163
163
  }
164
- function SkelCustom({ as, ...rest }) {
164
+ function SkelItem({ as, ...rest }) {
165
165
  return createSkelComponent(as)(rest);
166
166
  }
167
167
  const Root = import_core.SkelRoot;
168
- const Custom = SkelCustom;
168
+ const Item = SkelItem;
169
169
  const a = createSkelComponent("a");
170
170
  const address = createSkelComponent("address");
171
171
  const article = createSkelComponent("article");
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ function createSkelComponent(type, isVoidTag = false) {
7
7
  const loadingStyle = isLoading ? {
8
8
  width: sw,
9
9
  height: sh,
10
- borderRadius: sr || "var(--skel-ui-radius)",
10
+ borderRadius: sr,
11
11
  color: "transparent",
12
12
  cursor: "default",
13
13
  userSelect: "none",
@@ -20,8 +20,8 @@ function createSkelComponent(type, isVoidTag = false) {
20
20
  style: { ...style, ...loadingStyle },
21
21
  "aria-hidden": isLoading,
22
22
  "data-loading": isLoading,
23
- // Use base64 transparent image while loading to avoid broken image ui. This doesn't trigger error on other media tags.
24
- ...isLoading && "src" in props && props.src === void 0 ? {
23
+ // Use base64 transparent image while loading to avoid broken image ui for falsy src. This doesn't trigger error on other media tags.
24
+ ...isLoading && "src" in props ? {
25
25
  src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAgEB/6mZBQAAAABJRU5ErkJggg=="
26
26
  } : {}
27
27
  },
@@ -29,11 +29,11 @@ function createSkelComponent(type, isVoidTag = false) {
29
29
  );
30
30
  };
31
31
  }
32
- function SkelCustom({ as, ...rest }) {
32
+ function SkelItem({ as, ...rest }) {
33
33
  return createSkelComponent(as)(rest);
34
34
  }
35
35
  const Root = SkelRoot;
36
- const Custom = SkelCustom;
36
+ const Item = SkelItem;
37
37
  const a = createSkelComponent("a");
38
38
  const address = createSkelComponent("address");
39
39
  const article = createSkelComponent("article");
@@ -133,7 +133,7 @@ const video = createSkelComponent("video");
133
133
  const wbr = createSkelComponent("wbr", true);
134
134
  const webview = createSkelComponent("webview");
135
135
  export {
136
- Custom,
136
+ Item,
137
137
  Root,
138
138
  a,
139
139
  address,
@@ -1,12 +1,12 @@
1
1
  import { SkelComponentProps, SkelRoot } from "@skel-ui/core";
2
2
  import type { ComponentProps, ComponentType } from "react";
3
3
  import React from "react";
4
- type SkelCustomProps<T extends ComponentType<ComponentProps<T>>> = {
4
+ type SkelItemProps<T extends ComponentType<ComponentProps<T>>> = {
5
5
  as: T;
6
6
  } & ComponentProps<T> & Pick<SkelComponentProps<T>, "sw" | "sh" | "sr">;
7
- declare function SkelCustom<T extends ComponentType<ComponentProps<T>>>({ as, ...rest }: SkelCustomProps<T>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
7
+ declare function SkelItem<T extends ComponentType<ComponentProps<T>>>({ as, ...rest }: SkelItemProps<T>): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
8
8
  export declare const Root: typeof SkelRoot;
9
- export declare const Custom: typeof SkelCustom;
9
+ export declare const Item: typeof SkelItem;
10
10
  export declare const a: ({ sw, sh, sr, style, children, ...props }: SkelComponentProps<"a">) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
11
11
  export declare const address: ({ sw, sh, sr, style, children, ...props }: SkelComponentProps<"address">) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
12
12
  export declare const article: ({ sw, sh, sr, style, children, ...props }: SkelComponentProps<"article">) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
package/dist/styles.css CHANGED
@@ -1,29 +1,32 @@
1
1
  :root {
2
- --skel-ui-color1: #cbd5e1;
3
- --skel-ui-color2: #f1f0f0;
2
+ --skel-ui-color: #cbd5e1;
4
3
  --skel-ui-radius: 0.25rem;
4
+ --skel-ui-animation-delay: 0s;
5
5
  --skel-ui-animation-easing: cubic-bezier(0.4, 0, 0.6, 1);
6
6
  }
7
- [aria-hidden=true][data-loading=true] {
8
- animation: skel-ui-shimmer var(--skel-ui-animation-duration, 2s) var(--skel-ui-animation-easing) infinite !important;
7
+ [data-loading=true] {
8
+ border-radius: var(--skel-ui-radius);
9
+ }
10
+ [data-loading=true] {
11
+ animation: skel-ui-shimmer var(--skel-ui-animation-duration, 2s) var(--skel-ui-animation-easing) var(--skel-ui-animation-delay) infinite !important;
9
12
  background-image:
10
13
  linear-gradient(
11
14
  to right,
12
- var(--skel-ui-color1) 33%,
13
- var(--skel-ui-color2),
14
- var(--skel-ui-color1) 66%);
15
+ var(--skel-ui-color) 33%,
16
+ var(--skel-ui-shimmer-color, #f1f0f0),
17
+ var(--skel-ui-color) 66%);
15
18
  background-size: 300%;
16
19
  }
17
- .skel-ui-pulse [aria-hidden=true][data-loading=true] {
18
- animation: skel-ui-pulse var(--skel-ui-animation-duration, 1s) var(--skel-ui-animation-easing) infinite alternate-reverse !important;
19
- background-color: var(--skel-ui-color1);
20
+ .skel-ui-pulse [data-loading=true] {
21
+ animation: skel-ui-pulse var(--skel-ui-animation-duration, 1s) var(--skel-ui-animation-easing) var(--skel-ui-animation-delay) infinite alternate-reverse !important;
22
+ background-color: var(--skel-ui-color);
20
23
  }
21
24
  @keyframes skel-ui-pulse {
22
25
  0% {
23
26
  opacity: 1;
24
27
  }
25
28
  100% {
26
- opacity: 0.35;
29
+ opacity: 0.5;
27
30
  }
28
31
  }
29
32
  @keyframes skel-ui-shimmer {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@skel-ui/react",
3
3
  "author": "https://github.com/sudoaugustin",
4
- "version": "1.0.0-alpha.fa3737d",
4
+ "version": "1.0.0-alpha.fc281bd",
5
5
  "license": "MIT",
6
- "description": "Next era of skeleton loading for React",
6
+ "description": "Lightweight and powerful skeleton loading library for React.",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
@@ -35,6 +35,16 @@
35
35
  "./styles.css": "./dist/styles.css",
36
36
  "./$components": "./stories/components/index.tsx"
37
37
  },
38
+ "typesVersions": {
39
+ "*": {
40
+ "utils": [
41
+ "./dist/utils.d.ts"
42
+ ],
43
+ "tailwind": [
44
+ "./dist/tailwind.d.ts"
45
+ ]
46
+ }
47
+ },
38
48
  "bugs": {
39
49
  "url": "https://github.com/sudoaugustin/skel-ui/issues"
40
50
  },
@@ -43,6 +53,9 @@
43
53
  "type": "git",
44
54
  "url": "git+https://github.com/sudoaugustin/skel-ui"
45
55
  },
56
+ "dependencies": {
57
+ "@skel-ui/core": "1.0.0"
58
+ },
46
59
  "devDependencies": {
47
60
  "@chromatic-com/storybook": "^1.9.0",
48
61
  "@storybook/addon-essentials": "^8.3.4",
@@ -67,13 +80,12 @@
67
80
  },
68
81
  "peerDependencies": {
69
82
  "react": "^17.0 || ^18.0",
70
- "react-dom": "^17.0 || ^18.0",
71
- "@skel-ui/core": "1.0.0"
83
+ "react-dom": "^17.0 || ^18.0"
72
84
  },
73
85
  "scripts": {
74
86
  "dev": "storybook dev -p 6006 --no-open",
75
87
  "build": "rm -rf dist && pnpm build:dts && pnpm build:css && pnpm build:esm && pnpm build:cjs",
76
- "build:dts": "tsc -p tsconfig.json --outDir dist --emitDeclarationOnly",
88
+ "build:dts": "tsc -p tsconfig.build.json --outDir dist",
77
89
  "build:css": "esbuild src/styles.css --outdir=dist",
78
90
  "build:esm": "esbuild src/*.ts* --format=esm --outdir=dist/esm",
79
91
  "build:cjs": "esbuild src/*.ts* --format=cjs --outdir=dist/cjs"
@@ -1 +0,0 @@
1
- export default function Animations(): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +0,0 @@
1
- import { ImgHTMLAttributes } from "react";
2
- type Props = ImgHTMLAttributes<HTMLImageElement>;
3
- export default function Image({ ...rest }: Props): import("react/jsx-runtime").JSX.Element;
4
- export {};
@@ -1,5 +0,0 @@
1
- type Props = {
2
- isLoading?: boolean;
3
- };
4
- export default function PostCard(props: Props): import("react/jsx-runtime").JSX.Element;
5
- export {};
@@ -1 +0,0 @@
1
- export default function PostCardList(): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +0,0 @@
1
- import Animations from "./Animations";
2
- import Image from "./Image";
3
- import PostCard from "./PostCard";
4
- import PostCardList from "./PostCardList";
5
- export { Animations, Image, PostCard, PostCardList };
@@ -1,8 +0,0 @@
1
- import "../src/styles.css";
2
- import { Animations, PostCard, PostCardList } from "./components";
3
- declare const _default: {
4
- title: string;
5
- component: typeof import("@skel-ui/core").SkelRoot;
6
- };
7
- export default _default;
8
- export { Animations, PostCard, PostCardList };
File without changes
File without changes