@astryxdesign/cli 0.7.9-canary.7aaf2a1 → 0.7.9-canary.7b831ae

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.
@@ -271,7 +271,7 @@ useIsHydrating useIsHydrating hooks/useAnimatedLayout.doc.mjs hooks/useIsHydrati
271
271
  useIsomorphicLayoutEffect useIsomorphicLayoutEffect hooks/useAnimatedLayout.doc.mjs hooks/useIsomorphicLayoutEffect.ts
272
272
  useLayerDismissal useLayerDismissal Layer/Layer.doc.mjs Layer/useLayerDismissal.ts
273
273
  useLightbox useLightbox Lightbox/useLightbox.doc.mjs Lightbox/useLightbox.tsx
274
- useLinkComponent useLinkComponent Link/Link.doc.mjs Link/useLinkComponent.ts
274
+ useLinkComponent useLinkComponent Link/useLinkComponent.doc.mjs Link/useLinkComponent.ts
275
275
  useLinkify useLinkify Link/Link.doc.mjs Link/useLinkify.tsx
276
276
  useListFormatter useListFormatter i18n/InternationalizationProvider.doc.mjs i18n/useListFormatter.ts
277
277
  useMenuDrillIn useMenuDrillIn DropdownMenu/DropdownMenu.doc.mjs DropdownMenu/useMenuDrillIn.tsx
@@ -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: 'useLinkComponent',
7
+ name: 'useLinkComponent — Article Cards',
8
+ displayName: 'useLinkComponent — Article Cards',
9
+ description:
10
+ 'A custom Article card renders its title link with the component useLinkComponent resolves: the as prop first, then the nearest LinkProvider, then a native anchor. Inside a LinkProvider wired to a client-side router, the title navigates without a page load and updates the router location. With as="a" the title is a native anchor even inside the provider, and outside the provider it falls back to the next provider up or a native anchor.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['LinkProvider', 'Card', 'Layout', 'Text'],
14
+ };
@@ -0,0 +1,89 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {createContext, use, useState, type AnchorHTMLAttributes} from 'react';
6
+ import {Card} from '@astryxdesign/core/Card';
7
+ import {VStack} from '@astryxdesign/core/Layout';
8
+ import {
9
+ LinkProvider,
10
+ useLinkComponent,
11
+ type LinkComponentType,
12
+ } from '@astryxdesign/core/Link';
13
+ import {Text} from '@astryxdesign/core/Text';
14
+
15
+ const NavigateContext = createContext<(to: string) => void>(() => {});
16
+
17
+ function RouterLink({
18
+ to,
19
+ href: _href,
20
+ ...props
21
+ }: AnchorHTMLAttributes<HTMLAnchorElement> & {to: string}) {
22
+ const navigate = use(NavigateContext);
23
+ return (
24
+ <a
25
+ {...props}
26
+ href={to}
27
+ onClick={event => {
28
+ event.preventDefault();
29
+ navigate(to);
30
+ }}
31
+ />
32
+ );
33
+ }
34
+
35
+ function ArticleCard({
36
+ title,
37
+ href,
38
+ resolvedBy,
39
+ linkAs,
40
+ }: {
41
+ title: string;
42
+ href: string;
43
+ resolvedBy: string;
44
+ linkAs?: LinkComponentType;
45
+ }) {
46
+ const LinkComponent = useLinkComponent(linkAs);
47
+ return (
48
+ <Card padding={3}>
49
+ <VStack gap={1}>
50
+ <Text type="body" weight="bold">
51
+ <LinkComponent href={href}>{title}</LinkComponent>
52
+ </Text>
53
+ <Text type="supporting" color="secondary">
54
+ {resolvedBy}
55
+ </Text>
56
+ </VStack>
57
+ </Card>
58
+ );
59
+ }
60
+
61
+ export default function UseLinkComponentHookUsage() {
62
+ const [route, setRoute] = useState('/');
63
+
64
+ return (
65
+ <VStack gap={3}>
66
+ <Text type="body">Router location: {route}</Text>
67
+ <NavigateContext value={setRoute}>
68
+ <LinkProvider component={RouterLink}>
69
+ <ArticleCard
70
+ title="Getting started"
71
+ href="/articles/getting-started"
72
+ resolvedBy="LinkProvider: the router's link, no page load"
73
+ />
74
+ <ArticleCard
75
+ title="Style guide (PDF)"
76
+ href="#style-guide"
77
+ resolvedBy='as="a": a native anchor, even inside the provider'
78
+ linkAs="a"
79
+ />
80
+ </LinkProvider>
81
+ </NavigateContext>
82
+ <ArticleCard
83
+ title="Release notes"
84
+ href="#release-notes"
85
+ resolvedBy="Outside the provider: the app's LinkProvider, or a native anchor"
86
+ />
87
+ </VStack>
88
+ );
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.9-canary.7aaf2a1",
3
+ "version": "0.7.9-canary.7b831ae",
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.7aaf2a1",
128
- "@astryxdesign/core": "0.7.9-canary.7aaf2a1",
129
- "@astryxdesign/lab": "0.7.9-canary.7aaf2a1",
130
- "@astryxdesign/theme-neutral": "0.7.9-canary.7aaf2a1"
127
+ "@astryxdesign/charts": "0.7.9-canary.7b831ae",
128
+ "@astryxdesign/core": "0.7.9-canary.7b831ae",
129
+ "@astryxdesign/lab": "0.7.9-canary.7b831ae",
130
+ "@astryxdesign/theme-neutral": "0.7.9-canary.7b831ae"
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.7aaf2a1",
148
- "@astryxdesign/core": "0.7.9-canary.7aaf2a1",
149
- "@astryxdesign/lab": "0.7.9-canary.7aaf2a1",
150
- "@astryxdesign/theme-neutral": "0.7.9-canary.7aaf2a1",
147
+ "@astryxdesign/charts": "0.7.9-canary.7b831ae",
148
+ "@astryxdesign/core": "0.7.9-canary.7b831ae",
149
+ "@astryxdesign/lab": "0.7.9-canary.7b831ae",
150
+ "@astryxdesign/theme-neutral": "0.7.9-canary.7b831ae",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",