Skip to content

Commit

Permalink
feat(Sidebar): improved mobile handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Utzel-Butzel committed Apr 19, 2021
1 parent 4a64ddb commit 962323e
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 15 deletions.
4 changes: 0 additions & 4 deletions .storybook/blocks/DocsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import React, { FC } from 'react';
/*import { Title } from './Title';
import { Subtitle } from './Subtitle';
import { Description } from './Description';
*/
import { Subtitle } from './Subtitle';
import { Primary } from './Primary';
import { Description } from './Description';
Expand Down
2 changes: 0 additions & 2 deletions .storybook/blocks/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,11 @@ const getPreviewProps = (
};

export const Preview: FC<PreviewProps> = (props) => {
console.log('props', props);
const docsContext = useContext(DocsContext);
const sourceContext = useContext(SourceContext);
const previewProps = getPreviewProps(props, docsContext, sourceContext);
const { children } = props;

console.log('waaahh', docsContext, previewProps);
return (
<MDXProvider components={resetComponents}>
<PurePreview
Expand Down
57 changes: 53 additions & 4 deletions src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export default function Sidebar({
<div className={classes} {...other}>
<div className={`${prefix}--sidebar-item-content`}>{sidebar}</div>
<div id="scroll-container" className={`${prefix}--content-section`}>
<div className={`${prefix}--sidebar-content-mobile-header`}>
{sidebarMobileHeader}
</div>
<div className={`${prefix}--sidebar-content__children`}>{children}</div>
{children}
</div>
</div>
);
Expand Down Expand Up @@ -79,6 +76,58 @@ SidebarHeader.propTypes = {
noPadding: PropTypes.bool,
};

export function SidebarContentHeader({
className,
children,
noPadding,
...other
}) {
const classes = classNames(
`${prefix}--sidebar-content-mobile-header`,
className,
{}
);

return (
<div className={classes} {...other}>
{children}
</div>
);
}

SidebarContentHeader.propTypes = {
/**
The children of header of content area
*/
children: PropTypes.node,
};

export function SidebarContentBody({
className,
children,
noPadding,
...other
}) {
const classes = classNames(
`${prefix}--sidebar-content__children`,
className,
{}
);

return (
<div className={classes} {...other}>
{children}
</div>
);
}

SidebarContentBody.propTypes = {
/**
The children of header of content area
*/
children: PropTypes.node,
};

export function SidebarScroll({ children, ...other }) {
return (
<div className={`${prefix}--sidebar-content__scroll`} {...other}>
Expand Down
11 changes: 8 additions & 3 deletions src/components/Sidebar/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.#{$prefix}--sidebar-content__children {
background-color: var(--ui-01);
flex: 1;
overflow: auto;
}

.#{$prefix}--sidebar-content__scroll {
Expand Down Expand Up @@ -55,7 +56,6 @@
align-items: stretch;
//height: 100vh;
flex: 1;
overflow: auto;
@include breakpointMax(bp--md--major) {
.#{$prefix}--sidebar-content__container--active & {
transform: translateX(0%);
Expand All @@ -67,26 +67,31 @@
width: 100%;
height: 100%;
overflow: auto;
transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
z-index: 100;
}
}
.#{$prefix}--sidebar-content-mobile-header {
display: none;
@include breakpointMax(bp--sm--major) {
@include breakpointMax(bp--md--major) {
display: block;
padding: 1em;
display: flex;
justify-content: space-between;
align-items: center;
background: var(--ui-01);
border-bottom: 1px solid var(--ui-02);
z-index: 10000;
width: 100%;
}
}

.#{$prefix}--sidebar-content__back-button {
font-weight: 500;
color: var(--interactive-01);
cursor: pointer;
display: inline-block;
text-decoration: none i !important;
svg {
margin-right: 0.3em;
path {
Expand Down
8 changes: 7 additions & 1 deletion src/components/Sidebar/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
export default from './Sidebar';
export { SidebarHeader, SidebarScroll, SidebarBackButton } from './Sidebar';
export {
SidebarHeader,
SidebarContentHeader,
SidebarContentBody,
SidebarScroll,
SidebarBackButton,
} from './Sidebar';
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ export SelectItemGroup from './components/SelectItemGroup';
export Sidebar, {
SidebarHeader,
SidebarScroll,
SidebarContentHeader,
SidebarContentBody,
SidebarBackButton,
} from './components/Sidebar';

export Switch from './components/Switch';
export Slider from './components/Slider';
export Story from './components/Story';
Expand Down

0 comments on commit 962323e

Please sign in to comment.