dhre-ui-kit 0.0.2 → 0.0.3
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/package.json +4 -4
- package/src/components/badge/Badge.test.tsx +12 -0
- package/src/components/badge/Badge.tsx +2 -1
- package/src/components/button/Button.interface.ts +0 -2
- package/src/components/button/Button.tsx +2 -7
- package/src/components/customText/CustomText.tsx +3 -3
- package/src/theme/ThemeContext.tsx +6 -6
- package/src/theme/fonts.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dhre-ui-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"react": "18.2.0",
|
|
28
28
|
"react-native": "0.74.3",
|
|
29
29
|
"react-native-blob-util": "^0.19.11",
|
|
30
|
-
"react-native-otp-verify": "^1.1.8",
|
|
31
30
|
"react-native-gesture-handler": "2.17.0",
|
|
31
|
+
"react-native-otp-verify": "^1.1.8",
|
|
32
32
|
"react-native-pdf": "^6.7.5",
|
|
33
33
|
"react-native-progress": "^5.0.1",
|
|
34
34
|
"react-native-svg": "^15.4.0",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"rn-tooltip": "^3.0.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@babel/core": "^7.
|
|
42
|
-
"@babel/preset-env": "^7.25.
|
|
41
|
+
"@babel/core": "^7.25.2",
|
|
42
|
+
"@babel/preset-env": "^7.25.4",
|
|
43
43
|
"@babel/runtime": "^7.20.0",
|
|
44
44
|
"@eslint/js": "^9.7.0",
|
|
45
45
|
"@react-native/babel-preset": "0.74.85",
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {render, screen} from '@testing-library/react-native';
|
|
3
3
|
import Badge from './Badge';
|
|
4
|
+
import {useSelector} from 'react-redux';
|
|
5
|
+
|
|
6
|
+
// Mock the useSelector hook
|
|
4
7
|
|
|
5
8
|
describe('Badge component', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
(useSelector as unknown as jest.Mock).mockImplementation(() => {
|
|
11
|
+
return 'light';
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
6
15
|
it('renders text correctly', () => {
|
|
7
16
|
const text = 'Test Badge';
|
|
8
17
|
render(
|
|
@@ -26,6 +35,7 @@ describe('Badge component', () => {
|
|
|
26
35
|
}}
|
|
27
36
|
/>,
|
|
28
37
|
);
|
|
38
|
+
// Your assertions here
|
|
29
39
|
});
|
|
30
40
|
|
|
31
41
|
it('renders with custom style', () => {
|
|
@@ -41,5 +51,7 @@ describe('Badge component', () => {
|
|
|
41
51
|
|
|
42
52
|
const badge = screen.getByTestId('BADGE');
|
|
43
53
|
expect(badge).toBeDefined();
|
|
54
|
+
// You can also check if the custom style is applied correctly
|
|
55
|
+
expect(badge.props.style).toContainEqual(customStyle);
|
|
44
56
|
});
|
|
45
57
|
});
|
|
@@ -4,6 +4,7 @@ import commonStyles from '../../utils/commonStyles';
|
|
|
4
4
|
import styles from './Badge.styles';
|
|
5
5
|
import {SvgProps} from 'react-native-svg';
|
|
6
6
|
import CustomTypography from '../customTypography/CustomTypography';
|
|
7
|
+
import {withThemeProvider} from '../../theme/withThemeProvider';
|
|
7
8
|
|
|
8
9
|
interface BadgeProps {
|
|
9
10
|
text?: string;
|
|
@@ -44,4 +45,4 @@ const Badge: React.FC<BadgeProps> = ({
|
|
|
44
45
|
);
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
export default Badge;
|
|
48
|
+
export default withThemeProvider(Badge);
|
|
@@ -5,8 +5,6 @@ import {BUTTON_TYPES} from '../../utils/constants';
|
|
|
5
5
|
import {ButtonProps} from './Button.interface';
|
|
6
6
|
import {DHRE_COLORS_TEXT} from '../../theme/colors';
|
|
7
7
|
import CustomTypography from '../customTypography/CustomTypography';
|
|
8
|
-
import { useTheme } from '../../theme/ThemeContext';
|
|
9
|
-
import { withThemeProvider } from '../../theme/withThemeProvider';
|
|
10
8
|
|
|
11
9
|
const Button: React.FC<ButtonProps> = ({
|
|
12
10
|
onPress,
|
|
@@ -20,11 +18,8 @@ const Button: React.FC<ButtonProps> = ({
|
|
|
20
18
|
titleShown = true,
|
|
21
19
|
iconShown = false,
|
|
22
20
|
iconName,
|
|
23
|
-
buttonContainerColor='SURFACE_PRIMARY',
|
|
24
21
|
}) => {
|
|
25
|
-
const
|
|
26
|
-
console.log(theme[buttonContainerColor],)
|
|
27
|
-
const buttonStyles = [styles.button, styles[buttonType], buttonStyle,{backgroundColor:theme[buttonContainerColor]}];
|
|
22
|
+
const buttonStyles = [styles.button, styles[buttonType], buttonStyle];
|
|
28
23
|
const textStyle = [styles[buttonType + BUTTON_TYPES.TEXT], titleStyle];
|
|
29
24
|
const iconStyle = [styles.iconStyle, iconStyles];
|
|
30
25
|
|
|
@@ -54,5 +49,5 @@ const Button: React.FC<ButtonProps> = ({
|
|
|
54
49
|
</View>
|
|
55
50
|
);
|
|
56
51
|
};
|
|
57
|
-
export default withThemeProvider(Button);
|
|
58
52
|
|
|
53
|
+
export default Button;
|
|
@@ -9,17 +9,17 @@ interface CustomTextProps extends TextProps {
|
|
|
9
9
|
text: string;
|
|
10
10
|
variant: keyof typeof FONT_STYLES | string;
|
|
11
11
|
style?: TextStyle;
|
|
12
|
-
textColor?:string
|
|
12
|
+
textColor?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const CustomText: React.FC<CustomTextProps> = ({
|
|
16
16
|
text,
|
|
17
17
|
style,
|
|
18
18
|
variant,
|
|
19
|
-
textColor='SURFACE_STATIC',
|
|
19
|
+
textColor = 'SURFACE_STATIC',
|
|
20
20
|
...props
|
|
21
21
|
}) => {
|
|
22
|
-
const {
|
|
22
|
+
const {theme} = useTheme();
|
|
23
23
|
return (
|
|
24
24
|
<CustomTypography
|
|
25
25
|
variant={variant}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, {createContext, useContext, ReactNode} from 'react';
|
|
2
|
-
|
|
3
2
|
import {useSelector} from 'react-redux';
|
|
4
3
|
import theme from './themes';
|
|
5
4
|
|
|
@@ -13,9 +12,10 @@ interface ThemeProviderProps {
|
|
|
13
12
|
children: ReactNode;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export const ThemeProvider: React.FC<ThemeProviderProps> = ({
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export const ThemeProvider: React.FC<ThemeProviderProps> = ({children}) => {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
const mode = useSelector((state: any) => state.theme.currentTheme);
|
|
18
|
+
// const mode = 'light'
|
|
19
19
|
// Filter the theme based on the mode (light or dark)
|
|
20
20
|
const filteredTheme = Object.keys(theme).reduce((acc, key) => {
|
|
21
21
|
acc[key] = theme[key][mode];
|
|
@@ -23,12 +23,12 @@ export const ThemeProvider: React.FC<ThemeProviderProps> = ({ children }) => {
|
|
|
23
23
|
}, {} as Record<string, string>);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<ThemeContext.Provider value={{
|
|
26
|
+
<ThemeContext.Provider value={{theme: filteredTheme}}>
|
|
27
27
|
{children}
|
|
28
28
|
</ThemeContext.Provider>
|
|
29
29
|
);
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
export const useTheme = (): ThemeContextType => {
|
|
33
33
|
const context = useContext(ThemeContext);
|
|
34
34
|
if (context === undefined) {
|
package/src/theme/fonts.ts
CHANGED
|
@@ -15,6 +15,14 @@ const createFontStyle = (
|
|
|
15
15
|
fontFamily,
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
export const meraasActivFontfamily: TextStyle = {
|
|
19
|
+
fontFamily: 'MeraasAktiv_Rg'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const serifActivFontfamily: TextStyle = {
|
|
23
|
+
fontFamily: 'PT Serif'
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
export const FONT_STYLES: FontStyles = {
|
|
19
27
|
// Bold headding styles
|
|
20
28
|
H1_BOLD: createFontStyle('MeraasAktiv_Bd', 40, 56),
|