@vvedantb/ui 0.75.5 → 0.76.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/dist/src/ui/ui-config.js +36 -8
- package/dist/tokens/src/css/surface-flat.css +30 -0
- package/dist/tokens/src/tokens.css +1 -0
- package/package.json +1 -1
- package/src/client.ts +1 -1
- package/src/index.ts +1 -1
- package/src/ui/ui-config.tsx +14 -1
- package/tokens/src/css/surface-flat.css +30 -0
- package/tokens/src/tokens.css +1 -0
package/dist/src/ui/ui-config.js
CHANGED
|
@@ -4,24 +4,52 @@ import { cn } from "../utils/cn.js";
|
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
const UiConfigContext = /*#__PURE__*/React.createContext({});
|
|
6
6
|
function UiConfigProvider(t0) {
|
|
7
|
-
const $ = _c(
|
|
7
|
+
const $ = _c(6);
|
|
8
8
|
const {
|
|
9
9
|
config,
|
|
10
|
+
surface,
|
|
10
11
|
children
|
|
11
12
|
} = t0;
|
|
12
13
|
let t1;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
let t2;
|
|
15
|
+
if ($[0] !== surface) {
|
|
16
|
+
t1 = () => {
|
|
17
|
+
if (!surface || typeof document === "undefined") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const root = document.documentElement;
|
|
21
|
+
const previous = root.getAttribute("data-surface");
|
|
22
|
+
root.setAttribute("data-surface", surface);
|
|
23
|
+
return () => {
|
|
24
|
+
if (previous === null) {
|
|
25
|
+
root.removeAttribute("data-surface");
|
|
26
|
+
} else {
|
|
27
|
+
root.setAttribute("data-surface", previous);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
t2 = [surface];
|
|
32
|
+
$[0] = surface;
|
|
33
|
+
$[1] = t1;
|
|
34
|
+
$[2] = t2;
|
|
35
|
+
} else {
|
|
36
|
+
t1 = $[1];
|
|
37
|
+
t2 = $[2];
|
|
38
|
+
}
|
|
39
|
+
React.useLayoutEffect(t1, t2);
|
|
40
|
+
let t3;
|
|
41
|
+
if ($[3] !== children || $[4] !== config) {
|
|
42
|
+
t3 = /*#__PURE__*/_jsx(UiConfigContext.Provider, {
|
|
15
43
|
value: config,
|
|
16
44
|
children: children
|
|
17
45
|
});
|
|
18
|
-
$[
|
|
19
|
-
$[
|
|
20
|
-
$[
|
|
46
|
+
$[3] = children;
|
|
47
|
+
$[4] = config;
|
|
48
|
+
$[5] = t3;
|
|
21
49
|
} else {
|
|
22
|
-
|
|
50
|
+
t3 = $[5];
|
|
23
51
|
}
|
|
24
|
-
return
|
|
52
|
+
return t3;
|
|
25
53
|
}
|
|
26
54
|
function useUiConfig(name) {
|
|
27
55
|
return React.useContext(UiConfigContext)[name];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @vvedantb/ui/tokens/css/surface-flat.css: the flat surface style.
|
|
3
|
+
* UiConfigProvider sets data-surface on the root element. The default is
|
|
4
|
+
* glass. With data-surface="flat", the rules below remove the glass rim,
|
|
5
|
+
* highlight and drop shadow that components carry as utility classes.
|
|
6
|
+
* Rule 1 clears the highlight overlay (an ::after pseudo-element).
|
|
7
|
+
* Rule 2 clears elements that carry the highlight as their own box-shadow.
|
|
8
|
+
* The tab pill is plain CSS and has its own rule.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
:root[data-surface="flat"] [class*="after:shadow-[inset"]::after {
|
|
12
|
+
box-shadow: none !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:root[data-surface="flat"]
|
|
16
|
+
:is([class*="inset_1.5px_1.5px_1px"], [class*="inset_1px_1px_1px"]):not(
|
|
17
|
+
[class*="after:shadow-[inset"]
|
|
18
|
+
) {
|
|
19
|
+
box-shadow: none !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill {
|
|
23
|
+
background: var(--tabs-pill-bg) !important;
|
|
24
|
+
backdrop-filter: none !important;
|
|
25
|
+
box-shadow: none !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill::after {
|
|
29
|
+
display: none !important;
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.76.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
|
|
6
6
|
"type": "module",
|
package/src/client.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { cn } from "./utils/cn";
|
|
2
2
|
export { UiConfigProvider, useUiConfig } from "./ui/ui-config";
|
|
3
|
-
export type { UiConfig, UiConfigProviderProps } from "./ui/ui-config";
|
|
3
|
+
export type { UiConfig, UiConfigProviderProps, UiSurface } from "./ui/ui-config";
|
|
4
4
|
export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes";
|
|
5
5
|
export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes";
|
|
6
6
|
export * from "./ui/surface-classes";
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { cn } from "./utils/cn";
|
|
2
2
|
export { UiConfigProvider, useUiConfig } from "./ui/ui-config";
|
|
3
|
-
export type { UiConfig, UiConfigProviderProps } from "./ui/ui-config";
|
|
3
|
+
export type { UiConfig, UiConfigProviderProps, UiSurface } from "./ui/ui-config";
|
|
4
4
|
export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes";
|
|
5
5
|
export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes";
|
|
6
6
|
export * from "./ui/surface-classes";
|
package/src/ui/ui-config.tsx
CHANGED
|
@@ -122,10 +122,23 @@ const UiConfigContext = React.createContext<UiConfig>({});
|
|
|
122
122
|
|
|
123
123
|
export interface UiConfigProviderProps {
|
|
124
124
|
config: UiConfig;
|
|
125
|
+
surface?: UiSurface;
|
|
125
126
|
children?: React.ReactNode;
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
export type UiSurface = "glass" | "flat";
|
|
130
|
+
|
|
131
|
+
function UiConfigProvider({ config, surface, children }: UiConfigProviderProps) {
|
|
132
|
+
React.useLayoutEffect(() => {
|
|
133
|
+
if (!surface || typeof document === "undefined") return;
|
|
134
|
+
const root = document.documentElement;
|
|
135
|
+
const previous = root.getAttribute("data-surface");
|
|
136
|
+
root.setAttribute("data-surface", surface);
|
|
137
|
+
return () => {
|
|
138
|
+
if (previous === null) root.removeAttribute("data-surface");
|
|
139
|
+
else root.setAttribute("data-surface", previous);
|
|
140
|
+
};
|
|
141
|
+
}, [surface]);
|
|
129
142
|
return <UiConfigContext.Provider value={config}>{children}</UiConfigContext.Provider>;
|
|
130
143
|
}
|
|
131
144
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @vvedantb/ui/tokens/css/surface-flat.css: the flat surface style.
|
|
3
|
+
* UiConfigProvider sets data-surface on the root element. The default is
|
|
4
|
+
* glass. With data-surface="flat", the rules below remove the glass rim,
|
|
5
|
+
* highlight and drop shadow that components carry as utility classes.
|
|
6
|
+
* Rule 1 clears the highlight overlay (an ::after pseudo-element).
|
|
7
|
+
* Rule 2 clears elements that carry the highlight as their own box-shadow.
|
|
8
|
+
* The tab pill is plain CSS and has its own rule.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
:root[data-surface="flat"] [class*="after:shadow-[inset"]::after {
|
|
12
|
+
box-shadow: none !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:root[data-surface="flat"]
|
|
16
|
+
:is([class*="inset_1.5px_1.5px_1px"], [class*="inset_1px_1px_1px"]):not(
|
|
17
|
+
[class*="after:shadow-[inset"]
|
|
18
|
+
) {
|
|
19
|
+
box-shadow: none !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill {
|
|
23
|
+
background: var(--tabs-pill-bg) !important;
|
|
24
|
+
backdrop-filter: none !important;
|
|
25
|
+
box-shadow: none !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:root[data-surface="flat"] .t-tabs--segmented .t-tabs-pill::after {
|
|
29
|
+
display: none !important;
|
|
30
|
+
}
|