@qumra/fanar-native 0.1.1 → 0.1.4
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/lib/components/Surfaces.js +1 -1
- package/lib/icons.d.ts +13 -0
- package/lib/icons.js +87 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/qumra/NavIcon.js +7 -5
- package/lib/qumra/QumraIcon.js +10 -4
- package/lib/qumra/data.generated.js +168 -24
- package/lib/theme/context.d.ts +2 -1
- package/lib/theme/context.js +3 -3
- package/lib/theme/theme.d.ts +1 -1
- package/lib/theme/theme.js +11 -3
- package/package.json +5 -3
package/lib/theme/context.d.ts
CHANGED
|
@@ -17,8 +17,9 @@ export interface FanarProviderProps {
|
|
|
17
17
|
mode?: ColorMode | 'system';
|
|
18
18
|
lang?: Lang;
|
|
19
19
|
fonts?: FontSet;
|
|
20
|
+
fontScale?: number;
|
|
20
21
|
}
|
|
21
|
-
export declare function FanarProvider({ children, mode, lang, fonts, }: FanarProviderProps): import("react").JSX.Element;
|
|
22
|
+
export declare function FanarProvider({ children, mode, lang, fonts, fontScale, }: FanarProviderProps): import("react").JSX.Element;
|
|
22
23
|
export declare function useFanar(): FanarContextValue;
|
|
23
24
|
export declare function useTheme(): FanarTheme;
|
|
24
25
|
export declare function useLang(): {
|
package/lib/theme/context.js
CHANGED
|
@@ -5,13 +5,13 @@ import { buildTheme } from './theme';
|
|
|
5
5
|
import { ALEXANDRIA } from './fonts';
|
|
6
6
|
import { phrase, translate } from '../i18n';
|
|
7
7
|
const Ctx = createContext(null);
|
|
8
|
-
export function FanarProvider({ children, mode = 'system', lang = 'ar', fonts = ALEXANDRIA, }) {
|
|
8
|
+
export function FanarProvider({ children, mode = 'system', lang = 'ar', fonts = ALEXANDRIA, fontScale = 1, }) {
|
|
9
9
|
const scheme = useColorScheme();
|
|
10
10
|
const resolved = mode === 'system' ? (scheme === 'dark' ? 'dark' : 'light') : mode;
|
|
11
11
|
const value = useMemo(() => {
|
|
12
12
|
const en = lang === 'en';
|
|
13
13
|
return {
|
|
14
|
-
theme: buildTheme(resolved, fonts),
|
|
14
|
+
theme: buildTheme(resolved, fonts, fontScale),
|
|
15
15
|
mode: resolved,
|
|
16
16
|
lang,
|
|
17
17
|
en,
|
|
@@ -20,7 +20,7 @@ export function FanarProvider({ children, mode = 'system', lang = 'ar', fonts =
|
|
|
20
20
|
p: (key, vars) => phrase(key, en, vars),
|
|
21
21
|
pick: (ar, enValue) => (en ? enValue : ar),
|
|
22
22
|
};
|
|
23
|
-
}, [resolved, lang, fonts]);
|
|
23
|
+
}, [resolved, lang, fonts, fontScale]);
|
|
24
24
|
return (_jsx(Ctx.Provider, { value: value, children: _jsx(View, { style: [styles.root, { direction: value.dir }], children: children }) }));
|
|
25
25
|
}
|
|
26
26
|
const styles = StyleSheet.create({ root: { flex: 1 } });
|
package/lib/theme/theme.d.ts
CHANGED
|
@@ -49,4 +49,4 @@ export interface FanarTheme {
|
|
|
49
49
|
minLeading: number;
|
|
50
50
|
colorOf: (name: ColorToken | (string & {}) | undefined, fallback: string) => string;
|
|
51
51
|
}
|
|
52
|
-
export declare function buildTheme(mode: ColorMode, fonts?: FontSet): FanarTheme;
|
|
52
|
+
export declare function buildTheme(mode: ColorMode, fonts?: FontSet, fontScale?: number): FanarTheme;
|
package/lib/theme/theme.js
CHANGED
|
@@ -43,8 +43,16 @@ function shadowScale(tokens) {
|
|
|
43
43
|
return out;
|
|
44
44
|
}
|
|
45
45
|
const CACHE = {};
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
function scaleText(base, scale) {
|
|
47
|
+
if (scale === 1)
|
|
48
|
+
return { ...base };
|
|
49
|
+
const out = {};
|
|
50
|
+
for (const k of Object.keys(base))
|
|
51
|
+
out[k] = Math.round(base[k] * scale);
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
export function buildTheme(mode, fonts = ALEXANDRIA, fontScale = 1) {
|
|
55
|
+
const key = `${mode}:${fontScale}:${Object.values(fonts).join('|')}`;
|
|
48
56
|
const hit = CACHE[key];
|
|
49
57
|
if (hit)
|
|
50
58
|
return hit;
|
|
@@ -62,7 +70,7 @@ export function buildTheme(mode, fonts = ALEXANDRIA) {
|
|
|
62
70
|
mode,
|
|
63
71
|
dark,
|
|
64
72
|
color,
|
|
65
|
-
text:
|
|
73
|
+
text: scaleText(TEXT_PX, fontScale),
|
|
66
74
|
radius: { ...RADIUS_PX },
|
|
67
75
|
shadow: shadowScale(tokens),
|
|
68
76
|
space: SPACE,
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qumra/fanar-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Qumra's React Native component library \u2014 the native sibling of @qumra/fanar. Token-driven, RTL-first, zero runtime dependencies.",
|
|
4
5
|
"license": "UNLICENSED",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"qumra",
|
|
@@ -35,9 +36,10 @@
|
|
|
35
36
|
"typecheck": "tsc -p tsconfig.check.json --noEmit",
|
|
36
37
|
"check-resolution": "node scripts/check-resolution.mjs",
|
|
37
38
|
"build": "node scripts/build.mjs",
|
|
38
|
-
"verify": "node scripts/check-resolution.mjs && node scripts/sync-tokens.mjs --check && node scripts/generate-tokens.mjs --check && npm run typecheck",
|
|
39
|
+
"verify": "node scripts/check-resolution.mjs && node scripts/check-icon-scale.mjs && node scripts/sync-tokens.mjs --check && node scripts/generate-tokens.mjs --check && npm run typecheck",
|
|
39
40
|
"prepublishOnly": "npm run verify && npm run build && npm run check-publish",
|
|
40
|
-
"check-publish": "node scripts/check-publish.mjs"
|
|
41
|
+
"check-publish": "node scripts/check-publish.mjs",
|
|
42
|
+
"check-icon-scale": "node scripts/check-icon-scale.mjs"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
45
|
"lucide-react-native": ">=0.400.0",
|