@snapbox/pkg-ui 1.0.1
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/components/AppIcon.d.ts +9 -0
- package/dist/components/AppIcon.js +34 -0
- package/dist/components/CustomNavigationBar.d.ts +3 -0
- package/dist/components/CustomNavigationBar.js +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/theme/colors.d.ts +6 -0
- package/dist/theme/colors.js +72 -0
- package/package.json +34 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyleProp, TextStyle } from "react-native";
|
|
3
|
+
export interface AppIconProps {
|
|
4
|
+
glyph: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
style?: StyleProp<TextStyle>;
|
|
8
|
+
}
|
|
9
|
+
export declare function AppIcon({ glyph, size, color, style }: AppIconProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import AntDesign from "@react-native-vector-icons/ant-design";
|
|
2
|
+
import Feather from "@react-native-vector-icons/feather";
|
|
3
|
+
import FontAwesome from "@react-native-vector-icons/fontawesome";
|
|
4
|
+
import Foundation from "@react-native-vector-icons/foundation";
|
|
5
|
+
import Ionicons from "@react-native-vector-icons/ionicons";
|
|
6
|
+
import Lucide from "@react-native-vector-icons/lucide";
|
|
7
|
+
import MaterialDesignIcons from "@react-native-vector-icons/material-design-icons";
|
|
8
|
+
import Octicons from "@react-native-vector-icons/octicons";
|
|
9
|
+
import React from "react";
|
|
10
|
+
const iconFamilies = {
|
|
11
|
+
AntDesign,
|
|
12
|
+
Feather,
|
|
13
|
+
FontAwesome,
|
|
14
|
+
Foundation,
|
|
15
|
+
Ionicons,
|
|
16
|
+
Lucide,
|
|
17
|
+
MaterialDesignIcons,
|
|
18
|
+
Octicons,
|
|
19
|
+
};
|
|
20
|
+
export function AppIcon({ glyph, size = 24, color, style }) {
|
|
21
|
+
const parts = glyph.split(":");
|
|
22
|
+
if (parts.length !== 2) {
|
|
23
|
+
console.warn(`Invalid glyph format: ${glyph}. Expected format "Family:name".`);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const family = parts[0];
|
|
27
|
+
const name = parts[1];
|
|
28
|
+
const IconComponent = iconFamilies[family];
|
|
29
|
+
if (!IconComponent) {
|
|
30
|
+
console.warn(`Icon family ${family} not found.`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return <IconComponent name={name} size={size} color={color} style={style}/>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Appbar } from "react-native-paper";
|
|
2
|
+
import { getHeaderTitle } from "@react-navigation/elements";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export function CustomNavigationBar({ navigation, route, options, back, }) {
|
|
5
|
+
const title = getHeaderTitle(options, route.name);
|
|
6
|
+
return (<Appbar.Header>
|
|
7
|
+
{back ? <Appbar.BackAction onPress={navigation.goBack}/> : null}
|
|
8
|
+
<Appbar.Content title={title}/>
|
|
9
|
+
</Appbar.Header>);
|
|
10
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { argbFromHex, hexFromArgb, themeFromSourceColor, } from "@material/material-color-utilities";
|
|
2
|
+
import Color from "color";
|
|
3
|
+
const opacity = {
|
|
4
|
+
level1: 0.08,
|
|
5
|
+
level2: 0.12,
|
|
6
|
+
level3: 0.16,
|
|
7
|
+
level4: 0.38,
|
|
8
|
+
};
|
|
9
|
+
const elevationLevels = [0.05, 0.08, 0.11, 0.12, 0.14];
|
|
10
|
+
export function generateThemeColors(primary, secondary, tertiary) {
|
|
11
|
+
const generateVariant = (type) => {
|
|
12
|
+
const baseTheme = themeFromSourceColor(argbFromHex(primary));
|
|
13
|
+
const scheme = baseTheme.schemes[type].toJSON();
|
|
14
|
+
if (secondary) {
|
|
15
|
+
const secondaryTheme = themeFromSourceColor(argbFromHex(secondary));
|
|
16
|
+
const secondaryScheme = secondaryTheme.schemes[type].toJSON();
|
|
17
|
+
scheme.secondary = secondaryScheme.primary;
|
|
18
|
+
scheme.onSecondary = secondaryScheme.onPrimary;
|
|
19
|
+
scheme.secondaryContainer = secondaryScheme.primaryContainer;
|
|
20
|
+
scheme.onSecondaryContainer = secondaryScheme.onPrimaryContainer;
|
|
21
|
+
}
|
|
22
|
+
if (tertiary) {
|
|
23
|
+
const tertiaryTheme = themeFromSourceColor(argbFromHex(tertiary));
|
|
24
|
+
const tertiaryScheme = tertiaryTheme.schemes[type].toJSON();
|
|
25
|
+
scheme.tertiary = tertiaryScheme.primary;
|
|
26
|
+
scheme.onTertiary = tertiaryScheme.onPrimary;
|
|
27
|
+
scheme.tertiaryContainer = tertiaryScheme.primaryContainer;
|
|
28
|
+
scheme.onTertiaryContainer = tertiaryScheme.onPrimaryContainer;
|
|
29
|
+
}
|
|
30
|
+
// Convert scheme ARGB values to rgb string
|
|
31
|
+
const rgbTheme = {};
|
|
32
|
+
for (const [key, value] of Object.entries(scheme)) {
|
|
33
|
+
rgbTheme[key] = Color(hexFromArgb(value))
|
|
34
|
+
.rgb()
|
|
35
|
+
.string();
|
|
36
|
+
}
|
|
37
|
+
// Prepare elevations
|
|
38
|
+
const elevations = {
|
|
39
|
+
level0: "transparent",
|
|
40
|
+
};
|
|
41
|
+
for (let i = 0; i < elevationLevels.length; i++) {
|
|
42
|
+
elevations[`level${i + 1}`] = Color(hexFromArgb(scheme.surface))
|
|
43
|
+
.mix(Color(hexFromArgb(scheme.primary)), elevationLevels[i])
|
|
44
|
+
.rgb()
|
|
45
|
+
.string();
|
|
46
|
+
}
|
|
47
|
+
// Prepare surface colors
|
|
48
|
+
const surfaceDisabled = Color(hexFromArgb(scheme.onSurface))
|
|
49
|
+
.alpha(opacity.level2)
|
|
50
|
+
.rgb()
|
|
51
|
+
.string();
|
|
52
|
+
const onSurfaceDisabled = Color(hexFromArgb(scheme.onSurface))
|
|
53
|
+
.alpha(opacity.level4)
|
|
54
|
+
.rgb()
|
|
55
|
+
.string();
|
|
56
|
+
const backdrop = Color(hexFromArgb(baseTheme.palettes.neutralVariant.tone(20)))
|
|
57
|
+
.alpha(0.4)
|
|
58
|
+
.rgb()
|
|
59
|
+
.string();
|
|
60
|
+
return {
|
|
61
|
+
...rgbTheme,
|
|
62
|
+
elevation: elevations,
|
|
63
|
+
surfaceDisabled,
|
|
64
|
+
onSurfaceDisabled,
|
|
65
|
+
backdrop,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
light: generateVariant("light"),
|
|
70
|
+
dark: generateVariant("dark"),
|
|
71
|
+
};
|
|
72
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@snapbox/pkg-ui",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"prepublishOnly": "yarn build"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@material/material-color-utilities": "^0.4.0",
|
|
13
|
+
"@react-native-vector-icons/ant-design": "^12.4.1",
|
|
14
|
+
"@react-native-vector-icons/feather": "^12.4.1",
|
|
15
|
+
"@react-native-vector-icons/fontawesome": "^12.4.1",
|
|
16
|
+
"@react-native-vector-icons/foundation": "^12.4.1",
|
|
17
|
+
"@react-native-vector-icons/ionicons": "^12.4.1",
|
|
18
|
+
"@react-native-vector-icons/lucide": "^12.4.1",
|
|
19
|
+
"@react-native-vector-icons/material-design-icons": "^12.4.1",
|
|
20
|
+
"@react-native-vector-icons/octicons": "^20.4.1",
|
|
21
|
+
"@react-navigation/elements": "^2.8.1",
|
|
22
|
+
"@react-navigation/native-stack": "^7.14.5",
|
|
23
|
+
"color": "^5.0.3",
|
|
24
|
+
"react-native-paper": "^5.15.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": "*",
|
|
28
|
+
"react-native": "*"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/color": "^4.2.1",
|
|
32
|
+
"typescript": "~5.9.2"
|
|
33
|
+
}
|
|
34
|
+
}
|