Skip to content

Commit 0dab870

Browse files
committed
Modernise Sass and use @use + @forward
1 parent 6a76aa7 commit 0dab870

File tree

12 files changed

+79
-73
lines changed

12 files changed

+79
-73
lines changed

src/furo/assets/styles/_scaffold.sass

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// HACK: Always having the scrollbar visible, prevents certain browsers from
1717
// causing the content to stutter horizontally between taller-than-viewport and
1818
// not-taller-than-viewport pages.
19+
@use "variables"
1920

2021
html
2122
overflow-x: hidden
@@ -108,14 +109,14 @@ article
108109
display: flex
109110
justify-content: flex-end
110111
// These next two lines took me two days to figure out.
111-
width: calc((100% - #{$full-width}) / 2 + #{$sidebar-width})
112-
min-width: $sidebar-width
112+
width: calc((100% - #{variables.$full-width}) / 2 + #{variables.$sidebar-width})
113+
min-width: variables.$sidebar-width
113114

114115
// Scroll-along sidebars
115116
.sidebar-container,
116117
.toc-drawer
117118
box-sizing: border-box
118-
width: $sidebar-width
119+
width: variables.$sidebar-width
119120

120121
.toc-drawer
121122
background: var(--color-toc-background)
@@ -142,8 +143,8 @@ article
142143

143144
// Central items.
144145
.content
145-
padding: 0 $content-padding
146-
width: $content-width
146+
padding: 0 variables.$content-padding
147+
width: variables.$content-width
147148

148149
display: flex
149150
flex-direction: column
@@ -341,46 +342,46 @@ article
341342
// Responsive layouting
342343
////////////////////////////////////////////////////////////////////////////////
343344
// Make things a bit bigger on bigger screens.
344-
@media (min-width: $full-width + $sidebar-width)
345+
@media (min-width: variables.$full-width + variables.$sidebar-width)
345346
html
346347
font-size: 110%
347348

348-
@media (max-width: $full-width)
349+
@media (max-width: variables.$full-width)
349350
// Collapse "toc" into the icon.
350351
.toc-content-icon
351352
display: flex
352353
.toc-drawer
353354
position: fixed
354355
height: 100vh
355356
top: 0
356-
right: -$sidebar-width
357+
right: - variables.$sidebar-width
357358
border-left: 1px solid var(--color-background-muted)
358359
.toc-tree
359360
border-left: none
360361
font-size: var(--toc-font-size--mobile)
361362

362363
// Accomodate for a changed content width.
363364
.sidebar-drawer
364-
width: calc((100% - #{$full-width - $sidebar-width}) / 2 + #{$sidebar-width})
365+
width: calc((100% - #{variables.$full-width - variables.$sidebar-width}) / 2 + #{variables.$sidebar-width})
365366

366-
@media (max-width: $content-padded-width + $sidebar-width)
367+
@media (max-width: variables.$content-padded-width + variables.$sidebar-width)
367368
// Center the page
368369
.content
369370
margin-left: auto
370371
margin-right: auto
371-
padding: 0 $content-padding--small
372+
padding: 0 variables.$content-padding--small
372373

373-
@media (max-width: $content-padded-width--small + $sidebar-width)
374+
@media (max-width: variables.$content-padded-width--small + variables.$sidebar-width)
374375
// Collapse "navigation".
375376
.nav-overlay-icon
376377
display: flex
377378
.sidebar-drawer
378379
position: fixed
379380
height: 100vh
380-
width: $sidebar-width
381+
width: variables.$sidebar-width
381382

382383
top: 0
383-
left: -$sidebar-width
384+
left: - variables.$sidebar-width
384385

385386
// Swap which icon is visible.
386387
.toc-header-icon, .theme-toggle-header
@@ -424,13 +425,13 @@ article
424425
flex-direction: column
425426
justify-content: center
426427

427-
@media (max-width: $content-width + 2* $content-padding--small)
428+
@media (max-width: variables.$content-width + 2* variables.$content-padding--small)
428429
// Content should respect window limits.
429430
.content
430431
width: 100%
431432
overflow-x: auto
432433

433-
@media (max-width: $content-width)
434+
@media (max-width: variables.$content-width)
434435
article[role=main] aside.sidebar
435436
float: none
436437
width: 100%
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "print"
2-
@import "screen-readers"
3-
@import "theme"
4-
@import "typography"
1+
@forward "print"
2+
@forward "screen-readers"
3+
@forward "theme"
4+
@forward "typography"

src/furo/assets/styles/base/_theme.sass

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
// This contains the bulk of the logic for handling dark mode, color scheme
44
// toggling and the handling of color-scheme-specific hiding of elements.
55
6+
@use "../variables"
7+
68
body
7-
@include fonts
8-
@include spacing
9-
@include icons
10-
@include admonitions
11-
@include default-admonition(#651fff, "abstract")
12-
@include default-topic(#14B8A6, "pencil")
9+
@include variables.fonts
10+
@include variables.spacing
11+
@include variables.icons
12+
@include variables.admonitions
13+
@include variables.default-admonition(#651fff, "abstract")
14+
@include variables.default-topic(#14B8A6, "pencil")
1315

14-
@include colors
16+
@include variables.colors
1517

1618
.only-light
1719
display: block !important
@@ -22,7 +24,7 @@ html body .only-dark
2224
@media not print
2325
// Enable dark-mode, if requested.
2426
body[data-theme="dark"]
25-
@include colors-dark
27+
@include variables.colors-dark
2628

2729
html & .only-light
2830
display: none !important
@@ -32,7 +34,7 @@ html body .only-dark
3234
// Enable dark mode, unless explicitly told to avoid.
3335
@media (prefers-color-scheme: dark)
3436
body:not([data-theme="light"])
35-
@include colors-dark
37+
@include variables.colors-dark
3638

3739
html & .only-light
3840
display: none !important

src/furo/assets/styles/components/_footer.sass

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This file contains the styles used for stylizing the footer that's shown
22
// below the content.
3+
@use "../variables"
34

45
footer
56
font-size: var(--font-size--small)
@@ -23,7 +24,7 @@ footer
2324

2425
line-height: 1.5
2526

26-
@media (max-width: $content-width)
27+
@media (max-width: variables.$content-width)
2728
text-align: center
2829
flex-direction: column-reverse
2930
gap: 0.25rem
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "footer"
2-
@import "search"
3-
@import "sidebar"
4-
@import "table_of_contents"
1+
@forward "footer"
2+
@forward "search"
3+
@forward "sidebar"
4+
@forward "table_of_contents"

src/furo/assets/styles/content/_admonitions.sass

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use "sass:list"
2-
//
2+
@use "../variables"
3+
34
// The design here is strongly inspired by mkdocs-material.
45
.admonition, .topic
56
margin: 1rem auto
@@ -65,7 +66,7 @@ p.topic-title
6566
.admonition
6667
border-left: 0.2rem solid var(--color-admonition-title)
6768

68-
@each $type, $value in $admonitions
69+
@each $type, $value in variables.$admonitions
6970
&.#{$type}
7071
border-left-color: var(--color-admonition-title--#{$type})
7172
> .admonition-title
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
@import "admonitions"
2-
@import "api"
3-
@import "blocks"
4-
@import "captions"
5-
@import "code"
6-
@import "footnotes"
7-
@import "images"
8-
@import "indexes"
9-
@import "lists"
10-
@import "math"
11-
@import "misc"
12-
@import "rubrics"
13-
@import "sidebar"
14-
@import "tables"
15-
@import "target"
16-
@import "gui-labels"
1+
@forward "admonitions"
2+
@forward "api"
3+
@forward "blocks"
4+
@forward "captions"
5+
@forward "code"
6+
@forward "footnotes"
7+
@forward "images"
8+
@forward "indexes"
9+
@forward "lists"
10+
@forward "math"
11+
@forward "misc"
12+
@forward "rubrics"
13+
@forward "sidebar"
14+
@forward "tables"
15+
@forward "target"
16+
@forward "gui-labels"

src/furo/assets/styles/content/_target.sass

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
@use "../variables"
2+
13
:target
24
scroll-margin-top: 2.5rem
35

4-
@media (max-width: $full-width - $sidebar-width)
6+
@media (max-width: variables.$full-width - variables.$sidebar-width)
57
:target
68
scroll-margin-top: calc(2.5rem + var(--header-height))
79

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@import "readthedocs"
2-
@import "copybutton"
3-
@import "sphinx-design"
4-
@import "sphinx-inline-tabs"
5-
@import "sphinx-panels"
1+
@forward "readthedocs"
2+
@forward "copybutton"
3+
@forward "sphinx-design"
4+
@forward "sphinx-inline-tabs"
5+
@forward "sphinx-panels"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@import "extensions"
1+
@use "extensions"

0 commit comments

Comments
 (0)