@linagora/twake-mui 15.0.0 → 15.1.0
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 +8 -0
- package/dist/components/Nav/index.d.ts +4 -3
- package/dist/components/Nav/index.js +17 -9
- package/dist/components/NavDesktopDropdown/index.js +4 -2
- package/dist/components/NavDesktopLimiter/index.js +5 -3
- package/dist/components/NavIcon/index.js +18 -10
- package/dist/components/NavItem/NavItemRoot.d.ts +1 -0
- package/dist/components/NavItem/NavItemRoot.js +18 -14
- package/dist/components/NavItem/index.js +4 -2
- package/dist/components/NavLink/NavDropdown.d.ts +2 -1
- package/dist/components/NavLink/NavDropdown.js +19 -5
- package/dist/components/NavLink/NavLinkBase.js +7 -3
- package/dist/components/NavLink/NavLinkRoot.d.ts +3 -2
- package/dist/components/NavLink/NavLinkRoot.js +19 -15
- package/dist/components/NavLink/locales/de.json +6 -0
- package/dist/components/NavLink/locales/en.json +6 -0
- package/dist/components/NavLink/locales/es.json +6 -0
- package/dist/components/NavLink/locales/fr.json +6 -0
- package/dist/components/NavLink/locales/it.json +6 -0
- package/dist/components/NavLink/locales/ru.json +6 -0
- package/dist/components/NavLink/locales/vi.json +6 -0
- package/dist/components/NavText/NavPrimaryText.d.ts +3 -2
- package/dist/components/NavText/NavPrimaryText.js +11 -7
- package/dist/components/NavText/index.js +4 -2
- package/dist/components/Sidebar/Sidebar.stories.d.ts +1 -0
- package/dist/components/Sidebar/Sidebar.stories.js +22 -2
- package/dist/components/Sidebar/SidebarContext.d.ts +1 -0
- package/dist/components/Sidebar/SidebarContext.js +2 -0
- package/dist/components/Sidebar/index.d.ts +6 -3
- package/dist/components/Sidebar/index.js +31 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# @linagora/twake-mui [15.1.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@15.0.0...@linagora/twake-mui@15.1.0) (2026-10-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **twake-mui:** Implement sidebar drawer ([43a443b](https://github.com/linagora/twake-ui/commit/43a443bcff5719c828382230971beb83be4fb10a))
|
|
7
|
+
* **twake-mui:** Separate click and toggle event in NavDropdown ([4ae7157](https://github.com/linagora/twake-ui/commit/4ae715714a04ba4eb606c598b7ec4e715c511dca))
|
|
8
|
+
|
|
1
9
|
# @linagora/twake-mui [15.0.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@14.4.0...@linagora/twake-mui@15.0.0) (2026-10-19)
|
|
2
10
|
|
|
3
11
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Theme } from '@mui/material/styles';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
declare const NavRoot: import("@emotion/styled").StyledComponent<import("@mui/material").ListOwnProps & Omit<import("@mui/material").ListOwnProps, keyof import("@mui/material").ListOwnProps> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "style" | "className" | "children" | "dense" | "disablePadding" | "classes" | "sx" | "subheader"> & import("@mui/system").MUIStyledCommonProps<Theme
|
|
4
|
-
|
|
2
|
+
declare const NavRoot: import("@emotion/styled").StyledComponent<import("@mui/material").ListOwnProps & Omit<import("@mui/material").ListOwnProps, keyof import("@mui/material").ListOwnProps> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "style" | "className" | "children" | "dense" | "disablePadding" | "classes" | "sx" | "subheader"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
3
|
+
disableMobileView: boolean;
|
|
4
|
+
}, {}, {}>;
|
|
5
|
+
export type NavProps = Omit<React.ComponentProps<typeof NavRoot>, 'disableMobileView'>;
|
|
5
6
|
export declare const Nav: (props: NavProps) => React.ReactElement;
|
|
6
7
|
export {};
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { List } from '@mui/material';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
3
|
+
import React, { useContext } from 'react';
|
|
4
|
+
import { SidebarContext } from '../Sidebar/SidebarContext';
|
|
5
|
+
const NavRoot = styled(List, {
|
|
6
|
+
shouldForwardProp: prop => prop !== 'disableMobileView'
|
|
7
|
+
})(({ theme, disableMobileView }) => ({
|
|
5
8
|
margin: '24px 0',
|
|
6
9
|
padding: 0,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
...(!disableMobileView && {
|
|
11
|
+
[theme.breakpoints.down('lg')]: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'space-around',
|
|
14
|
+
margin: '6px 0 4px'
|
|
15
|
+
}
|
|
16
|
+
})
|
|
12
17
|
}));
|
|
13
|
-
export const Nav = (props) =>
|
|
14
|
-
|
|
18
|
+
export const Nav = (props) => {
|
|
19
|
+
const disableMobileView = useContext(SidebarContext);
|
|
20
|
+
return (React.createElement("nav", null,
|
|
21
|
+
React.createElement(NavRoot, { ...props, disableMobileView: disableMobileView })));
|
|
22
|
+
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import React, { Children, isValidElement, useState } from 'react';
|
|
1
|
+
import React, { Children, isValidElement, useState, useContext } from 'react';
|
|
2
2
|
import { useBreakpoints } from '../../hooks/useBreakpoints';
|
|
3
3
|
import DropdownText from '../DropdownText';
|
|
4
4
|
import ListItem from '../ListItem';
|
|
5
|
+
import { SidebarContext } from '../Sidebar/SidebarContext';
|
|
5
6
|
export const NavDesktopDropdown = ({ label, children, defaultOpen = true, limit = 5 }) => {
|
|
7
|
+
const disableMobileView = useContext(SidebarContext);
|
|
6
8
|
const { isDesktop } = useBreakpoints();
|
|
7
9
|
const [open, setOpen] = useState(defaultOpen);
|
|
8
10
|
const isActivated = Children.toArray(children).filter(isValidElement).length > limit;
|
|
9
11
|
const onToggle = () => setOpen(current => !current);
|
|
10
|
-
if (!isDesktop)
|
|
12
|
+
if (!isDesktop && !disableMobileView)
|
|
11
13
|
return null;
|
|
12
14
|
return (React.createElement(React.Fragment, null,
|
|
13
15
|
React.createElement(ListItem, { size: "small", sx: { cursor: isActivated ? 'pointer' : undefined } },
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Bottom, Top } from '@linagora/twake-icons';
|
|
2
|
-
import React, { Children, isValidElement, useState } from 'react';
|
|
2
|
+
import React, { Children, isValidElement, useState, useContext } from 'react';
|
|
3
3
|
import { useExtendI18n, useI18n } from 'twake-i18n';
|
|
4
4
|
import { NavIcon } from '../NavIcon';
|
|
5
5
|
import { NavItem } from '../NavItem';
|
|
6
6
|
import { NavLink } from '../NavLink/NavLink';
|
|
7
7
|
import NavText from '../NavText';
|
|
8
|
+
import { SidebarContext } from '../Sidebar/SidebarContext';
|
|
8
9
|
import de from './locales/de.json';
|
|
9
10
|
import en from './locales/en.json';
|
|
10
11
|
import es from './locales/es.json';
|
|
@@ -16,12 +17,13 @@ import { useBreakpoints } from '../../hooks/useBreakpoints';
|
|
|
16
17
|
const locales = { de, en, es, fr, it, ru, vi };
|
|
17
18
|
export const NavDesktopLimiter = ({ children, max = 5 }) => {
|
|
18
19
|
useExtendI18n(locales);
|
|
20
|
+
const disableMobileView = useContext(SidebarContext);
|
|
19
21
|
const { t } = useI18n();
|
|
20
22
|
const [viewingAll, setViewingAll] = useState(false);
|
|
21
|
-
const {
|
|
23
|
+
const { isDesktop } = useBreakpoints();
|
|
22
24
|
const items = Children.toArray(children).filter(isValidElement);
|
|
23
25
|
const amountHidden = Math.max(0, items.length - max);
|
|
24
|
-
if (
|
|
26
|
+
if (!isDesktop && !disableMobileView)
|
|
25
27
|
return null;
|
|
26
28
|
return (React.createElement(React.Fragment, null,
|
|
27
29
|
viewingAll ? items : items.slice(0, max),
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { Icon } from '@linagora/twake-icons';
|
|
2
2
|
import { ListItemIcon } from '@mui/material';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
|
+
import { SidebarContext } from '../Sidebar/SidebarContext';
|
|
6
|
+
const NavIconRoot = styled(ListItemIcon, {
|
|
7
|
+
shouldForwardProp: prop => prop !== 'disableMobileView'
|
|
8
|
+
})(({ theme, disableMobileView }) => ({
|
|
6
9
|
minWidth: 0,
|
|
7
10
|
width: 'auto',
|
|
8
11
|
height: 'auto',
|
|
9
12
|
marginRight: 12,
|
|
10
13
|
color: theme.vars.palette.text.primary,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
...(!disableMobileView && {
|
|
15
|
+
[theme.breakpoints.down('lg')]: {
|
|
16
|
+
display: 'block',
|
|
17
|
+
marginRight: 0,
|
|
18
|
+
color: theme.vars.palette.text.secondary,
|
|
19
|
+
'& svg': { margin: '4px auto 5px', width: 16, height: 16 }
|
|
20
|
+
}
|
|
21
|
+
})
|
|
17
22
|
}));
|
|
18
|
-
export const NavIcon = ({ icon, ...props }) =>
|
|
19
|
-
|
|
23
|
+
export const NavIcon = ({ icon, ...props }) => {
|
|
24
|
+
const disableMobileView = useContext(SidebarContext);
|
|
25
|
+
return (React.createElement(NavIconRoot, { disableMobileView: disableMobileView, ...props },
|
|
26
|
+
React.createElement(Icon, { icon: icon, "aria-hidden": "true", focusable: "false" })));
|
|
27
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const NavItemRoot: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "style" | "className" | "children" | "alignItems" | "dense" | "disablePadding" | "disableGutters" | "classes" | "sx" | "divider" | "slotProps" | "slots" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
2
2
|
variant?: "primary" | "secondary" | "tertiary";
|
|
3
|
+
disableMobileView?: boolean;
|
|
3
4
|
}, {}, {}>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ListItem } from '@mui/material';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
export const NavItemRoot = styled(ListItem, {
|
|
4
|
-
shouldForwardProp: prop => prop !== 'secondary' && prop !== 'variant'
|
|
5
|
-
})(({ theme, variant = 'primary' }) => {
|
|
4
|
+
shouldForwardProp: prop => prop !== 'secondary' && prop !== 'variant' && prop !== 'disableMobileView'
|
|
5
|
+
})(({ theme, variant = 'primary', disableMobileView = false }) => {
|
|
6
6
|
const isSecondary = variant === 'secondary';
|
|
7
7
|
const isTertiary = variant === 'tertiary';
|
|
8
8
|
return {
|
|
@@ -27,22 +27,26 @@ export const NavItemRoot = styled(ListItem, {
|
|
|
27
27
|
backgroundColor: theme.vars.palette.action.focus
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
...(!disableMobileView && {
|
|
31
|
+
[theme.breakpoints.down('lg')]: {
|
|
32
|
+
display: 'block',
|
|
33
|
+
height: 'auto',
|
|
34
|
+
margin: '0 12px',
|
|
35
|
+
flex: '0 0 40px',
|
|
36
|
+
[`&.Mui-selected, &:has(.Mui-selected), &:has(.active)`]: {
|
|
37
|
+
color: theme.vars.palette.text.primary,
|
|
38
|
+
backgroundColor: 'transparent',
|
|
39
|
+
'&:hover': {
|
|
40
|
+
backgroundColor: 'transparent'
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
|
-
},
|
|
44
|
+
}),
|
|
43
45
|
...((isSecondary || isTertiary) && {
|
|
44
46
|
margin: '3px 16px',
|
|
45
|
-
|
|
47
|
+
...(!disableMobileView && {
|
|
48
|
+
[theme.breakpoints.down('lg')]: { display: 'none' }
|
|
49
|
+
}),
|
|
46
50
|
paddingLeft: isTertiary ? '3rem' : '2rem'
|
|
47
51
|
})
|
|
48
52
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Divider } from '@mui/material';
|
|
2
2
|
import cx from 'classnames';
|
|
3
|
-
import React, { forwardRef } from 'react';
|
|
3
|
+
import React, { forwardRef, useContext } from 'react';
|
|
4
4
|
import { NavBadge } from './NavBadge';
|
|
5
5
|
import { NavIndicator } from './NavIndicator';
|
|
6
6
|
import { NavItemActions } from './NavItemActions';
|
|
7
7
|
import { NavItemRoot } from './NavItemRoot';
|
|
8
|
+
import { SidebarContext } from '../Sidebar/SidebarContext';
|
|
8
9
|
export const NavItem = forwardRef((props, ref) => {
|
|
9
10
|
const { variant = 'primary', selected, children, className, badge, hasIndicator, secondaryAction, divider, ...rest } = props;
|
|
11
|
+
const disableMobileView = useContext(SidebarContext);
|
|
10
12
|
return (React.createElement(React.Fragment, null,
|
|
11
|
-
React.createElement(NavItemRoot, { ref: ref, variant: variant, className: cx(className, selected && 'Mui-selected'), ...rest },
|
|
13
|
+
React.createElement(NavItemRoot, { ref: ref, variant: variant, disableMobileView: disableMobileView, className: cx(className, selected && 'Mui-selected'), ...rest },
|
|
12
14
|
children,
|
|
13
15
|
(hasIndicator || badge || secondaryAction) && (React.createElement(NavItemActions, null,
|
|
14
16
|
hasIndicator && React.createElement(NavIndicator, null),
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { NavLinkBaseProps } from './NavLinkBase';
|
|
3
3
|
export interface NavDropdownProps extends Omit<NavLinkBaseProps, 'onToggle'> {
|
|
4
4
|
open?: boolean;
|
|
5
|
-
onToggle?:
|
|
5
|
+
onToggle?: () => void;
|
|
6
|
+
toggleLabel?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare const NavDropdown: React.ForwardRefExoticComponent<NavDropdownProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import { Icon, Dropdown } from '@linagora/twake-icons';
|
|
2
|
+
import { IconButton } from '@mui/material';
|
|
2
3
|
import { useTheme } from '@mui/material/styles';
|
|
3
4
|
import React, { forwardRef } from 'react';
|
|
5
|
+
import { useExtendI18n, useI18n } from 'twake-i18n';
|
|
4
6
|
import { NavLinkBase } from './NavLinkBase';
|
|
5
|
-
|
|
7
|
+
import de from './locales/de.json';
|
|
8
|
+
import en from './locales/en.json';
|
|
9
|
+
import es from './locales/es.json';
|
|
10
|
+
import fr from './locales/fr.json';
|
|
11
|
+
import it from './locales/it.json';
|
|
12
|
+
import ru from './locales/ru.json';
|
|
13
|
+
import vi from './locales/vi.json';
|
|
14
|
+
const locales = { de, en, es, fr, it, ru, vi };
|
|
15
|
+
export const NavDropdown = forwardRef(({ open, onToggle, toggleLabel, onClick, children, ...rest }, ref) => {
|
|
16
|
+
useExtendI18n(locales);
|
|
17
|
+
const { t } = useI18n();
|
|
6
18
|
const theme = useTheme();
|
|
7
19
|
const handleClick = (e) => {
|
|
8
|
-
if (onToggle) {
|
|
9
|
-
onToggle(e);
|
|
10
|
-
}
|
|
11
20
|
if (onClick) {
|
|
12
21
|
onClick(e);
|
|
13
22
|
}
|
|
14
23
|
};
|
|
15
24
|
return (React.createElement(NavLinkBase, { ref: ref, onClick: handleClick, "aria-expanded": open, ...rest },
|
|
16
25
|
children,
|
|
17
|
-
React.createElement(
|
|
26
|
+
React.createElement(IconButton, { className: "u-ml-half", size: "xsmall", "aria-label": toggleLabel ??
|
|
27
|
+
t(open ? 'NavDropdown.collapse' : 'NavDropdown.expand'), "aria-expanded": open, onClick: e => {
|
|
28
|
+
e.stopPropagation();
|
|
29
|
+
onToggle?.();
|
|
30
|
+
} },
|
|
31
|
+
React.createElement(Icon, { icon: Dropdown, rotate: open ? 0 : -90, size: 14, color: theme.vars.palette.text.primary }))));
|
|
18
32
|
});
|
|
19
33
|
NavDropdown.displayName = 'NavDropdown';
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
2
|
+
import React, { forwardRef, useContext } from 'react';
|
|
3
3
|
import { NavLinkRoot } from './NavLinkRoot';
|
|
4
|
+
import { SidebarContext } from '../Sidebar/SidebarContext';
|
|
4
5
|
export const NavLinkBase = forwardRef(({ selected, onClick, onKeyDown, className, children, ...rest }, ref) => {
|
|
5
|
-
|
|
6
|
+
const disableMobileView = useContext(SidebarContext);
|
|
7
|
+
return (React.createElement(NavLinkRoot, { ref: ref, disableMobileView: disableMobileView, role: "button", tabIndex: 0, onClick: onClick, onKeyDown: (e) => {
|
|
6
8
|
if (onKeyDown) {
|
|
7
9
|
onKeyDown(e);
|
|
8
10
|
}
|
|
9
|
-
if (
|
|
11
|
+
if (e.target === e.currentTarget &&
|
|
12
|
+
!e.defaultPrevented &&
|
|
13
|
+
(e.key === 'Enter' || e.key === ' ')) {
|
|
10
14
|
e.preventDefault();
|
|
11
15
|
e.currentTarget.click();
|
|
12
16
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const NavLinkRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
2
|
+
disableMobileView?: boolean;
|
|
3
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { styled } from '@mui/material/styles';
|
|
2
|
-
export const NavLinkRoot = styled('div'
|
|
2
|
+
export const NavLinkRoot = styled('div', {
|
|
3
|
+
shouldForwardProp: prop => prop !== 'disableMobileView'
|
|
4
|
+
})(({ theme, disableMobileView }) => ({
|
|
3
5
|
padding: 8,
|
|
4
6
|
width: '100%',
|
|
5
7
|
height: '100%',
|
|
@@ -22,20 +24,22 @@ export const NavLinkRoot = styled('div')(({ theme }) => ({
|
|
|
22
24
|
color: theme.vars.palette.primary.main
|
|
23
25
|
}
|
|
24
26
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
...(!disableMobileView && {
|
|
28
|
+
[theme.breakpoints.down('lg')]: {
|
|
29
|
+
display: 'block',
|
|
30
|
+
height: 'auto',
|
|
31
|
+
margin: 0,
|
|
32
|
+
padding: 0,
|
|
33
|
+
textAlign: 'center',
|
|
34
|
+
fontSize: theme.typography.pxToRem(11),
|
|
35
|
+
lineHeight: '12px',
|
|
36
|
+
'&.selected, &.active': {
|
|
37
|
+
color: theme.vars.palette.text.primary,
|
|
38
|
+
'&:hover': { backgroundColor: 'transparent' },
|
|
39
|
+
'& svg, & span': {
|
|
40
|
+
color: theme.vars.palette.text.primary
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
|
-
}
|
|
44
|
+
})
|
|
41
45
|
}));
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const NavPrimaryText: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
2
|
+
disableMobileView?: boolean;
|
|
3
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { styled } from '@mui/material/styles';
|
|
2
|
-
export const NavPrimaryText = styled('span'
|
|
2
|
+
export const NavPrimaryText = styled('span', {
|
|
3
|
+
shouldForwardProp: prop => prop !== 'disableMobileView'
|
|
4
|
+
})(({ theme, disableMobileView }) => ({
|
|
3
5
|
fontSize: theme.typography.pxToRem(14),
|
|
4
6
|
fontWeight: 500,
|
|
5
7
|
letterSpacing: '.15px',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
...(!disableMobileView && {
|
|
9
|
+
[theme.breakpoints.down('lg')]: {
|
|
10
|
+
display: 'block',
|
|
11
|
+
textAlign: 'center',
|
|
12
|
+
whiteSpace: 'nowrap',
|
|
13
|
+
fontSize: theme.typography.pxToRem(12)
|
|
14
|
+
}
|
|
15
|
+
})
|
|
12
16
|
}));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { NavPrimaryText } from './NavPrimaryText';
|
|
3
3
|
import { NavSecondaryText } from './NavSecondaryText';
|
|
4
4
|
import { NavTertiaryText } from './NavTertiaryText';
|
|
5
5
|
import { NavTextRoot } from './NavTextRoot';
|
|
6
|
+
import { SidebarContext } from '../Sidebar/SidebarContext';
|
|
6
7
|
const NavText = React.forwardRef(({ secondaryText, tertiaryText, tertiaryIcon, children, sx, ...rest }, ref) => {
|
|
8
|
+
const disableMobileView = useContext(SidebarContext);
|
|
7
9
|
return (React.createElement(NavTextRoot, { ref: ref, sx: sx, ...rest },
|
|
8
|
-
React.createElement(NavPrimaryText,
|
|
10
|
+
React.createElement(NavPrimaryText, { disableMobileView: disableMobileView }, children),
|
|
9
11
|
secondaryText && React.createElement(NavSecondaryText, null, secondaryText),
|
|
10
12
|
(tertiaryText || tertiaryIcon) && (React.createElement(NavTertiaryText, null,
|
|
11
13
|
tertiaryIcon,
|
|
@@ -21,8 +21,7 @@ const SidebarDemo = (props) => {
|
|
|
21
21
|
React.createElement(Sidebar, { ...props },
|
|
22
22
|
React.createElement(Nav, null,
|
|
23
23
|
React.createElement(NavItem, null,
|
|
24
|
-
React.createElement(NavDropdown, { ...makeProps(['Section 1']), open: openSection1, onToggle: (
|
|
25
|
-
e.stopPropagation();
|
|
24
|
+
React.createElement(NavDropdown, { ...makeProps(['Section 1']), open: openSection1, onToggle: () => {
|
|
26
25
|
setOpenSection1(prev => !prev);
|
|
27
26
|
} },
|
|
28
27
|
React.createElement(NavIcon, { icon: Warn }),
|
|
@@ -52,6 +51,14 @@ const meta = {
|
|
|
52
51
|
title: 'Sidebar',
|
|
53
52
|
component: Sidebar,
|
|
54
53
|
tags: ['autodocs'],
|
|
54
|
+
argTypes: {
|
|
55
|
+
anchor: { control: 'radio', options: ['bottom', 'left'] },
|
|
56
|
+
open: { control: 'boolean' }
|
|
57
|
+
},
|
|
58
|
+
args: {
|
|
59
|
+
anchor: 'bottom',
|
|
60
|
+
open: false
|
|
61
|
+
},
|
|
55
62
|
render: args => React.createElement(SidebarDemo, { ...args })
|
|
56
63
|
};
|
|
57
64
|
export default meta;
|
|
@@ -60,3 +67,16 @@ export const Default = {};
|
|
|
60
67
|
export const Screenshot = {
|
|
61
68
|
tags: ['argos']
|
|
62
69
|
};
|
|
70
|
+
export const DrawerMobile = {
|
|
71
|
+
tags: ['argos', '!autodocs'],
|
|
72
|
+
globals: { viewport: 'mobile' },
|
|
73
|
+
args: { anchor: 'left', open: true },
|
|
74
|
+
parameters: {
|
|
75
|
+
argos: {
|
|
76
|
+
modes: {
|
|
77
|
+
'desktop-light': { disabled: true },
|
|
78
|
+
'desktop-dark': { disabled: true }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SidebarContext: import("react").Context<boolean>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { SxProps } from '@mui/material';
|
|
2
|
-
import { Theme } from '@mui/material/styles';
|
|
1
|
+
import { DrawerProps, SxProps, Theme } from '@mui/material';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
export declare const SIDEBAR_MOBILE_HEIGHT = "--sidebarHeight";
|
|
5
4
|
export interface SidebarProps extends React.ComponentPropsWithoutRef<'aside'> {
|
|
6
5
|
sx?: SxProps<Theme>;
|
|
6
|
+
/** Mobile presentation: a bottom bar or a temporary left drawer. */
|
|
7
|
+
anchor?: 'bottom' | 'left';
|
|
8
|
+
open?: boolean;
|
|
9
|
+
onClose?: DrawerProps['onClose'];
|
|
7
10
|
}
|
|
8
|
-
export declare const Sidebar: React.
|
|
11
|
+
export declare const Sidebar: ({ children, anchor, open, onClose, sx, ...rest }: SidebarProps) => React.ReactElement;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { GlobalStyles } from '@mui/material';
|
|
1
|
+
import { Drawer, GlobalStyles } from '@mui/material';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { SidebarContext } from './SidebarContext';
|
|
5
|
+
import { useBreakpoints } from '../../hooks/useBreakpoints';
|
|
4
6
|
export const SIDEBAR_MOBILE_HEIGHT = '--sidebarHeight';
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
+
const SidebarRoot = styled('aside', {
|
|
8
|
+
shouldForwardProp: prop => prop !== 'anchor'
|
|
9
|
+
})(({ theme, anchor }) => ({
|
|
7
10
|
width: 236,
|
|
8
11
|
flex: '0 0 auto',
|
|
9
12
|
display: 'flex',
|
|
@@ -11,18 +14,30 @@ const SidebarRoot = styled('aside')(({ theme }) => ({
|
|
|
11
14
|
overflowX: 'hidden',
|
|
12
15
|
overflowY: 'auto',
|
|
13
16
|
backgroundColor: theme.vars.palette.background.default,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
...(anchor === 'bottom' && {
|
|
18
|
+
[theme.breakpoints.down('lg')]: {
|
|
19
|
+
position: 'fixed',
|
|
20
|
+
bottom: 0,
|
|
21
|
+
left: 0,
|
|
22
|
+
width: '100%',
|
|
23
|
+
height: `var(${SIDEBAR_MOBILE_HEIGHT}, 52px)`,
|
|
24
|
+
boxSizing: 'content-box',
|
|
25
|
+
display: 'block',
|
|
26
|
+
borderTop: `1px solid ${theme.vars.palette.divider}`,
|
|
27
|
+
zIndex: theme.zIndex.appBar
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}));
|
|
31
|
+
const SidebarDrawer = styled(Drawer)(({ theme }) => ({
|
|
32
|
+
'& .MuiDrawer-paper': {
|
|
33
|
+
width: 300,
|
|
34
|
+
maxWidth: 'calc(100vw - 56px)',
|
|
35
|
+
backgroundColor: theme.vars.palette.background.default
|
|
24
36
|
}
|
|
25
37
|
}));
|
|
26
|
-
export const Sidebar =
|
|
27
|
-
|
|
28
|
-
React.createElement(
|
|
38
|
+
export const Sidebar = ({ children, anchor = 'bottom', open = false, onClose, sx, ...rest }) => {
|
|
39
|
+
const { isDesktop } = useBreakpoints();
|
|
40
|
+
return (React.createElement(SidebarContext.Provider, { value: anchor === 'left' },
|
|
41
|
+
anchor === 'bottom' && (React.createElement(GlobalStyles, { styles: { ':root': { [SIDEBAR_MOBILE_HEIGHT]: '52px' } } })),
|
|
42
|
+
anchor === 'left' && !isDesktop ? (React.createElement(SidebarDrawer, { ...rest, variant: "temporary", anchor: "left", open: open, onClose: onClose, sx: sx }, children)) : (React.createElement(SidebarRoot, { anchor: anchor, sx: sx, ...rest }, children))));
|
|
43
|
+
};
|