Skip to content

Commit 6d4443c

Browse files
authored
Merge pull request #3860 from Blargian/menu_breakpoint_improvements
Refactor of styling
2 parents 30e0786 + a9b2521 commit 6d4443c

File tree

28 files changed

+109
-78
lines changed

28 files changed

+109
-78
lines changed

src/components/ColorModeToggler/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
3-
import styles from './styles.module.css'
3+
import styles from './styles.module.scss'
44

55
export default function ColorModeToggle({className = ''}) {
66
const disabled = useThemeConfig().colorMode.disableSwitch;
@@ -25,7 +25,7 @@ export default function ColorModeToggle({className = ''}) {
2525
<path d="M8.7227 0.724664C8.7227 0.330045 8.39191 0 8.0036 0C7.60809 0 7.2773 0.330045 7.2773 0.724664V2.18834C7.2773 2.57578 7.60809 2.90583 8.0036 2.90583C8.39191 2.90583 8.7227 2.57578 8.7227 2.18834V0.724664ZM11.5991 3.4009C11.3258 3.67354 11.3258 4.13274 11.6063 4.41256C11.8796 4.6852 12.347 4.69238 12.6274 4.40538L13.6629 3.3722C13.9434 3.09238 13.9362 2.62601 13.6629 2.34619C13.3897 2.07354 12.9222 2.08072 12.649 2.35336L11.5991 3.4009ZM3.37258 4.40538C3.64584 4.6852 4.11326 4.6852 4.38652 4.41256C4.66697 4.14709 4.66697 3.66637 4.4009 3.4009L3.3582 2.35336C3.09213 2.08789 2.61753 2.07354 2.34427 2.34619C2.07101 2.62601 2.06382 3.09238 2.33708 3.36502L3.37258 4.40538ZM7.9964 11.774C10.0602 11.774 11.7717 10.0664 11.7717 8C11.7717 5.93363 10.0602 4.22601 7.9964 4.22601C5.93258 4.22601 4.22112 5.93363 4.22112 8C4.22112 10.0664 5.93258 11.774 7.9964 11.774ZM7.9964 10.4395C6.65888 10.4395 5.55146 9.33453 5.55146 8C5.55146 6.66547 6.65888 5.56054 7.9964 5.56054C9.33393 5.56054 10.4413 6.66547 10.4413 8C10.4413 9.33453 9.33393 10.4395 7.9964 10.4395ZM15.2809 8.71749C15.6692 8.71749 16 8.38744 16 8C16 7.60538 15.6692 7.28251 15.2809 7.28251H13.8211C13.4328 7.28251 13.102 7.60538 13.102 8C13.102 8.38744 13.4328 8.71749 13.8211 8.71749H15.2809ZM0.719101 7.28251C0.330787 7.28251 0 7.60538 0 8C0 8.38744 0.330787 8.71749 0.719101 8.71749H2.17888C2.57438 8.71749 2.90517 8.38744 2.90517 8C2.90517 7.60538 2.57438 7.28251 2.17888 7.28251H0.719101ZM12.6202 11.5946C12.347 11.322 11.8796 11.322 11.5991 11.5946C11.3258 11.8744 11.3258 12.3336 11.6063 12.6135L12.649 13.6538C12.9294 13.9265 13.3897 13.9193 13.6701 13.6395C13.9434 13.3668 13.9434 12.9076 13.6629 12.6278L12.6202 11.5946ZM2.33708 12.6206C2.05663 12.9004 2.05663 13.3668 2.3227 13.6395C2.60315 13.9121 3.07056 13.9193 3.34382 13.6466L4.38652 12.6135C4.66697 12.3336 4.66697 11.8744 4.4009 11.6018C4.12045 11.322 3.65303 11.322 3.37258 11.5946L2.33708 12.6206ZM8.7227 13.8117C8.7227 13.4242 8.39191 13.0942 8.0036 13.0942C7.60809 13.0942 7.2773 13.4242 7.2773 13.8117V15.2753C7.2773 15.6628 7.60809 16 8.0036 16C8.39191 16 8.7227 15.6628 8.7227 15.2753V13.8117Z" fill="currentColor"/>
2626
</svg>
2727
)}
28-
<div><span>{`${colorMode}`}</span><span className={styles.themeModeText}> Mode</span></div>
28+
<div><span>{`${colorMode}`}</span></div>
2929
</button>
3030
);
3131
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use '../../css/breakpoints.scss' as breakpoints;
2+
13
.colorModeButton {
24
display: flex;
35
align-items: center;
@@ -19,20 +21,5 @@
1921
white-space: nowrap;
2022
}
2123

22-
@media (max-width: 1100px) {
23-
.themeModeText {
24-
display: none;
25-
}
26-
}
27-
28-
@media (max-width: 997px) {
29-
.themeModeText {
30-
display: block;
31-
}
3224

33-
.colorModeWrapper {
34-
display: flex;
35-
gap: 0.3rem;
36-
}
37-
}
3825

src/components/DocsCategoryDropdown/styles.module.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '../../css/breakpoints.css';
2+
13
.docsNavDropdownContainer {
24
padding: 8px;
35
border-radius: 10px;
@@ -85,7 +87,7 @@
8587
transform: translateY(30px);
8688
}
8789

88-
@media (max-width: 768px) {
90+
@media (max-width: var(--mobile-breakpoint)) {
8991
.docsNavDropdownMenu {
9092
position: absolute;
9193
min-width: 95%;
@@ -201,13 +203,13 @@
201203
font-size: 0.75rem;
202204
}
203205

204-
@media screen and (max-width: 1100px) {
206+
@media screen and (max-width: var(--laptop-breakpoint)) {
205207
.docsNavDropdownContainer {
206208
padding: 0px;
207209
}
208210

209211
[data-theme="dark"] .docsNavDropdownContainer {
210-
background-color: #201c1c;
212+
211213
}
212214

213215
[data-theme="light"] .docsNavDropdownContainer {

src/components/MobileSideBarMenu/Content.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import styles from './styles.module.css'
2+
import styles from './styles.module.scss'
33
import IconClose from '@theme/Icon/Close';
44
import SearchBar from "@theme/SearchBar";
55
import clsx from 'clsx'

src/components/MobileSideBarMenu/Hamburger.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import styles from './styles.module.css'
2+
import styles from './styles.module.scss'
33

44
const Hamburger = ({onClick}) =>
55
{

src/components/MobileSideBarMenu/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useState} from 'react';
22
import Hamburger from "./Hamburger";
33
import MobileSideBarMenuContents from './Content';
4-
import styles from './styles.module.css';
4+
import styles from './styles.module.scss';
55

66
const MobileSideBarMenu = ({sidebar}) => {
77
const [currentMenuState, setMenuState] = useState(false);

src/components/MobileSideBarMenu/styles.module.css renamed to src/components/MobileSideBarMenu/styles.module.scss

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
@use '../../css/breakpoints.scss' as breakpoints;
2+
13
.docsNavBurger {
2-
display: none;
4+
display: flex;
35
}
46

57
.docsMobileMenu {
@@ -68,6 +70,7 @@
6870
margin-top: 1em;
6971
margin-bottom: 2em;
7072
}
73+
7174
.docsMobileMenu_header{
7275
margin-top: 4rem;
7376
margin-bottom: 1rem;
@@ -77,12 +80,8 @@
7780
justify-content: space-between;
7881
}
7982

80-
@media (max-width: 1400px) {
81-
82-
}
83-
84-
@media (max-width: 996px) {
83+
@media (min-width: breakpoints.$laptop-breakpoint) {
8584
.docsNavBurger {
86-
display: flex;
85+
display: none;
8786
}
8887
}

src/components/Navigation/styles.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
$menu-breakpoint: 997px;
1+
@use '../../css/breakpoints.scss' as breakpoints;
2+
3+
$menu-breakpoint: breakpoints.$laptop-breakpoint;
24

35
:root {
46
--ch-nav-v2-border-color: #dfdfdf;

src/css/breakpoints.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Breakpoints for responsive design
2+
* These variables can be used in media queries to apply styles at different screen sizes.
3+
*/
4+
5+
:root {
6+
--mobile-breakpoint: 996px;
7+
--tablet-breakpoint: 1024px;
8+
--laptop-breakpoint: 1330px;
9+
--large-desktop-breakpoint: 1440px;
10+
}

src/css/breakpoints.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
Needed because we cannot import css into scss and use var(--some-variable)
3+
*/
4+
$mobile-breakpoint: 996px;
5+
$tablet-breakpoint: 1024px;
6+
$laptop-breakpoint: 1330px;
7+
$large-desktop-breakpoint: 1440px;

0 commit comments

Comments
 (0)