@a-type/ui 0.8.5 → 0.8.7
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/cjs/components/button/classes.js +2 -2
- package/dist/cjs/components/button/classes.js.map +1 -1
- package/dist/cjs/components/dialog/Dialog.js +1 -1
- package/dist/cjs/components/dialog/Dialog.js.map +1 -1
- package/dist/cjs/components/input/Input.js +1 -1
- package/dist/cjs/components/input/Input.js.map +1 -1
- package/dist/cjs/components/layouts/PageContent.js +1 -1
- package/dist/cjs/components/layouts/PageContent.js.map +1 -1
- package/dist/cjs/components/layouts/layouts.stories.js +1 -2
- package/dist/cjs/components/layouts/layouts.stories.js.map +1 -1
- package/dist/cjs/components/navBar/NavBar.d.ts +10 -3
- package/dist/cjs/components/navBar/NavBar.js +34 -9
- package/dist/cjs/components/navBar/NavBar.js.map +1 -1
- package/dist/cjs/components/tooltip/Tooltip.js +1 -1
- package/dist/cjs/components/tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/components/tooltip/Tooltip.stories.d.ts +18 -0
- package/dist/cjs/components/tooltip/Tooltip.stories.js +22 -0
- package/dist/cjs/components/tooltip/Tooltip.stories.js.map +1 -0
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useTitleBarColor.d.ts +5 -0
- package/dist/cjs/hooks/useTitleBarColor.js +37 -0
- package/dist/cjs/hooks/useTitleBarColor.js.map +1 -0
- package/dist/css/main.css +2 -2
- package/dist/esm/components/button/classes.js +2 -2
- package/dist/esm/components/button/classes.js.map +1 -1
- package/dist/esm/components/dialog/Dialog.js +1 -1
- package/dist/esm/components/dialog/Dialog.js.map +1 -1
- package/dist/esm/components/input/Input.js +1 -1
- package/dist/esm/components/input/Input.js.map +1 -1
- package/dist/esm/components/layouts/PageContent.js +1 -1
- package/dist/esm/components/layouts/PageContent.js.map +1 -1
- package/dist/esm/components/layouts/layouts.stories.js +2 -3
- package/dist/esm/components/layouts/layouts.stories.js.map +1 -1
- package/dist/esm/components/navBar/NavBar.d.ts +10 -3
- package/dist/esm/components/navBar/NavBar.js +11 -6
- package/dist/esm/components/navBar/NavBar.js.map +1 -1
- package/dist/esm/components/tooltip/Tooltip.js +1 -1
- package/dist/esm/components/tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/tooltip/Tooltip.stories.d.ts +18 -0
- package/dist/esm/components/tooltip/Tooltip.stories.js +19 -0
- package/dist/esm/components/tooltip/Tooltip.stories.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useTitleBarColor.d.ts +5 -0
- package/dist/esm/hooks/useTitleBarColor.js +32 -0
- package/dist/esm/hooks/useTitleBarColor.js.map +1 -0
- package/package.json +1 -1
- package/src/components/button/classes.tsx +2 -2
- package/src/components/dialog/Dialog.tsx +1 -1
- package/src/components/input/Input.tsx +2 -2
- package/src/components/layouts/PageContent.tsx +1 -1
- package/src/components/layouts/layouts.stories.tsx +5 -7
- package/src/components/navBar/NavBar.tsx +39 -10
- package/src/components/tooltip/Tooltip.stories.tsx +26 -0
- package/src/components/tooltip/Tooltip.tsx +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useTitleBarColor.ts +34 -0
|
@@ -16,7 +16,7 @@ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
|
16
16
|
import classNames from 'clsx';
|
|
17
17
|
function Content(_a) {
|
|
18
18
|
var { children, className } = _a, props = __rest(_a, ["children", "className"]);
|
|
19
|
-
return (_jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, Object.assign({ className: classNames('layer-components:relative layer-components:rounded-
|
|
19
|
+
return (_jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, Object.assign({ className: classNames('layer-components:relative layer-components:rounded-md layer-components:py-2 layer-components:px-3 layer-components:bg-black layer-components:text-white layer-components:text-sm layer-components:leading-tight layer-components:shadow-sm layer-components:select-none layer-components:hidden layer-components:z-tooltip layer-components:sm:display-initial', '[&[data-state=delayed-open]]:display-initial', '[&[data-state=instant-open]]:display-initial', 'layer-components:transform-origin-[var(--radix-tooltip-content-transform-origin)]', 'layer-components:[&[data-state=delayed-open]]:animate-popover-in', className) }, props, { children: [children, _jsx(TooltipPrimitive.Arrow, { className: "fill-black" })] })) }));
|
|
20
20
|
}
|
|
21
21
|
// Exports
|
|
22
22
|
export const TooltipProvider = TooltipPrimitive.Provider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAGb,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,UAAU,MAAM,MAAM,CAAC;AAE9B,SAAS,OAAO,CAAC,EAIsB;QAJtB,EAChB,QAAQ,EACR,SAAS,OAE6B,EADnC,KAAK,cAHQ,yBAIhB,CADQ;IAER,OAAO,CACN,KAAC,gBAAgB,CAAC,MAAM,cACvB,MAAC,gBAAgB,CAAC,OAAO,kBACxB,SAAS,EAAE,UAAU,CACpB,
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAGb,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,UAAU,MAAM,MAAM,CAAC;AAE9B,SAAS,OAAO,CAAC,EAIsB;QAJtB,EAChB,QAAQ,EACR,SAAS,OAE6B,EADnC,KAAK,cAHQ,yBAIhB,CADQ;IAER,OAAO,CACN,KAAC,gBAAgB,CAAC,MAAM,cACvB,MAAC,gBAAgB,CAAC,OAAO,kBACxB,SAAS,EAAE,UAAU,CACpB,sJAAsJ,EACtJ,8CAA8C,EAC9C,8CAA8C,EAC9C,mFAAmF,EACnF,kEAAkE,EAClE,SAAS,CACT,IACG,KAAK,eAER,QAAQ,EACT,KAAC,gBAAgB,CAAC,KAAK,IAAC,SAAS,EAAC,YAAY,GAAG,KACvB,GACF,CAC1B,CAAC;AACH,CAAC;AAED,UAAU;AACV,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC,QAAQ,CAAC;AAEzD,MAAM,UAAU,OAAO,CAAC,EAQvB;QARuB,EACvB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,QAAQ,OAIR,EAHG,IAAI,cALgB,2CAMvB,CADO;IAIP,OAAO,CACN,MAAC,gBAAgB,CAAC,IAAI,kBAAC,IAAI,EAAE,IAAI,iBAC/B,QAAQ,CAAC,CAAC,CAAC,CACX,QAAQ,CACR,CAAC,CAAC,CAAC,CACH,KAAC,gBAAgB,CAAC,cAAc,kBAAC,OAAO,UAAK,IAAI,cAC/C,QAAQ,IACwB,CAClC,EACD,KAAC,OAAO,kBAAC,UAAU,EAAE,EAAE,gBAAG,OAAO,IAAW,KACrB,CACxB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
import { Tooltip } from './Tooltip.js';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof Tooltip;
|
|
6
|
+
argTypes: {};
|
|
7
|
+
parameters: {
|
|
8
|
+
controls: {
|
|
9
|
+
expanded: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
args: {
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof Tooltip>;
|
|
18
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @unocss-include
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Tooltip } from './Tooltip.js';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Tooltip',
|
|
6
|
+
component: Tooltip,
|
|
7
|
+
argTypes: {},
|
|
8
|
+
parameters: {
|
|
9
|
+
controls: { expanded: true },
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
content: 'hello world',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
export const Default = {
|
|
17
|
+
render: (args) => (_jsx(Tooltip, Object.assign({}, args, { children: _jsx("button", { children: "Hover me" }) }))),
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=Tooltip.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.stories.js","sourceRoot":"","sources":["../../../../src/components/tooltip/Tooltip.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,IAAI,GAAG;IACZ,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,OAAO;IAClB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE;QACX,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC5B;IACD,IAAI,EAAE;QACL,OAAO,EAAE,aAAa;KACtB;CAC8B,CAAC;AAEjC,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,OAAO,GAAU;IAC7B,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CACjB,KAAC,OAAO,oBAAK,IAAI,cAChB,wCAAyB,IAChB,CACV;CACD,CAAC"}
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// @unocss-include
|
|
2
|
+
var _a, _b;
|
|
3
|
+
import { useCallback, useEffect } from 'react';
|
|
4
|
+
let defaultColor = '#ffffff';
|
|
5
|
+
if (typeof document !== 'undefined') {
|
|
6
|
+
defaultColor =
|
|
7
|
+
(_b = (_a = document.querySelector('meta[name=theme-color]')) === null || _a === void 0 ? void 0 : _a.getAttribute('content')) !== null && _b !== void 0 ? _b : defaultColor;
|
|
8
|
+
}
|
|
9
|
+
function changeThemeColor(color) {
|
|
10
|
+
// evaluate css var if necessary
|
|
11
|
+
if (color.startsWith('var(')) {
|
|
12
|
+
const root = document.documentElement;
|
|
13
|
+
const cssVar = color.slice(4, -1).trim();
|
|
14
|
+
color = getComputedStyle(root).getPropertyValue(cssVar);
|
|
15
|
+
}
|
|
16
|
+
var metaThemeColor = document.querySelector('meta[name=theme-color]');
|
|
17
|
+
metaThemeColor === null || metaThemeColor === void 0 ? void 0 : metaThemeColor.setAttribute('content', color);
|
|
18
|
+
}
|
|
19
|
+
export function useTitleBarColor(color) {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
changeThemeColor(color);
|
|
22
|
+
return () => {
|
|
23
|
+
changeThemeColor(defaultColor);
|
|
24
|
+
};
|
|
25
|
+
}, [color]);
|
|
26
|
+
}
|
|
27
|
+
export function useSetTitleBarColor() {
|
|
28
|
+
const setColor = useCallback((color) => changeThemeColor(color), []);
|
|
29
|
+
const resetColor = useCallback(() => changeThemeColor(defaultColor), []);
|
|
30
|
+
return { setColor, resetColor };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useTitleBarColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTitleBarColor.js","sourceRoot":"","sources":["../../../src/hooks/useTitleBarColor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/C,IAAI,YAAY,GAAG,SAAS,CAAC;AAC7B,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;IACpC,YAAY;QACX,MAAA,MAAA,QAAQ,CAAC,aAAa,CAAC,wBAAwB,CAAC,0CAAE,YAAY,CAAC,SAAS,CAAC,mCACzE,YAAY,CAAC;CACd;AAED,SAAS,gBAAgB,CAAC,KAAa;IACtC,gCAAgC;IAChC,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC;QACtC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;KACxD;IACD,IAAI,cAAc,GAAG,QAAQ,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;IACtE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,SAAS,CAAC,GAAG,EAAE;QACd,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,GAAG,EAAE;YACX,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAChC,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACb,CAAC;AAED,MAAM,UAAU,mBAAmB;IAClC,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7E,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;IACzE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ export function getButtonClassName({
|
|
|
16
16
|
'layer-components:(px-4 py-2 bg-[var(--bg)] [--webkit-tap-highlight-color:transparent] [line-height:1] text-size-md font-sans border border-solid border-transparent rounded-full cursor-pointer font-bold flex flex-row gap-1 items-center relative overflow-visible select-none all:transition duration-200 shadow-none whitespace-nowrap)',
|
|
17
17
|
'layer-components:hover:(bg-[var(--hover)] shadow-[0_0_0_6px_var(--hover)])',
|
|
18
18
|
'layer-components:focus:outline-off',
|
|
19
|
-
'layer-components:focus-visible:(outline-off shadow
|
|
19
|
+
'layer-components:focus-visible:(outline-off [box-shadow:0_0_0_6px_var(--focus,var(--hover))])',
|
|
20
20
|
'layer-components:active:(shadow-[0_0_0_6px_var(--active)] bg-[var(--active)])',
|
|
21
21
|
'important:disabled:(opacity-50 cursor-default bg-[var(--bg)] shadow-none)',
|
|
22
22
|
'important:[&[data-disabled=true]]:(opacity-50 cursor-default bg-[var(--bg)] shadow-none)',
|
|
@@ -36,7 +36,7 @@ export function getButtonClassName({
|
|
|
36
36
|
const colors = {
|
|
37
37
|
primary: `layer-variants:[&.btn-color-primary]:([--bg:var(--color-primary-light)] [--hover:var(--color-primary)] [--focus:var(--color-primary)] [--active:var(--color-primary)] color-black border-black focus-visible:([--bg:var(--color-primary)]))`,
|
|
38
38
|
accent: `layer-variants:[&.btn-color-accent]:([--bg:var(--color-accent-wash)] [--hover:var(--color-accent-light)] [--focus:var(--color-accent-light)] [--active:var(--color-accent-light)] color-black border-black focus-visible:([--bg:var(--color-accent-light)]))`,
|
|
39
|
-
default: `layer-variants:[&.btn-color-default]:([--bg:var(--color-white)] [--hover:var(--color-gray-2)] [--focus:var(--color-gray-
|
|
39
|
+
default: `layer-variants:[&.btn-color-default]:([--bg:var(--color-white)] [--hover:var(--color-gray-2)] [--focus:var(--color-gray-dark-blend)] [--active:var(--color-gray-3)] color-black border-black)`,
|
|
40
40
|
ghost: `layer-variants:[&.btn-color-ghost]:([--bg:transparent] [--hover:var(--color-gray-blend)] [--focus:var(--color-gray-dark-blend)] [--active:var(--color-gray-dark-blend)] color-dark-blend)`,
|
|
41
41
|
destructive: `layer-variants:[&.btn-color-destructive]:([--bg:var(--color-attention-light)] [--hover:var(--color-attention-light)] [--focus:var(--color-attention-light)] [--active:var(--color-attention-light)] border-black color-black hover:([--bg:var(--colors-attention)]))`,
|
|
42
42
|
ghostDestructive: `layer-variants:[&.btn-color-ghostDestructive]:([--bg:transparent] [--hover:rgb(from_var(--color-attention-light)_r_g_b/0.25)] [--focus:var(--color-attention-light)] [--active:var(--color-attention-light)] color-attention-dark)`,
|
|
@@ -21,7 +21,7 @@ import { useDrag } from '@use-gesture/react';
|
|
|
21
21
|
|
|
22
22
|
const StyledOverlay = withClassName(
|
|
23
23
|
DialogPrimitive.Overlay,
|
|
24
|
-
'layer-components:(fixed inset-0 z-dialog-backdrop animate-fade-in animate-duration-200 bg-gray-dark-blend)',
|
|
24
|
+
'layer-components:(fixed inset-0 z-dialog-backdrop animate-fade-in animate-duration-200 bg-gray-dark-blend [box-shadow:inset_0_30px_60px_0px_#00001020] border-top-1 border-top-solid border-top-gray-5)',
|
|
25
25
|
'layer-components:[&[data-state=closed]]:animate-fade-out',
|
|
26
26
|
'motion-reduce:animate-none',
|
|
27
27
|
);
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export const inputClassName = classNames(
|
|
11
11
|
'layer-components:(px-4 py-2 text-md font-sans rounded-lg bg-white select-auto min-w-60px color-black border-default)',
|
|
12
|
-
'layer-components:focus:(outline-none bg-gray2)',
|
|
13
|
-
'layer-components:focus-visible:(outline-none
|
|
12
|
+
'layer-components:focus:(outline-none bg-gray2 ring-4 ring-white)',
|
|
13
|
+
'layer-components:focus-visible:(outline-none ring-primary-wash)',
|
|
14
14
|
'layer-components:md:(min-w-120px)',
|
|
15
15
|
);
|
|
16
16
|
|
|
@@ -29,7 +29,7 @@ export function PageContent({
|
|
|
29
29
|
<div
|
|
30
30
|
className={classNames(
|
|
31
31
|
'layer-components:([grid-area:content] max-w-full min-w-0 w-full flex flex-col items-start relative flex-1 gap-3)',
|
|
32
|
-
'layer-components:(rounded-b-lg border-b border-b-solid border-b-[#00000070] bg-wash sm:border-none sm:rounded-0)',
|
|
32
|
+
'layer-components:(rounded-b-lg border-b border-b-solid border-b-[#00000070] bg-wash [box-shadow:0_0_10px_0_#00000024] sm:border-none sm:rounded-0 sm:shadow-none)',
|
|
33
33
|
{ 'layer-variants:(overflow-y-auto h-full)': scrollable },
|
|
34
34
|
className,
|
|
35
35
|
)}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
NavBarItem,
|
|
7
7
|
NavBarItemIcon,
|
|
8
8
|
NavBarItemIconWrapper,
|
|
9
|
+
NavBarItemPip,
|
|
9
10
|
NavBarItemText,
|
|
10
11
|
NavBarRoot,
|
|
11
12
|
} from '../navBar.js';
|
|
@@ -37,19 +38,16 @@ export const Default: Story = {
|
|
|
37
38
|
<NavBarRoot>
|
|
38
39
|
<NavBarItem>
|
|
39
40
|
<NavBarItemIconWrapper>
|
|
40
|
-
<NavBarItemIcon
|
|
41
|
-
<Icon name="placeholder" />
|
|
42
|
-
</NavBarItemIcon>
|
|
41
|
+
<NavBarItemIcon name="calendar" />
|
|
43
42
|
</NavBarItemIconWrapper>
|
|
44
43
|
<NavBarItemText>Item 1</NavBarItemText>
|
|
45
44
|
</NavBarItem>
|
|
46
|
-
<NavBarItem>
|
|
45
|
+
<NavBarItem active={true}>
|
|
47
46
|
<NavBarItemIconWrapper>
|
|
48
|
-
<NavBarItemIcon
|
|
49
|
-
<Icon name="placeholder" />
|
|
50
|
-
</NavBarItemIcon>
|
|
47
|
+
<NavBarItemIcon name="book" />
|
|
51
48
|
</NavBarItemIconWrapper>
|
|
52
49
|
<NavBarItemText>Item 2</NavBarItemText>
|
|
50
|
+
<NavBarItemPip />
|
|
53
51
|
</NavBarItem>
|
|
54
52
|
</NavBarRoot>
|
|
55
53
|
</PageNav>
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import classNames from 'clsx';
|
|
1
|
+
import classNames, { clsx } from 'clsx';
|
|
2
2
|
import { withClassName } from '../../hooks.js';
|
|
3
3
|
import { ReactNode, forwardRef } from 'react';
|
|
4
4
|
import { Slot } from '@radix-ui/react-slot';
|
|
5
|
+
import { Icon, IconProps } from '../icon.js';
|
|
5
6
|
|
|
6
7
|
export const navBarItemClass = classNames(
|
|
7
|
-
'layer-components:(flex flex-col items-center justify-center whitespace-nowrap py-1 px-3 bg-transparent rounded-md border-none cursor-pointer text-sm transition-colors h-full gap-6px relative text-
|
|
8
|
+
'layer-components:(flex flex-col items-center justify-center whitespace-nowrap py-1 px-3 bg-transparent rounded-md border-none cursor-pointer text-sm transition-colors h-full gap-6px relative text-gray-7 select-none)',
|
|
8
9
|
'layer-components:sm:(flex-row-reverse h-auto justify-start gap-2 overflow-visible)',
|
|
9
|
-
'layer-components:hover:bg-
|
|
10
|
-
'layer-components:focus-visible:(outline-none bg-
|
|
11
|
-
'layer-components:active:bg-
|
|
10
|
+
'layer-components:hover:bg-primary-wash',
|
|
11
|
+
'layer-components:focus-visible:(outline-none bg-primary-wash)',
|
|
12
|
+
'layer-components:active:bg-primary-wash layer-components:sm:active:bg-gray-dark-blend',
|
|
13
|
+
'layer-components:[&[data-active=true]]:(bg-primary-wash text-primary-dark)',
|
|
12
14
|
);
|
|
13
15
|
|
|
14
16
|
export interface NavBarItemProps {
|
|
15
17
|
asChild?: boolean;
|
|
16
18
|
className?: string;
|
|
17
19
|
children?: ReactNode;
|
|
20
|
+
active?: boolean;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export const NavBarItem = forwardRef<HTMLDivElement, NavBarItemProps>(
|
|
21
|
-
function NavBarItem({ asChild, className, ...rest }, ref) {
|
|
24
|
+
function NavBarItem({ asChild, className, active, ...rest }, ref) {
|
|
22
25
|
const Comp = asChild ? Slot : 'div';
|
|
23
26
|
|
|
24
27
|
return (
|
|
25
28
|
<Comp
|
|
26
29
|
ref={ref}
|
|
27
30
|
className={classNames(navBarItemClass, className)}
|
|
31
|
+
data-active={active}
|
|
28
32
|
{...rest}
|
|
29
33
|
/>
|
|
30
34
|
);
|
|
@@ -33,7 +37,8 @@ export const NavBarItem = forwardRef<HTMLDivElement, NavBarItemProps>(
|
|
|
33
37
|
|
|
34
38
|
export const NavBarItemIconWrapper = withClassName(
|
|
35
39
|
'div',
|
|
36
|
-
'layer-components:(relative flex) layer-components:sm:(p-6px rounded-full bg-
|
|
40
|
+
'layer-components:(relative flex) layer-components:sm:(p-6px rounded-full bg-gray-blend)',
|
|
41
|
+
'layer-variants:[*[data-active=true]_&]:bg-primary-light',
|
|
37
42
|
);
|
|
38
43
|
|
|
39
44
|
export const NavBarItemText = withClassName(
|
|
@@ -41,9 +46,33 @@ export const NavBarItemText = withClassName(
|
|
|
41
46
|
'layer-components:(overflow-hidden pl-1 inline-block text-xxs whitespace-nowrap text-ellipsis) layer-components:sm:(text-md leading-normal)',
|
|
42
47
|
);
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
interface NavBarItemIconProps {
|
|
50
|
+
asChild?: boolean;
|
|
51
|
+
name?: IconProps['name'];
|
|
52
|
+
className?: string;
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export const NavBarItemIcon = forwardRef<any, NavBarItemIconProps>(
|
|
56
|
+
function NavBarItemIcon(
|
|
57
|
+
{ children, asChild, className, name = 'placeholder', ...rest },
|
|
58
|
+
ref,
|
|
59
|
+
) {
|
|
60
|
+
const Comp = asChild ? Slot : Icon;
|
|
61
|
+
return (
|
|
62
|
+
<Comp
|
|
63
|
+
name={name}
|
|
64
|
+
className={clsx(
|
|
65
|
+
'layer-components:(relative z-1 flex fill-none)',
|
|
66
|
+
'layer-variants:[*[data-active=true]_&]:fill-primary-light',
|
|
67
|
+
className,
|
|
68
|
+
)}
|
|
69
|
+
{...rest}
|
|
70
|
+
ref={ref}
|
|
71
|
+
>
|
|
72
|
+
{children}
|
|
73
|
+
</Comp>
|
|
74
|
+
);
|
|
75
|
+
},
|
|
47
76
|
);
|
|
48
77
|
|
|
49
78
|
export const NavBarItemPip = withClassName(
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Tooltip } from './Tooltip.js';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Tooltip',
|
|
6
|
+
component: Tooltip,
|
|
7
|
+
argTypes: {},
|
|
8
|
+
parameters: {
|
|
9
|
+
controls: { expanded: true },
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
content: 'hello world',
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta<typeof Tooltip>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
type Story = StoryObj<typeof Tooltip>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: (args) => (
|
|
22
|
+
<Tooltip {...args}>
|
|
23
|
+
<button>Hover me</button>
|
|
24
|
+
</Tooltip>
|
|
25
|
+
),
|
|
26
|
+
};
|
|
@@ -13,7 +13,7 @@ function Content({
|
|
|
13
13
|
<TooltipPrimitive.Portal>
|
|
14
14
|
<TooltipPrimitive.Content
|
|
15
15
|
className={classNames(
|
|
16
|
-
'layer-components:(relative rounded-
|
|
16
|
+
'layer-components:(relative rounded-md py-2 px-3 bg-black text-white text-sm leading-tight shadow-sm select-none hidden z-tooltip sm:display-initial)',
|
|
17
17
|
'[&[data-state=delayed-open]]:display-initial',
|
|
18
18
|
'[&[data-state=instant-open]]:display-initial',
|
|
19
19
|
'layer-components:transform-origin-[var(--radix-tooltip-content-transform-origin)]',
|
|
@@ -23,7 +23,7 @@ function Content({
|
|
|
23
23
|
{...props}
|
|
24
24
|
>
|
|
25
25
|
{children}
|
|
26
|
-
<TooltipPrimitive.Arrow className="fill-
|
|
26
|
+
<TooltipPrimitive.Arrow className="fill-black" />
|
|
27
27
|
</TooltipPrimitive.Content>
|
|
28
28
|
</TooltipPrimitive.Portal>
|
|
29
29
|
);
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
let defaultColor = '#ffffff';
|
|
4
|
+
if (typeof document !== 'undefined') {
|
|
5
|
+
defaultColor =
|
|
6
|
+
document.querySelector('meta[name=theme-color]')?.getAttribute('content') ??
|
|
7
|
+
defaultColor;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function changeThemeColor(color: string) {
|
|
11
|
+
// evaluate css var if necessary
|
|
12
|
+
if (color.startsWith('var(')) {
|
|
13
|
+
const root = document.documentElement;
|
|
14
|
+
const cssVar = color.slice(4, -1).trim();
|
|
15
|
+
color = getComputedStyle(root).getPropertyValue(cssVar);
|
|
16
|
+
}
|
|
17
|
+
var metaThemeColor = document.querySelector('meta[name=theme-color]');
|
|
18
|
+
metaThemeColor?.setAttribute('content', color);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useTitleBarColor(color: string) {
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
changeThemeColor(color);
|
|
24
|
+
return () => {
|
|
25
|
+
changeThemeColor(defaultColor);
|
|
26
|
+
};
|
|
27
|
+
}, [color]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function useSetTitleBarColor() {
|
|
31
|
+
const setColor = useCallback((color: string) => changeThemeColor(color), []);
|
|
32
|
+
const resetColor = useCallback(() => changeThemeColor(defaultColor), []);
|
|
33
|
+
return { setColor, resetColor };
|
|
34
|
+
}
|