@sublime-ui/library 0.1.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/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/components/AppBar/AppBar.d.ts +6 -0
- package/dist/components/AppBar/AppBar.js +55 -0
- package/dist/components/AppBar/AppBar.types.d.ts +11 -0
- package/dist/components/AppBar/AppBar.types.js +0 -0
- package/dist/components/AppBar/index.d.ts +3 -0
- package/dist/components/AppBar/index.js +4 -0
- package/dist/components/Avatar/Avatar.d.ts +7 -0
- package/dist/components/Avatar/Avatar.js +30 -0
- package/dist/components/Avatar/Avatar.types.d.ts +12 -0
- package/dist/components/Avatar/Avatar.types.js +0 -0
- package/dist/components/Avatar/index.d.ts +4 -0
- package/dist/components/Avatar/index.js +4 -0
- package/dist/components/Badge/Badge.d.ts +7 -0
- package/dist/components/Badge/Badge.js +75 -0
- package/dist/components/Badge/Badge.types.d.ts +12 -0
- package/dist/components/Badge/Badge.types.js +0 -0
- package/dist/components/Badge/index.d.ts +4 -0
- package/dist/components/Badge/index.js +4 -0
- package/dist/components/Banner/Banner.d.ts +7 -0
- package/dist/components/Banner/Banner.js +68 -0
- package/dist/components/Banner/Banner.types.d.ts +13 -0
- package/dist/components/Banner/Banner.types.js +0 -0
- package/dist/components/Banner/index.d.ts +4 -0
- package/dist/components/Banner/index.js +4 -0
- package/dist/components/BottomNav/BottomNav.d.ts +7 -0
- package/dist/components/BottomNav/BottomNav.js +9 -0
- package/dist/components/BottomNav/BottomNav.types.d.ts +10 -0
- package/dist/components/BottomNav/BottomNav.types.js +0 -0
- package/dist/components/BottomNav/index.d.ts +3 -0
- package/dist/components/BottomNav/index.js +4 -0
- package/dist/components/Button/Button.d.ts +7 -0
- package/dist/components/Button/Button.js +42 -0
- package/dist/components/Button/Button.types.d.ts +17 -0
- package/dist/components/Button/Button.types.js +0 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/Button/index.js +4 -0
- package/dist/components/Card/Card.d.ts +6 -0
- package/dist/components/Card/Card.js +26 -0
- package/dist/components/Card/Card.types.d.ts +10 -0
- package/dist/components/Card/Card.types.js +0 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/Card/index.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +7 -0
- package/dist/components/Checkbox/Checkbox.js +34 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +17 -0
- package/dist/components/Checkbox/Checkbox.types.js +0 -0
- package/dist/components/Checkbox/index.d.ts +4 -0
- package/dist/components/Checkbox/index.js +4 -0
- package/dist/components/Dialog/Dialog.d.ts +6 -0
- package/dist/components/Dialog/Dialog.js +51 -0
- package/dist/components/Dialog/Dialog.types.d.ts +12 -0
- package/dist/components/Dialog/Dialog.types.js +0 -0
- package/dist/components/Dialog/index.d.ts +3 -0
- package/dist/components/Dialog/index.js +4 -0
- package/dist/components/Divider/Divider.d.ts +6 -0
- package/dist/components/Divider/Divider.js +19 -0
- package/dist/components/Divider/Divider.types.d.ts +7 -0
- package/dist/components/Divider/Divider.types.js +0 -0
- package/dist/components/Divider/index.d.ts +3 -0
- package/dist/components/Divider/index.js +4 -0
- package/dist/components/Drawer/Drawer.d.ts +8 -0
- package/dist/components/Drawer/Drawer.js +9 -0
- package/dist/components/Drawer/Drawer.types.d.ts +13 -0
- package/dist/components/Drawer/Drawer.types.js +0 -0
- package/dist/components/Drawer/index.d.ts +4 -0
- package/dist/components/Drawer/index.js +4 -0
- package/dist/components/Fab/Fab.d.ts +7 -0
- package/dist/components/Fab/Fab.js +33 -0
- package/dist/components/Fab/Fab.types.d.ts +11 -0
- package/dist/components/Fab/Fab.types.js +0 -0
- package/dist/components/Fab/index.d.ts +4 -0
- package/dist/components/Fab/index.js +4 -0
- package/dist/components/GlassAppBar/GlassAppBar.d.ts +6 -0
- package/dist/components/GlassAppBar/GlassAppBar.js +57 -0
- package/dist/components/GlassAppBar/GlassAppBar.types.d.ts +12 -0
- package/dist/components/GlassAppBar/GlassAppBar.types.js +0 -0
- package/dist/components/GlassAppBar/index.d.ts +3 -0
- package/dist/components/GlassAppBar/index.js +4 -0
- package/dist/components/Icon/Icon.d.ts +8 -0
- package/dist/components/Icon/Icon.js +46 -0
- package/dist/components/Icon/Icon.types.d.ts +14 -0
- package/dist/components/Icon/Icon.types.js +0 -0
- package/dist/components/Icon/index.d.ts +5 -0
- package/dist/components/Icon/index.js +4 -0
- package/dist/components/Input/Input.d.ts +6 -0
- package/dist/components/Input/Input.js +43 -0
- package/dist/components/Input/Input.types.d.ts +13 -0
- package/dist/components/Input/Input.types.js +0 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Input/index.js +4 -0
- package/dist/components/Select/Select.d.ts +6 -0
- package/dist/components/Select/Select.js +50 -0
- package/dist/components/Select/Select.types.d.ts +15 -0
- package/dist/components/Select/Select.types.js +0 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/Select/index.js +4 -0
- package/dist/components/Spinner/Spinner.d.ts +7 -0
- package/dist/components/Spinner/Spinner.js +35 -0
- package/dist/components/Spinner/Spinner.types.d.ts +9 -0
- package/dist/components/Spinner/Spinner.types.js +0 -0
- package/dist/components/Spinner/index.d.ts +4 -0
- package/dist/components/Spinner/index.js +4 -0
- package/dist/components/Surface/Surface.d.ts +6 -0
- package/dist/components/Surface/Surface.js +29 -0
- package/dist/components/Surface/Surface.types.d.ts +11 -0
- package/dist/components/Surface/Surface.types.js +0 -0
- package/dist/components/Surface/index.d.ts +3 -0
- package/dist/components/Surface/index.js +4 -0
- package/dist/components/Switch/Switch.d.ts +7 -0
- package/dist/components/Switch/Switch.js +34 -0
- package/dist/components/Switch/Switch.types.d.ts +17 -0
- package/dist/components/Switch/Switch.types.js +0 -0
- package/dist/components/Switch/index.d.ts +4 -0
- package/dist/components/Switch/index.js +4 -0
- package/dist/components/Text/Text.d.ts +7 -0
- package/dist/components/Text/Text.js +34 -0
- package/dist/components/Text/Text.types.d.ts +13 -0
- package/dist/components/Text/Text.types.js +0 -0
- package/dist/components/Text/index.d.ts +4 -0
- package/dist/components/Text/index.js +4 -0
- package/dist/components/Tooltip/Tooltip.d.ts +6 -0
- package/dist/components/Tooltip/Tooltip.js +8 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +11 -0
- package/dist/components/Tooltip/Tooltip.types.js +0 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/components/Tooltip/index.js +4 -0
- package/dist/components/common.d.ts +11 -0
- package/dist/components/common.js +0 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +54 -0
- package/dist/notifications/NotificationContext.d.ts +33 -0
- package/dist/notifications/NotificationContext.js +34 -0
- package/dist/notifications/NotificationHost.d.ts +5 -0
- package/dist/notifications/NotificationHost.js +22 -0
- package/dist/notifications/useNotify.d.ts +13 -0
- package/dist/notifications/useNotify.js +19 -0
- package/dist/provider/SublimeProvider.d.ts +12 -0
- package/dist/provider/SublimeProvider.js +23 -0
- package/dist/provider/TokenContext.d.ts +14 -0
- package/dist/provider/TokenContext.js +5 -0
- package/dist/provider/resolveTokens.d.ts +7 -0
- package/dist/provider/resolveTokens.js +13 -0
- package/dist/provider/useTokens.d.ts +7 -0
- package/dist/provider/useTokens.js +12 -0
- package/dist/tokens/generateThemes.d.ts +10 -0
- package/dist/tokens/generateThemes.js +44 -0
- package/dist/tokens/tokens.d.ts +74 -0
- package/dist/tokens/tokens.js +78 -0
- package/package.json +53 -0
- package/src/components/AppBar/AppBar.native.tsx +28 -0
- package/src/components/AppBar/AppBar.tsx +51 -0
- package/src/components/AppBar/AppBar.types.ts +9 -0
- package/src/components/AppBar/index.ts +2 -0
- package/src/components/Avatar/Avatar.native.tsx +38 -0
- package/src/components/Avatar/Avatar.tsx +38 -0
- package/src/components/Avatar/Avatar.types.ts +10 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Badge/Badge.native.tsx +97 -0
- package/src/components/Badge/Badge.tsx +89 -0
- package/src/components/Badge/Badge.types.ts +11 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Banner/Banner.native.tsx +89 -0
- package/src/components/Banner/Banner.tsx +78 -0
- package/src/components/Banner/Banner.types.ts +11 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/BottomNav/BottomNav.native.tsx +87 -0
- package/src/components/BottomNav/BottomNav.tsx +9 -0
- package/src/components/BottomNav/BottomNav.types.ts +8 -0
- package/src/components/BottomNav/index.ts +2 -0
- package/src/components/Button/Button.native.tsx +27 -0
- package/src/components/Button/Button.tsx +37 -0
- package/src/components/Button/Button.types.ts +17 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Card/Card.native.tsx +24 -0
- package/src/components/Card/Card.tsx +30 -0
- package/src/components/Card/Card.types.ts +8 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.native.tsx +58 -0
- package/src/components/Checkbox/Checkbox.tsx +35 -0
- package/src/components/Checkbox/Checkbox.types.ts +15 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Dialog/Dialog.native.tsx +28 -0
- package/src/components/Dialog/Dialog.tsx +49 -0
- package/src/components/Dialog/Dialog.types.ts +10 -0
- package/src/components/Dialog/index.ts +2 -0
- package/src/components/Divider/Divider.native.tsx +30 -0
- package/src/components/Divider/Divider.tsx +16 -0
- package/src/components/Divider/Divider.types.ts +5 -0
- package/src/components/Divider/index.ts +2 -0
- package/src/components/Drawer/Drawer.native.tsx +113 -0
- package/src/components/Drawer/Drawer.tsx +9 -0
- package/src/components/Drawer/Drawer.types.ts +11 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Fab/Fab.native.tsx +41 -0
- package/src/components/Fab/Fab.tsx +36 -0
- package/src/components/Fab/Fab.types.ts +9 -0
- package/src/components/Fab/index.ts +2 -0
- package/src/components/GlassAppBar/GlassAppBar.native.tsx +29 -0
- package/src/components/GlassAppBar/GlassAppBar.tsx +53 -0
- package/src/components/GlassAppBar/GlassAppBar.types.ts +10 -0
- package/src/components/GlassAppBar/index.ts +2 -0
- package/src/components/Icon/Icon.native.tsx +39 -0
- package/src/components/Icon/Icon.tsx +57 -0
- package/src/components/Icon/Icon.types.ts +13 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Input/Input.native.tsx +34 -0
- package/src/components/Input/Input.tsx +33 -0
- package/src/components/Input/Input.types.ts +11 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Select/Select.native.tsx +63 -0
- package/src/components/Select/Select.tsx +48 -0
- package/src/components/Select/Select.types.ts +14 -0
- package/src/components/Select/index.ts +2 -0
- package/src/components/Spinner/Spinner.native.tsx +38 -0
- package/src/components/Spinner/Spinner.tsx +37 -0
- package/src/components/Spinner/Spinner.types.ts +7 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Surface/Surface.native.tsx +32 -0
- package/src/components/Surface/Surface.tsx +31 -0
- package/src/components/Surface/Surface.types.ts +10 -0
- package/src/components/Surface/index.ts +2 -0
- package/src/components/Switch/Switch.native.tsx +58 -0
- package/src/components/Switch/Switch.tsx +35 -0
- package/src/components/Switch/Switch.types.ts +15 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Text/Text.native.tsx +31 -0
- package/src/components/Text/Text.tsx +34 -0
- package/src/components/Text/Text.types.ts +12 -0
- package/src/components/Text/index.ts +2 -0
- package/src/components/Tooltip/Tooltip.native.tsx +6 -0
- package/src/components/Tooltip/Tooltip.tsx +10 -0
- package/src/components/Tooltip/Tooltip.types.ts +9 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/common.ts +10 -0
- package/src/index.ts +33 -0
- package/src/notifications/NotificationContext.tsx +57 -0
- package/src/notifications/NotificationHost.native.tsx +20 -0
- package/src/notifications/NotificationHost.tsx +27 -0
- package/src/notifications/useNotify.ts +18 -0
- package/src/provider/SublimeProvider.native.tsx +29 -0
- package/src/provider/SublimeProvider.tsx +30 -0
- package/src/provider/TokenContext.ts +13 -0
- package/src/provider/resolveTokens.ts +16 -0
- package/src/provider/useTokens.ts +10 -0
- package/src/test-utils/renderWeb.tsx +8 -0
- package/src/tokens/generateThemes.ts +49 -0
- package/src/tokens/tokens.ts +71 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Snackbar } from 'react-native-paper';
|
|
2
|
+
import { useNotificationQueue } from './NotificationContext.js';
|
|
3
|
+
|
|
4
|
+
export function NotificationHost() {
|
|
5
|
+
const { queue, dismiss } = useNotificationQueue();
|
|
6
|
+
const current = queue[0];
|
|
7
|
+
if (!current) return null;
|
|
8
|
+
return (
|
|
9
|
+
<Snackbar
|
|
10
|
+
visible
|
|
11
|
+
onDismiss={() => dismiss(current.id)}
|
|
12
|
+
duration={current.duration}
|
|
13
|
+
{...(current.action
|
|
14
|
+
? { action: { label: current.action.label, onPress: current.action.onPress } }
|
|
15
|
+
: {})}
|
|
16
|
+
>
|
|
17
|
+
{current.message}
|
|
18
|
+
</Snackbar>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Snackbar, Alert } from '@mui/material';
|
|
2
|
+
import { useNotificationQueue, type Tone } from './NotificationContext.js';
|
|
3
|
+
|
|
4
|
+
const severityOf = (tone: Tone): 'success' | 'error' | 'warning' | 'info' =>
|
|
5
|
+
tone === 'neutral' ? 'info' : tone;
|
|
6
|
+
|
|
7
|
+
export function NotificationHost() {
|
|
8
|
+
const { queue, dismiss } = useNotificationQueue();
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
{queue.map((n, i) => (
|
|
12
|
+
<Snackbar
|
|
13
|
+
key={n.id}
|
|
14
|
+
open
|
|
15
|
+
autoHideDuration={n.duration}
|
|
16
|
+
onClose={() => dismiss(n.id)}
|
|
17
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
18
|
+
style={{ bottom: 16 + i * 64 }}
|
|
19
|
+
>
|
|
20
|
+
<Alert severity={severityOf(n.tone)} onClose={() => dismiss(n.id)} variant="filled">
|
|
21
|
+
{n.message}
|
|
22
|
+
</Alert>
|
|
23
|
+
</Snackbar>
|
|
24
|
+
))}
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useNotificationQueue, type NotifyOptions, type Tone } from './NotificationContext.js';
|
|
3
|
+
|
|
4
|
+
export function useNotify() {
|
|
5
|
+
const { notify, dismiss } = useNotificationQueue();
|
|
6
|
+
return useMemo(() => {
|
|
7
|
+
const toned = (tone: Tone) => (message: string, opts?: NotifyOptions) =>
|
|
8
|
+
notify(message, { ...opts, tone });
|
|
9
|
+
return {
|
|
10
|
+
notify,
|
|
11
|
+
dismiss,
|
|
12
|
+
success: toned('success'),
|
|
13
|
+
error: toned('error'),
|
|
14
|
+
warning: toned('warning'),
|
|
15
|
+
info: toned('info'),
|
|
16
|
+
};
|
|
17
|
+
}, [notify, dismiss]);
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ReactNode, useMemo } from 'react';
|
|
2
|
+
import { PaperProvider } from 'react-native-paper';
|
|
3
|
+
import { generateThemes } from '../tokens/generateThemes.js';
|
|
4
|
+
import { defaultTokens, type SublimeTokens } from '../tokens/tokens.js';
|
|
5
|
+
import { TokenContext } from './TokenContext.js';
|
|
6
|
+
import { resolveTokens } from './resolveTokens.js';
|
|
7
|
+
import { NotificationProvider } from '../notifications/NotificationContext.js';
|
|
8
|
+
import { NotificationHost } from '../notifications/NotificationHost.native.js';
|
|
9
|
+
|
|
10
|
+
export interface SublimeProviderProps {
|
|
11
|
+
mode?: 'light' | 'dark';
|
|
12
|
+
tokens?: SublimeTokens;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function SublimeProvider({ mode = 'light', tokens = defaultTokens, children }: SublimeProviderProps) {
|
|
17
|
+
const { paperTheme } = useMemo(() => generateThemes(tokens, mode), [tokens, mode]);
|
|
18
|
+
const resolved = useMemo(() => resolveTokens(tokens, mode), [tokens, mode]);
|
|
19
|
+
return (
|
|
20
|
+
<PaperProvider theme={paperTheme}>
|
|
21
|
+
<TokenContext.Provider value={resolved}>
|
|
22
|
+
<NotificationProvider>
|
|
23
|
+
{children}
|
|
24
|
+
<NotificationHost />
|
|
25
|
+
</NotificationProvider>
|
|
26
|
+
</TokenContext.Provider>
|
|
27
|
+
</PaperProvider>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ReactNode, useMemo } from 'react';
|
|
2
|
+
import { ThemeProvider, CssBaseline } from '@mui/material';
|
|
3
|
+
import { generateThemes } from '../tokens/generateThemes.js';
|
|
4
|
+
import { defaultTokens, type SublimeTokens } from '../tokens/tokens.js';
|
|
5
|
+
import { TokenContext } from './TokenContext.js';
|
|
6
|
+
import { resolveTokens } from './resolveTokens.js';
|
|
7
|
+
import { NotificationProvider } from '../notifications/NotificationContext.js';
|
|
8
|
+
import { NotificationHost } from '../notifications/NotificationHost.js';
|
|
9
|
+
|
|
10
|
+
export interface SublimeProviderProps {
|
|
11
|
+
mode?: 'light' | 'dark';
|
|
12
|
+
tokens?: SublimeTokens;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function SublimeProvider({ mode = 'light', tokens = defaultTokens, children }: SublimeProviderProps) {
|
|
17
|
+
const { muiTheme } = useMemo(() => generateThemes(tokens, mode), [tokens, mode]);
|
|
18
|
+
const resolved = useMemo(() => resolveTokens(tokens, mode), [tokens, mode]);
|
|
19
|
+
return (
|
|
20
|
+
<ThemeProvider theme={muiTheme}>
|
|
21
|
+
<CssBaseline />
|
|
22
|
+
<TokenContext.Provider value={resolved}>
|
|
23
|
+
<NotificationProvider>
|
|
24
|
+
{children}
|
|
25
|
+
<NotificationHost />
|
|
26
|
+
</NotificationProvider>
|
|
27
|
+
</TokenContext.Provider>
|
|
28
|
+
</ThemeProvider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import type { ColorTokens, SublimeTokens } from '../tokens/tokens.js';
|
|
3
|
+
|
|
4
|
+
export interface ResolvedTokens {
|
|
5
|
+
color: ColorTokens;
|
|
6
|
+
radii: SublimeTokens['radii'];
|
|
7
|
+
shadows: SublimeTokens['shadows'];
|
|
8
|
+
spacing: SublimeTokens['spacing'];
|
|
9
|
+
typography: SublimeTokens['typography'];
|
|
10
|
+
mode: 'light' | 'dark';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const TokenContext = createContext<ResolvedTokens | null>(null);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SublimeTokens } from '../tokens/tokens.js';
|
|
2
|
+
import type { ResolvedTokens } from './TokenContext.js';
|
|
3
|
+
|
|
4
|
+
export function resolveTokens(
|
|
5
|
+
tokens: SublimeTokens,
|
|
6
|
+
mode: 'light' | 'dark',
|
|
7
|
+
): ResolvedTokens {
|
|
8
|
+
return {
|
|
9
|
+
color: tokens.color[mode],
|
|
10
|
+
radii: tokens.radii,
|
|
11
|
+
shadows: tokens.shadows,
|
|
12
|
+
spacing: tokens.spacing,
|
|
13
|
+
typography: tokens.typography,
|
|
14
|
+
mode,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { TokenContext, type ResolvedTokens } from './TokenContext.js';
|
|
3
|
+
|
|
4
|
+
export function useTokens(): ResolvedTokens {
|
|
5
|
+
const tokens = useContext(TokenContext);
|
|
6
|
+
if (tokens === null) {
|
|
7
|
+
throw new Error('useTokens must be used within a <SublimeProvider>.');
|
|
8
|
+
}
|
|
9
|
+
return tokens;
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createElement, type ReactElement } from 'react';
|
|
2
|
+
import { render, type RenderResult } from '@testing-library/react';
|
|
3
|
+
import { SublimeProvider } from '../provider/SublimeProvider.js';
|
|
4
|
+
|
|
5
|
+
/** Renders a web component tree inside SublimeProvider (light mode). */
|
|
6
|
+
export function renderWeb(ui: ReactElement): RenderResult {
|
|
7
|
+
return render(createElement(SublimeProvider, { mode: 'light', children: ui }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { MD3LightTheme, MD3DarkTheme, type MD3Theme } from 'react-native-paper';
|
|
2
|
+
import { createTheme, type Theme } from '@mui/material';
|
|
3
|
+
import type { SublimeTokens } from './tokens.js';
|
|
4
|
+
|
|
5
|
+
export function generateThemes(
|
|
6
|
+
tokens: SublimeTokens,
|
|
7
|
+
mode: 'light' | 'dark',
|
|
8
|
+
): { paperTheme: MD3Theme; muiTheme: Theme } {
|
|
9
|
+
const c = tokens.color[mode];
|
|
10
|
+
const base = mode === 'dark' ? MD3DarkTheme : MD3LightTheme;
|
|
11
|
+
|
|
12
|
+
const paperTheme: MD3Theme = {
|
|
13
|
+
...base,
|
|
14
|
+
roundness: tokens.radii.md,
|
|
15
|
+
colors: {
|
|
16
|
+
...base.colors,
|
|
17
|
+
primary: c.primary,
|
|
18
|
+
onPrimary: c.primaryFg,
|
|
19
|
+
secondary: c.secondary,
|
|
20
|
+
onSecondary: c.secondaryFg,
|
|
21
|
+
error: c.danger,
|
|
22
|
+
background: c.background,
|
|
23
|
+
onBackground: c.foreground,
|
|
24
|
+
surface: c.surface,
|
|
25
|
+
onSurface: c.foreground,
|
|
26
|
+
outline: c.surfaceBorder,
|
|
27
|
+
outlineVariant: c.divider,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const muiTheme = createTheme({
|
|
32
|
+
palette: {
|
|
33
|
+
mode,
|
|
34
|
+
primary: { main: c.primary, contrastText: c.primaryFg },
|
|
35
|
+
secondary: { main: c.secondary, contrastText: c.secondaryFg },
|
|
36
|
+
success: { main: c.success },
|
|
37
|
+
warning: { main: c.warning },
|
|
38
|
+
error: { main: c.danger },
|
|
39
|
+
info: { main: c.info },
|
|
40
|
+
background: { default: c.background, paper: c.surface },
|
|
41
|
+
text: { primary: c.foreground, secondary: c.mutedFg },
|
|
42
|
+
divider: c.divider,
|
|
43
|
+
},
|
|
44
|
+
shape: { borderRadius: tokens.radii.md },
|
|
45
|
+
typography: { fontFamily: tokens.typography.family },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return { paperTheme, muiTheme };
|
|
49
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export interface ColorTokens {
|
|
2
|
+
primary: string; primaryFg: string;
|
|
3
|
+
secondary: string; secondaryFg: string;
|
|
4
|
+
success: string; warning: string; danger: string; info: string;
|
|
5
|
+
background: string; foreground: string; mutedFg: string;
|
|
6
|
+
surface: string; surfaceBorder: string; surfaceHover: string;
|
|
7
|
+
glassBg: string; glassBorder: string; divider: string; ring: string;
|
|
8
|
+
primarySoftBg: string; primarySoftFg: string;
|
|
9
|
+
successSoftBg: string; successSoftFg: string;
|
|
10
|
+
warningSoftBg: string; warningSoftFg: string;
|
|
11
|
+
dangerSoftBg: string; dangerSoftFg: string;
|
|
12
|
+
infoSoftBg: string; infoSoftFg: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SublimeTokens {
|
|
16
|
+
color: { light: ColorTokens; dark: ColorTokens };
|
|
17
|
+
radii: { sm: number; md: number; lg: number; full: number };
|
|
18
|
+
shadows: { sm: string; md: string; lg: string };
|
|
19
|
+
spacing: { xs: number; sm: number; md: number; lg: number; xl: number };
|
|
20
|
+
typography: {
|
|
21
|
+
family: string;
|
|
22
|
+
sizes: { xs: number; sm: number; md: number; lg: number; xl: number; '2xl': number };
|
|
23
|
+
weights: { regular: number; medium: number; semibold: number; bold: number };
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const light: ColorTokens = {
|
|
28
|
+
primary: 'rgb(37,99,235)', primaryFg: 'rgb(255,255,255)',
|
|
29
|
+
secondary: 'rgb(100,116,139)', secondaryFg: 'rgb(255,255,255)',
|
|
30
|
+
success: 'rgb(22,163,74)', warning: 'rgb(217,119,6)', danger: 'rgb(220,38,38)', info: 'rgb(2,132,199)',
|
|
31
|
+
background: 'rgb(247,250,255)', foreground: 'rgb(15,23,42)', mutedFg: 'rgba(71,85,105,0.85)',
|
|
32
|
+
surface: 'rgba(243,248,255,0.90)', surfaceBorder: 'rgba(15,23,42,0.08)', surfaceHover: 'rgba(59,130,246,0.06)',
|
|
33
|
+
glassBg: 'rgba(236,244,255,0.60)', glassBorder: 'rgba(15,23,42,0.08)', divider: 'rgba(15,23,42,0.06)',
|
|
34
|
+
ring: 'rgba(59,130,246,0.45)',
|
|
35
|
+
primarySoftBg: 'rgba(59,130,246,0.08)', primarySoftFg: 'rgb(29,78,216)',
|
|
36
|
+
successSoftBg: 'rgba(34,197,94,0.10)', successSoftFg: 'rgb(21,128,61)',
|
|
37
|
+
warningSoftBg: 'rgba(245,158,11,0.12)', warningSoftFg: 'rgb(180,83,9)',
|
|
38
|
+
dangerSoftBg: 'rgba(244,63,94,0.08)', dangerSoftFg: 'rgb(190,18,60)',
|
|
39
|
+
infoSoftBg: 'rgba(14,165,233,0.10)', infoSoftFg: 'rgb(3,105,161)',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const dark: ColorTokens = {
|
|
43
|
+
primary: 'rgb(96,165,250)', primaryFg: 'rgb(8,12,20)',
|
|
44
|
+
secondary: 'rgb(148,163,184)', secondaryFg: 'rgb(8,12,20)',
|
|
45
|
+
success: 'rgb(74,222,128)', warning: 'rgb(251,191,36)', danger: 'rgb(251,113,133)', info: 'rgb(56,189,248)',
|
|
46
|
+
background: 'rgb(8,12,20)', foreground: 'rgb(245,247,251)', mutedFg: 'rgba(229,231,235,0.65)',
|
|
47
|
+
surface: 'rgba(96,165,250,0.06)', surfaceBorder: 'rgba(255,255,255,0.08)', surfaceHover: 'rgba(255,255,255,0.06)',
|
|
48
|
+
glassBg: 'rgba(96,165,250,0.05)', glassBorder: 'rgba(255,255,255,0.08)', divider: 'rgba(255,255,255,0.06)',
|
|
49
|
+
ring: 'rgba(96,165,250,0.55)',
|
|
50
|
+
primarySoftBg: 'rgba(59,130,246,0.12)', primarySoftFg: 'rgb(147,197,253)',
|
|
51
|
+
successSoftBg: 'rgba(34,197,94,0.16)', successSoftFg: 'rgb(134,239,172)',
|
|
52
|
+
warningSoftBg: 'rgba(245,158,11,0.18)', warningSoftFg: 'rgb(253,224,71)',
|
|
53
|
+
dangerSoftBg: 'rgba(244,63,94,0.18)', dangerSoftFg: 'rgb(253,164,175)',
|
|
54
|
+
infoSoftBg: 'rgba(14,165,233,0.16)', infoSoftFg: 'rgb(125,211,252)',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const defaultTokens: SublimeTokens = {
|
|
58
|
+
color: { light, dark },
|
|
59
|
+
radii: { sm: 8, md: 12, lg: 16, full: 999 },
|
|
60
|
+
shadows: {
|
|
61
|
+
sm: '0 1px 2px rgba(15,23,42,0.06)',
|
|
62
|
+
md: '0 4px 12px rgba(15,23,42,0.10)',
|
|
63
|
+
lg: '0 12px 32px rgba(15,23,42,0.16)',
|
|
64
|
+
},
|
|
65
|
+
spacing: { xs: 4, sm: 8, md: 12, lg: 16, xl: 24 },
|
|
66
|
+
typography: {
|
|
67
|
+
family: 'Inter, system-ui, sans-serif',
|
|
68
|
+
sizes: { xs: 12, sm: 14, md: 16, lg: 18, xl: 22, '2xl': 28 },
|
|
69
|
+
weights: { regular: 400, medium: 500, semibold: 600, bold: 700 },
|
|
70
|
+
},
|
|
71
|
+
};
|