@trypattern/sdk 0.1.29 → 0.1.30
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.
|
@@ -11,7 +11,9 @@ type CardProps = {
|
|
|
11
11
|
to?: AppPath;
|
|
12
12
|
href?: string;
|
|
13
13
|
onClick?: () => void;
|
|
14
|
+
hover?: 'zoom' | 'outline';
|
|
15
|
+
isPressable?: boolean;
|
|
14
16
|
style?: Placement;
|
|
15
17
|
};
|
|
16
|
-
export declare function Card({ children, surface, padding, paddingBlock, to, href, onClick, style }: CardProps): import("react").JSX.Element;
|
|
18
|
+
export declare function Card({ children, surface, padding, paddingBlock, to, href, onClick, hover, isPressable, style }: CardProps): import("react").JSX.Element;
|
|
17
19
|
export {};
|
package/dist/components/Card.js
CHANGED
|
@@ -2,12 +2,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Button as BaseButton } from '@base-ui/react/button';
|
|
3
3
|
import * as stylex from '@stylexjs/stylex';
|
|
4
4
|
import { Link as RouterLink } from 'react-router';
|
|
5
|
-
import { colors, radii, shadows, space } from "../theme/tokens.stylex.js";
|
|
5
|
+
import { borders, breakpoints, colors, motion, radii, shadows, space } from "../theme/tokens.stylex.js";
|
|
6
6
|
import { focusRing } from "./controlLook.js";
|
|
7
7
|
import { interact, textOf } from "./interaction.js";
|
|
8
|
-
export function Card({ children, surface = 'subtle', padding = 'lg', paddingBlock, to, href, onClick, style }) {
|
|
8
|
+
export function Card({ children, surface = 'subtle', padding = 'lg', paddingBlock, to, href, onClick, hover, isPressable = false, style }) {
|
|
9
9
|
const isInteractive = to !== undefined || href !== undefined || onClick !== undefined;
|
|
10
|
-
const className = stylex.props(styles.card, surfaces[surface], paddings[padding], paddingBlock !== undefined && paddingBlocks[paddingBlock], isInteractive && styles.interactive, isInteractive && focusRing.visible, style).className;
|
|
10
|
+
const className = stylex.props(styles.card, surfaces[surface], paddings[padding], paddingBlock !== undefined && paddingBlocks[paddingBlock], isInteractive && styles.interactive, isInteractive && focusRing.visible, isInteractive && hover === 'zoom' && stylex.defaultMarker(), isInteractive && hover === 'outline' && styles.outline, isInteractive && isPressable && styles.pressable, style).className;
|
|
11
11
|
const report = (event) => {
|
|
12
12
|
interact({
|
|
13
13
|
primitive: 'Card',
|
|
@@ -40,6 +40,30 @@ const styles = stylex.create({
|
|
|
40
40
|
textAlign: 'start',
|
|
41
41
|
textDecoration: 'none',
|
|
42
42
|
outlineOffset: 0
|
|
43
|
+
},
|
|
44
|
+
outline: {
|
|
45
|
+
boxShadow: {
|
|
46
|
+
default: shadows.default,
|
|
47
|
+
[breakpoints.canHover]: {
|
|
48
|
+
default: shadows.default,
|
|
49
|
+
':hover': `0 0 0 ${borders.thin} ${colors.borderStrong}`
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
transitionTimingFunction: motion.easeOut,
|
|
53
|
+
transitionDuration: motion.fast,
|
|
54
|
+
transitionProperty: 'box-shadow, transform'
|
|
55
|
+
},
|
|
56
|
+
pressable: {
|
|
57
|
+
transform: {
|
|
58
|
+
default: null,
|
|
59
|
+
':active': {
|
|
60
|
+
default: 'scale(0.98)',
|
|
61
|
+
[breakpoints.reducedMotion]: 'none'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
transitionTimingFunction: motion.easeOut,
|
|
65
|
+
transitionDuration: motion.fast,
|
|
66
|
+
transitionProperty: 'box-shadow, transform'
|
|
43
67
|
}
|
|
44
68
|
});
|
|
45
69
|
const surfaces = stylex.create({
|
package/dist/components/Image.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import * as stylex from '@stylexjs/stylex';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { imageSources, transformsOn } from "../media.js";
|
|
5
|
-
import { colors, motion } from "../theme/tokens.stylex.js";
|
|
5
|
+
import { breakpoints, colors, motion } from "../theme/tokens.stylex.js";
|
|
6
6
|
export function Image({ image, sizes, priority = false, aspect, style }) {
|
|
7
7
|
const key = image?.key ?? null;
|
|
8
8
|
const [seen, setSeen] = useState({
|
|
@@ -30,7 +30,7 @@ export function Image({ image, sizes, priority = false, aspect, style }) {
|
|
|
30
30
|
}
|
|
31
31
|
}, alt: image.alt, width: sources.width, height: sources.height, loading: priority ? 'eager' : 'lazy', decoding: priority ? 'auto' : 'async', fetchPriority: priority ? 'high' : 'auto', sizes: sizes, srcSet: sources.srcSet, src: sources.src, onLoad: () => setSeen((current) => current.key === key && current.status === 'shown'
|
|
32
32
|
? current
|
|
33
|
-
: { key, status: 'fading' }), onError: () => setSeen({ key, status: 'failed' }), ...stylex.props(styles.image, status === 'fading' && styles.fading, status === 'shown' && styles.shown) })] }));
|
|
33
|
+
: { key, status: 'fading' }), onError: () => setSeen({ key, status: 'failed' }), ...stylex.props(styles.image, styles.zoomable, status === 'fading' && styles.fading, status === 'shown' && styles.shown) })] }));
|
|
34
34
|
}
|
|
35
35
|
const MISSING_ASPECT = 4 / 3;
|
|
36
36
|
function servedWithTransforms() {
|
|
@@ -68,9 +68,24 @@ const styles = stylex.create({
|
|
|
68
68
|
opacity: 1,
|
|
69
69
|
transitionTimingFunction: motion.easeOut,
|
|
70
70
|
transitionDuration: motion.base,
|
|
71
|
-
transitionProperty: 'opacity'
|
|
71
|
+
transitionProperty: 'opacity, transform'
|
|
72
72
|
},
|
|
73
73
|
shown: {
|
|
74
74
|
opacity: 1
|
|
75
|
+
},
|
|
76
|
+
zoomable: {
|
|
77
|
+
transform: {
|
|
78
|
+
default: null,
|
|
79
|
+
[breakpoints.canHover]: {
|
|
80
|
+
default: null,
|
|
81
|
+
[stylex.when.ancestor(':hover')]: {
|
|
82
|
+
default: 'scale(1.04)',
|
|
83
|
+
[breakpoints.reducedMotion]: 'none'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
transitionTimingFunction: motion.easeOut,
|
|
88
|
+
transitionDuration: motion.slide,
|
|
89
|
+
transitionProperty: 'transform'
|
|
75
90
|
}
|
|
76
91
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
2
|
export const breakpoints = stylex.defineConsts({
|
|
3
3
|
compact: '@media (max-width: 767px)',
|
|
4
|
+
canHover: '@media (hover: hover)',
|
|
4
5
|
reducedMotion: '@media (prefers-reduced-motion: reduce)',
|
|
5
6
|
coarsePointer: '@media (pointer: coarse)'
|
|
6
7
|
});
|