@istmx/ui 0.1.6 → 0.1.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/README.md CHANGED
@@ -33,6 +33,12 @@ Add the magnifying dock navigation with:
33
33
  npx @istmx/ui add dock-navigation
34
34
  ```
35
35
 
36
+ Add the searchable mobile menu dock with:
37
+
38
+ ```sh
39
+ npx @istmx/ui add mobile-menu-dock
40
+ ```
41
+
36
42
  Add the scroll-scrubbed image story with:
37
43
 
38
44
  ```sh
@@ -114,6 +120,7 @@ npx @istmx/ui add animated-text --no-install
114
120
  npx @istmx/ui add animated-text --overwrite
115
121
  npx @istmx/ui add image-accordion
116
122
  npx @istmx/ui add dock-navigation
123
+ npx @istmx/ui add mobile-menu-dock
117
124
  ```
118
125
 
119
126
  - `--no-install` copies the source and prints the dependency command instead
package/bin/istmx.mjs CHANGED
@@ -6,7 +6,7 @@ import { access, mkdir, readFile, writeFile } from 'node:fs/promises'
6
6
  import path from 'node:path'
7
7
  import { fileURLToPath } from 'node:url'
8
8
 
9
- const VERSION = '0.1.6'
9
+ const VERSION = '0.1.7'
10
10
  const COMPONENTS = {
11
11
  'animated-text': { fileName: 'animated-text.tsx' },
12
12
  'image-accordion': { fileName: 'image-accordion.tsx' },
@@ -14,6 +14,10 @@ const COMPONENTS = {
14
14
  fileName: 'dock-navigation.tsx',
15
15
  dependencies: ['@tabler/icons-react'],
16
16
  },
17
+ 'mobile-menu-dock': {
18
+ fileName: 'mobile-menu-dock.tsx',
19
+ dependencies: ['@tabler/icons-react'],
20
+ },
17
21
  'scroll-story-cards': {
18
22
  fileName: 'scroll-story-cards.tsx',
19
23
  dependencies: ['@tabler/icons-react'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@istmx/ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Add editable ISTMX UI components to your project.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,210 @@
1
+ 'use client'
2
+
3
+ import Link from 'next/link'
4
+ import { useEffect, useState } from 'react'
5
+ import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
6
+ import {
7
+ IconArrowRight,
8
+ IconArrowUpRight,
9
+ IconGridDots,
10
+ IconSearch,
11
+ IconX,
12
+ } from '@tabler/icons-react'
13
+ import { cn } from '@/lib/utils'
14
+
15
+ export type MobileMenuDockItem = {
16
+ label: string
17
+ href: string
18
+ active?: boolean
19
+ }
20
+
21
+ export type MobileMenuDockSearchItem = {
22
+ name: string
23
+ slug: string
24
+ category: string
25
+ description: string
26
+ }
27
+
28
+ export type MobileMenuDockProps = {
29
+ items: MobileMenuDockItem[]
30
+ searchItems: readonly MobileMenuDockSearchItem[]
31
+ label?: string
32
+ placement?: 'fixed' | 'inline'
33
+ className?: string
34
+ }
35
+
36
+ export default function MobileMenuDock({
37
+ items,
38
+ searchItems,
39
+ label = 'Mobile navigation',
40
+ placement = 'fixed',
41
+ className,
42
+ }: MobileMenuDockProps) {
43
+ const [open, setOpen] = useState(false)
44
+ const [query, setQuery] = useState('')
45
+ const reduceMotion = useReducedMotion()
46
+ const filteredComponents = searchItems.filter((item) =>
47
+ `${item.name} ${item.category} ${item.description}`
48
+ .toLowerCase()
49
+ .includes(query.trim().toLowerCase()),
50
+ )
51
+
52
+ useEffect(() => {
53
+ if (!open) return
54
+
55
+ const onKeyDown = (event: KeyboardEvent) => {
56
+ if (event.key === 'Escape') {
57
+ setOpen(false)
58
+ setQuery('')
59
+ }
60
+ }
61
+
62
+ window.addEventListener('keydown', onKeyDown)
63
+ return () => window.removeEventListener('keydown', onKeyDown)
64
+ }, [open])
65
+
66
+ function toggleMenu() {
67
+ setOpen((current) => !current)
68
+ setQuery('')
69
+ }
70
+
71
+ return (
72
+ <div
73
+ className={cn(
74
+ placement === 'fixed'
75
+ ? 'fixed inset-x-0 bottom-[calc(env(safe-area-inset-bottom)+0.75rem)] z-50 mx-auto w-[min(21rem,calc(100vw-2rem))] sm:hidden'
76
+ : 'relative z-10 mx-auto w-full',
77
+ className,
78
+ )}
79
+ >
80
+ <AnimatePresence initial={false}>
81
+ {open ? (
82
+ <motion.nav
83
+ id="mobile-menu-dock-panel"
84
+ aria-label={label}
85
+ className="border-border/80 bg-background/95 mb-2 overflow-hidden rounded-xl border p-1.5 shadow-[0_12px_40px_rgba(0,0,0,0.2)] backdrop-blur-xl"
86
+ initial={
87
+ reduceMotion ? { opacity: 0 } : { opacity: 0, y: 8, scale: 0.985 }
88
+ }
89
+ animate={{ opacity: 1, y: 0, scale: 1 }}
90
+ exit={
91
+ reduceMotion ? { opacity: 0 } : { opacity: 0, y: 5, scale: 0.99 }
92
+ }
93
+ transition={{
94
+ duration: reduceMotion ? 0.12 : 0.2,
95
+ ease: 'easeOut',
96
+ }}
97
+ >
98
+ <div className="border-border/60 text-muted border-b px-3.5 py-2 font-mono text-[9px] tracking-[0.12em] uppercase">
99
+ {query.trim() ? 'Components' : 'Navigate'}
100
+ </div>
101
+ <ul className="max-h-[min(55vh,24rem)] overflow-y-auto">
102
+ {query.trim() ? (
103
+ filteredComponents.length ? (
104
+ filteredComponents.map((item) => (
105
+ <li key={item.slug}>
106
+ <Link
107
+ href={`/library/${item.slug}`}
108
+ onClick={() => {
109
+ setOpen(false)
110
+ setQuery('')
111
+ }}
112
+ className="text-muted hover:bg-surface/70 hover:text-foreground flex min-h-12 items-center gap-3 rounded-lg px-3.5 transition-colors"
113
+ >
114
+ <span className="min-w-0 flex-1">
115
+ <span className="flex items-center justify-between gap-3">
116
+ <span className="font-display text-foreground text-sm font-medium">
117
+ {item.name}
118
+ </span>
119
+ <span className="font-mono text-[9px] tracking-wide uppercase">
120
+ {item.category}
121
+ </span>
122
+ </span>
123
+ <span className="mt-0.5 block truncate text-xs">
124
+ {item.description}
125
+ </span>
126
+ </span>
127
+ <IconArrowRight
128
+ aria-hidden="true"
129
+ className="shrink-0"
130
+ size={15}
131
+ stroke={1.6}
132
+ />
133
+ </Link>
134
+ </li>
135
+ ))
136
+ ) : (
137
+ <li className="text-muted px-3.5 py-4 text-center text-sm">
138
+ No components match “{query}”.
139
+ </li>
140
+ )
141
+ ) : (
142
+ items.map((item) => (
143
+ <li key={item.href}>
144
+ <Link
145
+ href={item.href}
146
+ aria-current={item.active ? 'page' : undefined}
147
+ onClick={() => {
148
+ setOpen(false)
149
+ setQuery('')
150
+ }}
151
+ className={cn(
152
+ 'flex min-h-11 items-center justify-between rounded-lg px-3.5 text-sm transition-colors',
153
+ item.active
154
+ ? 'bg-surface text-foreground'
155
+ : 'text-muted hover:bg-surface/70 hover:text-foreground',
156
+ )}
157
+ >
158
+ {item.label}
159
+ <IconArrowUpRight
160
+ aria-hidden="true"
161
+ className="text-muted/60"
162
+ size={15}
163
+ stroke={1.6}
164
+ />
165
+ </Link>
166
+ </li>
167
+ ))
168
+ )}
169
+ </ul>
170
+ </motion.nav>
171
+ ) : null}
172
+ </AnimatePresence>
173
+
174
+ <div className="border-border/80 bg-background/95 flex h-12 items-center gap-2 rounded-xl border px-2.5 shadow-[0_8px_28px_rgba(0,0,0,0.16)] backdrop-blur-xl">
175
+ <IconSearch
176
+ aria-hidden="true"
177
+ className="text-muted shrink-0"
178
+ size={17}
179
+ stroke={1.7}
180
+ />
181
+ <input
182
+ value={query}
183
+ onChange={(event) => {
184
+ setQuery(event.target.value)
185
+ setOpen(true)
186
+ }}
187
+ onFocus={() => setOpen(true)}
188
+ placeholder="Search components..."
189
+ aria-label="Search components by name, category, or description"
190
+ aria-controls="mobile-menu-dock-panel"
191
+ className="text-foreground placeholder:text-muted/70 min-w-0 flex-1 bg-transparent text-sm outline-none"
192
+ />
193
+ <button
194
+ type="button"
195
+ onClick={toggleMenu}
196
+ aria-label={open ? 'Close navigation menu' : 'Open navigation menu'}
197
+ aria-expanded={open}
198
+ aria-controls="mobile-menu-dock-panel"
199
+ className="border-border/70 bg-surface/45 text-muted hover:border-foreground/40 hover:text-foreground focus-visible:outline-foreground inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors focus-visible:outline-2 focus-visible:outline-offset-2"
200
+ >
201
+ {open ? (
202
+ <IconX aria-hidden="true" size={16} stroke={1.8} />
203
+ ) : (
204
+ <IconGridDots aria-hidden="true" size={16} stroke={1.8} />
205
+ )}
206
+ </button>
207
+ </div>
208
+ </div>
209
+ )
210
+ }