@farcaster/snap 1.13.0 → 1.15.0
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/dist/react/components/action-button.js +18 -10
- package/dist/react/components/badge.js +8 -6
- package/dist/react/components/bar-chart.js +12 -17
- package/dist/react/components/cell-grid.js +16 -15
- package/dist/react/components/icon.js +4 -10
- package/dist/react/components/input.js +12 -6
- package/dist/react/components/item-group.js +3 -1
- package/dist/react/components/item.d.ts +3 -3
- package/dist/react/components/item.js +4 -3
- package/dist/react/components/progress.js +3 -3
- package/dist/react/components/separator.js +3 -1
- package/dist/react/components/slider.js +14 -10
- package/dist/react/components/switch.js +10 -12
- package/dist/react/components/text.js +5 -7
- package/dist/react/components/toggle-group.js +20 -6
- package/dist/react/hooks/use-snap-colors.d.ts +38 -0
- package/dist/react/hooks/use-snap-colors.js +82 -0
- package/dist/react/index.js +8 -5
- package/dist/react-native/components/snap-action-button.js +8 -18
- package/dist/react-native/components/snap-cell-grid.js +1 -1
- package/dist/react-native/components/snap-switch.js +1 -1
- package/dist/react-native/components/snap-toggle-group.js +8 -10
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/theme.d.ts +6 -0
- package/dist/react-native/theme.js +12 -6
- package/dist/ui/catalog.d.ts +1 -0
- package/dist/ui/cell-grid.d.ts +1 -0
- package/dist/ui/cell-grid.js +1 -0
- package/llms.txt +1 -0
- package/package.json +1 -1
- package/src/react/components/action-button.tsx +24 -17
- package/src/react/components/badge.tsx +14 -17
- package/src/react/components/bar-chart.tsx +21 -19
- package/src/react/components/cell-grid.tsx +16 -19
- package/src/react/components/icon.tsx +5 -18
- package/src/react/components/input.tsx +20 -9
- package/src/react/components/item-group.tsx +4 -1
- package/src/react/components/item.tsx +13 -10
- package/src/react/components/progress.tsx +12 -7
- package/src/react/components/separator.tsx +8 -1
- package/src/react/components/slider.tsx +18 -15
- package/src/react/components/switch.tsx +12 -16
- package/src/react/components/text.tsx +11 -8
- package/src/react/components/toggle-group.tsx +26 -9
- package/src/react/hooks/use-snap-colors.ts +129 -0
- package/src/react/index.tsx +19 -18
- package/src/react-native/components/snap-action-button.tsx +8 -20
- package/src/react-native/components/snap-cell-grid.tsx +1 -1
- package/src/react-native/components/snap-switch.tsx +1 -1
- package/src/react-native/components/snap-toggle-group.tsx +8 -10
- package/src/react-native/index.tsx +1 -1
- package/src/react-native/theme.tsx +18 -6
- package/src/ui/cell-grid.ts +1 -0
- package/dist/react/hooks/use-snap-accent.d.ts +0 -13
- package/dist/react/hooks/use-snap-accent.js +0 -32
- package/src/react/hooks/use-snap-accent.ts +0 -45
|
@@ -10,6 +10,12 @@ export type SnapNativeColors = {
|
|
|
10
10
|
border: string;
|
|
11
11
|
inputBg: string;
|
|
12
12
|
muted: string;
|
|
13
|
+
/** Subtle tint for toggle button resting state */
|
|
14
|
+
mutedSubtle: string;
|
|
15
|
+
/** Slightly stronger tint for hover/press state */
|
|
16
|
+
mutedHover: string;
|
|
17
|
+
/** Stronger tint for selected state (toggle group) */
|
|
18
|
+
mutedSelected: string;
|
|
13
19
|
};
|
|
14
20
|
|
|
15
21
|
const DEFAULT_LIGHT: SnapNativeColors = {
|
|
@@ -17,9 +23,12 @@ const DEFAULT_LIGHT: SnapNativeColors = {
|
|
|
17
23
|
surface: "#ffffff",
|
|
18
24
|
text: "#111111",
|
|
19
25
|
textSecondary: "#6b7280",
|
|
20
|
-
border: "#
|
|
21
|
-
inputBg: "
|
|
22
|
-
muted: "
|
|
26
|
+
border: "#E5E7EB",
|
|
27
|
+
inputBg: "rgba(0,0,0,0.12)",
|
|
28
|
+
muted: "rgba(0,0,0,0.12)",
|
|
29
|
+
mutedSubtle: "rgba(0,0,0,0.06)",
|
|
30
|
+
mutedHover: "rgba(0,0,0,0.10)",
|
|
31
|
+
mutedSelected: "rgba(0,0,0,0.18)",
|
|
23
32
|
};
|
|
24
33
|
|
|
25
34
|
const DEFAULT_DARK: SnapNativeColors = {
|
|
@@ -27,9 +36,12 @@ const DEFAULT_DARK: SnapNativeColors = {
|
|
|
27
36
|
surface: "#1a1d24",
|
|
28
37
|
text: "#fafafa",
|
|
29
38
|
textSecondary: "#a1a1aa",
|
|
30
|
-
border: "#
|
|
31
|
-
inputBg: "
|
|
32
|
-
muted: "
|
|
39
|
+
border: "#2D2D44",
|
|
40
|
+
inputBg: "rgba(255,255,255,0.03)",
|
|
41
|
+
muted: "rgba(255,255,255,0.03)",
|
|
42
|
+
mutedSubtle: "rgba(255,255,255,0.02)",
|
|
43
|
+
mutedHover: "rgba(255,255,255,0.04)",
|
|
44
|
+
mutedSelected: "rgba(255,255,255,0.10)",
|
|
33
45
|
};
|
|
34
46
|
|
|
35
47
|
// ─── Context ──────────────────────────────────────────
|
package/src/ui/cell-grid.ts
CHANGED
|
@@ -22,6 +22,7 @@ export const cellGridProps = z
|
|
|
22
22
|
rows: z.number().int().min(GRID_MIN_ROWS).max(GRID_MAX_ROWS),
|
|
23
23
|
cells: z.array(cellGridCellSchema),
|
|
24
24
|
gap: z.enum(GRID_GAP_VALUES).optional(),
|
|
25
|
+
rowHeight: z.number().int().min(8).max(64).optional(),
|
|
25
26
|
select: z.enum(["off", "single", "multiple"]).optional(),
|
|
26
27
|
})
|
|
27
28
|
.superRefine((val, ctx) => {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties } from "react";
|
|
2
|
-
import type { PaletteColor } from "@farcaster/snap";
|
|
3
|
-
/**
|
|
4
|
-
* CSS variables so Neynar controls (`bg-primary`, `data-checked:bg-primary`, etc.)
|
|
5
|
-
* use the snap `theme.accent` inside json-render catalog components.
|
|
6
|
-
*/
|
|
7
|
-
export declare function useSnapAccentScopeStyle(): CSSProperties;
|
|
8
|
-
/** Active snap palette table for the current docs shell theme. */
|
|
9
|
-
export declare function useSnapPalette(): {
|
|
10
|
-
hex: (name: string) => string;
|
|
11
|
-
map: Record<PaletteColor, string>;
|
|
12
|
-
theme: "light" | "dark";
|
|
13
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useStateStore } from "@json-render/react";
|
|
4
|
-
import { PALETTE_DARK_HEX, PALETTE_LIGHT_HEX } from "@farcaster/snap";
|
|
5
|
-
import { useColorMode } from "@neynar/ui/color-mode";
|
|
6
|
-
import { resolveSnapPaletteHex } from "../lib/resolve-palette-hex.js";
|
|
7
|
-
import { snapPreviewPrimaryCssProperties } from "../lib/preview-primary-css.js";
|
|
8
|
-
import { useSnapPreviewPageAccent } from "../accent-context.js";
|
|
9
|
-
/**
|
|
10
|
-
* CSS variables so Neynar controls (`bg-primary`, `data-checked:bg-primary`, etc.)
|
|
11
|
-
* use the snap `theme.accent` inside json-render catalog components.
|
|
12
|
-
*/
|
|
13
|
-
export function useSnapAccentScopeStyle() {
|
|
14
|
-
const { get } = useStateStore();
|
|
15
|
-
const { mode } = useColorMode();
|
|
16
|
-
const pageAccent = useSnapPreviewPageAccent();
|
|
17
|
-
const fromState = get("/theme/accent");
|
|
18
|
-
const accentRaw = (typeof pageAccent === "string" && pageAccent.length > 0
|
|
19
|
-
? pageAccent
|
|
20
|
-
: fromState) ?? undefined;
|
|
21
|
-
const accentName = typeof accentRaw === "string" && accentRaw.length > 0
|
|
22
|
-
? accentRaw
|
|
23
|
-
: "purple";
|
|
24
|
-
return useMemo(() => snapPreviewPrimaryCssProperties(accentName, mode), [accentName, mode]);
|
|
25
|
-
}
|
|
26
|
-
/** Active snap palette table for the current docs shell theme. */
|
|
27
|
-
export function useSnapPalette() {
|
|
28
|
-
const { mode } = useColorMode();
|
|
29
|
-
const map = mode === "dark" ? PALETTE_DARK_HEX : PALETTE_LIGHT_HEX;
|
|
30
|
-
const hex = (name) => resolveSnapPaletteHex(name, mode);
|
|
31
|
-
return { hex, map, theme: mode };
|
|
32
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useMemo, type CSSProperties } from "react";
|
|
4
|
-
import { useStateStore } from "@json-render/react";
|
|
5
|
-
import type { PaletteColor } from "@farcaster/snap";
|
|
6
|
-
import { PALETTE_DARK_HEX, PALETTE_LIGHT_HEX } from "@farcaster/snap";
|
|
7
|
-
import { useColorMode } from "@neynar/ui/color-mode";
|
|
8
|
-
import { resolveSnapPaletteHex } from "../lib/resolve-palette-hex";
|
|
9
|
-
import { snapPreviewPrimaryCssProperties } from "../lib/preview-primary-css";
|
|
10
|
-
import { useSnapPreviewPageAccent } from "../accent-context";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* CSS variables so Neynar controls (`bg-primary`, `data-checked:bg-primary`, etc.)
|
|
14
|
-
* use the snap `theme.accent` inside json-render catalog components.
|
|
15
|
-
*/
|
|
16
|
-
export function useSnapAccentScopeStyle(): CSSProperties {
|
|
17
|
-
const { get } = useStateStore();
|
|
18
|
-
const { mode } = useColorMode();
|
|
19
|
-
const pageAccent = useSnapPreviewPageAccent();
|
|
20
|
-
const fromState = get("/theme/accent");
|
|
21
|
-
const accentRaw =
|
|
22
|
-
(typeof pageAccent === "string" && pageAccent.length > 0
|
|
23
|
-
? pageAccent
|
|
24
|
-
: fromState) ?? undefined;
|
|
25
|
-
const accentName =
|
|
26
|
-
typeof accentRaw === "string" && accentRaw.length > 0
|
|
27
|
-
? accentRaw
|
|
28
|
-
: "purple";
|
|
29
|
-
return useMemo(
|
|
30
|
-
() => snapPreviewPrimaryCssProperties(accentName, mode),
|
|
31
|
-
[accentName, mode],
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Active snap palette table for the current docs shell theme. */
|
|
36
|
-
export function useSnapPalette(): {
|
|
37
|
-
hex: (name: string) => string;
|
|
38
|
-
map: Record<PaletteColor, string>;
|
|
39
|
-
theme: "light" | "dark";
|
|
40
|
-
} {
|
|
41
|
-
const { mode } = useColorMode();
|
|
42
|
-
const map = mode === "dark" ? PALETTE_DARK_HEX : PALETTE_LIGHT_HEX;
|
|
43
|
-
const hex = (name: string) => resolveSnapPaletteHex(name, mode);
|
|
44
|
-
return { hex, map, theme: mode };
|
|
45
|
-
}
|