etendo-ui-library 1.0.70 → 1.0.71
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/components/tab/Tab.test.tsx +10 -13
- package/components/tab/Tab.tsx +51 -53
- package/components/tab/Tab.types.ts +7 -52
- package/components/tab/Tabs.stories.tsx +22 -27
- package/components/tab/__snapshots__/Tab.test.tsx.snap +185 -270
- package/components/tab/index.ts +1 -5
- package/package.json +1 -1
- package/storybook-static/{0.8c714f5c.iframe.bundle.js → 0.936bc955.iframe.bundle.js} +1 -1
- package/storybook-static/{4.d6d32e48.iframe.bundle.js → 4.beb6667d.iframe.bundle.js} +3 -3
- package/storybook-static/{4.d6d32e48.iframe.bundle.js.LICENSE.txt → 4.beb6667d.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/4.beb6667d.iframe.bundle.js.map +1 -0
- package/storybook-static/{5.46687043.iframe.bundle.js → 5.8cb39632.iframe.bundle.js} +1 -1
- package/storybook-static/{6.ec239662.iframe.bundle.js → 6.95d9a42e.iframe.bundle.js} +3 -3
- package/storybook-static/{6.ec239662.iframe.bundle.js.LICENSE.txt → 6.95d9a42e.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/6.95d9a42e.iframe.bundle.js.map +1 -0
- package/storybook-static/{7.29c10ea5.iframe.bundle.js → 7.dcbb2917.iframe.bundle.js} +1 -1
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/main.c60d2170.iframe.bundle.js +1 -0
- package/storybook-static/{runtime~main.743ef67e.iframe.bundle.js → runtime~main.80084830.iframe.bundle.js} +1 -1
- package/storybook-static/vendors~main.95f275f0.iframe.bundle.js +3 -0
- package/storybook-static/{vendors~main.e6f2d23f.iframe.bundle.js.LICENSE.txt → vendors~main.95f275f0.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/vendors~main.95f275f0.iframe.bundle.js.map +1 -0
- package/components/tab/Tab.styles.tsx +0 -107
- package/components/tab/TabItem.tsx +0 -88
- package/components/tab/TabItemSecundary.tsx +0 -88
- package/components/tab/TabSecundary.tsx +0 -65
- package/storybook-static/4.d6d32e48.iframe.bundle.js.map +0 -1
- package/storybook-static/6.ec239662.iframe.bundle.js.map +0 -1
- package/storybook-static/main.63b24d6c.iframe.bundle.js +0 -1
- package/storybook-static/vendors~main.e6f2d23f.iframe.bundle.js +0 -3
- package/storybook-static/vendors~main.e6f2d23f.iframe.bundle.js.map +0 -1
|
@@ -2,26 +2,23 @@ import React from 'react';
|
|
|
2
2
|
import renderer from 'react-test-renderer';
|
|
3
3
|
import Tab from './Tab';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
{name: '
|
|
7
|
-
{name: '
|
|
8
|
-
{name: '
|
|
9
|
-
{name: '
|
|
10
|
-
{name: '
|
|
11
|
-
{name: 'Observations', route: '', key: 'observations'},
|
|
5
|
+
const datasetTab = [
|
|
6
|
+
{name: 'Home', route: '/home', key: 'user'},
|
|
7
|
+
{name: 'About', route: '/about', key: 'vehicles'},
|
|
8
|
+
{name: 'Staff', route: '/staff', key: 'staff'},
|
|
9
|
+
{name: 'Login', route: '/login', key: 'skills'},
|
|
10
|
+
{name: 'Logout', route: '/logout', key: 'movilApp'},
|
|
12
11
|
];
|
|
13
12
|
|
|
14
|
-
const onCheckSelectedMock = () => dataset[0];
|
|
15
|
-
|
|
16
13
|
describe('Running Test for Tab', () => {
|
|
17
14
|
it('Check Tab Disabled', () => {
|
|
18
15
|
const tree = renderer
|
|
19
16
|
.create(
|
|
20
17
|
<Tab
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
tabInformation={datasetTab}
|
|
19
|
+
selectedTab={1}
|
|
20
|
+
setSelectedTab={() => {}}
|
|
21
|
+
height={40}
|
|
25
22
|
/>,
|
|
26
23
|
)
|
|
27
24
|
.toJSON();
|
package/components/tab/Tab.tsx
CHANGED
|
@@ -1,62 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
import React
|
|
3
|
-
import {
|
|
1
|
+
// Imports
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {View, Text, StyleSheet, TouchableOpacity} from 'react-native';
|
|
4
|
+
import {BLUE, GREY_BLUE_50, WHITE, YELLOW} from '../../styles/colors';
|
|
5
|
+
import {TabProps} from './Tab.types';
|
|
4
6
|
|
|
5
|
-
import TabItem from './TabItem';
|
|
6
|
-
import {TabProps, Info, TabStyleType} from './Tab.types';
|
|
7
|
-
import {TabStyleVariant} from './Tab.styles';
|
|
8
|
-
|
|
9
|
-
/* Styles - This function allows you to obtain the styles of the Tab component */
|
|
10
|
-
const getStyle = (style: TabStyleType, item: Info, pathname: any) => {
|
|
11
|
-
/* Returns the style chosen by the programmer */
|
|
12
|
-
if (item.route === pathname) {
|
|
13
|
-
return [TabStyleVariant[style].tabs, TabStyleVariant[style].tabsActive];
|
|
14
|
-
} else {
|
|
15
|
-
return TabStyleVariant[style].tabs;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/* Tab component */
|
|
20
7
|
const Tab = ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
tabInformation,
|
|
9
|
+
selectedTab,
|
|
10
|
+
setSelectedTab,
|
|
11
|
+
height,
|
|
12
|
+
fontFamily,
|
|
13
|
+
fontWeight,
|
|
27
14
|
}: TabProps) => {
|
|
28
|
-
/* Variable to handle the state of the tabs */
|
|
29
|
-
const [toggleItem, setToggleItem] = useState<number>(-1);
|
|
30
|
-
|
|
31
15
|
return (
|
|
32
|
-
<View style={
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
16
|
+
<View style={styles.container}>
|
|
17
|
+
{tabInformation.map((tabItem: any, index: number) => (
|
|
18
|
+
<TouchableOpacity
|
|
19
|
+
key={index}
|
|
20
|
+
style={[
|
|
21
|
+
styles.tab,
|
|
22
|
+
{
|
|
23
|
+
flex: 1 / tabInformation.length,
|
|
24
|
+
backgroundColor: index === selectedTab ? BLUE : GREY_BLUE_50,
|
|
25
|
+
height: height,
|
|
26
|
+
borderTopColor: index === selectedTab ? YELLOW : 'transparent',
|
|
27
|
+
},
|
|
28
|
+
]}
|
|
29
|
+
onPress={() => (setSelectedTab ? setSelectedTab(index) : {})}
|
|
30
|
+
>
|
|
31
|
+
<Text
|
|
32
|
+
style={{
|
|
33
|
+
color: index === selectedTab ? WHITE : BLUE,
|
|
34
|
+
fontFamily: fontFamily,
|
|
35
|
+
fontWeight: fontWeight,
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{tabItem.name}
|
|
39
|
+
</Text>
|
|
40
|
+
</TouchableOpacity>
|
|
41
|
+
))}
|
|
58
42
|
</View>
|
|
59
43
|
);
|
|
60
44
|
};
|
|
61
45
|
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
container: {
|
|
48
|
+
flexDirection: 'row',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
},
|
|
51
|
+
tab: {
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
borderBottomWidth: 3,
|
|
55
|
+
borderBottomColor: BLUE,
|
|
56
|
+
borderTopWidth: 4,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
62
60
|
export default Tab;
|
|
@@ -1,56 +1,11 @@
|
|
|
1
1
|
/* Imports */
|
|
2
|
-
import {StyleProp, TextStyle, ViewStyle} from 'react-native';
|
|
3
|
-
|
|
4
|
-
/* Type declaration */
|
|
5
|
-
export type Info = {
|
|
6
|
-
name: string;
|
|
7
|
-
route: string;
|
|
8
|
-
key: string;
|
|
9
|
-
};
|
|
10
2
|
|
|
11
3
|
export interface TabProps {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
renderItem?:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export interface TabItemProps {
|
|
21
|
-
style: StyleProp<ViewStyle>;
|
|
22
|
-
item: Info;
|
|
23
|
-
onPress: () => void;
|
|
24
|
-
index: number;
|
|
25
|
-
toggleItem: number;
|
|
26
|
-
styleText: TabStyleType;
|
|
27
|
-
sizeText: TabStyleFontSize;
|
|
28
|
-
renderItem: (item: any, styles: any) => JSX.Element;
|
|
29
|
-
pathname?: string;
|
|
4
|
+
tabInformation: any[];
|
|
5
|
+
selectedTab: number;
|
|
6
|
+
setSelectedTab?: (any: any | undefined) => any | Array<any>;
|
|
7
|
+
height?: number | string;
|
|
8
|
+
renderItem?: JSX.Element | Array<JSX.Element>;
|
|
9
|
+
fontFamily?: string | number | any;
|
|
10
|
+
fontWeight?: string | number | any;
|
|
30
11
|
}
|
|
31
|
-
|
|
32
|
-
/* Declaration of style types */
|
|
33
|
-
export type TabStyleType = 'primary' | 'secondary';
|
|
34
|
-
export type TabStyleFontSize = 'small' | 'medium' | 'large';
|
|
35
|
-
|
|
36
|
-
export type TabStyleRecord = Record<
|
|
37
|
-
TabStyleType,
|
|
38
|
-
{
|
|
39
|
-
container: ViewStyle;
|
|
40
|
-
containerSecundary: ViewStyle;
|
|
41
|
-
containerTabs?: ViewStyle;
|
|
42
|
-
tabs: ViewStyle;
|
|
43
|
-
tabsSecundary: ViewStyle;
|
|
44
|
-
tabsActive: ViewStyle;
|
|
45
|
-
tabsActiveSecundary: ViewStyle;
|
|
46
|
-
itemText: TextStyle;
|
|
47
|
-
itemTextSecundary: TextStyle;
|
|
48
|
-
}
|
|
49
|
-
>;
|
|
50
|
-
|
|
51
|
-
export type TabStyleText = Record<
|
|
52
|
-
TabStyleFontSize,
|
|
53
|
-
{
|
|
54
|
-
fontSize: TextStyle;
|
|
55
|
-
}
|
|
56
|
-
>;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
2
|
import {Story, Meta} from '@storybook/react';
|
|
3
3
|
|
|
4
4
|
import Tab from './Tab';
|
|
5
|
-
import {TabProps} from './Tab.types';
|
|
6
5
|
import {View} from 'react-native';
|
|
7
|
-
import { styles } from './Tab.styles';
|
|
8
|
-
import addMarginContainer from '../../helpers/addMargin';
|
|
9
6
|
|
|
10
7
|
const meta: Meta = {
|
|
11
8
|
title: 'Etendo/Tab',
|
|
@@ -15,32 +12,30 @@ const meta: Meta = {
|
|
|
15
12
|
export default meta;
|
|
16
13
|
|
|
17
14
|
/* Information to pass */
|
|
18
|
-
const
|
|
19
|
-
{name: '
|
|
20
|
-
{name: '
|
|
21
|
-
{name: '
|
|
22
|
-
{name: '
|
|
23
|
-
{name: '
|
|
24
|
-
{name: 'Routing options', route: '', key: 'routing options'},
|
|
25
|
-
{name: 'Map', route: '', key: 'map'},
|
|
15
|
+
const datasetTab = [
|
|
16
|
+
{name: 'Home', route: '/home', key: 'user'},
|
|
17
|
+
{name: 'About', route: '/about', key: 'vehicles'},
|
|
18
|
+
{name: 'Staff', route: '/staff', key: 'staff'},
|
|
19
|
+
{name: 'Login', route: '/login', key: 'skills'},
|
|
20
|
+
{name: 'Logout', route: '/logout', key: 'movilApp'},
|
|
26
21
|
];
|
|
27
22
|
|
|
28
|
-
/* This function allows you to select by default the first tab */
|
|
29
|
-
const onCheckSelectedMock = () => dataset[0];
|
|
30
|
-
|
|
31
23
|
/* Templates */
|
|
32
|
-
const Template0: Story<TabProps> = args => (
|
|
33
|
-
<View style={[styles.storiesContainer, addMarginContainer()]}>
|
|
34
|
-
<Tab {...args} />
|
|
35
|
-
</View>
|
|
36
|
-
);
|
|
37
24
|
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
const Template0: Story<any> = args => {
|
|
26
|
+
const [selectedTab, setSelectedTab] = useState(0);
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
return (
|
|
29
|
+
<View style={{padding: 20}}>
|
|
30
|
+
<Tab
|
|
31
|
+
tabInformation={datasetTab}
|
|
32
|
+
selectedTab={selectedTab}
|
|
33
|
+
setSelectedTab={setSelectedTab}
|
|
34
|
+
height={40}
|
|
35
|
+
/>
|
|
36
|
+
</View>
|
|
37
|
+
);
|
|
46
38
|
};
|
|
39
|
+
|
|
40
|
+
/* Story exports */
|
|
41
|
+
export const TabDefault = Template0.bind({});
|