diff --git a/components/Auction/Auction.module.css b/components/Auction/Auction.module.css index 9184538..fb80861 100644 --- a/components/Auction/Auction.module.css +++ b/components/Auction/Auction.module.css @@ -25,10 +25,10 @@ .auctionContainer { display: flex; width: 70%; - background-color: rgb(245, 235, 235); + background-color: var(--colorAuctionBackground); justify-content: space-around; align-items: center; - border: 1px solid #f4f4f4; + border: 1px solid var(--colorBackgroundLight); border-radius: 20px; box-shadow: 0 0 15px - 7px rgba(0, 0, 0, 0.65); margin-bottom: 20px; diff --git a/components/Auction/new.module.css b/components/Auction/new.module.css index f4b69a4..fbf9e41 100644 --- a/components/Auction/new.module.css +++ b/components/Auction/new.module.css @@ -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; + border-color: var(--colorBackgroundMedium); } .submitBtn:hover { diff --git a/components/Dark-Theme/Themes.js b/components/Dark-Theme/Themes.js new file mode 100644 index 0000000..735bffe --- /dev/null +++ b/components/Dark-Theme/Themes.js @@ -0,0 +1,48 @@ +export const lightTheme = { + colorBackgroundLight: '#f4f4f4', + colorBackgroundMedium: '#f4f4f4', + colorBackgroundDark: '#f4f4f4', + colorExchangeBackground: 'aliceblue', + colorBodyBackground: '#e9ebff', + colorText: '#363636', + colorTransactionBorder: '#f0e2e7', + colorCardBorder: '#f4f4f4', + colorButtonGreen: '#2ecc71', + colorButtonRed: '#ff3838', + colorButtonPink: '#ee1a75', + colorButtonBorder: 'white', + colorFilterHover: '#bdc3c7', + colorAuctionBackground: 'rgb(245, 235, 235)', + colorWhite: 'black', + colorAuctionInput: '#ccc', + colorStockLabel: '#464646', + colorChartBackground: 'white', + 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', +}; diff --git a/components/Dark-Theme/globalStyles.js b/components/Dark-Theme/globalStyles.js new file mode 100644 index 0000000..f6e7c20 --- /dev/null +++ b/components/Dark-Theme/globalStyles.js @@ -0,0 +1,20 @@ +import { createGlobalStyle } from 'styled-components'; + +const GlobalStyles = createGlobalStyle` + :root{ + ${({ theme }) => { + let style = ``; + for (const variableName in theme) { + if (variableName in theme) { + style += `--${variableName}: ${theme[variableName]};`; + } + } + return style; + }} + } + body{ + transition: all 0.50s linear; + } + `; + +export default GlobalStyles; diff --git a/components/Dark-Theme/useDarkMode.js b/components/Dark-Theme/useDarkMode.js new file mode 100644 index 0000000..e42b2bc --- /dev/null +++ b/components/Dark-Theme/useDarkMode.js @@ -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'); + const [themeData, setThemeData] = useState(lightTheme); + const [mountedComponent, setMountedComponent] = useState(false); + const setMode = (mode) => { + setCookie('theme', mode, 30); + setTheme(mode); + const themeMode = mode === 'light' ? lightTheme : darkTheme; + setThemeData(themeMode); + }; + + const themeToggler = () => { + const toggle = theme === 'light' ? setMode('dark') : setMode('light'); + 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]; +}; diff --git a/components/NavBar/index.js b/components/NavBar/index.js index 68bd451..4e4c1bb 100644 --- a/components/NavBar/index.js +++ b/components/NavBar/index.js @@ -4,6 +4,8 @@ import styles from './navbar.module.css'; import Link from 'next/link'; import Image from 'next/image'; 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'; const GITHUB_LOGO = '/assets/github.png'; const DEFAULT_AVATAR = '/assets/default_avatar.jpg'; + const [theme, themeData, themeToggler] = useDarkModeContext(); const [userData, setUserData] = useState({}); const [toggle, setToggle] = useState(false); const [isLoggedIn, setIsLoggedIn] = useState(false); @@ -132,6 +135,9 @@ const NavBar = () => { ); })} +
  • + +
  • { return props.inverted ? InvertedButtonStles : BaseButtonStyles; }; + export const CustomButtonContainer = styled.button` border-radius: 6px; cursor: pointer; diff --git a/components/dark-theme-icon/dark-mode.module.css b/components/dark-theme-icon/dark-mode.module.css new file mode 100644 index 0000000..68e244a --- /dev/null +++ b/components/dark-theme-icon/dark-mode.module.css @@ -0,0 +1,5 @@ +.container img { + width: 20px; + height: 20px; + cursor: pointer; +} diff --git a/components/dark-theme-icon/index.js b/components/dark-theme-icon/index.js new file mode 100644 index 0000000..02d7c36 --- /dev/null +++ b/components/dark-theme-icon/index.js @@ -0,0 +1,20 @@ +import React from 'react'; +import classNames from './dark-mode.module.css'; + +function DarkThemeIcon({ theme, themeToggleHandler }) { + return ( +
    + {theme === 'light' ? ( + moon + ) : ( + sun + )} +
    + ); +} + +export default DarkThemeIcon; diff --git a/components/exchange-rate-row/exchange-rate-row.module.css b/components/exchange-rate-row/exchange-rate-row.module.css index cb4d28d..fb712e0 100644 --- a/components/exchange-rate-row/exchange-rate-row.module.css +++ b/components/exchange-rate-row/exchange-rate-row.module.css @@ -2,7 +2,7 @@ font-weight: 500; display: flex; justify-content: space-between; - background-color: aliceblue; + background-color: var(--colorExchangeBackground); margin: 5px; padding: 5px; border-radius: 6px; diff --git a/components/filter/filter.module.css b/components/filter/filter.module.css index 141a2df..43f341f 100644 --- a/components/filter/filter.module.css +++ b/components/filter/filter.module.css @@ -8,11 +8,11 @@ .showList li { list-style-type: none; padding: 7px; - background-color: #fff; + background-color: var(--colorBackgroundLight); } .showList li:hover { - background-color: #bdc3c7; + background-color: var(--colorFilterHover); } .showList { diff --git a/components/filter/index.js b/components/filter/index.js index b2e7a51..e615781 100644 --- a/components/filter/index.js +++ b/components/filter/index.js @@ -2,8 +2,10 @@ import styles from './filter.module.css'; import Image from 'next/image'; import { useState, useRef } from 'react'; 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) => { >
    Filter icon { min-width: 300px; border-radius: 4px; transition: 0.2s; - background: #ffffff; + background: var(--colorBackgroundMedium); } .stock-card:hover { box-shadow: 0px 4px 10px #ccc; @@ -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 { 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); } `} diff --git a/components/stock-operation-modal/stock-operation.module.css b/components/stock-operation-modal/stock-operation.module.css index f8ca7e6..3375463 100644 --- a/components/stock-operation-modal/stock-operation.module.css +++ b/components/stock-operation-modal/stock-operation.module.css @@ -13,7 +13,7 @@ .modalWrapper { position: fixed; z-index: 100; - background: white; + background: var(--colorBackgroundMedium); border-radius: 10px; padding: 20px 20px; width: 40%; @@ -50,7 +50,7 @@ .label { font-weight: bold; margin: 0.5rem 0; - color: #464646; + color: var(--colorStockLabel); } .select { @@ -61,6 +61,8 @@ border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; + background-color: var(--colorBackgroundDark); + color: var(--colorWhite); } .closedButton { @@ -96,7 +98,7 @@ .modalWrapper { position: fixed; z-index: 100; - background: white; + background: var(--colorBackgroundMedium); border-radius: 10px; padding: 20px 10px; width: 80%; diff --git a/components/transaction-chart/index.js b/components/transaction-chart/index.js index 61ca055..59e312d 100644 --- a/components/transaction-chart/index.js +++ b/components/transaction-chart/index.js @@ -38,7 +38,7 @@ function getDataset(transactionData) { }; } -const TransactionChart = ({ transactionChartData }) => { +const TransactionChart = ({ transactionChartData, theme }) => { const [chartData, setChartData] = useState({}); useEffect(() => { const chart = () => { @@ -62,6 +62,7 @@ const TransactionChart = ({ transactionChartData }) => { { ticks: { autoSkip: true, + fontColor: theme === 'light' ? '#666' : '#fff', }, gridLines: { display: true, @@ -70,6 +71,9 @@ const TransactionChart = ({ transactionChartData }) => { ], xAxes: [ { + ticks: { + fontColor: theme === 'light' ? '#666' : '#fff', + }, gridLines: { display: true, }, diff --git a/components/transaction-chart/transaction-chart.module.css b/components/transaction-chart/transaction-chart.module.css index d76785a..cce0df7 100644 --- a/components/transaction-chart/transaction-chart.module.css +++ b/components/transaction-chart/transaction-chart.module.css @@ -2,8 +2,8 @@ display: flex; justify-content: center; width: calc(50em/2); - background-color: #fdfbfb; - border: 1px solid #f4f1f1; + background-color: var(--colorChartBackground); + border: 1px solid var(--colorChartBorder); cursor: pointer; font-size: 20px; } diff --git a/components/transaction-details/transaction-details.module.css b/components/transaction-details/transaction-details.module.css index 3e7412d..6986a16 100644 --- a/components/transaction-details/transaction-details.module.css +++ b/components/transaction-details/transaction-details.module.css @@ -10,8 +10,8 @@ justify-content: flex-start; flex-wrap: wrap; width: 100%; - border-top: 1px solid #f0e2e7; - border-bottom: 1px solid #f0e2e7;; + border-top: 1px solid var(--colorTransactionBorder); + border-bottom: 1px solid var(--colorTransactionBorder); cursor: pointer; height:6em; font-size: 17px; diff --git a/components/transaction-operation/transaction-operation.module.css b/components/transaction-operation/transaction-operation.module.css index 709df7c..2a56b46 100644 --- a/components/transaction-operation/transaction-operation.module.css +++ b/components/transaction-operation/transaction-operation.module.css @@ -13,7 +13,7 @@ .modalWrapper { position: fixed; z-index: 100; - background: white; + background: var(--colorBackgroundMedium); border-radius: 10px; padding: 32px 24px; width: 40%; @@ -50,7 +50,7 @@ .label { font-weight: bold; margin: 0.5rem 0; - color: #464646; + color: var(--colorStockLabel); } .select { @@ -61,6 +61,8 @@ border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; + background-color: var(--colorBackgroundDark); + color: var(--colorWhite); } .closedButton { @@ -96,7 +98,7 @@ .modalWrapper { position: fixed; z-index: 100; - background: white; + background: var(--colorBackgroundMedium); border-radius: 10px; padding: 20px 10px; width: 80%; diff --git a/pages/_app.js b/pages/_app.js index 8b08555..2a9aae6 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -2,7 +2,14 @@ import React from 'react'; import { wrapper } from '../redux/store'; import '../styles/globals.css'; +import { DarkModeProvider } from 'stores/dark-mode-context'; -const MyApp = ({ Component, pageProps }) => ; +const MyApp = ({ Component, pageProps }) => { + return ( + + + + ); +}; export default wrapper.withRedux(MyApp); diff --git a/pages/auction/index.js b/pages/auction/index.js index 4022eca..1f84db9 100644 --- a/pages/auction/index.js +++ b/pages/auction/index.js @@ -5,23 +5,44 @@ import { Footer } from '@components/footer'; import Head from 'next/head'; import HandleAuctions from '@components/Auction'; import styles from '@components/Auction/Auction.module.css'; +import GlobalStyles from '@components/Dark-Theme/globalStyles'; +import { ThemeProvider } from 'styled-components'; +import { useDarkModeContext } from 'stores/dark-mode-context'; const Auctions = () => { + const [ + theme, + themeData, + themeToggler, + mountedComponent, + ] = useDarkModeContext(); + + if (!mountedComponent) return
    ; return ( -
    - - Auction | Crypto - - - - -
    - + + <> + +
    + + Auction | Crypto + + + + +
    + +
    + + +
    - - -
    -
    + + ); }; diff --git a/pages/auction/new.js b/pages/auction/new.js index d1a0c03..0cb4601 100644 --- a/pages/auction/new.js +++ b/pages/auction/new.js @@ -5,23 +5,42 @@ import { Footer } from '@components/footer'; import Head from 'next/head'; import CreateNewAuction from '@components/Auction/createNewAuction'; import styles from '@components/Auction/Auction.module.css'; +import GlobalStyles from '@components/Dark-Theme/globalStyles'; +import { ThemeProvider } from 'styled-components'; +import { useDarkModeContext } from 'stores/dark-mode-context'; const NewAuction = () => { + const [ + theme, + themeData, + themeToggler, + mountedComponent, + ] = useDarkModeContext(); + + if (!mountedComponent) return
    ; return ( -
    - - Create New Auction | Crypto - - - - - -

    Go Back

    -
    - - -
    -
    + + <> + +
    + + Create New Auction | Crypto + + + + + +

    Go Back

    +
    + + +
    +
    + +
    ); }; diff --git a/pages/currency-exchange/index.js b/pages/currency-exchange/index.js index 852956e..6ad1bb0 100644 --- a/pages/currency-exchange/index.js +++ b/pages/currency-exchange/index.js @@ -5,20 +5,36 @@ import NavBar from '@components/NavBar'; import ExchageRaterow from '@components/exchange-rate-row'; import exchageRates from 'mock/exchange-rates'; import styles from './currency-exchange.module.css'; +import GlobalStyles from '@components/Dark-Theme/globalStyles'; +import { ThemeProvider } from 'styled-components'; +import { useDarkModeContext } from 'stores/dark-mode-context'; export default function Bank() { const { exchange_rates } = styles; + const [ + theme, + themeData, + themeToggler, + mountedComponent, + ] = useDarkModeContext(); + + if (!mountedComponent) return
    ; return ( -
    - - Currency Exchange - - - -
    - {exchageRates.map((row) => ( - - ))} -
    -
    + + <> + +
    + + Currency Exchange + + + +
    + {exchageRates.map((row) => ( + + ))} +
    +
    + +
    ); } diff --git a/pages/index.js b/pages/index.js index b0c7f1b..5acaba2 100644 --- a/pages/index.js +++ b/pages/index.js @@ -12,45 +12,63 @@ import TransactionOperationModal from '@components/transaction-operation-modal'; import NavBar from '@components/NavBar'; import CustomButton from 'components/custom-button'; import { useRouter } from 'next/router'; +import GlobalStyles from '@components/Dark-Theme/globalStyles'; +import { ThemeProvider } from 'styled-components'; +import { useDarkModeContext } from 'stores/dark-mode-context'; export default function Home() { const router = useRouter(); + const [ + theme, + themeData, + themeToggler, + mountedComponent, + ] = useDarkModeContext(); + if (!mountedComponent) return
    ; return ( -
    - - Bank Dashboard - - - -
    -
    -
    - - -
    -
    -
    - router.push('/currency-exchange')} - buttonPrimary - > - Go to currency Exchange - -
    -
    -
    - + + <> + +
    + + Bank Dashboard + + + +
    +
    +
    + +
    -
    -
    -
    -

    Latest Transactions

    +
    + router.push('/currency-exchange')} + buttonPrimary + > + Go to currency Exchange + +
    +
    +
    + +
    +
    +
    +
    +
    +

    Latest Transactions

    +
    + +
    - -
    +
    +
    - -
    -
    + + ); } diff --git a/pages/trading/index.js b/pages/trading/index.js index 474fff8..db682eb 100644 --- a/pages/trading/index.js +++ b/pages/trading/index.js @@ -7,10 +7,19 @@ import NavBar from '@components/NavBar'; import Link from 'next/link'; import { getStocks } from '../../redux/action'; import styles from '../../styles/Home.module.css'; +import GlobalStyles from '@components/Dark-Theme/globalStyles'; +import { ThemeProvider } from 'styled-components'; +import { useDarkModeContext } from 'stores/dark-mode-context'; const Invest = () => { const stocks = useSelector((state) => state.stocksDetails.stocks); const dispatch = useDispatch(); + const [ + theme, + themeData, + themeToggler, + mountedComponent, + ] = useDarkModeContext(); useEffect(() => { const fetchData = async () => { @@ -21,48 +30,52 @@ const Invest = () => { fetchData(); }, []); + if (!mountedComponent) return
    ; return ( - <> - -
    -
    -
    -
    - {stocks.map((itemName) => ( - - ))} -
    -
    - -
    Sell Stocks
    - + + <> + + +
    +
    +
    +
    + {stocks.map((itemName) => ( + + ))} +
    +
    + +
    Sell Stocks
    + +
    +
    -
    -
    - -
    - + .content { + min-height: 87vh; + padding-bottom: 75px; + } + .shoppinglist-container { + display: flex; + flex-wrap: wrap; + justify-content: space-evenly; + align-items: stretch; + } + `} +
    + + ); }; diff --git a/pages/trading/sell.js b/pages/trading/sell.js index 2191f04..dd26716 100644 --- a/pages/trading/sell.js +++ b/pages/trading/sell.js @@ -7,6 +7,9 @@ import { Card } from '@components/stock-card'; import Link from 'next/link'; import { getUserStocks } from '../../redux/action'; import styles from '../../styles/Home.module.css'; +import GlobalStyles from '@components/Dark-Theme/globalStyles'; +import { ThemeProvider } from 'styled-components'; +import { useDarkModeContext } from 'stores/dark-mode-context'; const SellStocks = () => { const userStocksData = useSelector( @@ -14,6 +17,12 @@ const SellStocks = () => { ); const userStocks = userStocksData.stocks; const dispatch = useDispatch(); + const [ + theme, + themeData, + themeToggler, + mountedComponent, + ] = useDarkModeContext(); useEffect(() => { const fetchData = async () => { @@ -24,13 +33,19 @@ const SellStocks = () => { fetchData(); }, []); + if (!mountedComponent) return
    ; const showAlert = () => { return ( -
    - - Please log in to continue! - -
    + + <> + +
    + + Please log in to continue! + +
    + +
    ); }; @@ -41,45 +56,49 @@ const SellStocks = () => { )); const NO_STOCKS_MESSAGE = "You don't have any stocks yet. Click below to buy some"; + if (!mountedComponent) return
    ; return ( - <> - -
    -
    - {userStocksData.isLoggedIn && ( -
    -
    - {availableStocks.length ? availableStocks : NO_STOCKS_MESSAGE} + + <> + + +
    +
    + {userStocksData.isLoggedIn && ( +
    +
    + {availableStocks.length ? availableStocks : NO_STOCKS_MESSAGE} +
    +
    + +
    Buy Stocks
    + +
    -
    - -
    Buy Stocks
    - -
    -
    - )} -
    {!userStocksData.isLoggedIn && showAlert()}
    -
    -
    - -
    - + .content { + min-height: 87vh; + padding-bottom: 75px; + } + .shoppinglist-container { + display: flex; + flex-wrap: wrap; + justify-content: space-evenly; + align-items: stretch; + } + `} +
    + + ); }; diff --git a/public/assets/filter-icon-dark.svg b/public/assets/filter-icon-dark.svg new file mode 100644 index 0000000..a720cba --- /dev/null +++ b/public/assets/filter-icon-dark.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/assets/moon.png b/public/assets/moon.png new file mode 100644 index 0000000..30396f9 Binary files /dev/null and b/public/assets/moon.png differ diff --git a/public/assets/sun.png b/public/assets/sun.png new file mode 100644 index 0000000..5dbfe2c Binary files /dev/null and b/public/assets/sun.png differ diff --git a/stores/dark-mode-context.js b/stores/dark-mode-context.js new file mode 100644 index 0000000..4317578 --- /dev/null +++ b/stores/dark-mode-context.js @@ -0,0 +1,29 @@ +/* eslint-disable react-hooks/rules-of-hooks */ +import { createContext, useContext } from 'react'; +import { useDarkMode } from '@components/Dark-Theme/useDarkMode'; + +const DarkModeContext = createContext(); + +export function DarkModeProvider({ children }) { + const [theme, themeData, themeToggler, mountedComponent] = useDarkMode(); + + let sharedState = [theme, themeData, themeToggler, mountedComponent]; + + return ( + + {children} + + ); +} + +export function useDarkModeContext() { + const state = useContext(DarkModeContext); + + if (state === undefined) { + throw new Error( + 'useDarkModeContext must be used within a DarkModeProvider' + ); + } + + return state; +} diff --git a/styles/Home.module.css b/styles/Home.module.css index e05e993..e57e3ef 100644 --- a/styles/Home.module.css +++ b/styles/Home.module.css @@ -24,20 +24,20 @@ width: 7rem; } .greenButton { - background-color: #2ecc71; + background-color: var(--colorButtonGreen); text-align: center; border: none; } .redButton { - background-color: #ff3838; + background-color: var(--colorButtonRed); text-align: center; border: none; } .card { - border: 1px solid #f4f4f4; + border: 1px solid var(--colorCardBorder); border-radius: 5px; padding: 1px; - background: white; + background: var(--colorBackgroundLight); font-size: 20px; margin-top: 10px; } @@ -79,7 +79,7 @@ margin: 0; padding: 1rem; display: block; - color:#540075; + color: var(--colorStockText); font-weight: bold; font-size: 1.2rem; cursor: pointer; diff --git a/styles/globals.css b/styles/globals.css index 270cded..e8fb35a 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -1,11 +1,11 @@ -html, body { padding: 0; margin: 0; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; - background-color: #e9ebff; + background-color: var(--colorBodyBackground); min-height: 100%; + color: var(--colorText); } @media only screen and (min-width: 905px) { html, @@ -21,7 +21,7 @@ a { box-sizing: border-box; } .text-gray { - color: #363636; + color: var(--colorText); } .card { margin: 10px; diff --git a/utils/cookie.js b/utils/cookie.js new file mode 100644 index 0000000..0aaa3d0 --- /dev/null +++ b/utils/cookie.js @@ -0,0 +1,22 @@ +const setCookie = (name, value, days) => { + const domain = '.realdevsquad.com'; + const expires = new Date( + Date.now() + 24 * days * 60 * 60 * 1000 + ).toUTCString(); + const encodeValue = encodeURIComponent(value); + const cookieStr = `${name}=${encodeValue}; expires=${expires}; domain=${domain}; path=/`; + document.cookie = cookieStr; +}; + +const getCookie = (cookieName) => { + const name = `${cookieName}=`; + const allCookieArray = document.cookie.split(';'); + for (let i = 0; i < allCookieArray.length; i += 1) { + const temp = allCookieArray[i].trim(); + if (temp.indexOf(name) === 0) + return decodeURIComponent(temp.substring(name.length, temp.length)); + } + return ''; +}; + +export { setCookie, getCookie };