@tomo-inc/tomo-ui 0.0.8 → 0.0.10
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/package.json +5 -3
- package/project.json +19 -1
- package/src/App.tsx +134 -14
- package/src/components/index.ts +1 -0
- package/src/components/modal/index.tsx +9 -12
- package/src/components/passcodeInput/index.tsx +81 -0
- package/src/components/toast/index.ts +1 -2
- package/src/index.ts +1 -0
- package/src/style.css +1 -2
- package/src/tailwind/plugin.ts +195 -144
- package/src/tailwind/tailwind.css +2 -1
- package/src/tailwind/theme-to-css.ts +256 -0
- package/src/theme-context.tsx +47 -0
- package/src/theme-provider.tsx +32 -6
- package/src/types.ts +7 -0
- package/src/components/modal/modal-body.tsx +0 -10
- package/src/components/modal/modal-content.tsx +0 -17
- package/src/components/modal/modal-context.tsx +0 -12
- package/src/components/modal/modal-footer.tsx +0 -12
- package/src/components/modal/modal-header.tsx +0 -28
- package/src/components/modal/modal.tsx +0 -152
- package/src/components/modal/use-disclosure.ts +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomo-inc/tomo-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
"private": false,
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@heroui/react": "2.8.5",
|
|
20
|
-
"@heroui/
|
|
20
|
+
"@heroui/system": "^2.4.23",
|
|
21
|
+
"@heroui/theme": "^2.4.23",
|
|
22
|
+
"color": "^5.0.3",
|
|
23
|
+
"flat": "^6.0.1",
|
|
21
24
|
"framer-motion": "^11.5.6",
|
|
22
|
-
"next-themes": "^0.4.6",
|
|
23
25
|
"qr-code-styling": "^1.9.2"
|
|
24
26
|
},
|
|
25
27
|
"peerDependencies": {
|
package/project.json
CHANGED
|
@@ -3,5 +3,23 @@
|
|
|
3
3
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
4
|
"sourceRoot": "uikits/tomo-ui/src",
|
|
5
5
|
"projectType": "library",
|
|
6
|
-
"tags": ["scope:uikit", "type:tomo-uikit"]
|
|
6
|
+
"tags": ["scope:uikit", "type:tomo-uikit"],
|
|
7
|
+
"targets": {
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "nx:run-commands",
|
|
10
|
+
"outputs": ["{projectRoot}/dist"],
|
|
11
|
+
"options": {
|
|
12
|
+
"command": "echo 'tomo-ui uses source files directly, no build needed' || true",
|
|
13
|
+
"cwd": "uikits/tomo-ui"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publish": {
|
|
17
|
+
"executor": "nx:run-commands",
|
|
18
|
+
"dependsOn": ["build"],
|
|
19
|
+
"options": {
|
|
20
|
+
"command": "pnpm publish --access public --no-git-checks --tag ${NPM_TAG:-latest}",
|
|
21
|
+
"cwd": "uikits/tomo-ui"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
7
25
|
}
|
package/src/App.tsx
CHANGED
|
@@ -1,23 +1,143 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Switch, useDisclosure } from "@heroui/react";
|
|
2
|
+
import { useTheme } from ".";
|
|
2
3
|
import { Button } from "./components/button";
|
|
3
|
-
import { Input
|
|
4
|
+
import { Input } from "./components/input";
|
|
5
|
+
import { Modal, ModalContent, ModalHeader } from "./components/modal";
|
|
6
|
+
|
|
4
7
|
import "./style.css";
|
|
5
8
|
import { TomoUIProvider } from "./theme-provider";
|
|
9
|
+
import { ThemeConfig } from "./types";
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
const _dogeThemeConfig: ThemeConfig = {
|
|
12
|
+
themes: {
|
|
13
|
+
light: {
|
|
14
|
+
colors: {
|
|
15
|
+
foreground: "#12122A",
|
|
16
|
+
background: "#FFF",
|
|
17
|
+
content1: "#FCFCFD",
|
|
18
|
+
primary: {
|
|
19
|
+
50: "#FFFBEA",
|
|
20
|
+
100: "#FFF3C4",
|
|
21
|
+
200: "#FCE588",
|
|
22
|
+
300: "#FADB5F",
|
|
23
|
+
400: "#F7C948",
|
|
24
|
+
500: "#FCD436",
|
|
25
|
+
600: "#F0B429",
|
|
26
|
+
700: "#DE911D",
|
|
27
|
+
800: "#CB6E17",
|
|
28
|
+
900: "#B44D12",
|
|
29
|
+
foreground: "#12122A",
|
|
30
|
+
DEFAULT: "#FCD436",
|
|
31
|
+
},
|
|
32
|
+
danger: "#FF5A5A",
|
|
33
|
+
warning: "#FFAD32",
|
|
34
|
+
success: "#079455",
|
|
35
|
+
t1: "#12122A",
|
|
36
|
+
t2: "#616184",
|
|
37
|
+
t3: "#8989AB",
|
|
38
|
+
t4: "#C1C0D8",
|
|
39
|
+
t5: "#EEC41F",
|
|
40
|
+
} as any,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const MoonIcon = (props: React.SVGProps<SVGSVGElement>) => {
|
|
8
46
|
return (
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
<svg
|
|
48
|
+
aria-hidden="true"
|
|
49
|
+
focusable="false"
|
|
50
|
+
height="1em"
|
|
51
|
+
role="presentation"
|
|
52
|
+
viewBox="0 0 24 24"
|
|
53
|
+
width="1em"
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<path
|
|
57
|
+
d="M21.53 15.93c-.16-.27-.61-.69-1.73-.49a8.46 8.46 0 01-1.88.13 8.409 8.409 0 01-5.91-2.82 8.068 8.068 0 01-1.44-8.66c.44-1.01.13-1.54-.09-1.76s-.77-.55-1.83-.11a10.318 10.318 0 00-6.32 10.21 10.475 10.475 0 007.04 8.99 10 10 0 002.89.55c.16.01.32.02.48.02a10.5 10.5 0 008.47-4.27c.67-.93.49-1.519.32-1.79z"
|
|
58
|
+
fill="currentColor"
|
|
19
59
|
/>
|
|
20
|
-
</
|
|
60
|
+
</svg>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const SunIcon = (props: React.SVGProps<SVGSVGElement>) => {
|
|
65
|
+
return (
|
|
66
|
+
<svg
|
|
67
|
+
aria-hidden="true"
|
|
68
|
+
focusable="false"
|
|
69
|
+
height="1em"
|
|
70
|
+
role="presentation"
|
|
71
|
+
viewBox="0 0 24 24"
|
|
72
|
+
width="1em"
|
|
73
|
+
{...props}
|
|
74
|
+
>
|
|
75
|
+
<g fill="currentColor">
|
|
76
|
+
<path d="M19 12a7 7 0 11-7-7 7 7 0 017 7z" />
|
|
77
|
+
<path d="M12 22.96a.969.969 0 01-1-.96v-.08a1 1 0 012 0 1.038 1.038 0 01-1 1.04zm7.14-2.82a1.024 1.024 0 01-.71-.29l-.13-.13a1 1 0 011.41-1.41l.13.13a1 1 0 010 1.41.984.984 0 01-.7.29zm-14.28 0a1.024 1.024 0 01-.71-.29 1 1 0 010-1.41l.13-.13a1 1 0 011.41 1.41l-.13.13a1 1 0 01-.7.29zM22 13h-.08a1 1 0 010-2 1.038 1.038 0 011.04 1 .969.969 0 01-.96 1zM2.08 13H2a1 1 0 010-2 1.038 1.038 0 011.04 1 .969.969 0 01-.96 1zm16.93-7.01a1.024 1.024 0 01-.71-.29 1 1 0 010-1.41l.13-.13a1 1 0 011.41 1.41l-.13.13a.984.984 0 01-.7.29zm-14.02 0a1.024 1.024 0 01-.71-.29l-.13-.14a1 1 0 011.41-1.41l.13.13a1 1 0 010 1.41.97.97 0 01-.7.3zM12 3.04a.969.969 0 01-1-.96V2a1 1 0 012 0 1.038 1.038 0 01-1 1.04z" />
|
|
78
|
+
</g>
|
|
79
|
+
</svg>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const SwitchTheme = () => {
|
|
84
|
+
const { theme, setTheme } = useTheme();
|
|
85
|
+
return (
|
|
86
|
+
<Switch
|
|
87
|
+
color="success"
|
|
88
|
+
size="lg"
|
|
89
|
+
endContent={<MoonIcon />}
|
|
90
|
+
startContent={<SunIcon />}
|
|
91
|
+
isSelected={theme === "dark"}
|
|
92
|
+
onValueChange={(isSelected) => setTheme(isSelected ? "dark" : "light")}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function App() {
|
|
98
|
+
const { isOpen, onOpen, onOpenChange } = useDisclosure();
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div>
|
|
102
|
+
<TomoUIProvider>
|
|
103
|
+
<div className="bg-content1 p-4 rounded-lg flex flex-col gap-4 border border-primary">
|
|
104
|
+
<div className="flex items-center justify-between">
|
|
105
|
+
<h1 className="text-2xl font-bold text-foreground">Tomo Theme Config Preview</h1>
|
|
106
|
+
<SwitchTheme />
|
|
107
|
+
</div>
|
|
108
|
+
<Input label="Email" type="email" />
|
|
109
|
+
<Button color="primary" variant="solid">
|
|
110
|
+
Click me
|
|
111
|
+
</Button>
|
|
112
|
+
<Button color="primary" variant="bordered">
|
|
113
|
+
Click me
|
|
114
|
+
</Button>
|
|
115
|
+
</div>
|
|
116
|
+
</TomoUIProvider>
|
|
117
|
+
<br />
|
|
118
|
+
<TomoUIProvider themeConfig={_dogeThemeConfig}>
|
|
119
|
+
<div className="bg-content1 p-4 rounded-lg flex flex-col gap-4 border border-primary">
|
|
120
|
+
<div className="flex items-center justify-between">
|
|
121
|
+
<h1 className="text-2xl font-bold text-foreground">Doge Theme Config Preview</h1>
|
|
122
|
+
<SwitchTheme />
|
|
123
|
+
</div>
|
|
124
|
+
<Input label="Email" type="email" />
|
|
125
|
+
<Button color="primary" variant="solid">
|
|
126
|
+
Click me
|
|
127
|
+
</Button>
|
|
128
|
+
<Button color="primary" variant="bordered" onPress={onOpen}>
|
|
129
|
+
Open Modal
|
|
130
|
+
</Button>
|
|
131
|
+
</div>
|
|
132
|
+
<Modal isOpen={isOpen} onOpenChange={onOpenChange}>
|
|
133
|
+
<ModalContent>
|
|
134
|
+
<ModalHeader>
|
|
135
|
+
<h1>Modal</h1>
|
|
136
|
+
</ModalHeader>
|
|
137
|
+
</ModalContent>
|
|
138
|
+
</Modal>
|
|
139
|
+
</TomoUIProvider>
|
|
140
|
+
</div>
|
|
21
141
|
);
|
|
22
142
|
}
|
|
23
143
|
export default App;
|
package/src/components/index.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
export { Modal } from "
|
|
2
|
-
export { ModalBody } from "./modal-body";
|
|
3
|
-
export { ModalContent } from "./modal-content";
|
|
4
|
-
export { ModalFooter } from "./modal-footer";
|
|
5
|
-
export { ModalHeader } from "./modal-header";
|
|
6
|
-
export { useDisclosure } from "./use-disclosure";
|
|
1
|
+
export { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, useDisclosure } from "@heroui/react";
|
|
7
2
|
|
|
8
|
-
export type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
export type {
|
|
4
|
+
ModalBodyProps,
|
|
5
|
+
ModalContentProps,
|
|
6
|
+
ModalFooterProps,
|
|
7
|
+
ModalHeaderProps,
|
|
8
|
+
ModalProps,
|
|
9
|
+
UseDisclosureProps,
|
|
10
|
+
} from "@heroui/react";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
interface PasscodeInputProps {
|
|
4
|
+
length?: number;
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (val: string) => void;
|
|
7
|
+
onFill?: (val: string) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function PasscodeInput({ length = 6, value, onChange, onFill }: PasscodeInputProps) {
|
|
11
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (inputRef.current) {
|
|
15
|
+
inputRef.current.focus();
|
|
16
|
+
}
|
|
17
|
+
}, []);
|
|
18
|
+
|
|
19
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
20
|
+
let val = e.target.value.replace(/\D/g, "");
|
|
21
|
+
if (val.length > length) val = val.slice(0, length);
|
|
22
|
+
|
|
23
|
+
onChange(val);
|
|
24
|
+
|
|
25
|
+
if (val.length === length) {
|
|
26
|
+
onFill?.(val);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
31
|
+
if (e.key === "Backspace" && value.length > 0) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
onChange(value.slice(0, -1));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const chars = Array(length)
|
|
38
|
+
.fill("")
|
|
39
|
+
.map((_, i) => value[i] || "");
|
|
40
|
+
|
|
41
|
+
// Current cursor position
|
|
42
|
+
const activeIndex = chars.findIndex((c) => c === "") === -1 ? length - 1 : chars.findIndex((c) => c === "");
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div className="flex gap-1 cursor-text w-full" onClick={() => inputRef.current?.focus()}>
|
|
46
|
+
{chars.map((char, i) => {
|
|
47
|
+
const isActive = i === activeIndex;
|
|
48
|
+
const isFilled = !!char;
|
|
49
|
+
|
|
50
|
+
let boxStyle = "";
|
|
51
|
+
if (isFilled) {
|
|
52
|
+
boxStyle = "border-primary bg-primary-50";
|
|
53
|
+
} else if (isActive) {
|
|
54
|
+
boxStyle = "border-primary bg-background";
|
|
55
|
+
} else {
|
|
56
|
+
boxStyle = "border-default bg-background";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
key={i}
|
|
62
|
+
className={`w-full h-[70px] flex items-center justify-center rounded-2xl border text-2xl font-bold transition-colors ${boxStyle}`}
|
|
63
|
+
>
|
|
64
|
+
{char || "-"}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
})}
|
|
68
|
+
|
|
69
|
+
<input
|
|
70
|
+
ref={inputRef}
|
|
71
|
+
type="text"
|
|
72
|
+
inputMode="numeric"
|
|
73
|
+
maxLength={length}
|
|
74
|
+
value={value}
|
|
75
|
+
onChange={handleChange}
|
|
76
|
+
onKeyDown={handleKeyDown}
|
|
77
|
+
className="absolute opacity-0 pointer-events-none"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { addToast, ToastProvider } from "@heroui/toast";
|
|
1
|
+
export { addToast, ToastProvider } from "@heroui/react";
|
package/src/index.ts
CHANGED
package/src/style.css
CHANGED