frame.theme 0.0.1

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 ADDED
@@ -0,0 +1,75 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+
45
+ ```
46
+
47
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
48
+
49
+ ```js
50
+ // eslint.config.js
51
+ import reactX from 'eslint-plugin-react-x'
52
+ import reactDom from 'eslint-plugin-react-dom'
53
+
54
+ export default defineConfig([
55
+ globalIgnores(['dist']),
56
+ {
57
+ files: ['**/*.{ts,tsx}'],
58
+ extends: [
59
+ // Other configs...
60
+ // Enable lint rules for React
61
+ reactX.configs['recommended-typescript'],
62
+ // Enable lint rules for React DOM
63
+ reactDom.configs.recommended,
64
+ ],
65
+ languageOptions: {
66
+ parserOptions: {
67
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
68
+ tsconfigRootDir: import.meta.dirname,
69
+ },
70
+ // other options...
71
+ },
72
+ },
73
+ ])
74
+
75
+ ```
@@ -0,0 +1,22 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+ import { defineConfig, globalIgnores } from 'eslint/config'
7
+
8
+ export default defineConfig([
9
+ globalIgnores(['dist']),
10
+ {
11
+ files: ['**/*.{ts,tsx}'],
12
+ extends: [
13
+ js.configs.recommended,
14
+ tseslint.configs.recommended,
15
+ reactHooks.configs.flat.recommended,
16
+ reactRefresh.configs.vite,
17
+ ],
18
+ languageOptions: {
19
+ globals: globals.browser,
20
+ },
21
+ },
22
+ ])
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>frame.theme</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "frame.theme",
3
+ "version": "0.0.1",
4
+ "description": "A sample theme for the Frame project",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "build": "tsc -b && vite build",
10
+ "prepublishOnly": "yarn build",
11
+ "lint": "eslint .",
12
+ "preview": "vite preview"
13
+ },
14
+ "peerDependencies": {
15
+ "@emotion/react": "^11.14.0",
16
+ "@emotion/styled": "^11.14.1",
17
+ "@mui/material": "^9.3.1"
18
+ },
19
+ "dependencies": {
20
+ "@emotion/react": "^11.14.0",
21
+ "@emotion/styled": "^11.14.1",
22
+ "@mui/material": "^9.3.1",
23
+ "react": "^19.2.8",
24
+ "react-dom": "^19.2.8"
25
+ },
26
+ "devDependencies": {
27
+ "@eslint/js": "^10.0.1",
28
+ "@types/node": "^24.13.3",
29
+ "@types/react": "^19.2.17",
30
+ "@types/react-dom": "^19.2.3",
31
+ "@vitejs/plugin-react": "^6.0.4",
32
+ "eslint": "^10.8.0",
33
+ "eslint-plugin-react-hooks": "^7.1.1",
34
+ "eslint-plugin-react-refresh": "^0.5.3",
35
+ "globals": "^17.7.0",
36
+ "typescript": "~6.0.2",
37
+ "typescript-eslint": "^8.65.0",
38
+ "vite": "^8.2.0",
39
+ "vite-plugin-dts": "^5.0.3"
40
+ }
41
+ }
package/src/App.css ADDED
@@ -0,0 +1,184 @@
1
+ .counter {
2
+ font-size: 16px;
3
+ padding: 5px 10px;
4
+ border-radius: 5px;
5
+ color: var(--accent);
6
+ background: var(--accent-bg);
7
+ border: 2px solid transparent;
8
+ transition: border-color 0.3s;
9
+ margin-bottom: 24px;
10
+
11
+ &:hover {
12
+ border-color: var(--accent-border);
13
+ }
14
+ &:focus-visible {
15
+ outline: 2px solid var(--accent);
16
+ outline-offset: 2px;
17
+ }
18
+ }
19
+
20
+ .hero {
21
+ position: relative;
22
+
23
+ .base,
24
+ .framework,
25
+ .vite {
26
+ inset-inline: 0;
27
+ margin: 0 auto;
28
+ }
29
+
30
+ .base {
31
+ width: 170px;
32
+ position: relative;
33
+ z-index: 0;
34
+ }
35
+
36
+ .framework,
37
+ .vite {
38
+ position: absolute;
39
+ }
40
+
41
+ .framework {
42
+ z-index: 1;
43
+ top: 34px;
44
+ height: 28px;
45
+ transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
46
+ scale(1.4);
47
+ }
48
+
49
+ .vite {
50
+ z-index: 0;
51
+ top: 107px;
52
+ height: 26px;
53
+ width: auto;
54
+ transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
55
+ scale(0.8);
56
+ }
57
+ }
58
+
59
+ #center {
60
+ display: flex;
61
+ flex-direction: column;
62
+ gap: 25px;
63
+ place-content: center;
64
+ place-items: center;
65
+ flex-grow: 1;
66
+
67
+ @media (max-width: 1024px) {
68
+ padding: 32px 20px 24px;
69
+ gap: 18px;
70
+ }
71
+ }
72
+
73
+ #next-steps {
74
+ display: flex;
75
+ border-top: 1px solid var(--border);
76
+ text-align: left;
77
+
78
+ & > div {
79
+ flex: 1 1 0;
80
+ padding: 32px;
81
+ @media (max-width: 1024px) {
82
+ padding: 24px 20px;
83
+ }
84
+ }
85
+
86
+ .icon {
87
+ margin-bottom: 16px;
88
+ width: 22px;
89
+ height: 22px;
90
+ }
91
+
92
+ @media (max-width: 1024px) {
93
+ flex-direction: column;
94
+ text-align: center;
95
+ }
96
+ }
97
+
98
+ #docs {
99
+ border-right: 1px solid var(--border);
100
+
101
+ @media (max-width: 1024px) {
102
+ border-right: none;
103
+ border-bottom: 1px solid var(--border);
104
+ }
105
+ }
106
+
107
+ #next-steps ul {
108
+ list-style: none;
109
+ padding: 0;
110
+ display: flex;
111
+ gap: 8px;
112
+ margin: 32px 0 0;
113
+
114
+ .logo {
115
+ height: 18px;
116
+ }
117
+
118
+ a {
119
+ color: var(--text-h);
120
+ font-size: 16px;
121
+ border-radius: 6px;
122
+ background: var(--social-bg);
123
+ display: flex;
124
+ padding: 6px 12px;
125
+ align-items: center;
126
+ gap: 8px;
127
+ text-decoration: none;
128
+ transition: box-shadow 0.3s;
129
+
130
+ &:hover {
131
+ box-shadow: var(--shadow);
132
+ }
133
+ .button-icon {
134
+ height: 18px;
135
+ width: 18px;
136
+ }
137
+ }
138
+
139
+ @media (max-width: 1024px) {
140
+ margin-top: 20px;
141
+ flex-wrap: wrap;
142
+ justify-content: center;
143
+
144
+ li {
145
+ flex: 1 1 calc(50% - 8px);
146
+ }
147
+
148
+ a {
149
+ width: 100%;
150
+ justify-content: center;
151
+ box-sizing: border-box;
152
+ }
153
+ }
154
+ }
155
+
156
+ #spacer {
157
+ height: 88px;
158
+ border-top: 1px solid var(--border);
159
+ @media (max-width: 1024px) {
160
+ height: 48px;
161
+ }
162
+ }
163
+
164
+ .ticks {
165
+ position: relative;
166
+ width: 100%;
167
+
168
+ &::before,
169
+ &::after {
170
+ content: '';
171
+ position: absolute;
172
+ top: -4.5px;
173
+ border: 5px solid transparent;
174
+ }
175
+
176
+ &::before {
177
+ left: 0;
178
+ border-left-color: var(--border);
179
+ }
180
+ &::after {
181
+ right: 0;
182
+ border-right-color: var(--border);
183
+ }
184
+ }
package/src/App.tsx ADDED
@@ -0,0 +1,39 @@
1
+ import { NumberInput } from './NumberInput';
2
+ import { useState } from 'react';
3
+
4
+ function App() {
5
+ const [value, setValue] = useState<string>('42');
6
+
7
+ function onChangeValue(value: string) {
8
+ setValue(value);
9
+ // Handle value change logic here
10
+ }
11
+ const defaultValue = 10;
12
+ const label = 'Centration';
13
+ const errorMessage = {
14
+ negative: 'errorMessage.mustBePositive',
15
+ notNull: 'errorMessage.mustNotBeZero',
16
+ tooLarge: 'errorMessage.mustNotBeGreaterThan40',
17
+ largerThanSH: 'errorMessage.mustNotBeGreaterThanSH',
18
+ };
19
+
20
+ return (
21
+ <>
22
+ <section id="center">
23
+ <NumberInput
24
+ value={value}
25
+ onChange={onChangeValue}
26
+ label={label}
27
+ defaultValue={defaultValue.toString()}
28
+ errorMessage={errorMessage}
29
+ dataTestid={`number-input`}
30
+ />
31
+
32
+ <div className="ticks"></div>
33
+ <section id="spacer"></section>
34
+ </section>
35
+ </>
36
+ );
37
+ }
38
+
39
+ export default App;
@@ -0,0 +1,123 @@
1
+ import { TextField } from '@mui/material';
2
+ import {
3
+ useState,
4
+ useRef,
5
+ useEffect,
6
+ useCallback,
7
+ type ChangeEvent,
8
+ } from 'react';
9
+
10
+ export function NumberInput(props: {
11
+ value: string;
12
+ onChange: (value: string) => void;
13
+ label: string;
14
+ defaultValue?: string;
15
+ sh?: number;
16
+ errorMessage?: {
17
+ negative: string;
18
+ notNull: string;
19
+ tooLarge: string;
20
+ largerThanSH: string;
21
+ };
22
+ dataTestid: string;
23
+ readonly?: boolean;
24
+ }) {
25
+ const jsx = 'NumberInput';
26
+
27
+ const [error, setError] = useState<string>('');
28
+ const inputRef = useRef<HTMLInputElement>(null);
29
+
30
+ const checkValue = useCallback(
31
+ (value: string) => {
32
+ const parsedValue = parseFloat(value);
33
+ if (parsedValue < 0) {
34
+ setError(props.errorMessage?.negative || 'Number must be\npositive');
35
+ } else if (parsedValue === 0) {
36
+ setError(props.errorMessage?.notNull || 'Number must not be zero');
37
+ } else if (props.sh !== undefined && parsedValue > props.sh) {
38
+ setError(
39
+ props.errorMessage?.largerThanSH ||
40
+ 'must not be greater than\nthe Box height',
41
+ );
42
+ } else if (parsedValue > 40) {
43
+ setError(
44
+ props.errorMessage?.tooLarge || 'Number must not be\ngreater than 40',
45
+ );
46
+ } else {
47
+ setError('');
48
+ }
49
+ },
50
+ [props.errorMessage, props.sh],
51
+ );
52
+
53
+ // Validate value from the beginning and on prop changes
54
+ useEffect(() => {
55
+ checkValue(props.value);
56
+ }, [props.value, props.errorMessage, props.sh, checkValue]);
57
+
58
+ // Listen for external changes to the input value
59
+ useEffect(() => {
60
+ const inputElement = inputRef.current;
61
+ if (!inputElement) return;
62
+
63
+ const handleExternalChange = (event: Event) => {
64
+ const target = event.target as HTMLInputElement;
65
+ if (target && target.value !== props.value) {
66
+ // Trigger validation and update parent state
67
+ const inputValue = target.value;
68
+ checkValue(inputValue);
69
+ props.onChange(inputValue);
70
+ }
71
+ };
72
+
73
+ // Listen for input events (triggered by external dispatchEvent)
74
+ inputElement.addEventListener('input', handleExternalChange);
75
+ inputElement.addEventListener('change', handleExternalChange);
76
+
77
+ return () => {
78
+ inputElement.removeEventListener('input', handleExternalChange);
79
+ inputElement.removeEventListener('change', handleExternalChange);
80
+ };
81
+ }, [
82
+ props.value,
83
+ props.onChange,
84
+ props.errorMessage,
85
+ props.sh,
86
+ props,
87
+ checkValue,
88
+ ]);
89
+
90
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
91
+ const inputValue = e.target.value;
92
+ checkValue(inputValue);
93
+ props.onChange(inputValue);
94
+ };
95
+
96
+ return (
97
+ <div>
98
+ <TextField
99
+ data-testid={`${jsx}.Textfield.${props.dataTestid}`}
100
+ focused
101
+ color="secondary"
102
+ label={props.label}
103
+ variant="filled"
104
+ value={props.value}
105
+ // sx={{ width: '150px' }}
106
+ slotProps={{
107
+ input: {
108
+ 'data-testid': `Centration.${props.dataTestid}`,
109
+ style: { color: 'white' },
110
+ ref: inputRef,
111
+ readOnly: props.readonly ?? false,
112
+ } as any,
113
+ formHelperText: { sx: { whiteSpace: 'pre-line' } },
114
+ }}
115
+ type="number"
116
+ onChange={handleChange}
117
+ error={!!error}
118
+ helperText={error}
119
+ // defaultValue={defaultValue}
120
+ />
121
+ </div>
122
+ );
123
+ }
package/src/index.css ADDED
@@ -0,0 +1,111 @@
1
+ :root {
2
+ --text: #6b6375;
3
+ --text-h: #08060d;
4
+ --bg: #fff;
5
+ --border: #e5e4e7;
6
+ --code-bg: #f4f3ec;
7
+ --accent: #aa3bff;
8
+ --accent-bg: rgba(170, 59, 255, 0.1);
9
+ --accent-border: rgba(170, 59, 255, 0.5);
10
+ --social-bg: rgba(244, 243, 236, 0.5);
11
+ --shadow:
12
+ rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
13
+
14
+ --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
15
+ --heading: system-ui, 'Segoe UI', Roboto, sans-serif;
16
+ --mono: ui-monospace, Consolas, monospace;
17
+
18
+ font: 18px/145% var(--sans);
19
+ letter-spacing: 0.18px;
20
+ color-scheme: light dark;
21
+ color: var(--text);
22
+ background: var(--bg);
23
+ font-synthesis: none;
24
+ text-rendering: optimizeLegibility;
25
+ -webkit-font-smoothing: antialiased;
26
+ -moz-osx-font-smoothing: grayscale;
27
+
28
+ @media (max-width: 1024px) {
29
+ font-size: 16px;
30
+ }
31
+ }
32
+
33
+ @media (prefers-color-scheme: dark) {
34
+ :root {
35
+ --text: #9ca3af;
36
+ --text-h: #f3f4f6;
37
+ --bg: #16171d;
38
+ --border: #2e303a;
39
+ --code-bg: #1f2028;
40
+ --accent: #c084fc;
41
+ --accent-bg: rgba(192, 132, 252, 0.15);
42
+ --accent-border: rgba(192, 132, 252, 0.5);
43
+ --social-bg: rgba(47, 48, 58, 0.5);
44
+ --shadow:
45
+ rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
46
+ }
47
+
48
+ #social .button-icon {
49
+ filter: invert(1) brightness(2);
50
+ }
51
+ }
52
+
53
+ #root {
54
+ width: 1126px;
55
+ max-width: 100%;
56
+ margin: 0 auto;
57
+ text-align: center;
58
+ border-inline: 1px solid var(--border);
59
+ min-height: 100svh;
60
+ display: flex;
61
+ flex-direction: column;
62
+ box-sizing: border-box;
63
+ }
64
+
65
+ body {
66
+ margin: 0;
67
+ }
68
+
69
+ h1,
70
+ h2 {
71
+ font-family: var(--heading);
72
+ font-weight: 500;
73
+ color: var(--text-h);
74
+ }
75
+
76
+ h1 {
77
+ font-size: 56px;
78
+ letter-spacing: -1.68px;
79
+ margin: 32px 0;
80
+ @media (max-width: 1024px) {
81
+ font-size: 36px;
82
+ margin: 20px 0;
83
+ }
84
+ }
85
+ h2 {
86
+ font-size: 24px;
87
+ line-height: 118%;
88
+ letter-spacing: -0.24px;
89
+ margin: 0 0 8px;
90
+ @media (max-width: 1024px) {
91
+ font-size: 20px;
92
+ }
93
+ }
94
+ p {
95
+ margin: 0;
96
+ }
97
+
98
+ code,
99
+ .counter {
100
+ font-family: var(--mono);
101
+ display: inline-flex;
102
+ border-radius: 4px;
103
+ color: var(--text-h);
104
+ }
105
+
106
+ code {
107
+ font-size: 15px;
108
+ line-height: 135%;
109
+ padding: 4px 8px;
110
+ background: var(--code-bg);
111
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { NumberInput } from './NumberInput';
package/src/main.tsx ADDED
@@ -0,0 +1,9 @@
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import App from './App';
4
+
5
+ createRoot(document.getElementById('root')!).render(
6
+ <StrictMode>
7
+ <App />
8
+ </StrictMode>,
9
+ );
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "dist",
4
+ "rootDir": "./src",
5
+ "declaration": true,
6
+ "declarationDir": "./dist",
7
+ "module": "ESNext",
8
+ "target": "ESNext",
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "inlineSources": true,
12
+ "jsx": "react-jsx",
13
+ "moduleResolution": "bundler",
14
+ "esModuleInterop": true,
15
+ "skipLibCheck": true,
16
+ "strict": true,
17
+ "types": ["node"]
18
+ },
19
+ "include": ["src/**/*"],
20
+ "exclude": ["node_modules"]
21
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import dts from 'vite-plugin-dts';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ // https://vite.dev/config/
7
+ export default defineConfig({
8
+ plugins: [
9
+ react(),
10
+ dts({ include: ['src'], exclude: ['src/App.tsx', 'src/main.tsx'] }),
11
+ ],
12
+ build: {
13
+ lib: {
14
+ entry: fileURLToPath(new URL('./src/index.ts', import.meta.url)),
15
+ name: 'FrameTheme',
16
+ fileName: () => 'frame.theme.js',
17
+ formats: ['es'],
18
+ },
19
+ rollupOptions: {
20
+ external: [
21
+ 'react',
22
+ 'react-dom',
23
+ 'react/jsx-runtime',
24
+ '@mui/material',
25
+ '@emotion/react',
26
+ '@emotion/styled',
27
+ 'xstate',
28
+ '@xstate/react',
29
+ ],
30
+ output: {
31
+ globals: {
32
+ react: 'React',
33
+ 'react-dom': 'ReactDOM',
34
+ },
35
+ },
36
+ },
37
+ },
38
+ });