Skip to content

Commit

Permalink
add sidebar layout
Browse files Browse the repository at this point in the history
  • Loading branch information
azouaoui-med committed May 11, 2020
1 parent dbd8339 commit f3beefc
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add suffix prop to menuItem and submenu
- Add prefix prop to menuItem and submenu
- Add sidebar layout

- Add sidebar header component
- Add sidebar content component
- Add sidebar footer component

## [0.2.0] - 2020-05-08

Expand Down
22 changes: 22 additions & 0 deletions src/ProSidebar/SidebarContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { forwardRef, LegacyRef } from 'react';
import classNames from 'classnames';

export interface Props {
className?: string;
children?: React.ReactNode;
}

const SidebarContent: React.ForwardRefRenderFunction<unknown, Props> = (
{ children, className, ...rest },
ref,
) => {
const sidebarContentRef: LegacyRef<HTMLDivElement> =
(ref as any) || React.createRef<HTMLDivElement>();
return (
<div {...rest} ref={sidebarContentRef} className={classNames('pro-sidebar-content', className)}>
{children}
</div>
);
};

export default forwardRef<unknown, Props>(SidebarContent);
22 changes: 22 additions & 0 deletions src/ProSidebar/SidebarFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { forwardRef, LegacyRef } from 'react';
import classNames from 'classnames';

export interface Props {
className?: string;
children?: React.ReactNode;
}

const SidebarFooter: React.ForwardRefRenderFunction<unknown, Props> = (
{ children, className, ...rest },
ref,
) => {
const sidebarFooterRef: LegacyRef<HTMLDivElement> =
(ref as any) || React.createRef<HTMLDivElement>();
return (
<div {...rest} ref={sidebarFooterRef} className={classNames('pro-sidebar-footer', className)}>
{children}
</div>
);
};

export default forwardRef<unknown, Props>(SidebarFooter);
22 changes: 22 additions & 0 deletions src/ProSidebar/SidebarHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { forwardRef, LegacyRef } from 'react';
import classNames from 'classnames';

export interface Props {
className?: string;
children?: React.ReactNode;
}

const SidebarHeader: React.ForwardRefRenderFunction<unknown, Props> = (
{ children, className, ...rest },
ref,
) => {
const sidebarHeaderRef: LegacyRef<HTMLDivElement> =
(ref as any) || React.createRef<HTMLDivElement>();
return (
<div {...rest} ref={sidebarHeaderRef} className={classNames('pro-sidebar-header', className)}>
{children}
</div>
);
};

export default forwardRef<unknown, Props>(SidebarHeader);
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export { default as ProSidebar } from './ProSidebar/ProSidebar';
export { default as SidebarHeader } from './ProSidebar/SidebarHeader';
export { default as SidebarContent } from './ProSidebar/SidebarContent';
export { default as SidebarFooter } from './ProSidebar/SidebarFooter';
export { default as Menu } from './ProSidebar/Menu';
export { default as MenuItem } from './ProSidebar/MenuItem';
export { default as SubMenu } from './ProSidebar/SubMenu';
16 changes: 16 additions & 0 deletions src/scss/partials/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@
overflow-y: auto;
overflow-x: hidden;
position: relative;
display: flex;
flex-direction: column;

.pro-sidebar-header {
height: 60px;
line-height: 60px;
border-bottom: 1px solid rgba($sidebar-color, 0.2);
}
.pro-sidebar-content {
flex-grow: 1;
}
.pro-sidebar-footer {
height: 60px;
line-height: 60px;
border-top: 1px solid rgba($sidebar-color, 0.2);
}
ul {
list-style-type: none;
padding: 0;
Expand Down

0 comments on commit f3beefc

Please sign in to comment.