-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark mode #242
base: develop
Are you sure you want to change the base?
Dark mode #242
Changes from all commits
2090467
cc85be4
7682c8c
8802689
92c4317
ca990d8
9fd5006
85c07f8
6224ca0
1225995
fa519c1
99a20ea
b16b137
f34c9d2
daf5b90
142500f
fbb6599
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,18 @@ | |
display: flex; | ||
padding: 5% 10%; | ||
flex-direction: column; | ||
border: 1px solid #f4f4f4; | ||
border: 1px solid var(--colorBackgroundMedium); | ||
border-radius: 20px; | ||
box-shadow: 0 0 15px -7px rgba(0,0,0,.65); | ||
width: 40%; | ||
background-color: white; | ||
background-color: var(--colorBackgroundMedium); | ||
overflow-x: hidden; | ||
} | ||
|
||
.inputBox, .submitBtn { | ||
border: 0.5px solid #ccc; | ||
border: 0.5px solid var(--colorAuctionInput); | ||
background-color: var(--colorBackgroundDark); | ||
color: var(--colorWhite); | ||
border-radius: 5px; | ||
padding: 10px; | ||
padding-left: 10px; | ||
|
@@ -25,10 +27,15 @@ | |
width: 100%; | ||
} | ||
|
||
.inputBox:disabled{ | ||
background-color: var(--colorBackgroundLight); | ||
} | ||
|
||
.submitBtn { | ||
cursor: pointer; | ||
background-color: rgb(27, 199, 27); | ||
color: white; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consistency is missing in colour value declarations: either use |
||
border-color: var(--colorBackgroundMedium); | ||
} | ||
|
||
.submitBtn:hover { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export const lightTheme = { | ||
colorBackgroundLight: '#f4f4f4', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Light/medium/Dark has same value. Why to make 2 variables for the same value? |
||
colorBackgroundMedium: '#f4f4f4', | ||
colorBackgroundDark: '#f4f4f4', | ||
colorExchangeBackground: 'aliceblue', | ||
colorBodyBackground: '#e9ebff', | ||
colorText: '#363636', | ||
colorTransactionBorder: '#f0e2e7', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From there onwards, variable names are tied with the |
||
colorCardBorder: '#f4f4f4', | ||
colorButtonGreen: '#2ecc71', | ||
colorButtonRed: '#ff3838', | ||
colorButtonPink: '#ee1a75', | ||
colorButtonBorder: 'white', | ||
colorFilterHover: '#bdc3c7', | ||
colorAuctionBackground: 'rgb(245, 235, 235)', | ||
colorWhite: 'black', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name is |
||
colorAuctionInput: '#ccc', | ||
colorStockLabel: '#464646', | ||
colorChartBackground: 'white', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have consistency in the colour value declaration. Either use RGB, or name, or Hexa |
||
colorChartBorder: 'white', | ||
colorStockText: '#540075', | ||
colorNavbarLink: '#041484', | ||
colorActiveLink: '#e30464', | ||
}; | ||
export const darkTheme = { | ||
colorBackgroundLight: '#27262D', | ||
colorBackgroundMedium: '#1D1C22', | ||
colorBackgroundDark: '#0e0e11', | ||
colorExchangeBackground: 'var(--colorBackgroundMedium)', | ||
colorBodyBackground: 'var(--colorBackgroundLight)', | ||
colorText: '#E1E1EC', | ||
colorTransactionBorder: 'rgb(76, 39, 52)', | ||
colorCardBorder: 'rgb(51, 55, 57)', | ||
colorButtonGreen: '#1d8147', | ||
colorButtonRed: '#9e0000', | ||
colorButtonPink: '#c70f5f', | ||
colorButtonBorder: 'var(--colorButtonPink)', | ||
colorFilterHover: '#3a3f42', | ||
colorAuctionBackground: '#2e1717', | ||
colorWhite: '#fff', | ||
colorAuctionInput: 'white', | ||
colorStockLabel: 'var(--colorWhite)', | ||
colorChartBackground: '#241212', | ||
colorChartBorder: '#34383a', | ||
colorStockText: '#cf56ff', | ||
colorNavbarLink: '#7eb2fb', | ||
colorActiveLink: '#fb2e86', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createGlobalStyle } from 'styled-components'; | ||
|
||
const GlobalStyles = createGlobalStyle` | ||
:root{ | ||
${({ theme }) => { | ||
let style = ``; | ||
for (const variableName in theme) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name should |
||
if (variableName in theme) { | ||
style += `--${variableName}: ${theme[variableName]};`; | ||
} | ||
} | ||
return style; | ||
}} | ||
} | ||
body{ | ||
transition: all 0.50s linear; | ||
} | ||
`; | ||
|
||
export default GlobalStyles; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { setCookie, getCookie } from '../../utils/cookie'; | ||
import { lightTheme, darkTheme } from '@components/Dark-Theme/Themes'; | ||
|
||
export const useDarkMode = () => { | ||
const [theme, setTheme] = useState('light'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move ' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The names are not clear. It should be ' |
||
const [themeData, setThemeData] = useState(lightTheme); | ||
const [mountedComponent, setMountedComponent] = useState(false); | ||
const setMode = (mode) => { | ||
setCookie('theme', mode, 30); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for using |
||
setTheme(mode); | ||
const themeMode = mode === 'light' ? lightTheme : darkTheme; | ||
setThemeData(themeMode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name should be change to |
||
}; | ||
|
||
const themeToggler = () => { | ||
const toggle = theme === 'light' ? setMode('dark') : setMode('light'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move hardcoded content to constant |
||
return toggle; | ||
}; | ||
|
||
useEffect(() => { | ||
const localTheme = getCookie('theme'); | ||
const themeMode = localTheme === 'light' ? lightTheme : darkTheme; | ||
if (localTheme) { | ||
setTheme(localTheme); | ||
setThemeData(themeMode); | ||
} else { | ||
//default | ||
setMode('light'); | ||
} | ||
setMountedComponent(true); | ||
}, []); | ||
return [theme, themeData, themeToggler, mountedComponent]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should return the |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import styles from './navbar.module.css'; | |
import Link from 'next/link'; | ||
import Image from 'next/image'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not getting used. PLease remove this |
||
import GenericClosePopUp from '../Close-popup/GenericClosePopUp'; | ||
import DarkThemeIcon from '../dark-theme-icon/index'; | ||
import { useDarkModeContext } from 'stores/dark-mode-context'; | ||
import { USER_DATA_URL, LOGIN_URL, PATHS, NAV_MENU } from 'constants.js'; | ||
|
||
const NavBar = () => { | ||
|
@@ -12,6 +14,7 @@ const NavBar = () => { | |
const RDS_LOGO = '/assets/Real-Dev-Squad1x.png'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move all the assests URL to constant |
||
const GITHUB_LOGO = '/assets/github.png'; | ||
const DEFAULT_AVATAR = '/assets/default_avatar.jpg'; | ||
const [theme, themeData, themeToggler] = useDarkModeContext(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From there themeData is not getting used anywhere |
||
const [userData, setUserData] = useState({}); | ||
const [toggle, setToggle] = useState(false); | ||
const [isLoggedIn, setIsLoggedIn] = useState(false); | ||
|
@@ -132,6 +135,9 @@ const NavBar = () => { | |
</li> | ||
); | ||
})} | ||
<li className={styles.darkTheme}> | ||
<DarkThemeIcon theme={theme} themeToggleHandler={themeToggler} /> | ||
</li> | ||
<li | ||
className={`${styles.navBarLoginLi} ${ | ||
mountedComponent ? '' : 'd-none' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,11 @@ | |
overflow: hidden; | ||
background-color: #1d1283; | ||
} | ||
.darkTheme { | ||
padding: 19px 16px; | ||
margin: 10px; | ||
display: none; | ||
} | ||
|
||
.navBarLogoLi { | ||
padding: 12px 20px; | ||
|
@@ -121,14 +126,14 @@ | |
margin-top: 2px; | ||
text-decoration: none; | ||
font-weight: bold; | ||
color: #041484; | ||
color: var(--colorNavbarLink); | ||
cursor: pointer; | ||
background: none; | ||
border: none; | ||
} | ||
|
||
.active { | ||
color: #e30464; | ||
color: var(--colorActiveLink); | ||
} | ||
|
||
@media screen and (max-width: 970px) { | ||
|
@@ -182,6 +187,10 @@ | |
float: none; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not be using |
||
} | ||
|
||
.darkTheme { | ||
padding: 10px 40px; | ||
} | ||
|
||
.mainBanner, | ||
.logoImg { | ||
margin-top: 40px; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.container img { | ||
width: 20px; | ||
height: 20px; | ||
cursor: pointer; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import classNames from './dark-mode.module.css'; | ||
|
||
function DarkThemeIcon({ theme, themeToggleHandler }) { | ||
return ( | ||
<div | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
onClick={themeToggleHandler} | ||
onKeyDown={themeToggleHandler} | ||
className={classNames.container} | ||
> | ||
{theme === 'light' ? ( | ||
<img src="/assets/moon.png" alt="moon" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should come from constant also alt tag is wrong. |
||
) : ( | ||
<img src="/assets/sun.png" alt="sun" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should come from constant |
||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default DarkThemeIcon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ import styles from './filter.module.css'; | |
import Image from 'next/image'; | ||
import { useState, useRef } from 'react'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always have React import on the top. |
||
import GenericClosePopUp from '../Close-popup/GenericClosePopUp'; | ||
import { useDarkModeContext } from 'stores/dark-mode-context'; | ||
|
||
const Filter = (props) => { | ||
const [theme, themeData, themeToggler] = useDarkModeContext(); | ||
const { changeTransactions } = props; | ||
const [toggle, setToggle] = useState(false); | ||
const filterRef = useRef(); | ||
|
@@ -20,7 +22,11 @@ const Filter = (props) => { | |
> | ||
<div className="icon"> | ||
<Image | ||
src="/assets/filter-icon.svg" | ||
src={ | ||
theme === 'light' | ||
? '/assets/filter-icon.svg' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move the image |
||
: '/assets/filter-icon-dark.svg' | ||
} | ||
alt="Filter icon" | ||
width={20} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. width and height should come from constant. As well, the UL should come dynamic. create an Object with the list of options required... coop over it to create a List and then bind the event on it. Avoid doing any hardcoding of the content |
||
height={20} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ export const Card = ({ stock, operationType }) => { | |
min-width: 300px; | ||
border-radius: 4px; | ||
transition: 0.2s; | ||
background: #ffffff; | ||
background: var(--colorBackgroundMedium); | ||
} | ||
.stock-card:hover { | ||
box-shadow: 0px 4px 10px #ccc; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move color |
||
|
@@ -77,13 +77,13 @@ export const Card = ({ stock, operationType }) => { | |
text-align: center; | ||
width: 100%; | ||
padding: 1rem; | ||
background-color: #ffffff; | ||
background-color: var(--colorBackgroundMedium); | ||
} | ||
|
||
.stock-card-product-name { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Class name format is not consistent. Use camelCase |
||
font-weight: bold; | ||
font-size: 1.3em; | ||
color: #540075; | ||
color: var(--colorStockText); | ||
} | ||
p { | ||
margin-block-start: 0.5rem; | ||
|
@@ -96,7 +96,7 @@ export const Card = ({ stock, operationType }) => { | |
} | ||
.stock-card-product-quantity { | ||
font-size: 1.3em; | ||
color: #540075; | ||
color: var(--colorStockText); | ||
} | ||
`} | ||
</style> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repetitive code. Please remove
padding-left