azeriand-library 1.0.0 → 1.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/README.md +92 -0
- package/dist/background.jpg +0 -0
- package/dist/components/avatar.d.ts +7 -0
- package/dist/components/card/card.d.ts +15 -0
- package/dist/components/theme-context.d.ts +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +46 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +48 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +893 -0
- package/dist/styles/index.d.ts +0 -0
- package/package.json +50 -13
- package/src/styles/globals.css +321 -0
- package/dist/components/button.js +0 -2
- package/dist/index.js +0 -2
- package/dist/types/components/button.d.ts +0 -1
- package/dist/types/index.d.ts +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Azeriand Library
|
|
2
|
+
|
|
3
|
+
A React component library built with TypeScript and Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install azeriand-library
|
|
9
|
+
# or
|
|
10
|
+
yarn add azeriand-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Basic Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Button } from 'azeriand-library';
|
|
19
|
+
import 'azeriand-library/dist/style.css'; // Import the CSS
|
|
20
|
+
|
|
21
|
+
function App() {
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<Button color="#ff6b6b">
|
|
25
|
+
Click me!
|
|
26
|
+
</Button>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### With Tailwind CSS
|
|
33
|
+
|
|
34
|
+
If your project uses Tailwind CSS, make sure to include the library's source files in your Tailwind configuration:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
// tailwind.config.js
|
|
38
|
+
module.exports = {
|
|
39
|
+
content: [
|
|
40
|
+
"./src/**/*.{js,jsx,ts,tsx}",
|
|
41
|
+
"./node_modules/azeriand-library/dist/**/*.{js,jsx,ts,tsx}", // Add this line
|
|
42
|
+
],
|
|
43
|
+
// ... rest of your config
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then you can use the components without importing the CSS:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { Button } from 'azeriand-library';
|
|
51
|
+
|
|
52
|
+
function App() {
|
|
53
|
+
return (
|
|
54
|
+
<Button color="#ff6b6b">
|
|
55
|
+
Click me!
|
|
56
|
+
</Button>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Components
|
|
62
|
+
|
|
63
|
+
### Button
|
|
64
|
+
|
|
65
|
+
A customizable button component with Tailwind CSS styling.
|
|
66
|
+
|
|
67
|
+
#### Props
|
|
68
|
+
|
|
69
|
+
- `color?: string` - Background color for the button
|
|
70
|
+
|
|
71
|
+
#### Example
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<Button color="#3b82f6">Primary Button</Button>
|
|
75
|
+
<Button color="#10b981">Success Button</Button>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Install dependencies
|
|
82
|
+
yarn install
|
|
83
|
+
|
|
84
|
+
# Start Storybook for development
|
|
85
|
+
yarn storybook
|
|
86
|
+
|
|
87
|
+
# Build the library
|
|
88
|
+
yarn build
|
|
89
|
+
|
|
90
|
+
# Build Storybook for production
|
|
91
|
+
yarn build-storybook
|
|
92
|
+
```
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
type CardProps = {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
noPadding?: boolean;
|
|
5
|
+
noBlur?: boolean;
|
|
6
|
+
appearance?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
intensity?: number;
|
|
9
|
+
dark?: boolean;
|
|
10
|
+
onClick?: MouseEventHandler<HTMLElement>;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
};
|
|
14
|
+
export declare function Card({ children, noPadding, noBlur, appearance, color, intensity, dark, onClick, className, style }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
type ThemeMode = 'dark' | 'light';
|
|
3
|
+
type ThemeContext = {
|
|
4
|
+
theme: ThemeMode;
|
|
5
|
+
setTheme: (val: ThemeMode) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const ThemeContext: import('react').Context<ThemeContext>;
|
|
8
|
+
export default function ThemeContextComponent({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useState, useContext, useEffect } from "react";
|
|
3
|
+
function Avatar({ src, className = "", style }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(
|
|
5
|
+
"img",
|
|
6
|
+
{
|
|
7
|
+
className: `size-[3rem] rounded-2xl ${className}`,
|
|
8
|
+
src,
|
|
9
|
+
style
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
const DEFAULT_THEME = "dark";
|
|
14
|
+
const ThemeContext = createContext({ theme: DEFAULT_THEME, setTheme: () => {
|
|
15
|
+
} });
|
|
16
|
+
function Card({ children, noPadding, noBlur = false, appearance = "glass", color = "neutral", intensity, dark = true, onClick, className, style }) {
|
|
17
|
+
let [classNames, setClassNames] = useState("");
|
|
18
|
+
let [cardStyle, setCardStyle] = useState({});
|
|
19
|
+
const { theme } = useContext(ThemeContext);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let intensityValue = intensity;
|
|
22
|
+
if (intensityValue === void 0) {
|
|
23
|
+
intensityValue = theme === "dark" ? 600 : 300;
|
|
24
|
+
}
|
|
25
|
+
setCardStyle({
|
|
26
|
+
"--glass-color": `var(--color-${color}-${intensityValue})`,
|
|
27
|
+
"--card-text-color": `var(--color-${color}-${dark ? "100" : "800"})`,
|
|
28
|
+
backdropFilter: appearance === "glass" && !noBlur ? "blur(10px)" : void 0,
|
|
29
|
+
...style
|
|
30
|
+
});
|
|
31
|
+
let rounded = "rounded-md";
|
|
32
|
+
if (className) {
|
|
33
|
+
const roundedMatch = className.match(/rounded\-[a-z0-9]+/g);
|
|
34
|
+
if (roundedMatch) {
|
|
35
|
+
rounded = roundedMatch[roundedMatch.length - 1];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
setClassNames(`card ${rounded} ${appearance} ${className} ${noPadding ? "" : "p-[2rem]"}`);
|
|
39
|
+
}, [color, intensity, dark, appearance, noBlur, className, theme]);
|
|
40
|
+
return /* @__PURE__ */ jsx("article", { className: classNames, style: cardStyle, onClick, children });
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
Avatar,
|
|
44
|
+
Card
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/avatar.tsx","../src/components/theme-context.tsx","../src/components/card/card.tsx"],"sourcesContent":["\r\ntype AvatarProps = {\r\n src: string;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n}\r\n\r\nexport function Avatar({ src, className = '', style }: AvatarProps){\r\n return(\r\n <img className={`size-[3rem] rounded-2xl ${className}`} \r\n src={src} \r\n style={style}/>\r\n )\r\n}","import { useState, createContext } from 'react'\n\ntype ThemeMode = 'dark' | 'light';\nconst DEFAULT_THEME = 'dark';\n\ntype ThemeContext = {\n theme: ThemeMode,\n setTheme: (val: ThemeMode) => void\n}\n\nexport const ThemeContext = createContext<ThemeContext>({theme: DEFAULT_THEME, setTheme: () => {}}); //Creando el 'espacio compartido' al que los componentes pueden acceder??\n\nimport { ReactNode } from 'react';\n\nexport default function ThemeContextComponent({children}: {children: ReactNode}){\n\n const [theme, setTheme] = useState<ThemeMode>(DEFAULT_THEME)\n\n //Creando el componente donde todos los hijos pueden acceder al contexto (siendo children los props)\n return(\n <ThemeContext.Provider value={{theme, setTheme}}> \n {children}\n </ThemeContext.Provider>\n )\n}","import './card.css'\nimport { MouseEventHandler, ReactNode, useContext, useEffect, useState } from 'react';\nimport { ThemeContext } from '../theme-context';\n\ntype CardProps = {\n children?: ReactNode;\n noPadding?: boolean;\n noBlur?: boolean;\n appearance?: string;\n color?: string;\n intensity?: number;\n dark?: boolean;\n onClick?: MouseEventHandler<HTMLElement>;\n className?: string;\n style?: React.CSSProperties;\n}\nexport function Card({children, noPadding, noBlur = false, appearance = 'glass', color = 'neutral', intensity, dark = true, onClick, className, style}: CardProps){\n \n let [classNames, setClassNames] = useState(\"\")\n let [cardStyle, setCardStyle] = useState({})\n const {theme} = useContext(ThemeContext)\n \n useEffect(() => {\n\n let intensityValue = intensity\n \n if (intensityValue === undefined){\n intensityValue = theme === 'dark' ? 600 : 300;\n }\n \n setCardStyle({\n \"--glass-color\": `var(--color-${color}-${intensityValue})`,\n \"--card-text-color\": `var(--color-${color}-${dark ? '100' : '800'})`,\n backdropFilter: appearance === 'glass' && !noBlur ? 'blur(10px)' : undefined,\n ...style\n });\n\n let rounded = 'rounded-md'\n\n if (className){\n const roundedMatch = className.match(/rounded\\-[a-z0-9]+/g)\n if (roundedMatch){\n rounded = roundedMatch[roundedMatch.length - 1]\n }\n }\n\n setClassNames(`card ${rounded} ${appearance} ${className} ${noPadding ? '' : 'p-[2rem]'}`)\n\n \n }, [color, intensity, dark, appearance, noBlur, className, theme])\n\n return(\n <article className={classNames} style={cardStyle} onClick={onClick}>\n {children}\n </article>\n )\n\n}\n"],"names":[],"mappings":";;AAOO,SAAS,OAAO,EAAE,KAAK,YAAY,IAAI,SAAqB;AAC/D,SACI;AAAA,IAAC;AAAA,IAAA;AAAA,MAAI,WAAW,2BAA2B,SAAS;AAAA,MACpD;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAER;ACVA,MAAM,gBAAgB;AAOf,MAAM,eAAe,cAA4B,EAAC,OAAO,eAAe,UAAU,MAAM;AAAC,GAAE;ACM3F,SAAS,KAAK,EAAC,UAAU,WAAW,SAAS,OAAO,aAAa,SAAS,QAAQ,WAAW,WAAW,OAAO,MAAM,SAAS,WAAW,SAAkB;AAE9J,MAAI,CAAC,YAAY,aAAa,IAAI,SAAS,EAAE;AAC7C,MAAI,CAAC,WAAW,YAAY,IAAI,SAAS,CAAA,CAAE;AAC3C,QAAM,EAAC,MAAA,IAAS,WAAW,YAAY;AAEvC,YAAU,MAAM;AAEZ,QAAI,iBAAiB;AAErB,QAAI,mBAAmB,QAAU;AAC7B,uBAAiB,UAAU,SAAS,MAAM;AAAA,IAC9C;AAEA,iBAAa;AAAA,MACT,iBAAiB,eAAe,KAAK,IAAI,cAAc;AAAA,MACvD,qBAAqB,eAAe,KAAK,IAAI,OAAO,QAAQ,KAAK;AAAA,MACjE,gBAAgB,eAAe,WAAW,CAAC,SAAS,eAAe;AAAA,MACnE,GAAG;AAAA,IAAA,CACN;AAED,QAAI,UAAU;AAEd,QAAI,WAAU;AACV,YAAM,eAAe,UAAU,MAAM,qBAAqB;AAC1D,UAAI,cAAa;AACb,kBAAU,aAAa,aAAa,SAAS,CAAC;AAAA,MAClD;AAAA,IACJ;AAEA,kBAAc,QAAQ,OAAO,IAAI,UAAU,IAAI,SAAS,IAAI,YAAY,KAAK,UAAU,EAAE;AAAA,EAG7F,GAAG,CAAC,OAAO,WAAW,MAAM,YAAY,QAAQ,WAAW,KAAK,CAAC;AAEjE,6BACK,WAAA,EAAQ,WAAW,YAAY,OAAO,WAAW,SAC7C,UACL;AAGR;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.AzeriandLibrary = {}, global.React, global.React));
|
|
3
|
+
})(this, function(exports2, jsxRuntime, react) {
|
|
4
|
+
"use strict";
|
|
5
|
+
function Avatar({ src, className = "", style }) {
|
|
6
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7
|
+
"img",
|
|
8
|
+
{
|
|
9
|
+
className: `size-[3rem] rounded-2xl ${className}`,
|
|
10
|
+
src,
|
|
11
|
+
style
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
const DEFAULT_THEME = "dark";
|
|
16
|
+
const ThemeContext = react.createContext({ theme: DEFAULT_THEME, setTheme: () => {
|
|
17
|
+
} });
|
|
18
|
+
function Card({ children, noPadding, noBlur = false, appearance = "glass", color = "neutral", intensity, dark = true, onClick, className, style }) {
|
|
19
|
+
let [classNames, setClassNames] = react.useState("");
|
|
20
|
+
let [cardStyle, setCardStyle] = react.useState({});
|
|
21
|
+
const { theme } = react.useContext(ThemeContext);
|
|
22
|
+
react.useEffect(() => {
|
|
23
|
+
let intensityValue = intensity;
|
|
24
|
+
if (intensityValue === void 0) {
|
|
25
|
+
intensityValue = theme === "dark" ? 600 : 300;
|
|
26
|
+
}
|
|
27
|
+
setCardStyle({
|
|
28
|
+
"--glass-color": `var(--color-${color}-${intensityValue})`,
|
|
29
|
+
"--card-text-color": `var(--color-${color}-${dark ? "100" : "800"})`,
|
|
30
|
+
backdropFilter: appearance === "glass" && !noBlur ? "blur(10px)" : void 0,
|
|
31
|
+
...style
|
|
32
|
+
});
|
|
33
|
+
let rounded = "rounded-md";
|
|
34
|
+
if (className) {
|
|
35
|
+
const roundedMatch = className.match(/rounded\-[a-z0-9]+/g);
|
|
36
|
+
if (roundedMatch) {
|
|
37
|
+
rounded = roundedMatch[roundedMatch.length - 1];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
setClassNames(`card ${rounded} ${appearance} ${className} ${noPadding ? "" : "p-[2rem]"}`);
|
|
41
|
+
}, [color, intensity, dark, appearance, noBlur, className, theme]);
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: classNames, style: cardStyle, onClick, children });
|
|
43
|
+
}
|
|
44
|
+
exports2.Avatar = Avatar;
|
|
45
|
+
exports2.Card = Card;
|
|
46
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/components/avatar.tsx","../src/components/theme-context.tsx","../src/components/card/card.tsx"],"sourcesContent":["\r\ntype AvatarProps = {\r\n src: string;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n}\r\n\r\nexport function Avatar({ src, className = '', style }: AvatarProps){\r\n return(\r\n <img className={`size-[3rem] rounded-2xl ${className}`} \r\n src={src} \r\n style={style}/>\r\n )\r\n}","import { useState, createContext } from 'react'\n\ntype ThemeMode = 'dark' | 'light';\nconst DEFAULT_THEME = 'dark';\n\ntype ThemeContext = {\n theme: ThemeMode,\n setTheme: (val: ThemeMode) => void\n}\n\nexport const ThemeContext = createContext<ThemeContext>({theme: DEFAULT_THEME, setTheme: () => {}}); //Creando el 'espacio compartido' al que los componentes pueden acceder??\n\nimport { ReactNode } from 'react';\n\nexport default function ThemeContextComponent({children}: {children: ReactNode}){\n\n const [theme, setTheme] = useState<ThemeMode>(DEFAULT_THEME)\n\n //Creando el componente donde todos los hijos pueden acceder al contexto (siendo children los props)\n return(\n <ThemeContext.Provider value={{theme, setTheme}}> \n {children}\n </ThemeContext.Provider>\n )\n}","import './card.css'\nimport { MouseEventHandler, ReactNode, useContext, useEffect, useState } from 'react';\nimport { ThemeContext } from '../theme-context';\n\ntype CardProps = {\n children?: ReactNode;\n noPadding?: boolean;\n noBlur?: boolean;\n appearance?: string;\n color?: string;\n intensity?: number;\n dark?: boolean;\n onClick?: MouseEventHandler<HTMLElement>;\n className?: string;\n style?: React.CSSProperties;\n}\nexport function Card({children, noPadding, noBlur = false, appearance = 'glass', color = 'neutral', intensity, dark = true, onClick, className, style}: CardProps){\n \n let [classNames, setClassNames] = useState(\"\")\n let [cardStyle, setCardStyle] = useState({})\n const {theme} = useContext(ThemeContext)\n \n useEffect(() => {\n\n let intensityValue = intensity\n \n if (intensityValue === undefined){\n intensityValue = theme === 'dark' ? 600 : 300;\n }\n \n setCardStyle({\n \"--glass-color\": `var(--color-${color}-${intensityValue})`,\n \"--card-text-color\": `var(--color-${color}-${dark ? '100' : '800'})`,\n backdropFilter: appearance === 'glass' && !noBlur ? 'blur(10px)' : undefined,\n ...style\n });\n\n let rounded = 'rounded-md'\n\n if (className){\n const roundedMatch = className.match(/rounded\\-[a-z0-9]+/g)\n if (roundedMatch){\n rounded = roundedMatch[roundedMatch.length - 1]\n }\n }\n\n setClassNames(`card ${rounded} ${appearance} ${className} ${noPadding ? '' : 'p-[2rem]'}`)\n\n \n }, [color, intensity, dark, appearance, noBlur, className, theme])\n\n return(\n <article className={classNames} style={cardStyle} onClick={onClick}>\n {children}\n </article>\n )\n\n}\n"],"names":["jsx","createContext","useState","useContext","useEffect"],"mappings":";;;;AAOO,WAAS,OAAO,EAAE,KAAK,YAAY,IAAI,SAAqB;AAC/D,WACIA,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QAAI,WAAW,2BAA2B,SAAS;AAAA,QACpD;AAAA,QACA;AAAA,MAAA;AAAA,IAAA;AAAA,EAER;ACVA,QAAM,gBAAgB;AAOf,QAAM,eAAeC,MAAAA,cAA4B,EAAC,OAAO,eAAe,UAAU,MAAM;AAAA,EAAC,GAAE;ACM3F,WAAS,KAAK,EAAC,UAAU,WAAW,SAAS,OAAO,aAAa,SAAS,QAAQ,WAAW,WAAW,OAAO,MAAM,SAAS,WAAW,SAAkB;AAE9J,QAAI,CAAC,YAAY,aAAa,IAAIC,MAAAA,SAAS,EAAE;AAC7C,QAAI,CAAC,WAAW,YAAY,IAAIA,MAAAA,SAAS,CAAA,CAAE;AAC3C,UAAM,EAAC,MAAA,IAASC,MAAAA,WAAW,YAAY;AAEvCC,UAAAA,UAAU,MAAM;AAEZ,UAAI,iBAAiB;AAErB,UAAI,mBAAmB,QAAU;AAC7B,yBAAiB,UAAU,SAAS,MAAM;AAAA,MAC9C;AAEA,mBAAa;AAAA,QACT,iBAAiB,eAAe,KAAK,IAAI,cAAc;AAAA,QACvD,qBAAqB,eAAe,KAAK,IAAI,OAAO,QAAQ,KAAK;AAAA,QACjE,gBAAgB,eAAe,WAAW,CAAC,SAAS,eAAe;AAAA,QACnE,GAAG;AAAA,MAAA,CACN;AAED,UAAI,UAAU;AAEd,UAAI,WAAU;AACV,cAAM,eAAe,UAAU,MAAM,qBAAqB;AAC1D,YAAI,cAAa;AACb,oBAAU,aAAa,aAAa,SAAS,CAAC;AAAA,QAClD;AAAA,MACJ;AAEA,oBAAc,QAAQ,OAAO,IAAI,UAAU,IAAI,SAAS,IAAI,YAAY,KAAK,UAAU,EAAE;AAAA,IAG7F,GAAG,CAAC,OAAO,WAAW,MAAM,YAAY,QAAQ,WAAW,KAAK,CAAC;AAEjE,0CACK,WAAA,EAAQ,WAAW,YAAY,OAAO,WAAW,SAC7C,UACL;AAAA,EAGR;;;;;"}
|