@astryxdesign/cli 0.7.9-canary.ddb8b34 → 0.7.9-canary.de0bbc2

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.
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useScrollLock',
7
+ name: 'useScrollLock — Full-screen Mobile Menu',
8
+ displayName: 'useScrollLock — Full-screen Mobile Menu',
9
+ description:
10
+ 'A custom full-screen menu opened from a Menu button. useScrollLock pins the page behind it while it is open, so the page does not scroll or shift sideways, and closing the menu returns the reader to the same scroll position.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Button', 'Link', 'Layout'],
14
+ };
@@ -0,0 +1,80 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useEffect, useState} from 'react';
6
+ import * as stylex from '@stylexjs/stylex';
7
+ import {Button} from '@astryxdesign/core/Button';
8
+ import {useFocusTrap, useScrollLock} from '@astryxdesign/core/hooks';
9
+ import {VStack} from '@astryxdesign/core/Layout';
10
+ import {Link} from '@astryxdesign/core/Link';
11
+ import {colorVars, spacingVars} from '@astryxdesign/core/theme/tokens.stylex';
12
+
13
+ const styles = stylex.create({
14
+ menu: {
15
+ width: '100%',
16
+ height: '100%',
17
+ maxWidth: 'none',
18
+ maxHeight: 'none',
19
+ margin: 0,
20
+ borderWidth: 0,
21
+ overflowY: 'auto',
22
+ padding: spacingVars['--spacing-4'],
23
+ color: colorVars['--color-text-primary'],
24
+ backgroundColor: colorVars['--color-background-surface'],
25
+ },
26
+ });
27
+
28
+ const MENU_ITEMS = ['Products', 'Pricing', 'Customers', 'Support'];
29
+
30
+ export default function UseScrollLockHookUsage() {
31
+ const [isOpen, setIsOpen] = useState(false);
32
+ useScrollLock(isOpen);
33
+ const {containerRef, focusFirst} = useFocusTrap<HTMLDialogElement>({
34
+ isActive: isOpen,
35
+ onEscape: close,
36
+ });
37
+
38
+ // The dialog leaves the top layer before the state change, so the page is
39
+ // no longer inert when the focus trap hands focus back to Menu.
40
+ function close() {
41
+ containerRef.current?.close();
42
+ setIsOpen(false);
43
+ }
44
+
45
+ useEffect(() => {
46
+ const dialog = containerRef.current;
47
+ if (isOpen && dialog != null && !dialog.open) {
48
+ dialog.showModal();
49
+ focusFirst();
50
+ }
51
+ }, [isOpen, containerRef, focusFirst]);
52
+
53
+ return (
54
+ <>
55
+ <Button label="Menu" onClick={() => setIsOpen(true)} />
56
+ <dialog
57
+ ref={containerRef}
58
+ aria-label="Menu"
59
+ onCancel={event => {
60
+ event.preventDefault();
61
+ close();
62
+ }}
63
+ {...stylex.props(styles.menu)}>
64
+ <nav aria-label="Site menu">
65
+ <VStack gap={4} hAlign="start">
66
+ <Button label="Close menu" variant="secondary" onClick={close} />
67
+ {MENU_ITEMS.map(item => (
68
+ <Link
69
+ key={item}
70
+ href={`#menu-${item.toLowerCase()}`}
71
+ onClick={close}>
72
+ {item}
73
+ </Link>
74
+ ))}
75
+ </VStack>
76
+ </nav>
77
+ </dialog>
78
+ </>
79
+ );
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.9-canary.ddb8b34",
3
+ "version": "0.7.9-canary.de0bbc2",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -124,10 +124,10 @@
124
124
  "zod": "^4.4.3"
125
125
  },
126
126
  "peerDependencies": {
127
- "@astryxdesign/charts": "0.7.9-canary.ddb8b34",
128
- "@astryxdesign/core": "0.7.9-canary.ddb8b34",
129
- "@astryxdesign/lab": "0.7.9-canary.ddb8b34",
130
- "@astryxdesign/theme-neutral": "0.7.9-canary.ddb8b34"
127
+ "@astryxdesign/charts": "0.7.9-canary.de0bbc2",
128
+ "@astryxdesign/core": "0.7.9-canary.de0bbc2",
129
+ "@astryxdesign/lab": "0.7.9-canary.de0bbc2",
130
+ "@astryxdesign/theme-neutral": "0.7.9-canary.de0bbc2"
131
131
  },
132
132
  "peerDependenciesMeta": {
133
133
  "@astryxdesign/charts": {
@@ -144,10 +144,10 @@
144
144
  }
145
145
  },
146
146
  "devDependencies": {
147
- "@astryxdesign/charts": "0.7.9-canary.ddb8b34",
148
- "@astryxdesign/core": "0.7.9-canary.ddb8b34",
149
- "@astryxdesign/lab": "0.7.9-canary.ddb8b34",
150
- "@astryxdesign/theme-neutral": "0.7.9-canary.ddb8b34",
147
+ "@astryxdesign/charts": "0.7.9-canary.de0bbc2",
148
+ "@astryxdesign/core": "0.7.9-canary.de0bbc2",
149
+ "@astryxdesign/lab": "0.7.9-canary.de0bbc2",
150
+ "@astryxdesign/theme-neutral": "0.7.9-canary.de0bbc2",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",