mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-07 23:43:57 +02:00
feat: implement dark mode
This commit is contained in:
Generated
+21
-35
@@ -6830,8 +6830,7 @@
|
|||||||
},
|
},
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"aproba": {
|
"aproba": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
@@ -6849,13 +6848,11 @@
|
|||||||
},
|
},
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
@@ -6868,18 +6865,15 @@
|
|||||||
},
|
},
|
||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@@ -6982,8 +6976,7 @@
|
|||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@@ -6993,7 +6986,6 @@
|
|||||||
"is-fullwidth-code-point": {
|
"is-fullwidth-code-point": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
@@ -7006,20 +6998,17 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
@@ -7036,7 +7025,6 @@
|
|||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
@@ -7109,8 +7097,7 @@
|
|||||||
},
|
},
|
||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@@ -7120,7 +7107,6 @@
|
|||||||
"once": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
@@ -7196,8 +7182,7 @@
|
|||||||
},
|
},
|
||||||
"safe-buffer": {
|
"safe-buffer": {
|
||||||
"version": "5.1.2",
|
"version": "5.1.2",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"safer-buffer": {
|
"safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
@@ -7227,7 +7212,6 @@
|
|||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
@@ -7245,7 +7229,6 @@
|
|||||||
"strip-ansi": {
|
"strip-ansi": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^2.0.0"
|
"ansi-regex": "^2.0.0"
|
||||||
}
|
}
|
||||||
@@ -7284,13 +7267,11 @@
|
|||||||
},
|
},
|
||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -9634,14 +9615,12 @@
|
|||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
|
||||||
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
|
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"is-fullwidth-code-point": {
|
"is-fullwidth-code-point": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
|
||||||
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
|
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8="
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"slice-ansi": {
|
"slice-ansi": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@@ -9667,7 +9646,6 @@
|
|||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
||||||
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
|
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"ansi-regex": "^4.1.0"
|
"ansi-regex": "^4.1.0"
|
||||||
}
|
}
|
||||||
@@ -12810,6 +12788,14 @@
|
|||||||
"ts-pnp": "^1.1.2"
|
"ts-pnp": "^1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"polished": {
|
||||||
|
"version": "3.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/polished/-/polished-3.4.1.tgz",
|
||||||
|
"integrity": "sha512-GflTnlP5rrpDoigjczEkS6Ye7NDA4sFvAnlr5hSDrEvjiVj97Xzev3hZlLi3UB27fpxyTS9rWU64VzVLWkG+mg==",
|
||||||
|
"requires": {
|
||||||
|
"@babel/runtime": "^7.4.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"portfinder": {
|
"portfinder": {
|
||||||
"version": "1.0.21",
|
"version": "1.0.21",
|
||||||
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.21.tgz",
|
"resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.21.tgz",
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
"gatsby-source-filesystem": "^2.1.8",
|
"gatsby-source-filesystem": "^2.1.8",
|
||||||
"gatsby-transformer-remark": "^2.6.10",
|
"gatsby-transformer-remark": "^2.6.10",
|
||||||
"gatsby-transformer-sharp": "^2.2.5",
|
"gatsby-transformer-sharp": "^2.2.5",
|
||||||
|
"polished": "^3.4.1",
|
||||||
"prismjs": "^1.17.1",
|
"prismjs": "^1.17.1",
|
||||||
"ramda": "^0.26.1",
|
"ramda": "^0.26.1",
|
||||||
"react": "^16.8.6",
|
"react": "^16.8.6",
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import React, { createContext } from "react"
|
||||||
|
import { ThemeProvider as BaseThemeProvider } from "styled-components"
|
||||||
|
|
||||||
|
import { darkTheme, lightTheme } from "./design/themes"
|
||||||
|
import { useLocalStorage } from "./hooks/useLocalStorage"
|
||||||
|
|
||||||
|
interface IThemeProviderProps {
|
||||||
|
// TODO: type this properly, BaseThemeProvider doesn't like React.ReactNode
|
||||||
|
children: any
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IThemeContext {
|
||||||
|
theme: "dark" | "light"
|
||||||
|
setTheme: () => void
|
||||||
|
toggleTheme: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ThemeContext = createContext<IThemeContext | null>(null)
|
||||||
|
|
||||||
|
const ThemeProvider = ({ children }: IThemeProviderProps) => {
|
||||||
|
const [theme, setTheme] = useLocalStorage("theme", "light")
|
||||||
|
const themeObject = theme === "dark" ? darkTheme : lightTheme
|
||||||
|
|
||||||
|
const toggleTheme = () => {
|
||||||
|
setTheme(theme === "light" ? "dark" : "light")
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ThemeContext.Provider value={{ theme, setTheme, toggleTheme }}>
|
||||||
|
<BaseThemeProvider theme={themeObject}>{children}</BaseThemeProvider>
|
||||||
|
</ThemeContext.Provider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ThemeProvider }
|
||||||
@@ -9,7 +9,7 @@ export const DiscordButtonWrapper = styled.div`
|
|||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
background: #7289da;
|
background: ${props => props.theme.discord.base};
|
||||||
color: #fff;
|
color: #fff;
|
||||||
padding: 22px 35px;
|
padding: 22px 35px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
@@ -18,7 +18,7 @@ export const DiscordButtonWrapper = styled.div`
|
|||||||
box-shadow: 0 3px 18px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 3px 18px rgba(0, 0, 0, 0.3);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #5265ad;
|
background: ${props => props.theme.discord.darker};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import React, { Fragment, PropsWithChildren } from "react"
|
import React, { Fragment, PropsWithChildren } from "react"
|
||||||
|
|
||||||
import { GlobalStyles } from "../../globalStyles"
|
import { GlobalStyles } from "../../globalStyles"
|
||||||
|
import { ThemeProvider } from "../../ThemeProvider"
|
||||||
import { Container } from "../Container"
|
import { Container } from "../Container"
|
||||||
import { Footer } from "../Footer"
|
import { Footer } from "../Footer"
|
||||||
import { Header } from "../Header"
|
import { Header } from "../Header"
|
||||||
@@ -21,19 +22,21 @@ export function Layout({
|
|||||||
const isHome = location.pathname === "/"
|
const isHome = location.pathname === "/"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SC.LayoutWrapper>
|
<ThemeProvider>
|
||||||
<GlobalStyles />
|
<SC.LayoutWrapper>
|
||||||
<Header isHome={isHome} />
|
<GlobalStyles />
|
||||||
{!isHome && (
|
<Header isHome={isHome} />
|
||||||
<Fragment>
|
{!isHome && (
|
||||||
<SC.MainContent>
|
<Fragment>
|
||||||
<Container>{children}</Container>
|
<SC.MainContent>
|
||||||
</SC.MainContent>
|
<Container>{children}</Container>
|
||||||
<Footer />
|
</SC.MainContent>
|
||||||
<WavesBottom />
|
<Footer />
|
||||||
<SC.WavesSpacer />
|
<WavesBottom />
|
||||||
</Fragment>
|
<SC.WavesSpacer />
|
||||||
)}
|
</Fragment>
|
||||||
</SC.LayoutWrapper>
|
)}
|
||||||
|
</SC.LayoutWrapper>
|
||||||
|
</ThemeProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
|
import { transparentize } from "polished"
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
import { fontFamily } from "../../design/typography"
|
import { fontFamily } from "../../design/typography"
|
||||||
import Logo from "../../images/tph-logo.svg"
|
import Logo from "../../images/tph-logo.svg"
|
||||||
|
|
||||||
export const MobileHeaderWrapper = styled.div`
|
export const MobileHeaderWrapper = styled.div`
|
||||||
z-index: 50;
|
z-index: 50;
|
||||||
background: rgba(255, 255, 255, 0.8);
|
background: ${props => transparentize(0.2, props.theme.main.background)};
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -50,7 +51,7 @@ export const Burger = styled.div`
|
|||||||
content: "";
|
content: "";
|
||||||
height: 2px;
|
height: 2px;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
background: #222;
|
background: ${props => props.theme.main.foreground};
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Link } from "gatsby"
|
import { Link } from "gatsby"
|
||||||
|
import { darken, lighten } from "polished"
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
|
|
||||||
export const ResourceBreadcrumbWrapper = styled.div`
|
export const ResourceBreadcrumbWrapper = styled.div`
|
||||||
@@ -23,16 +24,20 @@ export const LinkWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
|
|
||||||
svg path {
|
svg path {
|
||||||
fill: #04b0a6;
|
fill: ${props => props.theme.main.link};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const StyledLink = styled(Link)`
|
export const StyledLink = styled(Link)`
|
||||||
color: #04b0a6;
|
color: ${props => props.theme.main.link};
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #045551;
|
color: #045551;
|
||||||
|
color: ${props =>
|
||||||
|
props.theme.name === "dark"
|
||||||
|
? lighten(0.15, props.theme.main.link)
|
||||||
|
: darken(0.15, props.theme.main.link)};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Link } from "gatsby"
|
import { Link } from "gatsby"
|
||||||
import styled, { css } from "styled-components"
|
import styled, { css } from "styled-components"
|
||||||
import { fontFamily, modularScale } from "../../design/typography"
|
import { fontFamily, modularScale } from "../../design/typography"
|
||||||
|
import { darken, lighten } from "polished"
|
||||||
|
|
||||||
export const ResourceHeaderWrapper = styled.div`
|
export const ResourceHeaderWrapper = styled.div`
|
||||||
border-bottom: 1px solid #dbdbdb;
|
border-bottom: 1px solid #dbdbdb;
|
||||||
@@ -57,13 +58,16 @@ export const ExternalResources = styled(ExtraLinks)``
|
|||||||
const extraLink = css`
|
const extraLink = css`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: #04b0a6;
|
color: ${props => props.theme.main.link};
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #045551;
|
color: ${props =>
|
||||||
|
props.theme.name === "dark"
|
||||||
|
? lighten(0.15, props.theme.main.link)
|
||||||
|
: darken(0.15, props.theme.main.link)};
|
||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
@@ -74,7 +78,7 @@ const extraLink = css`
|
|||||||
}
|
}
|
||||||
|
|
||||||
svg path {
|
svg path {
|
||||||
fill: #04b0a6;
|
fill: ${props => props.theme.main.link};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import React, { PropsWithChildren, useState } from "react"
|
|||||||
|
|
||||||
import { GlobalStyles } from "../../globalStyles"
|
import { GlobalStyles } from "../../globalStyles"
|
||||||
import { SidebarProvider } from "../../SidebarProvider"
|
import { SidebarProvider } from "../../SidebarProvider"
|
||||||
|
import { ThemeProvider } from "../../ThemeProvider"
|
||||||
import { MobileHeader } from "../MobileHeader"
|
import { MobileHeader } from "../MobileHeader"
|
||||||
import { ResourcesSidebar } from "../ResourcesSidebar"
|
import { ResourcesSidebar } from "../ResourcesSidebar"
|
||||||
import * as SC from "./styles"
|
import * as SC from "./styles"
|
||||||
@@ -25,19 +26,23 @@ export function ResourcesLayout({ children }: PropsWithChildren<{}>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarProvider>
|
<ThemeProvider>
|
||||||
<GlobalStyles />
|
<SidebarProvider>
|
||||||
<SC.Main>
|
<GlobalStyles />
|
||||||
<MobileHeader openMenu={openMenu} />
|
<SC.Main>
|
||||||
<ResourcesSidebar className={activeMobileMenu ? "is-open" : ""} />
|
<MobileHeader openMenu={openMenu} />
|
||||||
<SC.MainContent>
|
<ResourcesSidebar className={activeMobileMenu ? "is-open" : ""} />
|
||||||
<SC.Container>{children}</SC.Container>
|
<SC.MainContent>
|
||||||
</SC.MainContent>
|
<SC.Container>
|
||||||
</SC.Main>
|
{children}
|
||||||
<SC.Overlay
|
</SC.Container>
|
||||||
className={activeMobileMenu ? "is-open" : ""}
|
</SC.MainContent>
|
||||||
onClick={closeMenu}
|
</SC.Main>
|
||||||
/>
|
<SC.Overlay
|
||||||
</SidebarProvider>
|
className={activeMobileMenu ? "is-open" : ""}
|
||||||
|
onClick={closeMenu}
|
||||||
|
/>
|
||||||
|
</SidebarProvider>
|
||||||
|
</ThemeProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ export const Main = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
background: ${props => props.theme.main.background};
|
||||||
|
color: ${props => props.theme.main.foreground};
|
||||||
`
|
`
|
||||||
|
|
||||||
export const Overlay = styled.div`
|
export const Overlay = styled.div`
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Scrollbar from "react-perfect-scrollbar"
|
|||||||
import "react-perfect-scrollbar/dist/css/styles.css"
|
import "react-perfect-scrollbar/dist/css/styles.css"
|
||||||
import TriangleDown from "../../icons/triangle-down.svg"
|
import TriangleDown from "../../icons/triangle-down.svg"
|
||||||
import Banner from "../../images/tph-banner.svg"
|
import Banner from "../../images/tph-banner.svg"
|
||||||
|
import { ThemeToggler } from "../ThemeToggler"
|
||||||
import useSidebar from "./../../hooks/useSidebar"
|
import useSidebar from "./../../hooks/useSidebar"
|
||||||
import * as SC from "./styles"
|
import * as SC from "./styles"
|
||||||
import useBuildTree from "./useBuildTree"
|
import useBuildTree from "./useBuildTree"
|
||||||
@@ -93,23 +94,25 @@ function Folder({ item }: { item: IFolder }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const FirstLevelFolder = memo(({ item, index }: { item: IFolder; index: number }) => {
|
const FirstLevelFolder = memo(
|
||||||
const { current, setCurrent } = useSidebar()
|
({ item, index }: { item: IFolder; index: number }) => {
|
||||||
const collapsed = current !== index
|
const { current, setCurrent } = useSidebar()
|
||||||
|
const collapsed = current !== index
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SC.TreeWrapper className="firstLevel" collapsed={collapsed}>
|
<SC.TreeWrapper className="firstLevel" collapsed={collapsed}>
|
||||||
<SC.FirstLabel
|
<SC.FirstLabel
|
||||||
className={!collapsed ? "active" : undefined}
|
className={!collapsed ? "active" : undefined}
|
||||||
onClick={() => setCurrent(index)}
|
onClick={() => setCurrent(index)}
|
||||||
>
|
>
|
||||||
{item.title}
|
{item.title}
|
||||||
<SC.CollapseToggler />
|
<SC.CollapseToggler />
|
||||||
</SC.FirstLabel>
|
</SC.FirstLabel>
|
||||||
<SC.Children>{item.children.map(node => plantTree(node))}</SC.Children>
|
<SC.Children>{item.children.map(node => plantTree(node))}</SC.Children>
|
||||||
</SC.TreeWrapper>
|
</SC.TreeWrapper>
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) {
|
function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) {
|
||||||
return (
|
return (
|
||||||
@@ -140,6 +143,8 @@ export function ResourcesSidebar(props: React.HTMLAttributes<HTMLDivElement>) {
|
|||||||
<MenuItem to="/resources">resources</MenuItem>
|
<MenuItem to="/resources">resources</MenuItem>
|
||||||
<MenuItem to="/">tech</MenuItem>
|
<MenuItem to="/">tech</MenuItem>
|
||||||
</SC.Menu>
|
</SC.Menu>
|
||||||
|
|
||||||
|
<ThemeToggler />
|
||||||
</SC.Inner>
|
</SC.Inner>
|
||||||
</Scrollbar>
|
</Scrollbar>
|
||||||
</SC.ResourcesSidebarWrapper>
|
</SC.ResourcesSidebarWrapper>
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { Link } from "gatsby"
|
import { Link } from "gatsby"
|
||||||
|
import { transparentize } from "polished"
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
import ChevronUp from "../../icons/chevron-up.svg"
|
import ChevronUp from "../../icons/chevron-up.svg"
|
||||||
|
|
||||||
export const ResourcesSidebarWrapper = styled.div`
|
export const ResourcesSidebarWrapper = styled.div`
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
flex: 0 0 320px;
|
flex: 0 0 320px;
|
||||||
background: #f9f9f9;
|
background: ${props => props.theme.sidebar.background};
|
||||||
|
color: ${props => props.theme.sidebar.foreground};
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
@@ -60,11 +62,11 @@ export const FirstLabel = styled.div`
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 12px 15px 12px 0;
|
padding: 12px 15px 12px 0;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #a9a9a9;
|
color: ${props => transparentize(0.5, props.theme.sidebar.foreground)};
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: #000;
|
color: ${props => props.theme.sidebar.foreground};
|
||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
@@ -73,7 +75,7 @@ export const FirstLabel = styled.div`
|
|||||||
transition: transform 0.3s;
|
transition: transform 0.3s;
|
||||||
|
|
||||||
path {
|
path {
|
||||||
fill: #a9a9a9;
|
fill: ${props => transparentize(0.5, props.theme.sidebar.foreground)};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@ export const FirstLabel = styled.div`
|
|||||||
transform: rotate(0);
|
transform: rotate(0);
|
||||||
|
|
||||||
path {
|
path {
|
||||||
fill: #000;
|
fill: ${props => props.theme.sidebar.foreground};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@@ -105,20 +107,20 @@ export const TreeWrapper = styled.div<{ collapsed: boolean }>`
|
|||||||
|
|
||||||
& > ${Label} svg {
|
& > ${Label} svg {
|
||||||
transform: rotate(${props => (props.collapsed ? -90 : 0)}deg);
|
transform: rotate(${props => (props.collapsed ? -90 : 0)}deg);
|
||||||
|
fill: ${props => props.theme.sidebar.foreground};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const CollapseToggler = styled(ChevronUp)``
|
export const CollapseToggler = styled(ChevronUp)``
|
||||||
|
|
||||||
export const Inner = styled.div`
|
export const Inner = styled.div`
|
||||||
padding-top: 30px;
|
padding: 30px 0 30px 20px;
|
||||||
padding-left: 20px;
|
|
||||||
`
|
`
|
||||||
|
|
||||||
export const PageLink = styled(Link)`
|
export const PageLink = styled(Link)`
|
||||||
display: block;
|
display: block;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
color: #000;
|
color: ${props => props.theme.sidebar.foreground};
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
||||||
& + & {
|
& + & {
|
||||||
@@ -127,6 +129,7 @@ export const PageLink = styled(Link)`
|
|||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
color: ${props => props.theme.sidebar.active};
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -134,14 +137,14 @@ export const Menu = styled.nav`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border-top: 1px dashed #a5a5a5;
|
border-top: 1px dashed #a5a5a5;
|
||||||
margin-top: 20px;
|
margin: 20px 0 40px;
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
`
|
`
|
||||||
|
|
||||||
export const MenuItem = styled(Link)`
|
export const MenuItem = styled(Link)`
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
color: #000;
|
color: ${props => props.theme.sidebar.foreground};
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import React from "react"
|
||||||
|
import useTheme from "../../hooks/useTheme"
|
||||||
|
import * as SC from "./styles"
|
||||||
|
|
||||||
|
export function ThemeToggler() {
|
||||||
|
const { theme, toggleTheme } = useTheme()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SC.ThemeTogglerWrapper onClick={toggleTheme}>
|
||||||
|
<SC.Link>Switch to {theme === "dark" ? "light" : "dark"} mode</SC.Link>
|
||||||
|
</SC.ThemeTogglerWrapper>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { transparentize } from "polished"
|
||||||
|
import styled from "styled-components"
|
||||||
|
|
||||||
|
export const ThemeTogglerWrapper = styled.div``
|
||||||
|
|
||||||
|
export const Link = styled.span`
|
||||||
|
display: inline-block;
|
||||||
|
cursor: pointer;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-bottom: 2px solid
|
||||||
|
${props => transparentize(0.6, props.theme.sidebar.foreground)};
|
||||||
|
}
|
||||||
|
`
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
interface ISet {
|
||||||
|
background: string
|
||||||
|
foreground: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ITheme {
|
||||||
|
name: "dark" | "light"
|
||||||
|
sidebar: ISet & { active: string }
|
||||||
|
main: ISet & { link: string }
|
||||||
|
discord: {
|
||||||
|
base: string
|
||||||
|
darker: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseColors = {
|
||||||
|
discord: {
|
||||||
|
base: "#7289DA",
|
||||||
|
darker: "#5265AD",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export const darkTheme: ITheme = {
|
||||||
|
...baseColors,
|
||||||
|
name: "dark",
|
||||||
|
sidebar: {
|
||||||
|
background: "#293845",
|
||||||
|
foreground: "#FFFFFF",
|
||||||
|
active: "#00FCFF",
|
||||||
|
},
|
||||||
|
main: {
|
||||||
|
background: "#1F2A34",
|
||||||
|
foreground: "#FFFFFF",
|
||||||
|
link: "#04B0A6",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export const lightTheme: ITheme = {
|
||||||
|
...baseColors,
|
||||||
|
name: "light",
|
||||||
|
sidebar: {
|
||||||
|
background: "#F9F9F9",
|
||||||
|
foreground: "#000000",
|
||||||
|
active: "#499DEF",
|
||||||
|
},
|
||||||
|
main: {
|
||||||
|
background: "#FFFFFF",
|
||||||
|
foreground: "#000000",
|
||||||
|
link: "#04B0A6",
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { useEffect, useState } from "react"
|
||||||
|
|
||||||
|
export const useLocalStorage = (name: string, initialValue: string) => {
|
||||||
|
const windowGlobal = typeof window !== "undefined" && window
|
||||||
|
const [value, setValue] = useState(() => {
|
||||||
|
if (windowGlobal) {
|
||||||
|
const currentValue = windowGlobal.localStorage.getItem(name)
|
||||||
|
return currentValue ? JSON.parse(currentValue) : initialValue
|
||||||
|
}
|
||||||
|
return initialValue
|
||||||
|
})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (windowGlobal) {
|
||||||
|
windowGlobal.localStorage.setItem(name, JSON.stringify(value))
|
||||||
|
}
|
||||||
|
}, [name, value, windowGlobal])
|
||||||
|
|
||||||
|
return [value, setValue]
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { useContext } from "react"
|
||||||
|
import { IThemeContext, ThemeContext } from "../ThemeProvider"
|
||||||
|
|
||||||
|
export default function useTheme(): IThemeContext {
|
||||||
|
const themeContext = useContext(ThemeContext)
|
||||||
|
|
||||||
|
if (!themeContext) {
|
||||||
|
throw Error("Need context")
|
||||||
|
}
|
||||||
|
|
||||||
|
return themeContext
|
||||||
|
}
|
||||||
Vendored
+7
@@ -1,6 +1,13 @@
|
|||||||
|
import { ITheme } from "./src/design/themes"
|
||||||
|
import "styled-components"
|
||||||
|
|
||||||
declare module "*.svg"
|
declare module "*.svg"
|
||||||
declare module "*.png"
|
declare module "*.png"
|
||||||
|
|
||||||
type ComponentQuery<T> = {
|
type ComponentQuery<T> = {
|
||||||
readonly data: T
|
readonly data: T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare module "styled-components" {
|
||||||
|
export interface DefaultTheme extends ITheme {}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user