Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
refactor(my-diary): delete hard code colors
Browse files Browse the repository at this point in the history
affects: @my-diary/app, @components/form-add-post, @components/main-page-header,
@components/post-controls, @practice/my-diary, @ui/button, @ui/drawer, @ui/input, @ui/list,
@ui/text, @ui/theme

ISSUES CLOSED: #77
  • Loading branch information
ikorol3107 committed May 15, 2021
1 parent d4db3f7 commit fbbf65f
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 32 deletions.
8 changes: 3 additions & 5 deletions practice/my-diary/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,28 @@ import { ShowDrawerProvider } from '@store/show-drawer'
import { Box, Column, Layout } from '@ui/layout'

export const App = () => {
const uniqueKey = () => Math.random() * Date.now()
const [notes, setNotes] = useState([
{
note: 'Flight to Moscow',
important: false,
liked: false,
id: uniqueKey(),
id: 1,
onHover: false,
done: false,
},
{
note: 'Friends meeting',
important: false,
liked: false,
id: uniqueKey(),
id: 2,
onHover: false,
done: false,
},
{
note: 'Buy a new frying pan in Ikea',
important: false,
liked: false,
id: uniqueKey(),
id: 3,
onHover: false,
done: false,
},
Expand All @@ -52,7 +51,6 @@ export const App = () => {
<FilterProvider value={[filter, setFilter]}>
<ShowDrawerProvider value={[showDrawer, setShowDrawer]}>
<Box
margin='auto'
width='100%'
height='100%'
justifyContent='center'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export const FormAddPost = () => {
fontWeight='bold'
color='white'
backgroundColor='deepPurple'
borderRadius='gigant'
borderRadius='giant'
boxShadow='violet'
border='none'
onClick={() => {
setInputStatus('visible')
if (inputStatus === 'visible' && newNote !== '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const MainPageHeader = () => {
const [, setShowDrawer] = useShowDrawer()
return (
<Column>
<Row backgroundColor='deepPurple' lineHeights='gigant' alignItems='center'>
<Row backgroundColor='deepPurple' lineHeights='giant' alignItems='center'>
<Layout flexBasis={50} />
<HamburgerButtonIcon cursor='pointer' onClick={() => setShowDrawer(true)} />
<Layout flexBasis={220} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const PostControls = () => {
color='white'
backgroundColor='deepPurple'
borderRadius='rightSide'
border='1px solid'
onClick={() => {
setFilter('all')
setSearchValue('')
Expand All @@ -46,7 +47,7 @@ export const PostControls = () => {
<Button
backgroundColor={filter === 'all' ? 'deepPurple' : 'white'}
color={filter === 'all' ? 'white' : 'grayBlue'}
border='1px solid #e4eaff'
border='1px solid'
borderRadius='leftSide'
onClick={() => setFilter('all')}
>
Expand All @@ -57,15 +58,15 @@ export const PostControls = () => {
<Button
backgroundColor={filter === 'important' ? 'deepPurple' : 'white'}
color={filter === 'important' ? 'white' : 'grayBlue'}
border='1px solid #e4eaff'
border='1px solid'
onClick={() => setFilter('important')}
>
{intl.formatMessage(messages.important)}
</Button>
<Button
backgroundColor={filter === 'liked' ? 'deepPurple' : 'white'}
color={filter === 'liked' ? 'white' : 'grayBlue'}
border='1px solid #e4eaff'
border='1px solid'
borderRadius='rightSide'
onClick={() => setFilter('liked')}
>
Expand Down
4 changes: 2 additions & 2 deletions practice/my-diary/ui/button/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const Button = styled.button(
)

Button.defaultProps = {
color: '#6c757d',
border: 'none',
color: 'grey',
borderColor: 'purple',
fontSize: '17px',
fontWeight: '400',
textAlign: 'center',
Expand Down
21 changes: 11 additions & 10 deletions practice/my-diary/ui/drawer/src/Drawer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import styled from '@emotion/styled'
import { color, space } from 'styled-system'
import React from 'react'
import styled from '@emotion/styled'
import { color, shadow, space } from 'styled-system'

import { Box } from '@ui/layout'
import { Box } from '@ui/layout'

const StyledContainer = styled.div(
({ visible }) => ({
Expand All @@ -11,16 +11,15 @@ const StyledContainer = styled.div(
left: '0',
width: '100%',
height: '100%',
backgroundColor: 'transperent',
visibility: 'hidden',
zIndex: 1,
animation: `${visible ? 'appear' : visible === false && 'disappear'} 0.3s forwards`,
'@keyframes appear': {
from: { backgroundColor: 'transparent', visibility: 'hidden' },
to: { backgroundColor: 'rgba(0,0,0,0.2)', visibility: 'visible' },
to: { backgroundColor: 'grey', visibility: 'visible', opacity: '0.3' },
},
'@keyframes disappear': {
from: { backgroundColor: 'rgba(0,0,0,0.2)', visibility: 'visible' },
from: { backgroundColor: 'grey', visibility: 'visible', opacity: '0.3' },
to: { backgroundColor: 'transparent', visibility: 'hidden' },
},
}),
Expand All @@ -31,9 +30,8 @@ const StyledDrawer = styled.div(
({ visible }) => ({
width: '400px',
height: '100%',
backgroundColor: '#fff',
backgroundColor: 'white',
boxSizing: 'border-box',
boxShadow: '2px 0 5px rgba(0,0,0,0.2)',
position: 'fixed',
display: 'flex',
justifyContent: 'center',
Expand All @@ -54,13 +52,16 @@ const StyledDrawer = styled.div(
}),
color,
space,
shadow,
)

export const Drawer = ({ isVisible, onClose, children }) => {
return (
<Box>
<StyledContainer onClick={onClose} visible={isVisible} />
<StyledDrawer visible={isVisible}>{children}</StyledDrawer>
<StyledDrawer visible={isVisible} boxShadow='darkGrey'>
{children}
</StyledDrawer>
</Box>
)
}
8 changes: 6 additions & 2 deletions practice/my-diary/ui/input/src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ export const Input = styled.input(
() => ({
display: 'block',
height: '40px',
backgroundColor: '#fff',
border: '1px solid',
padding: '0 20px',
border: '1px solid #e4eaff',
fontSize: 16,
fontWeight: 400,
outline: 'none',
Expand All @@ -16,3 +15,8 @@ export const Input = styled.input(
border,
color,
)

Input.defaultProps = {
borderColor: 'purple',
backgroundColor: 'white',
}
7 changes: 3 additions & 4 deletions practice/my-diary/ui/list/src/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ export const Item = ({ notes, setNotes, note, deleteItem, toggleStatus }) => (
>
<Text
lineHeight='large'
color='grayBlue'
color='greyBlue'
textDecoration={note.done ? 'line-through' : 'none'}
textDecorationColor='#e4eaff'
>
{note.note}
</Text>
Expand All @@ -61,7 +60,7 @@ export const Item = ({ notes, setNotes, note, deleteItem, toggleStatus }) => (
>
<StarIcon
opacity={note.important || note.onHover ? '1' : '0'}
color={note.important ? '#FFD700' : 'gray'}
color={note.important ? 'khaki' : 'gray'}
/>
</Button>
<Button
Expand All @@ -77,7 +76,7 @@ export const Item = ({ notes, setNotes, note, deleteItem, toggleStatus }) => (
<Button
backgroundColor='white'
border='none'
color='grayBlue'
color='greyBlue'
onClick={() => setNotes(deleteItem(notes, note.id))}
opacity={note.onHover ? '1' : '0'}
>
Expand Down
1 change: 1 addition & 0 deletions practice/my-diary/ui/text/src/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ Text.defaultProps = {
fontFamily: ['Segoe UI', 'Roboto', 'Ubuntu', 'sans-serif'],
fontWeight: 'normal',
fontSize: '20px',
textDecorationColor: '#e4eaff',
}
3 changes: 1 addition & 2 deletions practice/my-diary/ui/theme/src/colors.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export const colors = {
grey: '#6c757d',
lightGray: 'rgba(0,0,0,0.2)',
purple: '#e4eaff',
deepPurple: '#b07fec',
blue: '#17a2b8',
grayBlue: '#919abc',
greyBlue: '#919abc',
white: '#fff',
yellow: '#FFD700',
}
2 changes: 1 addition & 1 deletion practice/my-diary/ui/theme/src/radii.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const radii = {
normal: 4,
extra: 18,
gigant: 35,
giant: 35,
leftSide: '15px 0 0 15px',
rightSide: '0 15px 15px 0',
}
3 changes: 2 additions & 1 deletion practice/my-diary/ui/theme/src/shadows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const shadows = {
gray: '0 0 10px rgba(0,0,0,0.5)',
grey: '0 0 10px rgba(0,0,0,0.5)',
darkGrey: '2px 0 5px rgba(0,0,0,0.2)',
violet: '0 0 10px rgba(176, 127, 236, 1)',
}

0 comments on commit fbbf65f

Please sign in to comment.