-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cb7297
commit 0efaf32
Showing
9 changed files
with
163 additions
and
3 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { useState } from 'react' | ||
import { ToggleCircle, ToggleContainer, ToggleWrapper, togglePropsType } from './Toggle'; | ||
|
||
type toggleStoryPropsType = { | ||
isDark: boolean; | ||
} | ||
|
||
const ToggleStory = ({isDark}:toggleStoryPropsType) => { | ||
const [ isOn, setIsOn ] = useState(false); | ||
|
||
return ( | ||
<ToggleWrapper onClick={()=>{ setIsOn(!isOn) }}> | ||
<ToggleContainer isDark={isDark}> | ||
<ToggleCircle isOn={isOn}/> | ||
</ToggleContainer> | ||
</ToggleWrapper> | ||
) | ||
} | ||
|
||
export default { | ||
title: 'Atoms/Button', | ||
component: ToggleStory, | ||
} | ||
|
||
export const ToggleTemplate = (args: toggleStoryPropsType) => <ToggleStory {...args}/> | ||
ToggleTemplate.args = { | ||
isDark: false, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import styled from "styled-components"; | ||
import tokens from '../../styles/tokens.json'; | ||
import { useSelector } from "react-redux"; | ||
import { RootState } from "../../redux/Store"; | ||
|
||
const globalTokens = tokens.global; | ||
|
||
export const ToggleWrapper = styled.div` | ||
cursor: pointer; | ||
width: fit-content; | ||
` | ||
export const ToggleContainer = styled.div<{isDark:boolean}>` | ||
position: relative; | ||
top: 0; | ||
left: 0; | ||
background-color: ${(props) => | ||
props.isDark ? "rgba(255,255,255,0.15)" : "rgba(205,5,5,0.25)"}; | ||
border-radius: ${globalTokens.BigRadius.value}px; | ||
width: 48px; | ||
height: 24px; | ||
padding: ${globalTokens.Spacing4.value}px ${globalTokens.Spacing12.value}px; | ||
box-shadow: ${globalTokens.RegularShadow.value.x}px | ||
${globalTokens.RegularShadow.value.y}px | ||
${globalTokens.RegularShadow.value.blur}px | ||
${globalTokens.RegularShadow.value.spread}px | ||
${(props) => (props.isDark ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)")}; | ||
`; | ||
export const ToggleCircle = styled.div<{isOn:boolean}>` | ||
position: absolute; | ||
top: 3px; | ||
left: 3px; | ||
border-radius: ${globalTokens.CircleRadius.value}%; | ||
background-color: ${globalTokens.White.value}; | ||
width: 18px; | ||
height: 18px; | ||
transform: ${(props) => props.isOn && "translateX(24px)"}; | ||
transition: 300ms; | ||
`; | ||
|
||
export type togglePropsType = { | ||
isOn: boolean; | ||
setIsOn: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
export const Toggle = ({isOn, setIsOn}:togglePropsType) => { | ||
const isDark = useSelector((state:RootState)=>state.uiSetting.isDark); | ||
|
||
return ( | ||
<ToggleWrapper onClick={()=>{ setIsOn(!isOn) }}> | ||
<ToggleContainer isDark={isDark}> | ||
<ToggleCircle isOn={isOn}/> | ||
</ToggleContainer> | ||
</ToggleWrapper> | ||
); | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { useState } from 'react'; | ||
import tokens from '../../styles/tokens.json'; | ||
import styled from 'styled-components'; | ||
import { BodyTextTypo } from '../../atoms/typographys/Typographys'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { RootState } from '../../redux/Store'; | ||
import logo from '../../assets/images/logos/logo.png'; | ||
import lightLogo from '../../assets/images/logos/lightLogo.png'; | ||
import { Toggle } from '../../atoms/toggle/Toggle'; | ||
import { setIsDark } from '../../redux/createSlice/uiSettingSlice'; | ||
|
||
const globalTokens = tokens.global; | ||
|
||
export const HeaderWrapper = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
` | ||
export const HeaderLogoContainer = styled.section` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
cursor: pointer; | ||
padding: ${globalTokens.Spacing4.value}px ${globalTokens.Spacing32.value}px; | ||
transition: 1000ms; | ||
&:active { | ||
opacity: 0.3; | ||
} | ||
` | ||
export const HeaderLogoTitle = styled(BodyTextTypo)` | ||
height: 50px; | ||
text-align: end; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: end; | ||
font-family: 'Saira Semi Condensed', sans-serif; | ||
` | ||
export const HeaderLogoImg = styled.img` | ||
width: 50px; | ||
transition: 300ms; | ||
` | ||
|
||
const HeaderLogo = () => { | ||
const navigate = useNavigate(); | ||
const dispatch = useDispatch(); | ||
const isDark = useSelector((state:RootState)=>state.uiSetting.isDark); | ||
|
||
const handleOnClick = () => { | ||
navigate('/'); | ||
} | ||
|
||
return ( | ||
<HeaderWrapper> | ||
<HeaderLogoContainer onClick={handleOnClick}> | ||
<HeaderLogoTitle isDark={isDark}>IT Prometheus</HeaderLogoTitle> | ||
<HeaderLogoImg src={isDark?lightLogo:logo}/> | ||
</HeaderLogoContainer> | ||
<Toggle isOn={isDark} setIsOn={()=>{ dispatch(setIsDark(!isDark)) }}/> | ||
</HeaderWrapper> | ||
); | ||
}; | ||
|
||
export default HeaderLogo; |