-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(version-update): version 1.0.2 - sidebar revamp and update
- Loading branch information
Showing
5 changed files
with
163 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
import React, { forwardRef, useContext } from 'react'; | ||
import classNames from 'classnames'; | ||
import React, { forwardRef, useContext } from "react"; | ||
import classNames from "classnames"; | ||
import PropTypes from "prop-types"; | ||
import { SidebarContext } from '../Sidebar'; | ||
import { SidebarContext } from "../Sidebar"; | ||
import { HeaderContainer } from "./SidebarHeader.style"; | ||
import { ThemeProvider } from "styled-components"; | ||
import { theme } from "./../../../theme"; | ||
|
||
const SidebarHeader = forwardRef( | ||
({ children, prefix, onToggle, className, ...rest }, ref) => { | ||
const sidebarHeaderRef = ref ? ref : React.createRef(); | ||
|
||
const SidebarHeader = forwardRef(({ children, prefix, onToggle, className, ...rest }, ref) => { | ||
const sidebarHeaderRef = ref ? ref : React.createRef(); | ||
const { toggled, handleToggleSidebar } = useContext(SidebarContext); | ||
|
||
const { toggled, handleToggleSidebar } = useContext(SidebarContext); | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<HeaderContainer | ||
{...rest} | ||
ref={sidebarHeaderRef} | ||
className={classNames(className)} | ||
> | ||
<div className={classNames("head-div", {toggled})}> | ||
{prefix ? <span className="icon-suffix" onClick={() => handleToggleSidebar(toggled)}>{prefix}</span> : null} | ||
<span className="head-text"> | ||
{children} | ||
</span> | ||
|
||
</div> | ||
</HeaderContainer> | ||
</ThemeProvider> | ||
); | ||
}); | ||
return ( | ||
<ThemeProvider theme={theme}> | ||
<HeaderContainer | ||
{...rest} | ||
ref={sidebarHeaderRef} | ||
className={classNames(className)} | ||
> | ||
<div className={classNames("head-div", { toggled })}> | ||
<span className="head-text">{children}</span> | ||
{prefix ? ( | ||
<span | ||
className="icon-suffix" | ||
onClick={() => handleToggleSidebar(toggled)} | ||
> | ||
{prefix} | ||
</span> | ||
) : null} | ||
</div> | ||
</HeaderContainer> | ||
</ThemeProvider> | ||
); | ||
} | ||
); | ||
|
||
SidebarHeader.propTypes = { | ||
className: PropTypes.string, | ||
children: PropTypes.node | ||
} | ||
className: PropTypes.string, | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default SidebarHeader; | ||
|
||
export { SidebarHeader as CDBSidebarHeader }; | ||
export { SidebarHeader as CDBSidebarHeader }; |
20 changes: 9 additions & 11 deletions
20
src/components/Sidebar/SidebarHeader/SidebarHeader.style.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
import styled from "styled-components"; | ||
|
||
|
||
export const HeaderContainer = styled.div` | ||
border-bottom: 1px solid hsla(0,0%,67.8%,.2); | ||
border-bottom: 1px solid hsla(0, 0%, 67.8%, 0.2); | ||
.head-div{ | ||
padding: 24px 29px; | ||
.head-div { | ||
padding: 24px 30px; | ||
font-weight: bold; | ||
font-size: 17px; | ||
letter-spacing: 1px; | ||
overflow: hidden; | ||
display: flex; | ||
justify-content: space-between; | ||
white-space: nowrap; | ||
.icon-suffix { | ||
margin: 0px 23px; | ||
cursor: pointer; | ||
cursor: pointer; | ||
} | ||
&.toggled { | ||
&.toggled { | ||
.head-text { | ||
display: none; | ||
} | ||
.icon-suffix { | ||
margin: 0px; | ||
} | ||
} | ||
} | ||
`; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.