@ponti-studios/ui 1.3.0 → 1.4.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/package.json
CHANGED
|
@@ -7,13 +7,36 @@ import { Slot } from "../../lib/slot";
|
|
|
7
7
|
import { Sheet, SheetClose, SheetContent, SheetTitle, SheetTrigger } from "../overlays/sheet";
|
|
8
8
|
import { Button } from "../primitives/button";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
type MobileMenuState = {
|
|
11
|
+
/** True while rendering inside the mobile Sheet copy of the nav content. */
|
|
12
|
+
isMobile: boolean;
|
|
13
|
+
variant?: NavigationVariant;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const MobileMenuContext = React.createContext<MobileMenuState>({ isMobile: false });
|
|
17
|
+
|
|
18
|
+
/** @internal Undocumented — not part of the public API surface. */
|
|
19
|
+
type NavigationVariant = "nokia";
|
|
20
|
+
|
|
21
|
+
// Nokia 3310-style monochrome LCD skin for the mobile Sheet. See
|
|
22
|
+
// src/styles/nokia.css for the palette/font tokens and scanline texture.
|
|
23
|
+
const NOKIA_SHEET_CLASSNAME =
|
|
24
|
+
"nokia-screen rounded-none border-[6px] border-nokia-bezel bg-nokia-screen p-4 font-nokia text-nokia-ink shadow-[0_0_0_3px_var(--color-nokia-screen-deep),0_10px_30px_-6px_rgba(0,0,0,0.65)]";
|
|
25
|
+
const NOKIA_SHEET_CLOSE_CLASSNAME =
|
|
26
|
+
"text-nokia-ink hover:bg-nokia-ink hover:text-nokia-screen rounded-none border-2 border-nokia-ink";
|
|
27
|
+
const NOKIA_LIST_CLASSNAME = "!grid grid-cols-3 gap-3";
|
|
28
|
+
const NOKIA_ITEM_CLASSNAME =
|
|
29
|
+
"!h-auto !max-h-none w-full flex-col justify-center gap-1 rounded-none border-2 border-nokia-ink/40 px-2 py-3 text-center font-nokia text-base tracking-widest uppercase hover:bg-transparent active:bg-nokia-ink active:text-nokia-screen data-[active]:border-nokia-ink data-[active]:bg-nokia-ink data-[active]:text-nokia-screen";
|
|
12
30
|
|
|
13
31
|
export interface NavigationRootProps {
|
|
14
32
|
children: ReactNode;
|
|
15
33
|
ariaLabel?: string;
|
|
16
34
|
className?: string;
|
|
35
|
+
/**
|
|
36
|
+
* @internal Undocumented mobile-Sheet skin, not part of the public API
|
|
37
|
+
* (no README/Storybook entry). Opt in at your own risk.
|
|
38
|
+
*/
|
|
39
|
+
variant?: NavigationVariant;
|
|
17
40
|
}
|
|
18
41
|
|
|
19
42
|
/**
|
|
@@ -30,8 +53,10 @@ function NavigationRoot({
|
|
|
30
53
|
children,
|
|
31
54
|
ariaLabel = "Primary navigation",
|
|
32
55
|
className,
|
|
56
|
+
variant,
|
|
33
57
|
}: NavigationRootProps) {
|
|
34
58
|
const [mobileOpen, setMobileOpen] = React.useState(false);
|
|
59
|
+
const isNokia = variant === "nokia";
|
|
35
60
|
|
|
36
61
|
const items = React.Children.toArray(children);
|
|
37
62
|
const brand = items.find(
|
|
@@ -63,10 +88,15 @@ function NavigationRoot({
|
|
|
63
88
|
<Menu className="size-4" aria-hidden="true" />
|
|
64
89
|
</Button>
|
|
65
90
|
</SheetTrigger>
|
|
66
|
-
<SheetContent
|
|
91
|
+
<SheetContent
|
|
92
|
+
className={isNokia ? NOKIA_SHEET_CLASSNAME : undefined}
|
|
93
|
+
closeClassName={isNokia ? NOKIA_SHEET_CLOSE_CLASSNAME : undefined}
|
|
94
|
+
>
|
|
67
95
|
<SheetTitle className="sr-only">Navigation menu</SheetTitle>
|
|
68
96
|
<div className="mt-8 flex flex-1 flex-col gap-4">
|
|
69
|
-
<MobileMenuContext.Provider value={true}
|
|
97
|
+
<MobileMenuContext.Provider value={{ isMobile: true, variant }}>
|
|
98
|
+
{rest}
|
|
99
|
+
</MobileMenuContext.Provider>
|
|
70
100
|
</div>
|
|
71
101
|
</SheetContent>
|
|
72
102
|
</Sheet>
|
|
@@ -93,12 +123,14 @@ export interface NavigationListProps {
|
|
|
93
123
|
|
|
94
124
|
/** Semantic `<ul>` of `Navigation.Item`s. Lays out horizontally on desktop, stacks inside the mobile Sheet. */
|
|
95
125
|
function NavigationList({ children, className }: NavigationListProps) {
|
|
96
|
-
const isMobile = React.useContext(MobileMenuContext);
|
|
126
|
+
const { isMobile, variant } = React.useContext(MobileMenuContext);
|
|
127
|
+
const isNokia = isMobile && variant === "nokia";
|
|
97
128
|
return (
|
|
98
129
|
<ul
|
|
99
130
|
className={cn(
|
|
100
131
|
"flex items-center gap-1",
|
|
101
132
|
isMobile && "flex-col items-stretch gap-1",
|
|
133
|
+
isNokia && NOKIA_LIST_CLASSNAME,
|
|
102
134
|
className,
|
|
103
135
|
)}
|
|
104
136
|
>
|
|
@@ -124,9 +156,11 @@ function NavigationItem({
|
|
|
124
156
|
children,
|
|
125
157
|
...props
|
|
126
158
|
}: NavigationItemProps) {
|
|
127
|
-
const isMobile = React.useContext(MobileMenuContext);
|
|
159
|
+
const { isMobile, variant } = React.useContext(MobileMenuContext);
|
|
160
|
+
const isNokia = isMobile && variant === "nokia";
|
|
128
161
|
const itemClassName = cn(
|
|
129
162
|
"inline-flex h-9 max-h-9 shrink-0 items-center px-3 py-2 text-sm font-medium hover:bg-muted hover:text-muted-foreground data-[active]:font-semibold data-[active]:text-foreground",
|
|
163
|
+
isNokia && NOKIA_ITEM_CLASSNAME,
|
|
130
164
|
className,
|
|
131
165
|
);
|
|
132
166
|
|
|
@@ -166,12 +200,14 @@ export interface NavigationActionProps {
|
|
|
166
200
|
* for a link that should close the menu when tapped.
|
|
167
201
|
*/
|
|
168
202
|
function NavigationAction({ children, className }: NavigationActionProps) {
|
|
169
|
-
const isMobile = React.useContext(MobileMenuContext);
|
|
203
|
+
const { isMobile, variant } = React.useContext(MobileMenuContext);
|
|
204
|
+
const isNokia = isMobile && variant === "nokia";
|
|
170
205
|
return (
|
|
171
206
|
<div
|
|
172
207
|
className={cn(
|
|
173
208
|
"flex items-center gap-3",
|
|
174
209
|
isMobile && "mt-2 flex-col items-stretch gap-3 border-t pt-4",
|
|
210
|
+
isNokia && "border-nokia-ink/40",
|
|
175
211
|
className,
|
|
176
212
|
)}
|
|
177
213
|
>
|
|
@@ -72,12 +72,15 @@ const sheetClassName = [
|
|
|
72
72
|
"md:w-3/4 md:max-w-sm md:min-h-0",
|
|
73
73
|
];
|
|
74
74
|
|
|
75
|
-
interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Popup> {
|
|
75
|
+
interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Popup> {
|
|
76
|
+
/** Applied to the built-in close button, alongside its default styling. */
|
|
77
|
+
closeClassName?: string;
|
|
78
|
+
}
|
|
76
79
|
|
|
77
80
|
const SheetContent = React.forwardRef<
|
|
78
81
|
React.ComponentRef<typeof SheetPrimitive.Popup>,
|
|
79
82
|
SheetContentProps
|
|
80
|
-
>(({ className, children, ...props }, ref) => (
|
|
83
|
+
>(({ className, closeClassName, children, ...props }, ref) => (
|
|
81
84
|
<SheetPortal>
|
|
82
85
|
<SheetOverlay />
|
|
83
86
|
<SheetPrimitive.Popup
|
|
@@ -86,7 +89,12 @@ const SheetContent = React.forwardRef<
|
|
|
86
89
|
className={cn(sheetClassName, className)}
|
|
87
90
|
{...props}
|
|
88
91
|
>
|
|
89
|
-
<SheetPrimitive.Close
|
|
92
|
+
<SheetPrimitive.Close
|
|
93
|
+
className={cn(
|
|
94
|
+
"text-muted-foreground hover:bg-muted hover:text-muted-foreground focus-visible:outline-ring absolute top-3 right-3 inline-flex size-9 items-center justify-center rounded-md border border-transparent transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 disabled:pointer-events-none md:top-4 md:right-4",
|
|
95
|
+
closeClassName,
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
90
98
|
<X className="size-4.5" />
|
|
91
99
|
<span className="sr-only">Close</span>
|
|
92
100
|
</SheetPrimitive.Close>
|
package/src/styles/index.css
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Undocumented "nokia" Navigation variant — Nokia 3310-style monochrome LCD
|
|
3
|
+
* skin for the mobile Sheet menu. Not part of the public API surface (no
|
|
4
|
+
* README/Storybook entry); opt in via `<Navigation variant="nokia">`.
|
|
5
|
+
*/
|
|
6
|
+
@import url("https://fonts.googleapis.com/css2?family=VT323&display=swap");
|
|
7
|
+
|
|
8
|
+
@theme {
|
|
9
|
+
--color-nokia-screen: #c8d6a6;
|
|
10
|
+
--color-nokia-screen-deep: #b0c188;
|
|
11
|
+
--color-nokia-ink: #26331b;
|
|
12
|
+
--color-nokia-bezel: #1a1a1a;
|
|
13
|
+
--font-nokia: "VT323", "Courier New", monospace;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* No `position: relative` here — SheetContent is `position: fixed` via its
|
|
17
|
+
* own Tailwind class, and a same-specificity `.nokia-screen { position:
|
|
18
|
+
* relative }` loaded later in the cascade would silently win and break the
|
|
19
|
+
* sheet's fixed/inset layout (bit us once already; see labs' app.css). The
|
|
20
|
+
* `::before` overlay below still gets a positioning context from the
|
|
21
|
+
* ancestor's `fixed`, so this class never needs to set position itself. */
|
|
22
|
+
.nokia-screen {
|
|
23
|
+
background-image: repeating-linear-gradient(
|
|
24
|
+
to bottom,
|
|
25
|
+
rgb(0 0 0 / 0.05) 0,
|
|
26
|
+
rgb(0 0 0 / 0.05) 1px,
|
|
27
|
+
transparent 1px,
|
|
28
|
+
transparent 3px
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.nokia-screen::before {
|
|
33
|
+
content: "";
|
|
34
|
+
position: absolute;
|
|
35
|
+
inset: 0;
|
|
36
|
+
box-shadow: inset 0 0 12px 2px rgb(0 0 0 / 0.25);
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
}
|