feat: implement theme toggle switch
This commit is contained in:
@@ -76,7 +76,7 @@
|
||||
|
||||
.dropdownSelect {
|
||||
color: #64adac;
|
||||
background-color: #05254a;
|
||||
background-color: inherit;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
@@ -90,7 +90,6 @@
|
||||
}
|
||||
|
||||
.selectItem {
|
||||
background-color: #05254a;
|
||||
color: #64adac;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
.wrapper {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
margin: 0 auto;
|
||||
overflow-y: auto;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
'use client';
|
||||
|
||||
import { themes, useThemeContext } from '../theme';
|
||||
import { DocSection, DocsStructure } from '../types/types';
|
||||
import Main from './Main';
|
||||
import NavBar from './NavBar';
|
||||
import styles from './Page.module.css';
|
||||
import SideBar from './SideBar';
|
||||
|
||||
export default function Page({
|
||||
version,
|
||||
versionSections,
|
||||
}: {
|
||||
version: DocsStructure;
|
||||
versionSections: DocSection[];
|
||||
}) {
|
||||
const { theme } = useThemeContext();
|
||||
const themeStyles = themes[theme];
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper} style={themeStyles}>
|
||||
<SideBar version={version} />
|
||||
<div className={styles.container}>
|
||||
<NavBar version={version} />
|
||||
<Main versionSections={versionSections} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,9 +3,9 @@
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
border-right: 1px solid #848586;
|
||||
padding: 1rem;
|
||||
padding: 0 1rem;
|
||||
overflow: auto;
|
||||
scrollbar-color: transparent #0b3766;
|
||||
background-color: inherit;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1000px) {
|
||||
@@ -14,27 +14,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
.container::-webkit-scrollbar {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.container::-webkit-scrollbar-thumb {
|
||||
background-color: transparent;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.container:hover::-webkit-scrollbar-thumb {
|
||||
background-color: #0b3766;
|
||||
}
|
||||
|
||||
.container::-webkit-scrollbar-corner {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.link {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.titleContainer {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background-color: inherit;
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 1rem;
|
||||
white-space: nowrap;
|
||||
@@ -43,7 +36,6 @@
|
||||
|
||||
.onspring {
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.api {
|
||||
@@ -73,11 +65,10 @@
|
||||
.link,
|
||||
.activeLink {
|
||||
text-decoration: none;
|
||||
color: #a3acb9;
|
||||
}
|
||||
|
||||
.link:hover {
|
||||
color: white;
|
||||
color: #64adac;
|
||||
}
|
||||
|
||||
.activeLink {
|
||||
@@ -100,4 +91,65 @@
|
||||
|
||||
.chevron {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 60px;
|
||||
height: 20px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
left: 4px;
|
||||
bottom: 4px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked+.slider {
|
||||
background-color: #05254a;
|
||||
}
|
||||
|
||||
input:focus+.slider {
|
||||
box-shadow: 0 0 1px #05254a;
|
||||
}
|
||||
|
||||
input:checked+.slider:before {
|
||||
-webkit-transform: translateX(40px);
|
||||
-ms-transform: translateX(40px);
|
||||
transform: translateX(40px);
|
||||
}
|
||||
|
||||
.slider.round {
|
||||
border-radius: 34px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ export default function SideBar({
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div>
|
||||
<div className={styles.titleContainer}>
|
||||
<Link href="/" className={styles.link}>
|
||||
<h1 className={styles.title}>
|
||||
<span className={styles.onspring}>
|
||||
@@ -106,14 +106,17 @@ export default function SideBar({
|
||||
<span className={styles.api}>API</span>
|
||||
</h1>
|
||||
</Link>
|
||||
<label className="switch">
|
||||
<label className={styles.switch}>
|
||||
<input
|
||||
title="Toggle dark mode"
|
||||
onChange={() =>
|
||||
setTheme(theme === 'light' ? 'dark' : 'light')
|
||||
}
|
||||
type="checkbox"
|
||||
/>
|
||||
<span className="slider round"></span>
|
||||
<span
|
||||
className={`${styles.slider} ${styles.round}`}
|
||||
></span>
|
||||
</label>
|
||||
</div>
|
||||
<ListTree docs={version.docs} />
|
||||
|
||||
Reference in New Issue
Block a user