@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aaron Mkandawire and Sublime UI contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @sublime-ui/library
|
|
2
|
+
|
|
3
|
+
The cross-platform design system for [Sublime UI](https://sublime-ui.github.io/sublime-ui/).
|
|
4
|
+
|
|
5
|
+
It is **tokens-first**: a single serializable `SublimeTokens` object drives both
|
|
6
|
+
the web theme (Material UI) and the mobile theme (React Native Paper), and a
|
|
7
|
+
shared set of components renders idiomatically on each platform.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { SublimeProvider } from '@sublime-ui/library';
|
|
11
|
+
import { tokens } from './theme/tokens';
|
|
12
|
+
|
|
13
|
+
export function App() {
|
|
14
|
+
return (
|
|
15
|
+
<SublimeProvider tokens={tokens}>
|
|
16
|
+
{/* navigation + screens */}
|
|
17
|
+
</SublimeProvider>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`generateThemes` turns your tokens into the per-platform theme objects, and
|
|
23
|
+
`useTokens()` makes them available anywhere.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @sublime-ui/library
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Web apps also need `@mui/material` + `@emotion/{react,styled}`; mobile apps need
|
|
32
|
+
`react-native-paper` + `react-native-safe-area-context` (declared as optional
|
|
33
|
+
peers).
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
Core components and theming:
|
|
38
|
+
**https://sublime-ui.github.io/sublime-ui/docs/library/components/overview**
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AppBar as MuiAppBar, Toolbar, Typography, IconButton, Box } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
function AppBar({ title, subtitle, onBack, actions, testID }) {
|
|
5
|
+
const tokens = useTokens();
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
MuiAppBar,
|
|
8
|
+
{
|
|
9
|
+
position: "static",
|
|
10
|
+
elevation: 0,
|
|
11
|
+
"data-testid": testID,
|
|
12
|
+
sx: {
|
|
13
|
+
backgroundColor: tokens.color.surface,
|
|
14
|
+
color: tokens.color.foreground,
|
|
15
|
+
borderBottom: `1px solid ${tokens.color.surfaceBorder}`
|
|
16
|
+
},
|
|
17
|
+
children: /* @__PURE__ */ jsxs(Toolbar, { sx: { gap: `${tokens.spacing.sm}px` }, children: [
|
|
18
|
+
onBack ? /* @__PURE__ */ jsx(
|
|
19
|
+
IconButton,
|
|
20
|
+
{
|
|
21
|
+
edge: "start",
|
|
22
|
+
"aria-label": "back",
|
|
23
|
+
onClick: onBack,
|
|
24
|
+
sx: { color: tokens.color.foreground },
|
|
25
|
+
children: /* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "\u2190" })
|
|
26
|
+
}
|
|
27
|
+
) : null,
|
|
28
|
+
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, minWidth: 0 }, children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
Typography,
|
|
31
|
+
{
|
|
32
|
+
variant: "h6",
|
|
33
|
+
noWrap: true,
|
|
34
|
+
sx: { fontWeight: tokens.typography.weights.semibold },
|
|
35
|
+
children: title
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
subtitle ? /* @__PURE__ */ jsx(
|
|
39
|
+
Typography,
|
|
40
|
+
{
|
|
41
|
+
variant: "caption",
|
|
42
|
+
noWrap: true,
|
|
43
|
+
sx: { display: "block", color: tokens.color.mutedFg },
|
|
44
|
+
children: subtitle
|
|
45
|
+
}
|
|
46
|
+
) : null
|
|
47
|
+
] }),
|
|
48
|
+
actions ?? null
|
|
49
|
+
] })
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
AppBar
|
|
55
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar as MuiAvatar } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
const pxFor = (size) => size === "sm" ? 28 : size === "lg" ? 56 : 40;
|
|
5
|
+
const initialsOf = (label) => label.trim().split(/\s+/).slice(0, 2).map((w) => w.charAt(0).toUpperCase()).join("");
|
|
6
|
+
function Avatar({ source, label, size = "md", testID }) {
|
|
7
|
+
const tokens = useTokens();
|
|
8
|
+
const dim = pxFor(size);
|
|
9
|
+
const initials = label ? initialsOf(label) : "";
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
MuiAvatar,
|
|
12
|
+
{
|
|
13
|
+
"data-testid": testID,
|
|
14
|
+
...source ? { src: source } : {},
|
|
15
|
+
...label ? { alt: label } : {},
|
|
16
|
+
sx: {
|
|
17
|
+
width: dim,
|
|
18
|
+
height: dim,
|
|
19
|
+
backgroundColor: tokens.color.primarySoftBg,
|
|
20
|
+
color: tokens.color.primarySoftFg,
|
|
21
|
+
fontWeight: tokens.typography.weights.semibold,
|
|
22
|
+
fontSize: dim * 0.4
|
|
23
|
+
},
|
|
24
|
+
children: source ? null : initials
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
Avatar
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Size } from '../common.js';
|
|
2
|
+
|
|
3
|
+
interface AvatarProps {
|
|
4
|
+
/** Image URI; when present the avatar shows the image. */
|
|
5
|
+
source?: string;
|
|
6
|
+
/** Fallback text; initials are derived from it when no source is present. */
|
|
7
|
+
label?: string;
|
|
8
|
+
size?: Size;
|
|
9
|
+
testID?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { AvatarProps };
|
|
File without changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Chip } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
const solidPair = (c, tone) => {
|
|
5
|
+
switch (tone) {
|
|
6
|
+
case "primary":
|
|
7
|
+
return { bg: c.primary, fg: c.primaryFg };
|
|
8
|
+
case "success":
|
|
9
|
+
return { bg: c.success, fg: c.primaryFg };
|
|
10
|
+
case "danger":
|
|
11
|
+
return { bg: c.danger, fg: c.primaryFg };
|
|
12
|
+
case "warning":
|
|
13
|
+
return { bg: c.warning, fg: c.primaryFg };
|
|
14
|
+
case "info":
|
|
15
|
+
return { bg: c.info, fg: c.primaryFg };
|
|
16
|
+
case "neutral":
|
|
17
|
+
default:
|
|
18
|
+
return { bg: c.secondary, fg: c.secondaryFg };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const softPair = (c, tone) => {
|
|
22
|
+
switch (tone) {
|
|
23
|
+
case "primary":
|
|
24
|
+
return { bg: c.primarySoftBg, fg: c.primarySoftFg };
|
|
25
|
+
case "success":
|
|
26
|
+
return { bg: c.successSoftBg, fg: c.successSoftFg };
|
|
27
|
+
case "danger":
|
|
28
|
+
return { bg: c.dangerSoftBg, fg: c.dangerSoftFg };
|
|
29
|
+
case "warning":
|
|
30
|
+
return { bg: c.warningSoftBg, fg: c.warningSoftFg };
|
|
31
|
+
case "info":
|
|
32
|
+
return { bg: c.infoSoftBg, fg: c.infoSoftFg };
|
|
33
|
+
case "neutral":
|
|
34
|
+
default:
|
|
35
|
+
return { bg: c.surfaceHover, fg: c.mutedFg };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const mutedPair = (c) => ({
|
|
39
|
+
bg: c.surfaceHover,
|
|
40
|
+
fg: c.mutedFg
|
|
41
|
+
});
|
|
42
|
+
const pairFor = (c, tone, variant) => {
|
|
43
|
+
if (variant === "solid") return solidPair(c, tone);
|
|
44
|
+
if (variant === "muted") return mutedPair(c);
|
|
45
|
+
return softPair(c, tone);
|
|
46
|
+
};
|
|
47
|
+
function Badge({
|
|
48
|
+
label,
|
|
49
|
+
tone = "neutral",
|
|
50
|
+
variant = "soft",
|
|
51
|
+
icon,
|
|
52
|
+
testID
|
|
53
|
+
}) {
|
|
54
|
+
const tokens = useTokens();
|
|
55
|
+
const { bg, fg } = pairFor(tokens.color, tone, variant);
|
|
56
|
+
return /* @__PURE__ */ jsx(
|
|
57
|
+
Chip,
|
|
58
|
+
{
|
|
59
|
+
size: "small",
|
|
60
|
+
label,
|
|
61
|
+
"data-testid": testID,
|
|
62
|
+
sx: {
|
|
63
|
+
backgroundColor: bg,
|
|
64
|
+
color: fg,
|
|
65
|
+
borderRadius: `${tokens.radii.full}px`,
|
|
66
|
+
fontWeight: tokens.typography.weights.medium,
|
|
67
|
+
...icon ? { "& .MuiChip-icon": { color: fg } } : {}
|
|
68
|
+
},
|
|
69
|
+
...icon ? { icon: /* @__PURE__ */ jsx("span", { className: "material-icons", "aria-hidden": true, children: icon }) } : {}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
Badge
|
|
75
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tone } from '../common.js';
|
|
2
|
+
|
|
3
|
+
type BadgeVariant = 'solid' | 'soft' | 'muted';
|
|
4
|
+
interface BadgeProps {
|
|
5
|
+
label: string;
|
|
6
|
+
tone?: Tone;
|
|
7
|
+
variant?: BadgeVariant;
|
|
8
|
+
icon?: string;
|
|
9
|
+
testID?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type { BadgeProps, BadgeVariant };
|
|
File without changes
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, AlertTitle } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
const severityFor = (tone) => {
|
|
5
|
+
switch (tone) {
|
|
6
|
+
case "success":
|
|
7
|
+
return "success";
|
|
8
|
+
case "danger":
|
|
9
|
+
return "error";
|
|
10
|
+
case "warning":
|
|
11
|
+
return "warning";
|
|
12
|
+
case "primary":
|
|
13
|
+
case "info":
|
|
14
|
+
case "neutral":
|
|
15
|
+
default:
|
|
16
|
+
return "info";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const softPair = (c, tone) => {
|
|
20
|
+
switch (tone) {
|
|
21
|
+
case "success":
|
|
22
|
+
return { bg: c.successSoftBg, fg: c.successSoftFg };
|
|
23
|
+
case "danger":
|
|
24
|
+
return { bg: c.dangerSoftBg, fg: c.dangerSoftFg };
|
|
25
|
+
case "warning":
|
|
26
|
+
return { bg: c.warningSoftBg, fg: c.warningSoftFg };
|
|
27
|
+
case "info":
|
|
28
|
+
return { bg: c.infoSoftBg, fg: c.infoSoftFg };
|
|
29
|
+
case "primary":
|
|
30
|
+
case "neutral":
|
|
31
|
+
default:
|
|
32
|
+
return { bg: c.primarySoftBg, fg: c.primarySoftFg };
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function Banner({
|
|
36
|
+
tone = "info",
|
|
37
|
+
title,
|
|
38
|
+
children,
|
|
39
|
+
onClose,
|
|
40
|
+
action,
|
|
41
|
+
testID
|
|
42
|
+
}) {
|
|
43
|
+
const tokens = useTokens();
|
|
44
|
+
const { bg, fg } = softPair(tokens.color, tone);
|
|
45
|
+
return /* @__PURE__ */ jsxs(
|
|
46
|
+
Alert,
|
|
47
|
+
{
|
|
48
|
+
severity: severityFor(tone),
|
|
49
|
+
"data-testid": testID,
|
|
50
|
+
...onClose ? { onClose } : {},
|
|
51
|
+
...action ? { action } : {},
|
|
52
|
+
sx: {
|
|
53
|
+
backgroundColor: bg,
|
|
54
|
+
color: fg,
|
|
55
|
+
borderRadius: `${tokens.radii.md}px`,
|
|
56
|
+
"& .MuiAlert-icon": { color: fg },
|
|
57
|
+
"& .MuiAlert-action": { color: fg }
|
|
58
|
+
},
|
|
59
|
+
children: [
|
|
60
|
+
title ? /* @__PURE__ */ jsx(AlertTitle, { sx: { fontWeight: tokens.typography.weights.semibold }, children: title }) : null,
|
|
61
|
+
children
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
Banner
|
|
68
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Tone } from '../common.js';
|
|
3
|
+
|
|
4
|
+
interface BannerProps {
|
|
5
|
+
tone?: Tone;
|
|
6
|
+
title?: string;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
action?: ReactNode;
|
|
10
|
+
testID?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type { BannerProps };
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ButtonProps } from './Button.types.js';
|
|
3
|
+
import '../common.js';
|
|
4
|
+
|
|
5
|
+
declare function Button({ children, onPress, variant, tone, size, disabled, loading, fullWidth, testID, }: ButtonProps): react.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { Button };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button as MuiButton, CircularProgress } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
const muiVariant = (v) => v === "solid" ? "contained" : v === "outline" ? "outlined" : "text";
|
|
5
|
+
const muiColor = (t) => t === "danger" ? "error" : t === "neutral" ? "inherit" : t;
|
|
6
|
+
function Button({
|
|
7
|
+
children,
|
|
8
|
+
onPress,
|
|
9
|
+
variant = "solid",
|
|
10
|
+
tone = "primary",
|
|
11
|
+
size = "md",
|
|
12
|
+
disabled,
|
|
13
|
+
loading,
|
|
14
|
+
fullWidth,
|
|
15
|
+
testID
|
|
16
|
+
}) {
|
|
17
|
+
const tokens = useTokens();
|
|
18
|
+
const soft = variant === "soft";
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
MuiButton,
|
|
21
|
+
{
|
|
22
|
+
variant: muiVariant(variant),
|
|
23
|
+
color: muiColor(tone),
|
|
24
|
+
size: size === "md" ? "medium" : size === "sm" ? "small" : "large",
|
|
25
|
+
disabled: Boolean(disabled || loading),
|
|
26
|
+
fullWidth: Boolean(fullWidth),
|
|
27
|
+
onClick: onPress,
|
|
28
|
+
"data-testid": testID,
|
|
29
|
+
sx: {
|
|
30
|
+
borderRadius: `${tokens.radii.md}px`,
|
|
31
|
+
textTransform: "none",
|
|
32
|
+
fontWeight: tokens.typography.weights.semibold,
|
|
33
|
+
...soft ? { backgroundColor: tokens.color.primarySoftBg, color: tokens.color.primarySoftFg, "&:hover": { backgroundColor: tokens.color.primarySoftBg } } : {}
|
|
34
|
+
},
|
|
35
|
+
startIcon: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: 16, color: "inherit" }) : void 0,
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
Button
|
|
42
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Variant, Tone, Size } from '../common.js';
|
|
3
|
+
|
|
4
|
+
interface ButtonProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
onPress?: () => void;
|
|
7
|
+
variant?: Variant;
|
|
8
|
+
tone?: Tone;
|
|
9
|
+
size?: Size;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
icon?: string;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
testID?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { type ButtonProps, Size, Tone, Variant };
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Card as MuiCard, CardActionArea } from "@mui/material";
|
|
3
|
+
import { useTokens } from "../../provider/useTokens.js";
|
|
4
|
+
function Card({ children, onPress, padded = true, testID }) {
|
|
5
|
+
const tokens = useTokens();
|
|
6
|
+
const pad = padded ? `${tokens.spacing.lg}px` : 0;
|
|
7
|
+
const body = onPress ? /* @__PURE__ */ jsx(CardActionArea, { onClick: onPress, sx: { p: pad }, children }) : children;
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
MuiCard,
|
|
10
|
+
{
|
|
11
|
+
elevation: 0,
|
|
12
|
+
"data-testid": testID,
|
|
13
|
+
sx: {
|
|
14
|
+
backgroundColor: tokens.color.glassBg,
|
|
15
|
+
border: `1px solid ${tokens.color.glassBorder}`,
|
|
16
|
+
borderRadius: `${tokens.radii.lg}px`,
|
|
17
|
+
boxShadow: tokens.shadows.sm,
|
|
18
|
+
...onPress ? {} : { p: pad }
|
|
19
|
+
},
|
|
20
|
+
children: body
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
Card
|
|
26
|
+
};
|
|
File without changes
|