melta-app 0.1.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/LICENSE +21 -0
- package/README.md +197 -0
- package/THIRD_PARTY_LICENSES.md +198 -0
- package/lib/module/components/ActionSheet.js +87 -0
- package/lib/module/components/ActionSheet.js.map +1 -0
- package/lib/module/components/Alert.js +93 -0
- package/lib/module/components/Alert.js.map +1 -0
- package/lib/module/components/Avatar.js +93 -0
- package/lib/module/components/Avatar.js.map +1 -0
- package/lib/module/components/BottomSheet.js +69 -0
- package/lib/module/components/BottomSheet.js.map +1 -0
- package/lib/module/components/Card.js +93 -0
- package/lib/module/components/Card.js.map +1 -0
- package/lib/module/components/Checkbox.js +115 -0
- package/lib/module/components/Checkbox.js.map +1 -0
- package/lib/module/components/EmptyState.js +70 -0
- package/lib/module/components/EmptyState.js.map +1 -0
- package/lib/module/components/Header.js +53 -0
- package/lib/module/components/Header.js.map +1 -0
- package/lib/module/components/Image.js +67 -0
- package/lib/module/components/Image.js.map +1 -0
- package/lib/module/components/Modal.js +95 -0
- package/lib/module/components/Modal.js.map +1 -0
- package/lib/module/components/Progress.js +113 -0
- package/lib/module/components/Progress.js.map +1 -0
- package/lib/module/components/Radio.js +134 -0
- package/lib/module/components/Radio.js.map +1 -0
- package/lib/module/components/Screen.js +57 -0
- package/lib/module/components/Screen.js.map +1 -0
- package/lib/module/components/Skeleton.js +169 -0
- package/lib/module/components/Skeleton.js.map +1 -0
- package/lib/module/components/Surface.js +49 -0
- package/lib/module/components/Surface.js.map +1 -0
- package/lib/module/components/TextField.js +84 -0
- package/lib/module/components/TextField.js.map +1 -0
- package/lib/module/components/Toast.js +105 -0
- package/lib/module/components/Toast.js.map +1 -0
- package/lib/module/components/Toggle.js +77 -0
- package/lib/module/components/Toggle.js.map +1 -0
- package/lib/module/components/action-sheet.styles.js +70 -0
- package/lib/module/components/action-sheet.styles.js.map +1 -0
- package/lib/module/components/alert.styles.js +80 -0
- package/lib/module/components/alert.styles.js.map +1 -0
- package/lib/module/components/avatar.styles.js +94 -0
- package/lib/module/components/avatar.styles.js.map +1 -0
- package/lib/module/components/bottom-sheet.styles.js +55 -0
- package/lib/module/components/bottom-sheet.styles.js.map +1 -0
- package/lib/module/components/card.styles.js +50 -0
- package/lib/module/components/card.styles.js.map +1 -0
- package/lib/module/components/checkbox.styles.js +55 -0
- package/lib/module/components/checkbox.styles.js.map +1 -0
- package/lib/module/components/empty-state.styles.js +60 -0
- package/lib/module/components/empty-state.styles.js.map +1 -0
- package/lib/module/components/header.styles.js +33 -0
- package/lib/module/components/header.styles.js.map +1 -0
- package/lib/module/components/image.styles.js +37 -0
- package/lib/module/components/image.styles.js.map +1 -0
- package/lib/module/components/index.js +26 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/components/modal.styles.js +68 -0
- package/lib/module/components/modal.styles.js.map +1 -0
- package/lib/module/components/progress.styles.js +55 -0
- package/lib/module/components/progress.styles.js.map +1 -0
- package/lib/module/components/radio.styles.js +96 -0
- package/lib/module/components/radio.styles.js.map +1 -0
- package/lib/module/components/screen.styles.js +38 -0
- package/lib/module/components/screen.styles.js.map +1 -0
- package/lib/module/components/skeleton.styles.js +114 -0
- package/lib/module/components/skeleton.styles.js.map +1 -0
- package/lib/module/components/surface.styles.js +37 -0
- package/lib/module/components/surface.styles.js.map +1 -0
- package/lib/module/components/textfield.styles.js +121 -0
- package/lib/module/components/textfield.styles.js.map +1 -0
- package/lib/module/components/toast.styles.js +81 -0
- package/lib/module/components/toast.styles.js.map +1 -0
- package/lib/module/components/toggle.styles.js +69 -0
- package/lib/module/components/toggle.styles.js.map +1 -0
- package/lib/module/contracts/contract-types.js +192 -0
- package/lib/module/contracts/contract-types.js.map +1 -0
- package/lib/module/icons/Icon.js +57 -0
- package/lib/module/icons/Icon.js.map +1 -0
- package/lib/module/icons/glyphs.js +257 -0
- package/lib/module/icons/glyphs.js.map +1 -0
- package/lib/module/icons/icon.styles.js +28 -0
- package/lib/module/icons/icon.styles.js.map +1 -0
- package/lib/module/icons/index.js +14 -0
- package/lib/module/icons/index.js.map +1 -0
- package/lib/module/index.js +20 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/primitives/Button.js +105 -0
- package/lib/module/primitives/Button.js.map +1 -0
- package/lib/module/primitives/Metric.js +68 -0
- package/lib/module/primitives/Metric.js.map +1 -0
- package/lib/module/primitives/Row.js +43 -0
- package/lib/module/primitives/Row.js.map +1 -0
- package/lib/module/primitives/Stack.js +39 -0
- package/lib/module/primitives/Stack.js.map +1 -0
- package/lib/module/primitives/Tag.js +160 -0
- package/lib/module/primitives/Tag.js.map +1 -0
- package/lib/module/primitives/Text.js +54 -0
- package/lib/module/primitives/Text.js.map +1 -0
- package/lib/module/primitives/_internal/focus-ring.js +57 -0
- package/lib/module/primitives/_internal/focus-ring.js.map +1 -0
- package/lib/module/primitives/button.styles.js +88 -0
- package/lib/module/primitives/button.styles.js.map +1 -0
- package/lib/module/primitives/index.js +11 -0
- package/lib/module/primitives/index.js.map +1 -0
- package/lib/module/primitives/metric.styles.js +54 -0
- package/lib/module/primitives/metric.styles.js.map +1 -0
- package/lib/module/primitives/row.styles.js +53 -0
- package/lib/module/primitives/row.styles.js.map +1 -0
- package/lib/module/primitives/stack.styles.js +37 -0
- package/lib/module/primitives/stack.styles.js.map +1 -0
- package/lib/module/primitives/tag.styles.js +56 -0
- package/lib/module/primitives/tag.styles.js.map +1 -0
- package/lib/module/primitives/text.styles.js +33 -0
- package/lib/module/primitives/text.styles.js.map +1 -0
- package/lib/module/theme/ThemeProvider.js +41 -0
- package/lib/module/theme/ThemeProvider.js.map +1 -0
- package/lib/module/theme/index.js +19 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/native-theme.js +201 -0
- package/lib/module/theme/native-theme.js.map +1 -0
- package/lib/module/theme/types.js +4 -0
- package/lib/module/theme/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/ActionSheet.d.ts +45 -0
- package/lib/typescript/src/components/ActionSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/Alert.d.ts +43 -0
- package/lib/typescript/src/components/Alert.d.ts.map +1 -0
- package/lib/typescript/src/components/Avatar.d.ts +45 -0
- package/lib/typescript/src/components/Avatar.d.ts.map +1 -0
- package/lib/typescript/src/components/BottomSheet.d.ts +36 -0
- package/lib/typescript/src/components/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/Card.d.ts +46 -0
- package/lib/typescript/src/components/Card.d.ts.map +1 -0
- package/lib/typescript/src/components/Checkbox.d.ts +40 -0
- package/lib/typescript/src/components/Checkbox.d.ts.map +1 -0
- package/lib/typescript/src/components/EmptyState.d.ts +36 -0
- package/lib/typescript/src/components/EmptyState.d.ts.map +1 -0
- package/lib/typescript/src/components/Header.d.ts +34 -0
- package/lib/typescript/src/components/Header.d.ts.map +1 -0
- package/lib/typescript/src/components/Image.d.ts +41 -0
- package/lib/typescript/src/components/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/Modal.d.ts +46 -0
- package/lib/typescript/src/components/Modal.d.ts.map +1 -0
- package/lib/typescript/src/components/Progress.d.ts +39 -0
- package/lib/typescript/src/components/Progress.d.ts.map +1 -0
- package/lib/typescript/src/components/Radio.d.ts +52 -0
- package/lib/typescript/src/components/Radio.d.ts.map +1 -0
- package/lib/typescript/src/components/Screen.d.ts +42 -0
- package/lib/typescript/src/components/Screen.d.ts.map +1 -0
- package/lib/typescript/src/components/Skeleton.d.ts +37 -0
- package/lib/typescript/src/components/Skeleton.d.ts.map +1 -0
- package/lib/typescript/src/components/Surface.d.ts +31 -0
- package/lib/typescript/src/components/Surface.d.ts.map +1 -0
- package/lib/typescript/src/components/TextField.d.ts +45 -0
- package/lib/typescript/src/components/TextField.d.ts.map +1 -0
- package/lib/typescript/src/components/Toast.d.ts +45 -0
- package/lib/typescript/src/components/Toast.d.ts.map +1 -0
- package/lib/typescript/src/components/Toggle.d.ts +39 -0
- package/lib/typescript/src/components/Toggle.d.ts.map +1 -0
- package/lib/typescript/src/components/action-sheet.styles.d.ts +65 -0
- package/lib/typescript/src/components/action-sheet.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/alert.styles.d.ts +61 -0
- package/lib/typescript/src/components/alert.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/avatar.styles.d.ts +60 -0
- package/lib/typescript/src/components/avatar.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/bottom-sheet.styles.d.ts +50 -0
- package/lib/typescript/src/components/bottom-sheet.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/card.styles.d.ts +27 -0
- package/lib/typescript/src/components/card.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/checkbox.styles.d.ts +55 -0
- package/lib/typescript/src/components/checkbox.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/empty-state.styles.d.ts +58 -0
- package/lib/typescript/src/components/empty-state.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/header.styles.d.ts +30 -0
- package/lib/typescript/src/components/header.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/image.styles.d.ts +28 -0
- package/lib/typescript/src/components/image.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +23 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/components/modal.styles.d.ts +66 -0
- package/lib/typescript/src/components/modal.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/progress.styles.d.ts +44 -0
- package/lib/typescript/src/components/progress.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/radio.styles.d.ts +91 -0
- package/lib/typescript/src/components/radio.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/screen.styles.d.ts +34 -0
- package/lib/typescript/src/components/screen.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/skeleton.styles.d.ts +105 -0
- package/lib/typescript/src/components/skeleton.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/surface.styles.d.ts +31 -0
- package/lib/typescript/src/components/surface.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/textfield.styles.d.ts +75 -0
- package/lib/typescript/src/components/textfield.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/toast.styles.d.ts +62 -0
- package/lib/typescript/src/components/toast.styles.d.ts.map +1 -0
- package/lib/typescript/src/components/toggle.styles.d.ts +53 -0
- package/lib/typescript/src/components/toggle.styles.d.ts.map +1 -0
- package/lib/typescript/src/contracts/contract-types.d.ts +193 -0
- package/lib/typescript/src/contracts/contract-types.d.ts.map +1 -0
- package/lib/typescript/src/icons/Icon.d.ts +40 -0
- package/lib/typescript/src/icons/Icon.d.ts.map +1 -0
- package/lib/typescript/src/icons/glyphs.d.ts +259 -0
- package/lib/typescript/src/icons/glyphs.d.ts.map +1 -0
- package/lib/typescript/src/icons/icon.styles.d.ts +20 -0
- package/lib/typescript/src/icons/icon.styles.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +12 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +12 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Button.d.ts +48 -0
- package/lib/typescript/src/primitives/Button.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Metric.d.ts +38 -0
- package/lib/typescript/src/primitives/Metric.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Row.d.ts +37 -0
- package/lib/typescript/src/primitives/Row.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Stack.d.ts +33 -0
- package/lib/typescript/src/primitives/Stack.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Tag.d.ts +43 -0
- package/lib/typescript/src/primitives/Tag.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Text.d.ts +45 -0
- package/lib/typescript/src/primitives/Text.d.ts.map +1 -0
- package/lib/typescript/src/primitives/_internal/focus-ring.d.ts +31 -0
- package/lib/typescript/src/primitives/_internal/focus-ring.d.ts.map +1 -0
- package/lib/typescript/src/primitives/button.styles.d.ts +29 -0
- package/lib/typescript/src/primitives/button.styles.d.ts.map +1 -0
- package/lib/typescript/src/primitives/index.d.ts +8 -0
- package/lib/typescript/src/primitives/index.d.ts.map +1 -0
- package/lib/typescript/src/primitives/metric.styles.d.ts +43 -0
- package/lib/typescript/src/primitives/metric.styles.d.ts.map +1 -0
- package/lib/typescript/src/primitives/row.styles.d.ts +50 -0
- package/lib/typescript/src/primitives/row.styles.d.ts.map +1 -0
- package/lib/typescript/src/primitives/stack.styles.d.ts +34 -0
- package/lib/typescript/src/primitives/stack.styles.d.ts.map +1 -0
- package/lib/typescript/src/primitives/tag.styles.d.ts +32 -0
- package/lib/typescript/src/primitives/tag.styles.d.ts.map +1 -0
- package/lib/typescript/src/primitives/text.styles.d.ts +26 -0
- package/lib/typescript/src/primitives/text.styles.d.ts.map +1 -0
- package/lib/typescript/src/theme/ThemeProvider.d.ts +32 -0
- package/lib/typescript/src/theme/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +15 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/native-theme.d.ts +3 -0
- package/lib/typescript/src/theme/native-theme.d.ts.map +1 -0
- package/lib/typescript/src/theme/types.d.ts +121 -0
- package/lib/typescript/src/theme/types.d.ts.map +1 -0
- package/package.json +120 -0
- package/src/components/ActionSheet.tsx +112 -0
- package/src/components/Alert.tsx +84 -0
- package/src/components/Avatar.tsx +110 -0
- package/src/components/BottomSheet.tsx +81 -0
- package/src/components/Card.tsx +102 -0
- package/src/components/Checkbox.tsx +107 -0
- package/src/components/EmptyState.tsx +64 -0
- package/src/components/Header.tsx +51 -0
- package/src/components/Image.tsx +89 -0
- package/src/components/Modal.tsx +113 -0
- package/src/components/Progress.tsx +124 -0
- package/src/components/Radio.tsx +151 -0
- package/src/components/Screen.tsx +62 -0
- package/src/components/Skeleton.tsx +154 -0
- package/src/components/Surface.tsx +37 -0
- package/src/components/TextField.tsx +102 -0
- package/src/components/Toast.tsx +103 -0
- package/src/components/Toggle.tsx +94 -0
- package/src/components/action-sheet.styles.ts +102 -0
- package/src/components/alert.styles.ts +115 -0
- package/src/components/avatar.styles.ts +110 -0
- package/src/components/bottom-sheet.styles.ts +78 -0
- package/src/components/card.styles.ts +56 -0
- package/src/components/checkbox.styles.ts +83 -0
- package/src/components/empty-state.styles.ts +98 -0
- package/src/components/header.styles.ts +44 -0
- package/src/components/image.styles.ts +36 -0
- package/src/components/index.ts +23 -0
- package/src/components/modal.styles.ts +106 -0
- package/src/components/progress.styles.ts +74 -0
- package/src/components/radio.styles.ts +132 -0
- package/src/components/screen.styles.ts +44 -0
- package/src/components/skeleton.styles.ts +155 -0
- package/src/components/surface.styles.ts +50 -0
- package/src/components/textfield.styles.ts +135 -0
- package/src/components/toast.styles.ts +115 -0
- package/src/components/toggle.styles.ts +73 -0
- package/src/contracts/contract-types.ts +199 -0
- package/src/icons/Icon.tsx +65 -0
- package/src/icons/glyphs.ts +54 -0
- package/src/icons/icon.styles.ts +37 -0
- package/src/icons/index.ts +12 -0
- package/src/index.ts +24 -0
- package/src/primitives/Button.tsx +114 -0
- package/src/primitives/Metric.tsx +67 -0
- package/src/primitives/Row.tsx +54 -0
- package/src/primitives/Stack.tsx +42 -0
- package/src/primitives/Tag.tsx +126 -0
- package/src/primitives/Text.tsx +71 -0
- package/src/primitives/_internal/focus-ring.tsx +59 -0
- package/src/primitives/button.styles.ts +69 -0
- package/src/primitives/index.ts +8 -0
- package/src/primitives/metric.styles.ts +75 -0
- package/src/primitives/row.styles.ts +66 -0
- package/src/primitives/stack.styles.ts +47 -0
- package/src/primitives/tag.styles.ts +65 -0
- package/src/primitives/text.styles.ts +42 -0
- package/src/theme/ThemeProvider.tsx +60 -0
- package/src/theme/index.ts +18 -0
- package/src/theme/native-theme.ts +215 -0
- package/src/theme/types.ts +137 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThemeProvider / useTheme — melta-app の theming 適用基盤(設計書 §3, B-3)。
|
|
3
|
+
*
|
|
4
|
+
* B-3: 形状(mode 非依存)は各 component 側で StyleSheet 化、色は theme.color.semantic[mode] から
|
|
5
|
+
* render 時に取る。Provider は「現在の mode と、その mode の semantic 色」を配る役割。
|
|
6
|
+
* useColorScheme() を Provider 内で1回だけ読む(RN コア、追加依存なし)。
|
|
7
|
+
*
|
|
8
|
+
* context value は useMemo 必須(§3): 毎レンダで新オブジェクトを配ると全 consumer が再レンダする。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createContext, useContext, useMemo, type ReactNode } from "react";
|
|
12
|
+
import { useColorScheme } from "react-native";
|
|
13
|
+
import { nativeTheme } from "./native-theme";
|
|
14
|
+
import type { NativeTheme, SemanticColors } from "./types";
|
|
15
|
+
|
|
16
|
+
export type ThemeMode = "light" | "dark";
|
|
17
|
+
|
|
18
|
+
export interface ThemeContextValue {
|
|
19
|
+
/** 正規化済み theme 全体(色以外の形状トークンもここから取る)。 */
|
|
20
|
+
theme: NativeTheme;
|
|
21
|
+
/** 現在の表示モード。 */
|
|
22
|
+
mode: ThemeMode;
|
|
23
|
+
/** 現在 mode の semantic 色(= theme.color.semantic[mode])。最頻アクセスなので展開済みで配る。 */
|
|
24
|
+
colors: SemanticColors;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ThemeContext = createContext<ThemeContextValue | null>(null);
|
|
28
|
+
|
|
29
|
+
interface ThemeProviderProps {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* 明示モード。指定時は OS の colorScheme を無視して固定する。
|
|
33
|
+
* カタログの light/dark トグル(§6)や、特定画面の固定表示に使う。
|
|
34
|
+
*/
|
|
35
|
+
forcedMode?: ThemeMode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function ThemeProvider({ children, forcedMode }: ThemeProviderProps) {
|
|
39
|
+
const system = useColorScheme();
|
|
40
|
+
const mode: ThemeMode = forcedMode ?? (system === "dark" ? "dark" : "light");
|
|
41
|
+
|
|
42
|
+
const value = useMemo<ThemeContextValue>(
|
|
43
|
+
() => ({
|
|
44
|
+
theme: nativeTheme,
|
|
45
|
+
mode,
|
|
46
|
+
colors: nativeTheme.color.semantic[mode],
|
|
47
|
+
}),
|
|
48
|
+
[mode],
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function useTheme(): ThemeContextValue {
|
|
55
|
+
const ctx = useContext(ThemeContext);
|
|
56
|
+
if (!ctx) {
|
|
57
|
+
throw new Error("useTheme は <ThemeProvider> の内側で呼んでください。");
|
|
58
|
+
}
|
|
59
|
+
return ctx;
|
|
60
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* melta-app theme エントリ。
|
|
3
|
+
* 型は types.ts、値は native-theme.ts(melta-contracts から自動生成)。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export * from "./types";
|
|
7
|
+
export { nativeTheme } from "./native-theme";
|
|
8
|
+
export { ThemeProvider, useTheme } from "./ThemeProvider";
|
|
9
|
+
export type { ThemeContextValue, ThemeMode } from "./ThemeProvider";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* letterSpacingRatio(em 相当の比率)を、適用先の fontSize から RN の letterSpacing(pt) に解決する。
|
|
13
|
+
* 例: resolveLetterSpacing(18, theme.typography.letterSpacingRatio.body)
|
|
14
|
+
* theme.typography.letterSpacingRatio.* をそのまま style.letterSpacing に入れる誤用を避けるための helper。
|
|
15
|
+
*/
|
|
16
|
+
export function resolveLetterSpacing(fontSize: number, ratio: number): number {
|
|
17
|
+
return fontSize * ratio;
|
|
18
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// ⚠️ 自動生成ファイル — 手で編集しないこと。
|
|
2
|
+
// 生成元: scripts/generate-native-theme.ts(入力 melta-contracts tokens.json)
|
|
3
|
+
// tokens version: 1.0.0
|
|
4
|
+
|
|
5
|
+
import type { NativeTheme } from "./types";
|
|
6
|
+
|
|
7
|
+
export const nativeTheme: NativeTheme = {
|
|
8
|
+
"color": {
|
|
9
|
+
"primary": {
|
|
10
|
+
"50": "#f0f5ff",
|
|
11
|
+
"100": "#dde8ff",
|
|
12
|
+
"200": "#c0d4ff",
|
|
13
|
+
"300": "#95b6ff",
|
|
14
|
+
"400": "#6492ff",
|
|
15
|
+
"500": "#2b70ef",
|
|
16
|
+
"600": "#2250df",
|
|
17
|
+
"700": "#1a40b5",
|
|
18
|
+
"800": "#13318d",
|
|
19
|
+
"900": "#0e266a",
|
|
20
|
+
"950": "#07194e"
|
|
21
|
+
},
|
|
22
|
+
"body": "#3d4b5f",
|
|
23
|
+
"semantic": {
|
|
24
|
+
"light": {
|
|
25
|
+
"bg-page": "#f9fafb",
|
|
26
|
+
"bg-page-alt": "#f3f4f6",
|
|
27
|
+
"bg-surface": "#ffffff",
|
|
28
|
+
"bg-surface-alt": "#f9fafb",
|
|
29
|
+
"text-heading": "#0f172a",
|
|
30
|
+
"text-default": "#3d4b5f",
|
|
31
|
+
"text-muted": "#64748b",
|
|
32
|
+
"border-default": "#e2e8f0",
|
|
33
|
+
"border-strong": "#cbd5e1",
|
|
34
|
+
"input-bg": "#ffffff",
|
|
35
|
+
"input-border": "#cbd5e1",
|
|
36
|
+
"text-on-accent": "#ffffff"
|
|
37
|
+
},
|
|
38
|
+
"dark": {
|
|
39
|
+
"bg-page": "#0f172a",
|
|
40
|
+
"bg-page-alt": "#1e293b",
|
|
41
|
+
"bg-surface": "#1e293b",
|
|
42
|
+
"bg-surface-alt": "#0f172a",
|
|
43
|
+
"text-heading": "#f1f5f9",
|
|
44
|
+
"text-default": "#cbd5e1",
|
|
45
|
+
"text-muted": "#94a3b8",
|
|
46
|
+
"border-default": "#334155",
|
|
47
|
+
"border-strong": "#475569",
|
|
48
|
+
"input-bg": "#0f172a",
|
|
49
|
+
"input-border": "#475569",
|
|
50
|
+
"text-on-accent": "#ffffff"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"status": {
|
|
54
|
+
"success": {
|
|
55
|
+
"base": "#059669",
|
|
56
|
+
"subtleLight": "#ecfdf5",
|
|
57
|
+
"textLight": "#047857",
|
|
58
|
+
"subtleDark": "rgba(5,150,105,0.12)",
|
|
59
|
+
"textDark": "#6ee7b7"
|
|
60
|
+
},
|
|
61
|
+
"warning": {
|
|
62
|
+
"base": "#d97706",
|
|
63
|
+
"subtleLight": "#fffbeb",
|
|
64
|
+
"textLight": "#b45309",
|
|
65
|
+
"subtleDark": "rgba(217,119,6,0.12)",
|
|
66
|
+
"textDark": "#fcd34d"
|
|
67
|
+
},
|
|
68
|
+
"danger": {
|
|
69
|
+
"base": "#ef4444",
|
|
70
|
+
"subtleLight": "#fef2f2",
|
|
71
|
+
"textLight": "#dc2626",
|
|
72
|
+
"subtleDark": "rgba(239,68,68,0.12)",
|
|
73
|
+
"textDark": "#fca5a5"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"typography": {
|
|
78
|
+
"fontFamily": {},
|
|
79
|
+
"fontSize": {
|
|
80
|
+
"xs": {
|
|
81
|
+
"fontSize": 13,
|
|
82
|
+
"lineHeight": 18
|
|
83
|
+
},
|
|
84
|
+
"sm": {
|
|
85
|
+
"fontSize": 15,
|
|
86
|
+
"lineHeight": 26
|
|
87
|
+
},
|
|
88
|
+
"base": {
|
|
89
|
+
"fontSize": 18,
|
|
90
|
+
"lineHeight": 36
|
|
91
|
+
},
|
|
92
|
+
"lg": {
|
|
93
|
+
"fontSize": 20,
|
|
94
|
+
"lineHeight": 30
|
|
95
|
+
},
|
|
96
|
+
"xl": {
|
|
97
|
+
"fontSize": 22,
|
|
98
|
+
"lineHeight": 31
|
|
99
|
+
},
|
|
100
|
+
"2xl": {
|
|
101
|
+
"fontSize": 26,
|
|
102
|
+
"lineHeight": 36
|
|
103
|
+
},
|
|
104
|
+
"3xl": {
|
|
105
|
+
"fontSize": 32,
|
|
106
|
+
"lineHeight": 45
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"fontWeight": {
|
|
110
|
+
"normal": "400",
|
|
111
|
+
"medium": "500",
|
|
112
|
+
"semibold": "600",
|
|
113
|
+
"bold": "700"
|
|
114
|
+
},
|
|
115
|
+
"letterSpacingRatio": {
|
|
116
|
+
"heading": 0.01,
|
|
117
|
+
"body": 0.02
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"spacing": {
|
|
121
|
+
"1": 4,
|
|
122
|
+
"2": 8,
|
|
123
|
+
"3": 12,
|
|
124
|
+
"4": 16,
|
|
125
|
+
"5": 20,
|
|
126
|
+
"6": 24,
|
|
127
|
+
"8": 32,
|
|
128
|
+
"10": 40,
|
|
129
|
+
"12": 48,
|
|
130
|
+
"14": 56,
|
|
131
|
+
"16": 64
|
|
132
|
+
},
|
|
133
|
+
"radius": {
|
|
134
|
+
"sm": 4,
|
|
135
|
+
"md": 8,
|
|
136
|
+
"lg": 12,
|
|
137
|
+
"full": 9999
|
|
138
|
+
},
|
|
139
|
+
"elevation": {
|
|
140
|
+
"none": {
|
|
141
|
+
"shadowColor": "#000000",
|
|
142
|
+
"shadowOffset": {
|
|
143
|
+
"width": 0,
|
|
144
|
+
"height": 0
|
|
145
|
+
},
|
|
146
|
+
"shadowOpacity": 0,
|
|
147
|
+
"shadowRadius": 0,
|
|
148
|
+
"elevation": 0
|
|
149
|
+
},
|
|
150
|
+
"sm": {
|
|
151
|
+
"shadowColor": "rgb(0, 0, 0)",
|
|
152
|
+
"shadowOffset": {
|
|
153
|
+
"width": 0,
|
|
154
|
+
"height": 1
|
|
155
|
+
},
|
|
156
|
+
"shadowOpacity": 0.05,
|
|
157
|
+
"shadowRadius": 2,
|
|
158
|
+
"elevation": 2
|
|
159
|
+
},
|
|
160
|
+
"md": {
|
|
161
|
+
"shadowColor": "rgb(0, 0, 0)",
|
|
162
|
+
"shadowOffset": {
|
|
163
|
+
"width": 0,
|
|
164
|
+
"height": 4
|
|
165
|
+
},
|
|
166
|
+
"shadowOpacity": 0.1,
|
|
167
|
+
"shadowRadius": 6,
|
|
168
|
+
"elevation": 5
|
|
169
|
+
},
|
|
170
|
+
"overlay": {
|
|
171
|
+
"shadowColor": "rgb(0, 0, 0)",
|
|
172
|
+
"shadowOffset": {
|
|
173
|
+
"width": 0,
|
|
174
|
+
"height": 20
|
|
175
|
+
},
|
|
176
|
+
"shadowOpacity": 0.1,
|
|
177
|
+
"shadowRadius": 25,
|
|
178
|
+
"elevation": 10
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"motion": {
|
|
182
|
+
"duration": {
|
|
183
|
+
"fast": 150,
|
|
184
|
+
"normal": 200,
|
|
185
|
+
"slow": 300
|
|
186
|
+
},
|
|
187
|
+
"easing": {
|
|
188
|
+
"default": [
|
|
189
|
+
0.4,
|
|
190
|
+
0,
|
|
191
|
+
0.2,
|
|
192
|
+
1
|
|
193
|
+
],
|
|
194
|
+
"in": [
|
|
195
|
+
0.4,
|
|
196
|
+
0,
|
|
197
|
+
1,
|
|
198
|
+
1
|
|
199
|
+
],
|
|
200
|
+
"out": [
|
|
201
|
+
0,
|
|
202
|
+
0,
|
|
203
|
+
0.2,
|
|
204
|
+
1
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"zIndex": {
|
|
209
|
+
"base": 0,
|
|
210
|
+
"dropdown": 20,
|
|
211
|
+
"sticky": 30,
|
|
212
|
+
"overlay": 40,
|
|
213
|
+
"modal": 50
|
|
214
|
+
}
|
|
215
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeTheme — melta の design contracts(melta-contracts の tokens.json)を
|
|
3
|
+
* React Native 向けに正規化した theme の型。
|
|
4
|
+
*
|
|
5
|
+
* 生成は scripts/generate-native-theme.ts(純粋変換は scripts/lib/normalize-tokens.ts)。
|
|
6
|
+
* web 形式 → RN 形式の正規化規則は requirements-melta-app.md §4 を参照。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ViewStyle } from "react-native";
|
|
10
|
+
|
|
11
|
+
/** primary パレット(50〜950)。値は hex 文字列。 */
|
|
12
|
+
export type PrimaryScale =
|
|
13
|
+
| "50"
|
|
14
|
+
| "100"
|
|
15
|
+
| "200"
|
|
16
|
+
| "300"
|
|
17
|
+
| "400"
|
|
18
|
+
| "500"
|
|
19
|
+
| "600"
|
|
20
|
+
| "700"
|
|
21
|
+
| "800"
|
|
22
|
+
| "900"
|
|
23
|
+
| "950";
|
|
24
|
+
|
|
25
|
+
/** semantic カラー(light / dark で同じキー集合を持つ)。値は色文字列。 */
|
|
26
|
+
export interface SemanticColors {
|
|
27
|
+
"bg-page": string;
|
|
28
|
+
"bg-page-alt": string;
|
|
29
|
+
"bg-surface": string;
|
|
30
|
+
"bg-surface-alt": string;
|
|
31
|
+
"text-heading": string;
|
|
32
|
+
"text-default": string;
|
|
33
|
+
"text-muted": string;
|
|
34
|
+
"border-default": string;
|
|
35
|
+
"border-strong": string;
|
|
36
|
+
"input-bg": string;
|
|
37
|
+
"input-border": string;
|
|
38
|
+
"text-on-accent": string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** status カラー(success / warning / danger)。light/dark の subtle・text を保持。 */
|
|
42
|
+
export interface StatusColors {
|
|
43
|
+
base: string;
|
|
44
|
+
subtleLight: string;
|
|
45
|
+
textLight: string;
|
|
46
|
+
subtleDark: string;
|
|
47
|
+
textDark: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ThemeColor {
|
|
51
|
+
primary: Record<PrimaryScale, string>;
|
|
52
|
+
body: string;
|
|
53
|
+
semantic: { light: SemanticColors; dark: SemanticColors };
|
|
54
|
+
status: { success: StatusColors; warning: StatusColors; danger: StatusColors };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type FontSizeKey = "xs" | "sm" | "base" | "lg" | "xl" | "2xl" | "3xl";
|
|
58
|
+
export type FontWeightKey = "normal" | "medium" | "semibold" | "bold";
|
|
59
|
+
/** RN の fontWeight は文字列。tokens の数値(400 等)を文字列化したもの。 */
|
|
60
|
+
export type FontWeightValue = "400" | "500" | "600" | "700";
|
|
61
|
+
|
|
62
|
+
export interface FontSizeEntry {
|
|
63
|
+
/** px 数値(tokens.json の px をそのまま採用) */
|
|
64
|
+
fontSize: number;
|
|
65
|
+
/** fontSize × lineHeight比率 を px に丸めた値 */
|
|
66
|
+
lineHeight: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ThemeTypography {
|
|
70
|
+
/**
|
|
71
|
+
* 初期は system default(未指定 = OS デフォルトフォント)。RN の fontFamily は string 一本で
|
|
72
|
+
* web の fallback 配列のようには効かず、Inter 等を焼くと expo-font でのロード必須になり実機で崩れる。
|
|
73
|
+
* Inter / JetBrains Mono の embed は expo-font 導入後に generator へ font マップを渡す Phase 2。
|
|
74
|
+
* それまでは sans/mono とも未指定(= OS の sans / monospace)にする。
|
|
75
|
+
*/
|
|
76
|
+
fontFamily: { sans?: string; mono?: string };
|
|
77
|
+
fontSize: Record<FontSizeKey, FontSizeEntry>;
|
|
78
|
+
fontWeight: Record<FontWeightKey, FontWeightValue>;
|
|
79
|
+
/**
|
|
80
|
+
* letterSpacing の em ratio を数値で保持する(px ではない)。
|
|
81
|
+
* tokens は em(fontSize 相対)だが RN の letterSpacing は絶対 pt のため token 単体では px 換算できない。
|
|
82
|
+
* 適用側は `resolveLetterSpacing(fontSize, ratio)`(= fontSize × ratio)で pt を算出すること。
|
|
83
|
+
* 名前を `Ratio` 付きにしているのは、ratio をそのまま style.letterSpacing に入れる誤用を防ぐため。
|
|
84
|
+
* (requirements §4 の「px に換算」からの意図的な乖離。理由はこのコメントの通り)
|
|
85
|
+
*/
|
|
86
|
+
letterSpacingRatio: { heading: number; body: number };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* elevation 1段。iOS は shadow* を、Android は elevation を読む(互いに無視するので
|
|
91
|
+
* 1つの ViewStyle に同居させて spread すれば両 OS に効く)。
|
|
92
|
+
*/
|
|
93
|
+
export type ElevationStyle = Pick<
|
|
94
|
+
ViewStyle,
|
|
95
|
+
"shadowColor" | "shadowOffset" | "shadowOpacity" | "shadowRadius" | "elevation"
|
|
96
|
+
>;
|
|
97
|
+
|
|
98
|
+
/** iOS 側の shadow props だけ(Android elevation は別途 mapping table で決める)。 */
|
|
99
|
+
export type ShadowStyle = Omit<ElevationStyle, "elevation">;
|
|
100
|
+
|
|
101
|
+
export type ElevationKey = "none" | "sm" | "md" | "overlay";
|
|
102
|
+
|
|
103
|
+
export type SpacingKey =
|
|
104
|
+
| "1"
|
|
105
|
+
| "2"
|
|
106
|
+
| "3"
|
|
107
|
+
| "4"
|
|
108
|
+
| "5"
|
|
109
|
+
| "6"
|
|
110
|
+
| "8"
|
|
111
|
+
| "10"
|
|
112
|
+
| "12"
|
|
113
|
+
| "14"
|
|
114
|
+
| "16";
|
|
115
|
+
|
|
116
|
+
export type RadiusKey = "sm" | "md" | "lg" | "full";
|
|
117
|
+
|
|
118
|
+
export interface ThemeMotion {
|
|
119
|
+
/** ms 数値 */
|
|
120
|
+
duration: { fast: number; normal: number; slow: number };
|
|
121
|
+
/** cubic-bezier の 4 引数(Easing.bezier(...) に展開して使う) */
|
|
122
|
+
easing: {
|
|
123
|
+
default: [number, number, number, number];
|
|
124
|
+
in: [number, number, number, number];
|
|
125
|
+
out: [number, number, number, number];
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface NativeTheme {
|
|
130
|
+
color: ThemeColor;
|
|
131
|
+
typography: ThemeTypography;
|
|
132
|
+
spacing: Record<SpacingKey, number>;
|
|
133
|
+
radius: Record<RadiusKey, number>;
|
|
134
|
+
elevation: Record<ElevationKey, ElevationStyle>;
|
|
135
|
+
motion: ThemeMotion;
|
|
136
|
+
zIndex: { base: number; dropdown: number; sticky: number; overlay: number; modal: number };
|
|
137
|
+
}
|