@astryxdesign/cli 0.7.8-canary.e3d2b45 → 0.7.8-canary.e5ace7e
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: 'useImageMode',
|
|
7
|
+
name: 'useImageMode — Photo Caption',
|
|
8
|
+
displayName: 'useImageMode — Photo Caption',
|
|
9
|
+
description:
|
|
10
|
+
'A photo banner with a caption over the sky. useImageMode samples only the strip under the caption and MediaTheme switches the caption between light and dark text from the result. A Beach photo switch swaps a night photo for a bright beach photo, and while the new photo loads the caption keeps the dark fallback.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 3 / 2,
|
|
13
|
+
componentsUsed: ['AspectRatio', 'MediaTheme', 'Switch', 'Text', 'Layout'],
|
|
14
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useState} from 'react';
|
|
6
|
+
import {AspectRatio} from '@astryxdesign/core/AspectRatio';
|
|
7
|
+
import {useImageMode} from '@astryxdesign/core/hooks';
|
|
8
|
+
import {VStack} from '@astryxdesign/core/Layout';
|
|
9
|
+
import {Switch} from '@astryxdesign/core/Switch';
|
|
10
|
+
import {Text} from '@astryxdesign/core/Text';
|
|
11
|
+
import {MediaTheme} from '@astryxdesign/core/theme';
|
|
12
|
+
|
|
13
|
+
const NIGHT_PHOTO = '/template-assets/moody-scene-horizontal-1.png';
|
|
14
|
+
const BEACH_PHOTO = '/template-assets/light-scene-horizontal-1.png';
|
|
15
|
+
|
|
16
|
+
const CAPTION_REGION = {x: 0, y: 0, width: 1, height: 0.3};
|
|
17
|
+
|
|
18
|
+
export default function UseImageModeHookUsage() {
|
|
19
|
+
const [isBeach, setIsBeach] = useState(false);
|
|
20
|
+
const src = isBeach ? BEACH_PHOTO : NIGHT_PHOTO;
|
|
21
|
+
const mode = useImageMode(src, {
|
|
22
|
+
region: CAPTION_REGION,
|
|
23
|
+
threshold: 0.4,
|
|
24
|
+
fallback: 'dark',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<VStack gap={3}>
|
|
29
|
+
<AspectRatio
|
|
30
|
+
ratio={3 / 2}
|
|
31
|
+
style={{
|
|
32
|
+
width: 360,
|
|
33
|
+
maxWidth: '100%',
|
|
34
|
+
borderRadius: 'var(--radius-container)',
|
|
35
|
+
}}>
|
|
36
|
+
<img
|
|
37
|
+
src={src}
|
|
38
|
+
alt={isBeach ? 'A beach under a pale sky' : 'Snowy peaks at night'}
|
|
39
|
+
style={{width: '100%', height: '100%', objectFit: 'cover'}}
|
|
40
|
+
/>
|
|
41
|
+
<div style={{position: 'absolute', inset: '0 0 auto', padding: 16}}>
|
|
42
|
+
<MediaTheme mode={mode ?? 'off'}>
|
|
43
|
+
<VStack gap={1}>
|
|
44
|
+
<Text type="body" weight="bold">
|
|
45
|
+
{isBeach ? 'Afternoon at the beach' : 'Night in the mountains'}
|
|
46
|
+
</Text>
|
|
47
|
+
<Text type="supporting">Sky behind the caption: {mode}</Text>
|
|
48
|
+
</VStack>
|
|
49
|
+
</MediaTheme>
|
|
50
|
+
</div>
|
|
51
|
+
</AspectRatio>
|
|
52
|
+
<Switch label="Beach photo" value={isBeach} onChange={setIsBeach} />
|
|
53
|
+
</VStack>
|
|
54
|
+
);
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.8-canary.
|
|
3
|
+
"version": "0.7.8-canary.e5ace7e",
|
|
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.8-canary.
|
|
128
|
-
"@astryxdesign/core": "0.7.8-canary.
|
|
129
|
-
"@astryxdesign/lab": "0.7.8-canary.
|
|
130
|
-
"@astryxdesign/theme-neutral": "0.7.8-canary.
|
|
127
|
+
"@astryxdesign/charts": "0.7.8-canary.e5ace7e",
|
|
128
|
+
"@astryxdesign/core": "0.7.8-canary.e5ace7e",
|
|
129
|
+
"@astryxdesign/lab": "0.7.8-canary.e5ace7e",
|
|
130
|
+
"@astryxdesign/theme-neutral": "0.7.8-canary.e5ace7e"
|
|
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.8-canary.
|
|
148
|
-
"@astryxdesign/core": "0.7.8-canary.
|
|
149
|
-
"@astryxdesign/lab": "0.7.8-canary.
|
|
150
|
-
"@astryxdesign/theme-neutral": "0.7.8-canary.
|
|
147
|
+
"@astryxdesign/charts": "0.7.8-canary.e5ace7e",
|
|
148
|
+
"@astryxdesign/core": "0.7.8-canary.e5ace7e",
|
|
149
|
+
"@astryxdesign/lab": "0.7.8-canary.e5ace7e",
|
|
150
|
+
"@astryxdesign/theme-neutral": "0.7.8-canary.e5ace7e",
|
|
151
151
|
"@heroicons/react": "^2.2.0",
|
|
152
152
|
"@stylexjs/stylex": "^0.19.0",
|
|
153
153
|
"@types/babel__core": "^7.20.5",
|