@tecsinapse/react-web-kit 1.5.0 → 1.6.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/CHANGELOG.md +54 -0
- package/dist/components/atoms/Accordion/Accordion.d.ts +9 -0
- package/dist/components/atoms/Accordion/Accordion.js +85 -0
- package/dist/components/atoms/Accordion/Accordion.js.map +1 -0
- package/dist/components/atoms/Accordion/animations.d.ts +41 -0
- package/dist/components/atoms/Accordion/animations.js +65 -0
- package/dist/components/atoms/Accordion/animations.js.map +1 -0
- package/dist/components/atoms/Accordion/index.d.ts +1 -0
- package/dist/components/atoms/Accordion/index.js +24 -0
- package/dist/components/atoms/Accordion/index.js.map +1 -0
- package/dist/components/atoms/Accordion/styled.d.ts +8 -0
- package/dist/components/atoms/Accordion/styled.js +53 -0
- package/dist/components/atoms/Accordion/styled.js.map +1 -0
- package/dist/components/atoms/Badge/index.js +2 -2
- package/dist/components/atoms/Button/index.js +2 -2
- package/dist/components/atoms/Button/styled.js +5 -3
- package/dist/components/atoms/Button/styled.js.map +1 -1
- package/dist/components/atoms/Input/index.js +2 -2
- package/dist/components/atoms/Modal/Modal.d.ts +8 -0
- package/dist/components/atoms/Modal/Modal.js +43 -0
- package/dist/components/atoms/Modal/Modal.js.map +1 -0
- package/dist/components/atoms/Modal/animations.d.ts +23 -0
- package/dist/components/atoms/Modal/animations.js +32 -0
- package/dist/components/atoms/Modal/animations.js.map +1 -0
- package/dist/components/atoms/Modal/index.d.ts +1 -0
- package/dist/components/atoms/Modal/index.js +24 -0
- package/dist/components/atoms/Modal/index.js.map +1 -0
- package/dist/components/atoms/Modal/styled.d.ts +2 -0
- package/dist/components/atoms/Modal/styled.js +39 -0
- package/dist/components/atoms/Modal/styled.js.map +1 -0
- package/dist/components/atoms/Overlay/Overlay.d.ts +10 -0
- package/dist/components/atoms/Overlay/Overlay.js +40 -0
- package/dist/components/atoms/Overlay/Overlay.js.map +1 -0
- package/dist/components/atoms/Overlay/animations.d.ts +18 -0
- package/dist/components/atoms/Overlay/animations.js +27 -0
- package/dist/components/atoms/Overlay/animations.js.map +1 -0
- package/dist/components/atoms/Overlay/index.d.ts +1 -0
- package/dist/components/atoms/Overlay/index.js +16 -0
- package/dist/components/atoms/Overlay/index.js.map +1 -0
- package/dist/components/atoms/Overlay/styled.d.ts +2 -0
- package/dist/components/atoms/Overlay/styled.js +36 -0
- package/dist/components/atoms/Overlay/styled.js.map +1 -0
- package/dist/components/atoms/Skeleton/index.js +2 -2
- package/dist/components/atoms/Table/Toolbar/index.js +2 -2
- package/dist/components/atoms/Tag/index.js +2 -2
- package/dist/components/molecules/Breadcrumbs/BreadcrumbItem/index.js +2 -2
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.d.ts +3 -3
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.js +3 -3
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/molecules/Breadcrumbs/index.d.ts +1 -1
- package/dist/components/molecules/Breadcrumbs/index.js +8 -2
- package/dist/components/molecules/Breadcrumbs/index.js.map +1 -1
- package/dist/components/molecules/Drawer/Drawer.js +8 -11
- package/dist/components/molecules/Drawer/Drawer.js.map +1 -1
- package/dist/components/molecules/Drawer/animations.d.ts +0 -18
- package/dist/components/molecules/Drawer/animations.js +1 -21
- package/dist/components/molecules/Drawer/animations.js.map +1 -1
- package/dist/components/molecules/Drawer/index.js +2 -2
- package/dist/components/molecules/Drawer/styled.d.ts +0 -1
- package/dist/components/molecules/Drawer/styled.js +2 -21
- package/dist/components/molecules/Drawer/styled.js.map +1 -1
- package/dist/components/molecules/InputPassword/InputPassword.js +2 -2
- package/dist/components/molecules/InputPassword/index.js +2 -2
- package/dist/components/molecules/Menubar/MenuBlock/MenuBlock.d.ts +4 -3
- package/dist/components/molecules/Menubar/MenuBlock/MenuBlock.js +14 -5
- package/dist/components/molecules/Menubar/MenuBlock/MenuBlock.js.map +1 -1
- package/dist/components/molecules/Menubar/MenuBlock/MenuItem/MenuItem.d.ts +1 -0
- package/dist/components/molecules/Menubar/MenuBlock/MenuItem/MenuItem.js +6 -3
- package/dist/components/molecules/Menubar/MenuBlock/MenuItem/MenuItem.js.map +1 -1
- package/dist/components/molecules/Menubar/MenuBlock/MenuItem/SubMenuBlock/SubMenuBlock.d.ts +1 -0
- package/dist/components/molecules/Menubar/MenuBlock/MenuItem/SubMenuBlock/SubMenuBlock.js +4 -2
- package/dist/components/molecules/Menubar/MenuBlock/MenuItem/SubMenuBlock/SubMenuBlock.js.map +1 -1
- package/dist/components/molecules/Menubar/Menubar.d.ts +3 -2
- package/dist/components/molecules/Menubar/Menubar.js +26 -33
- package/dist/components/molecules/Menubar/Menubar.js.map +1 -1
- package/dist/components/molecules/Menubar/MostUsed/MostUsed.d.ts +3 -2
- package/dist/components/molecules/Menubar/MostUsed/MostUsed.js +6 -3
- package/dist/components/molecules/Menubar/MostUsed/MostUsed.js.map +1 -1
- package/dist/components/molecules/Menubar/SearchResultItem/SearchResultItem.d.ts +1 -0
- package/dist/components/molecules/Menubar/SearchResultItem/SearchResultItem.js +4 -2
- package/dist/components/molecules/Menubar/SearchResultItem/SearchResultItem.js.map +1 -1
- package/dist/components/molecules/Menubar/animations.d.ts +2 -2
- package/dist/components/molecules/Menubar/animations.js +14 -22
- package/dist/components/molecules/Menubar/animations.js.map +1 -1
- package/dist/components/molecules/Menubar/index.d.ts +1 -0
- package/dist/components/molecules/Menubar/index.js +26 -3
- package/dist/components/molecules/Menubar/index.js.map +1 -1
- package/dist/components/molecules/Menubar/styled.js +5 -2
- package/dist/components/molecules/Menubar/styled.js.map +1 -1
- package/dist/components/molecules/Menubar/types.js +4 -0
- package/dist/components/molecules/Select/index.js +2 -2
- package/dist/components/molecules/Snackbar/index.js +2 -2
- package/dist/components/molecules/Snackbar/styled.js +2 -2
- package/dist/components/organisms/DataGrid/index.js +2 -2
- package/dist/components/organisms/DataGrid/types.js +4 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +99 -14
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/atoms/Accordion/Accordion.stories.tsx +35 -0
- package/src/components/atoms/Accordion/Accordion.tsx +99 -0
- package/src/components/atoms/Accordion/animations.ts +51 -0
- package/src/components/atoms/Accordion/index.ts +1 -0
- package/src/components/atoms/Accordion/styled.ts +35 -0
- package/src/components/atoms/Button/styled.ts +3 -1
- package/src/components/atoms/Modal/Modal.stories.tsx +55 -0
- package/src/components/atoms/Modal/Modal.tsx +34 -0
- package/src/components/atoms/Modal/animations.ts +12 -0
- package/src/components/atoms/Modal/index.ts +1 -0
- package/src/components/atoms/Modal/styled.ts +17 -0
- package/src/components/atoms/Overlay/Overlay.tsx +40 -0
- package/src/components/atoms/Overlay/animations.ts +11 -0
- package/src/components/atoms/Overlay/index.ts +1 -0
- package/src/components/atoms/Overlay/styled.ts +20 -0
- package/src/components/molecules/Breadcrumbs/Breadcrumbs.tsx +5 -5
- package/src/components/molecules/Breadcrumbs/index.ts +5 -1
- package/src/components/molecules/Drawer/Drawer.stories.tsx +10 -20
- package/src/components/molecules/Drawer/Drawer.tsx +3 -15
- package/src/components/molecules/Drawer/animations.ts +0 -11
- package/src/components/molecules/Drawer/styled.ts +1 -14
- package/src/components/molecules/Menubar/MenuBlock/MenuBlock.tsx +38 -31
- package/src/components/molecules/Menubar/MenuBlock/MenuItem/MenuItem.tsx +4 -2
- package/src/components/molecules/Menubar/MenuBlock/MenuItem/SubMenuBlock/SubMenuBlock.tsx +3 -2
- package/src/components/molecules/Menubar/Menubar.stories.tsx +19 -13
- package/src/components/molecules/Menubar/Menubar.tsx +48 -57
- package/src/components/molecules/Menubar/MostUsed/MostUsed.tsx +4 -2
- package/src/components/molecules/Menubar/SearchResultItem/SearchResultItem.tsx +7 -2
- package/src/components/molecules/Menubar/animations.ts +14 -21
- package/src/components/molecules/Menubar/index.ts +5 -0
- package/src/components/molecules/Menubar/styled.ts +3 -2
- package/src/index.ts +16 -2
|
@@ -2,26 +2,26 @@ import React, { ElementType, FC } from 'react';
|
|
|
2
2
|
import { StyledContainerBreadcrumbs } from './styled';
|
|
3
3
|
import { BreadcrumbItem } from './BreadcrumbItem';
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
export type BreadcrumbType = {
|
|
6
6
|
title: string;
|
|
7
7
|
Component: ElementType;
|
|
8
|
-
|
|
8
|
+
props?: any;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export interface BreadcrumbsProps {
|
|
12
|
-
breadcrumbs:
|
|
12
|
+
breadcrumbs: BreadcrumbType[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const Breadcrumbs: FC<BreadcrumbsProps> = ({ breadcrumbs }) => {
|
|
16
16
|
return (
|
|
17
17
|
<StyledContainerBreadcrumbs>
|
|
18
18
|
{breadcrumbs.map((item, index) => {
|
|
19
|
-
const {
|
|
19
|
+
const { props, Component = 'a', title } = item;
|
|
20
20
|
return (
|
|
21
21
|
<BreadcrumbItem
|
|
22
22
|
key={index}
|
|
23
23
|
Component={Component}
|
|
24
|
-
props={
|
|
24
|
+
props={props}
|
|
25
25
|
isLast={breadcrumbs.length - 1 === index}
|
|
26
26
|
title={title}
|
|
27
27
|
/>
|
|
@@ -8,35 +8,34 @@ import { default as Drawer, DrawerProps } from './Drawer';
|
|
|
8
8
|
export default {
|
|
9
9
|
title: 'Components/Drawer',
|
|
10
10
|
component: Drawer,
|
|
11
|
-
parameters: {
|
|
12
|
-
layout: 'fullscreen',
|
|
13
|
-
},
|
|
14
11
|
};
|
|
15
12
|
|
|
16
13
|
const Template: Story<DrawerProps> = ({ anchorPosition, open }) => {
|
|
17
14
|
const [isOpen, setOpen] = React.useState<boolean>(open);
|
|
18
15
|
|
|
19
|
-
const
|
|
16
|
+
const toggleOpen = () => {
|
|
20
17
|
setOpen(!isOpen);
|
|
21
18
|
};
|
|
22
19
|
|
|
23
20
|
return (
|
|
24
21
|
<>
|
|
25
|
-
<Drawer
|
|
22
|
+
<Drawer
|
|
23
|
+
open={isOpen}
|
|
24
|
+
onClose={toggleOpen}
|
|
25
|
+
anchorPosition={anchorPosition}
|
|
26
|
+
>
|
|
26
27
|
<StyledHeaderDrawerStory>
|
|
27
28
|
<StyledTextHeader typography="h4">Design System</StyledTextHeader>
|
|
28
29
|
<StyledHButtonHeaderStory>
|
|
29
|
-
<Button size="small" onPress={
|
|
30
|
+
<Button size="small" onPress={toggleOpen} variant="text">
|
|
30
31
|
<Icon name="close" type="material-community" />
|
|
31
32
|
</Button>
|
|
32
33
|
</StyledHButtonHeaderStory>
|
|
33
34
|
</StyledHeaderDrawerStory>
|
|
34
35
|
</Drawer>
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
</Button>
|
|
39
|
-
</StyledContainerButtonStory>
|
|
36
|
+
<Button onPress={toggleOpen}>
|
|
37
|
+
<StyledTextButton fontColor="light">Open Drawer</StyledTextButton>
|
|
38
|
+
</Button>
|
|
40
39
|
</>
|
|
41
40
|
);
|
|
42
41
|
};
|
|
@@ -48,15 +47,6 @@ Base.args = {
|
|
|
48
47
|
open: false,
|
|
49
48
|
};
|
|
50
49
|
|
|
51
|
-
const StyledContainerButtonStory = styled('div')`
|
|
52
|
-
display: flex;
|
|
53
|
-
flex-direction: row;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: center;
|
|
56
|
-
width: 100vw;
|
|
57
|
-
height: 100vh;
|
|
58
|
-
`;
|
|
59
|
-
|
|
60
50
|
const StyledHeaderDrawerStory = styled('div')`
|
|
61
51
|
display: flex;
|
|
62
52
|
flex-direction: row;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { StyledContainerDrawer
|
|
2
|
+
import { StyledContainerDrawer } from './styled';
|
|
3
3
|
import { Transition } from 'react-transition-group';
|
|
4
|
+
import { Overlay } from '../../atoms/Overlay';
|
|
4
5
|
import {
|
|
5
6
|
transitionStylesTopBottom,
|
|
6
7
|
defaultStylesTopBottom,
|
|
7
8
|
defaultStylesLeftRight,
|
|
8
|
-
transitionStylesOverlay,
|
|
9
9
|
transitionStylesLeftRight,
|
|
10
|
-
defaultStyleOverlay,
|
|
11
10
|
} from './animations';
|
|
12
11
|
|
|
13
12
|
export interface DrawerProps {
|
|
@@ -43,18 +42,7 @@ const Drawer: FC<DrawerProps> = ({
|
|
|
43
42
|
|
|
44
43
|
return (
|
|
45
44
|
<>
|
|
46
|
-
<
|
|
47
|
-
{state => (
|
|
48
|
-
<div
|
|
49
|
-
style={{
|
|
50
|
-
...defaultStyleOverlay,
|
|
51
|
-
...transitionStylesOverlay[state],
|
|
52
|
-
}}
|
|
53
|
-
>
|
|
54
|
-
<StyledOverlay onClick={open ? onClose : undefined} show={open} />
|
|
55
|
-
</div>
|
|
56
|
-
)}
|
|
57
|
-
</Transition>
|
|
45
|
+
<Overlay timeout={300} open={open} onClose={onClose} zIndex="drawer" />
|
|
58
46
|
<Transition in={open} timeout={300}>
|
|
59
47
|
{state => (
|
|
60
48
|
<StyledContainerDrawer
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
export const defaultStyleOverlay = {
|
|
2
|
-
transition: `opacity 700ms ease-in-out`,
|
|
3
|
-
opacity: 0,
|
|
4
|
-
};
|
|
5
|
-
export const transitionStylesOverlay = {
|
|
6
|
-
entering: { opacity: 1 },
|
|
7
|
-
entered: { opacity: 1 },
|
|
8
|
-
exiting: { opacity: 0 },
|
|
9
|
-
exited: { opacity: 0 },
|
|
10
|
-
};
|
|
11
|
-
|
|
12
1
|
export const transformLeftRigthClose = (anchorPosition: string) =>
|
|
13
2
|
anchorPosition === 'right' ? 'translateX(100%)' : 'translateX(-100%)';
|
|
14
3
|
|
|
@@ -3,19 +3,6 @@ import { hex2rgba, StyleProps } from '@tecsinapse/react-core';
|
|
|
3
3
|
import { DrawerProps } from './Drawer';
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
|
|
6
|
-
export const StyledOverlay = styled('div')<
|
|
7
|
-
Partial<StyleProps> & { show: boolean }
|
|
8
|
-
>`
|
|
9
|
-
background: ${({ theme }: StyleProps) =>
|
|
10
|
-
hex2rgba(theme.miscellaneous.overlay, 0.5)};
|
|
11
|
-
width: 100vw;
|
|
12
|
-
height: 100vh;
|
|
13
|
-
z-index: ${({ theme, show }: StyleProps & { show: boolean }) =>
|
|
14
|
-
show ? theme.zIndex.drawer : theme.zIndex.default};
|
|
15
|
-
cursor: ${({ show }) => (show ? 'pointer' : 'default')};
|
|
16
|
-
position: absolute;
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
6
|
const anchorLeft = ({ theme, anchorPosition }: StyleProps & DrawerProps) => {
|
|
20
7
|
return (
|
|
21
8
|
anchorPosition === 'left' &&
|
|
@@ -72,7 +59,7 @@ const baseStyles = ({ theme, anchorPosition }: StyleProps & DrawerProps) => {
|
|
|
72
59
|
position: fixed;
|
|
73
60
|
overflow: hidden;
|
|
74
61
|
background-color: ${theme.miscellaneous.bodyColor};
|
|
75
|
-
z-index: ${theme.zIndex.drawer
|
|
62
|
+
z-index: ${theme.zIndex.drawer};
|
|
76
63
|
`;
|
|
77
64
|
};
|
|
78
65
|
|
|
@@ -7,42 +7,49 @@ import {
|
|
|
7
7
|
StyledLeftComponent,
|
|
8
8
|
} from './styled';
|
|
9
9
|
import { ItemsOptions, OptionsType } from '../types';
|
|
10
|
+
import { Masonry } from '../../Masonry';
|
|
10
11
|
|
|
11
12
|
interface MenuBlockProps {
|
|
12
|
-
|
|
13
|
+
toggle: () => void;
|
|
14
|
+
options: OptionsType[];
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
const MenuBlock: React.FC<MenuBlockProps> = ({
|
|
17
|
+
const MenuBlock: React.FC<MenuBlockProps> = ({ options, toggle }) => {
|
|
16
18
|
return (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
<Masonry columns={4} spacingTop="kilo" spacingLeft="mega">
|
|
20
|
+
{options.map(data => (
|
|
21
|
+
<>
|
|
22
|
+
<StyledContainerMenu>
|
|
23
|
+
{data.leftComponents && (
|
|
24
|
+
<StyledLeftComponent>{data.leftComponents}</StyledLeftComponent>
|
|
25
|
+
)}
|
|
26
|
+
<Text fontWeight="bold">{data.title}</Text>
|
|
27
|
+
</StyledContainerMenu>
|
|
28
|
+
<StyledContainerItems>
|
|
29
|
+
{data.items.map(
|
|
30
|
+
({
|
|
31
|
+
title,
|
|
32
|
+
Component,
|
|
33
|
+
props,
|
|
34
|
+
rightComponents,
|
|
35
|
+
items,
|
|
36
|
+
}: ItemsOptions) => (
|
|
37
|
+
<MenuItem
|
|
38
|
+
items={items}
|
|
39
|
+
key={title}
|
|
40
|
+
title={title}
|
|
41
|
+
Component={Component}
|
|
42
|
+
rightComponents={rightComponents}
|
|
43
|
+
props={props}
|
|
44
|
+
toggle={toggle}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
)}
|
|
48
|
+
</StyledContainerItems>
|
|
49
|
+
</>
|
|
50
|
+
))}
|
|
51
|
+
</Masonry>
|
|
45
52
|
);
|
|
46
53
|
};
|
|
47
54
|
|
|
48
|
-
export default MenuBlock;
|
|
55
|
+
export default React.memo(MenuBlock);
|
|
@@ -11,6 +11,7 @@ interface MenuItemProps {
|
|
|
11
11
|
Component: ElementType;
|
|
12
12
|
/** Properties spread to wrapping Component */
|
|
13
13
|
props: any;
|
|
14
|
+
toggle: () => void;
|
|
14
15
|
rightComponents?: React.ReactNode;
|
|
15
16
|
items?: ItemsOptions[];
|
|
16
17
|
}
|
|
@@ -21,6 +22,7 @@ const MenuItem: React.FC<MenuItemProps> = ({
|
|
|
21
22
|
props = {},
|
|
22
23
|
rightComponents,
|
|
23
24
|
items,
|
|
25
|
+
toggle,
|
|
24
26
|
}) => {
|
|
25
27
|
const [open, setOpen] = React.useState<boolean>(false);
|
|
26
28
|
|
|
@@ -34,7 +36,7 @@ const MenuItem: React.FC<MenuItemProps> = ({
|
|
|
34
36
|
return (
|
|
35
37
|
<>
|
|
36
38
|
<StyledContainerItemText key={title}>
|
|
37
|
-
<Component {...props} style={noTextDecoration}>
|
|
39
|
+
<Component {...props} style={noTextDecoration} onClick={toggle}>
|
|
38
40
|
<Text
|
|
39
41
|
colorVariant={open ? 'primary' : 'secondary'}
|
|
40
42
|
colorTone={open ? 'medium' : 'dark'}
|
|
@@ -57,7 +59,7 @@ const MenuItem: React.FC<MenuItemProps> = ({
|
|
|
57
59
|
</StyledContainerItemText>
|
|
58
60
|
{open &&
|
|
59
61
|
items?.map(subItem => (
|
|
60
|
-
<SubMenuBlock key={subItem.title} data={subItem} />
|
|
62
|
+
<SubMenuBlock key={subItem.title} data={subItem} toggle={toggle} />
|
|
61
63
|
))}
|
|
62
64
|
</>
|
|
63
65
|
);
|
|
@@ -6,9 +6,10 @@ import { DummyBorder, StyledContainerItem } from './styled';
|
|
|
6
6
|
|
|
7
7
|
interface SubMenuBlockProps {
|
|
8
8
|
data: ItemsOptions;
|
|
9
|
+
toggle: () => void;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
const SubMenuBlock: React.FC<SubMenuBlockProps> = ({ data }) => {
|
|
12
|
+
const SubMenuBlock: React.FC<SubMenuBlockProps> = ({ data, toggle }) => {
|
|
12
13
|
const { Component, props, rightComponents, title } = data;
|
|
13
14
|
|
|
14
15
|
const noTextDecoration = { textDecoration: 'none' };
|
|
@@ -16,7 +17,7 @@ const SubMenuBlock: React.FC<SubMenuBlockProps> = ({ data }) => {
|
|
|
16
17
|
return (
|
|
17
18
|
<StyledContainerItem>
|
|
18
19
|
<DummyBorder />
|
|
19
|
-
<Component {...props} style={noTextDecoration}>
|
|
20
|
+
<Component {...props} style={noTextDecoration} onClick={toggle}>
|
|
20
21
|
<Text colorVariant="secondary" colorTone="medium" typography="sub">
|
|
21
22
|
<StyledText>{title}</StyledText>
|
|
22
23
|
</Text>
|
|
@@ -2,7 +2,7 @@ import React, { ElementType } from 'react';
|
|
|
2
2
|
import Menubar, { MenubarProps } from './Menubar';
|
|
3
3
|
import { Story } from '@storybook/react';
|
|
4
4
|
import styled from '@emotion/styled';
|
|
5
|
-
import { Icon, Text } from '@tecsinapse/react-core';
|
|
5
|
+
import { Avatar, Icon, Text } from '@tecsinapse/react-core';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
title: 'Components/Menu Bar',
|
|
@@ -253,20 +253,26 @@ const StyledImage = styled('img')`
|
|
|
253
253
|
margin-right: 35px;
|
|
254
254
|
`;
|
|
255
255
|
|
|
256
|
-
// Import type manually
|
|
257
256
|
const Template: Story<MenubarProps> = args => {
|
|
258
257
|
return (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
258
|
+
<>
|
|
259
|
+
<Menubar
|
|
260
|
+
{...args}
|
|
261
|
+
options={EXAMPLE_MENU}
|
|
262
|
+
mostUsed={MOST_USED}
|
|
263
|
+
leftComponents={
|
|
264
|
+
<StyledImage
|
|
265
|
+
src="https://www.tecsinapse.com.br/wp-content/themes/tecsinapse/img/logo.svg"
|
|
266
|
+
alt="TecSinapse"
|
|
267
|
+
/>
|
|
268
|
+
}
|
|
269
|
+
rightComponents={
|
|
270
|
+
<div style={{ marginLeft: 24 }}>
|
|
271
|
+
<Avatar name="Design System" />
|
|
272
|
+
</div>
|
|
273
|
+
}
|
|
274
|
+
/>
|
|
275
|
+
</>
|
|
270
276
|
);
|
|
271
277
|
};
|
|
272
278
|
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Icon,
|
|
4
|
-
Text,
|
|
5
|
-
ThemeProp,
|
|
6
|
-
useDebouncedState,
|
|
7
|
-
} from '@tecsinapse/react-core';
|
|
2
|
+
import { Icon, Text, useDebouncedState } from '@tecsinapse/react-core';
|
|
8
3
|
import { Transition } from 'react-transition-group';
|
|
9
|
-
import { useTheme } from '@emotion/react';
|
|
10
4
|
import {
|
|
11
5
|
StyledIconInput,
|
|
12
6
|
StyledMenuBar,
|
|
@@ -17,7 +11,6 @@ import {
|
|
|
17
11
|
StyledSearchResultsContainer,
|
|
18
12
|
StyledSearchTextContainer,
|
|
19
13
|
} from './styled';
|
|
20
|
-
import { Masonry } from '../Masonry';
|
|
21
14
|
import { MostUsedType, OptionsType } from './types';
|
|
22
15
|
import { MostUsed } from './MostUsed';
|
|
23
16
|
import { MenuBlock } from './MenuBlock';
|
|
@@ -29,32 +22,35 @@ import {
|
|
|
29
22
|
} from './animations';
|
|
30
23
|
|
|
31
24
|
export interface MenubarProps {
|
|
25
|
+
options: OptionsType[];
|
|
32
26
|
leftComponents?: React.ReactNode;
|
|
33
27
|
rightComponents?: React.ReactNode;
|
|
34
|
-
inputPlaceholder?: string;
|
|
35
|
-
options: OptionsType[];
|
|
36
28
|
/** Limited to first 4 elements */
|
|
37
29
|
mostUsed?: MostUsedType[];
|
|
38
30
|
mostUsedLabel?: string;
|
|
31
|
+
searchable?: boolean;
|
|
32
|
+
searchPlaceholder?: string;
|
|
39
33
|
searchResultsLabel?: string;
|
|
40
34
|
}
|
|
41
35
|
|
|
42
36
|
const Menubar: React.FC<MenubarProps> = ({
|
|
43
37
|
leftComponents,
|
|
44
38
|
rightComponents,
|
|
45
|
-
|
|
39
|
+
searchPlaceholder = 'O quê você deseja buscar?',
|
|
46
40
|
options,
|
|
47
41
|
mostUsed,
|
|
48
42
|
mostUsedLabel = 'Mais acessados',
|
|
49
43
|
searchResultsLabel = 'Resultados da busca',
|
|
44
|
+
searchable = true,
|
|
50
45
|
}) => {
|
|
51
46
|
const [search, setSearch] = React.useState<string>('');
|
|
52
47
|
const [results, setResults] = React.useState<MostUsedType[]>([]);
|
|
53
48
|
const [input, setInput] = useDebouncedState('', state => setSearch(state));
|
|
54
|
-
const [
|
|
55
|
-
const theme = useTheme() as ThemeProp;
|
|
49
|
+
const [open, setOpen] = React.useState<boolean>(false);
|
|
56
50
|
|
|
57
|
-
const
|
|
51
|
+
const toggleOpen = React.useCallback(() => setOpen(state => !state), [
|
|
52
|
+
setOpen,
|
|
53
|
+
]);
|
|
58
54
|
|
|
59
55
|
React.useEffect(() => {
|
|
60
56
|
if (search === '') return;
|
|
@@ -64,12 +60,8 @@ const Menubar: React.FC<MenubarProps> = ({
|
|
|
64
60
|
return (
|
|
65
61
|
<>
|
|
66
62
|
<StyledMenuBar>
|
|
67
|
-
<StyledMenuButton
|
|
68
|
-
|
|
69
|
-
color="primary"
|
|
70
|
-
onPress={toggleOpenClose}
|
|
71
|
-
>
|
|
72
|
-
{!isOpen ? (
|
|
63
|
+
<StyledMenuButton variant="filled" color="primary" onPress={toggleOpen}>
|
|
64
|
+
{!open ? (
|
|
73
65
|
<Icon
|
|
74
66
|
size="deca"
|
|
75
67
|
name="menu"
|
|
@@ -86,12 +78,12 @@ const Menubar: React.FC<MenubarProps> = ({
|
|
|
86
78
|
)}
|
|
87
79
|
</StyledMenuButton>
|
|
88
80
|
{leftComponents}
|
|
89
|
-
<Transition in={
|
|
81
|
+
<Transition in={open} timeout={250}>
|
|
90
82
|
{state => (
|
|
91
|
-
<
|
|
92
|
-
|
|
83
|
+
<StyledInputContainer style={getInputContainerStyles(state)}>
|
|
84
|
+
{searchable && (
|
|
93
85
|
<StyledInput
|
|
94
|
-
placeholder={
|
|
86
|
+
placeholder={searchPlaceholder}
|
|
95
87
|
leftComponent={
|
|
96
88
|
<StyledIconInput>
|
|
97
89
|
<Icon name="magnify" type="material-community" />
|
|
@@ -100,43 +92,42 @@ const Menubar: React.FC<MenubarProps> = ({
|
|
|
100
92
|
value={input}
|
|
101
93
|
onChange={setInput}
|
|
102
94
|
/>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
</div>
|
|
95
|
+
)}
|
|
96
|
+
</StyledInputContainer>
|
|
106
97
|
)}
|
|
107
98
|
</Transition>
|
|
99
|
+
{rightComponents}
|
|
108
100
|
</StyledMenuBar>
|
|
109
|
-
<Transition in={
|
|
101
|
+
<Transition in={open} timeout={250}>
|
|
110
102
|
{state => (
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
</div>
|
|
103
|
+
<StyledContainerOpenMenu style={getContainerOpenMenuStyles(state)}>
|
|
104
|
+
{!search ? (
|
|
105
|
+
<>
|
|
106
|
+
{mostUsed && (
|
|
107
|
+
<MostUsed
|
|
108
|
+
label={mostUsedLabel}
|
|
109
|
+
data={mostUsed}
|
|
110
|
+
toggle={toggleOpen}
|
|
111
|
+
/>
|
|
112
|
+
)}
|
|
113
|
+
<MenuBlock options={options} toggle={toggleOpen} />
|
|
114
|
+
</>
|
|
115
|
+
) : (
|
|
116
|
+
<StyledSearchResultsContainer>
|
|
117
|
+
<StyledSearchTextContainer>
|
|
118
|
+
<Text fontWeight="bold">{searchResultsLabel}</Text>
|
|
119
|
+
</StyledSearchTextContainer>
|
|
120
|
+
{results.map(result => (
|
|
121
|
+
<SearchResultItem
|
|
122
|
+
key={`${result.title}-${result.category}`}
|
|
123
|
+
data={result}
|
|
124
|
+
searchTerm={search}
|
|
125
|
+
toggle={toggleOpen}
|
|
126
|
+
/>
|
|
127
|
+
))}
|
|
128
|
+
</StyledSearchResultsContainer>
|
|
129
|
+
)}
|
|
130
|
+
</StyledContainerOpenMenu>
|
|
140
131
|
)}
|
|
141
132
|
</Transition>
|
|
142
133
|
</>
|