@lamenna/lxp-native 0.0.2 → 0.1.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.
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button options tests - React Native package
|
|
3
|
+
*
|
|
4
|
+
* These tests validate that the React Native package can consume the
|
|
5
|
+
* shared button configuration (variants, sizes, common styles). They
|
|
6
|
+
* deliberately avoid React Native runtime dependencies so they work
|
|
7
|
+
* in a plain Jest + ts-jest environment.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button options tests - React Native package
|
|
3
|
+
*
|
|
4
|
+
* These tests validate that the React Native package can consume the
|
|
5
|
+
* shared button configuration (variants, sizes, common styles). They
|
|
6
|
+
* deliberately avoid React Native runtime dependencies so they work
|
|
7
|
+
* in a plain Jest + ts-jest environment.
|
|
8
|
+
*/
|
|
9
|
+
import { buttonConfig } from "@lamenna/lxp-shared-components";
|
|
10
|
+
describe("Button options (React Native)", () => {
|
|
11
|
+
it("should expose primary and secondary variants", () => {
|
|
12
|
+
expect(buttonConfig.variants.primary).toBeDefined();
|
|
13
|
+
expect(buttonConfig.variants.secondary).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
it("should expose standard sizes", () => {
|
|
16
|
+
expect(buttonConfig.sizes.sm).toBeDefined();
|
|
17
|
+
expect(buttonConfig.sizes.md).toBeDefined();
|
|
18
|
+
expect(buttonConfig.sizes.lg).toBeDefined();
|
|
19
|
+
});
|
|
20
|
+
it("should have common button styles configured", () => {
|
|
21
|
+
expect(buttonConfig.common.borderRadius).toBeDefined();
|
|
22
|
+
expect(buttonConfig.common.cursor).toBe("pointer");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -3,4 +3,4 @@ import { TouchableOpacityProps } from "react-native";
|
|
|
3
3
|
import { ReactNativeButtonProps } from "@lamenna/lxp-shared-components";
|
|
4
4
|
export type { ReactNativeButtonProps as ButtonProps };
|
|
5
5
|
type Props = ReactNativeButtonProps & Omit<TouchableOpacityProps, "style">;
|
|
6
|
-
export declare const Button: ({ children, variant, size, disabled, testID, onPress, ...rest }: Props) => React.JSX.Element;
|
|
6
|
+
export declare const Button: ({ children, label, variant, size, disabled, testID, onPress, ...rest }: Props) => React.JSX.Element;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TouchableOpacity, Text, StyleSheet, } from "react-native";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
? styles.large
|
|
11
|
-
: styles.medium;
|
|
3
|
+
import { buttonConfig, } from "@lamenna/lxp-shared-components";
|
|
4
|
+
export const Button = ({ children, label, variant = "primary", size = "md", disabled = false, testID, onPress, ...rest }) => {
|
|
5
|
+
const variantConfig = buttonConfig.variants[variant];
|
|
6
|
+
const sizeStyle = size === "sm" ? styles.small : size === "lg" ? styles.large : styles.medium;
|
|
7
|
+
// `label` is the platform-agnostic text prop; `children` takes precedence for
|
|
8
|
+
// callers that need richer content.
|
|
9
|
+
const content = children ?? label;
|
|
12
10
|
return (<TouchableOpacity style={[
|
|
13
11
|
styles.button,
|
|
14
|
-
|
|
12
|
+
{
|
|
13
|
+
backgroundColor: variantConfig.backgroundColor,
|
|
14
|
+
},
|
|
15
15
|
sizeStyle,
|
|
16
16
|
disabled && styles.disabled,
|
|
17
17
|
]} onPress={onPress} activeOpacity={0.7} disabled={disabled} testID={testID} {...rest}>
|
|
18
|
-
<Text style={styles.text
|
|
18
|
+
<Text style={[styles.text, { color: variantConfig.color }]}>
|
|
19
|
+
{content}
|
|
20
|
+
</Text>
|
|
19
21
|
</TouchableOpacity>);
|
|
20
22
|
};
|
|
21
23
|
const styles = StyleSheet.create({
|
|
@@ -24,12 +26,6 @@ const styles = StyleSheet.create({
|
|
|
24
26
|
alignItems: "center",
|
|
25
27
|
justifyContent: "center",
|
|
26
28
|
},
|
|
27
|
-
primaryButton: {
|
|
28
|
-
backgroundColor: "#2563EB",
|
|
29
|
-
},
|
|
30
|
-
secondaryButton: {
|
|
31
|
-
backgroundColor: "#7C3AED",
|
|
32
|
-
},
|
|
33
29
|
small: {
|
|
34
30
|
paddingVertical: 6,
|
|
35
31
|
paddingHorizontal: 12,
|
|
@@ -43,7 +39,7 @@ const styles = StyleSheet.create({
|
|
|
43
39
|
paddingHorizontal: 32,
|
|
44
40
|
},
|
|
45
41
|
disabled: {
|
|
46
|
-
opacity: 0.
|
|
42
|
+
opacity: 0.5,
|
|
47
43
|
},
|
|
48
44
|
text: {
|
|
49
45
|
color: "#FFFFFF",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lamenna/lxp-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React Native components for LXP",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,27 +11,27 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"react": "^
|
|
15
|
-
"react-native": ">=0.
|
|
14
|
+
"react": "^19.0.0",
|
|
15
|
+
"react-native": ">=0.83.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@lamenna/lxp-core": "0.0
|
|
19
|
-
"@lamenna/lxp-tokens": "0.0
|
|
20
|
-
"@lamenna/lxp-shared-components": "0.0
|
|
18
|
+
"@lamenna/lxp-core": "0.1.0",
|
|
19
|
+
"@lamenna/lxp-tokens": "0.1.0",
|
|
20
|
+
"@lamenna/lxp-shared-components": "0.1.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/react": "
|
|
23
|
+
"@types/react": "^19.0.0",
|
|
24
24
|
"@types/react-native": "^0.73.0",
|
|
25
|
-
"react": "^
|
|
26
|
-
"react-native": "
|
|
27
|
-
"typescript": "^5.
|
|
25
|
+
"react": "^19.2.3",
|
|
26
|
+
"react-native": "0.83.0",
|
|
27
|
+
"typescript": "^5.9.3"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc",
|
|
31
31
|
"dev": "tsc --watch",
|
|
32
|
-
"test": "jest",
|
|
33
|
-
"test:watch": "jest --watch",
|
|
34
|
-
"test:coverage": "jest --coverage",
|
|
32
|
+
"test": "jest --passWithNoTests",
|
|
33
|
+
"test:watch": "jest --watch --passWithNoTests",
|
|
34
|
+
"test:coverage": "jest --coverage --passWithNoTests",
|
|
35
35
|
"clean": "rm -rf dist"
|
|
36
36
|
}
|
|
37
37
|
}
|