Skip to content

Commit a35529c

Browse files
committed
Manual fixes for stylelint
1 parent ce583b8 commit a35529c

File tree

12 files changed

+133
-143
lines changed

12 files changed

+133
-143
lines changed

src/pydata_sphinx_theme/assets/styles/abstracts/_accessibility.scss

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
// loading the math module
1+
@use "sass:color";
2+
@use "sass:map";
23
@use "sass:math";
34

4-
/**
5-
* Get color combinations that meet a minimum contrast ratio as per WCAG 2
6-
*/
5+
// Get color combinations that meet a minimum contrast ratio as per WCAG 2
6+
77
// @param {color} $bg - Background color of the element
88
// @param {color} optional $target-color-contrast-dark $target-color-contrast-light - Target text colors, defaul to our
99
// $foundation-black and $foundation-white colors
1010
// @return {color} $max-ratio-color - The color that has the highest contrast ratio
11-
//
1211
@function a11y-combination(
1312
$bg,
1413
$target-color-contrast-dark: $foundation-black,
@@ -50,25 +49,25 @@
5049
// Return WCAG2.1 relative luminance
5150
// See https://www.w3.org/TR/WCAG/#dfn-relative-luminance
5251
// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
53-
//
5452
@function luminance($target-color) {
5553
$rgb-col: (
56-
"r": red($target-color),
57-
"g": green($target-color),
58-
"b": blue($target-color),
54+
"r": color.red($target-color),
55+
"g": color.green($target-color),
56+
"b": color.blue($target-color),
5957
);
6058

6159
@each $channel, $value in $rgb-col {
6260
// here we get RsRGB, GsRGB, and BsRGB
63-
@if math.div($value, 255) <=0.03928 {
64-
$rgb-col: map-merge(
61+
// stylelint-disable-next-line number-max-precision
62+
@if math.div($value, 255) <= 0.03928 {
63+
$rgb-col: map.merge(
6564
$rgb-col,
6665
(
6766
$channel: math.div(math.div($value, 255), 12.92),
6867
)
6968
);
7069
} @else {
71-
$rgb-col: map-merge(
70+
$rgb-col: map.merge(
7271
$rgb-col,
7372
(
7473
$channel:
@@ -78,8 +77,9 @@
7877
}
7978
}
8079

81-
@return (
82-
0.2126 * map-get($rgb-col, "r") + 0.7152 * map-get($rgb-col, "g") + 0.0722 *
83-
map-get($rgb-col, "b")
84-
);
80+
$r: map.get($rgb-col, "r");
81+
$g: map.get($rgb-col, "g");
82+
$b: map.get($rgb-col, "b");
83+
84+
@return (0.2126 * $r + 0.7152 * $g + 0.0722 * $b);
8585
}

src/pydata_sphinx_theme/assets/styles/abstracts/_color.scss

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
* Miscellaneous color functions and mixins
33
**/
44

5-
// loading the math module
5+
@use "sass:list";
6+
@use "sass:map";
7+
@use "sass:meta";
68
@use "sass:math";
9+
@use "sass:string";
710

811
// We must add ::before pseudo-element to some theme components (such as admonitions)
912
// because users were instructed to customize the background color this way.
@@ -32,7 +35,7 @@
3235
// @return {*}
3336
@function map-deep-get($map, $keys...) {
3437
@each $key in $keys {
35-
$map: map-get($map, $key);
38+
$map: map.get($map, $key);
3639
}
3740

3841
@return $map;
@@ -46,7 +49,7 @@
4649
// @param {String/Color} $color - Color definition from map
4750
// @return {Color} - Color type (in hex)
4851
@function check-color($color) {
49-
@if type-of($color) == string {
52+
@if meta.type-of($color) == string {
5053
$color: from-hex($color);
5154
}
5255

@@ -58,12 +61,12 @@
5861
*/
5962
// @param {String} $string - String representation of a color
6063
@function from-hex($string) {
61-
$string-lower: to-lower-case($string);
64+
$string-lower: string.to-lower-case($string);
6265
$r: "";
6366
$g: "";
6467
$b: "";
6568
$hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f";
66-
$length: str-length($string);
69+
$length: string.length($string);
6770
$max: if($length == 4, 1, 2);
6871

6972
// Check for length accuracy
@@ -73,18 +76,18 @@
7376

7477
// Loop from the second character (omitting #)
7578
@for $i from 2 through $length {
76-
$c: str-slice($string-lower, $i, $i);
79+
$c: string.slice($string-lower, $i, $i);
7780

7881
// If wrong character, return
79-
@if index($hex, $c) == null {
82+
@if not list.index($hex, $c) {
8083
@return $string;
8184
}
8285

83-
@if str-length($r) < $max {
86+
@if string.length($r) < $max {
8487
$r: $r + $c;
85-
} @else if str-length($g) < $max {
88+
} @else if string.length($g) < $max {
8689
$g: $g + $c;
87-
} @else if str-length($b) < $max {
90+
} @else if string.length($b) < $max {
8891
$b: $b + $c;
8992
}
9093
}
@@ -95,18 +98,18 @@
9598
$b: $b + $b;
9699
}
97100

98-
@return rgb(_hex-to-dec($r), _hex-to-dec($g), _hex-to-dec($b));
101+
@return rgb(hex-to-dec($r), hex-to-dec($g), hex-to-dec($b));
99102
}
100103

101-
@function _hex-to-dec($string) {
104+
@function hex-to-dec($string) {
102105
$hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f";
103-
$string: to-lower-case($string);
104-
$length: str-length($string);
106+
$string: string.to-lower-case($string);
107+
$length: string.length($string);
105108
$dec: 0;
106109

107110
@for $i from 1 through $length {
108111
$factor: 1 + (15 * ($length - $i));
109-
$index: index($hex, str-slice($string, $i, $i));
112+
$index: list.index($hex, string.slice($string, $i, $i));
110113
$dec: $dec + $factor * ($index - 1);
111114
}
112115

src/pydata_sphinx_theme/assets/styles/abstracts/_links.scss

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
/**
2-
* Consistent styling for links
3-
**/
1+
// Consistent styling for links
2+
// ============================
3+
4+
@use "sass:string";
45

56
// Define some useful variables for links styling consistency
6-
//
7-
// Thickness of the underline for links
8-
// the default will be either:
7+
8+
// The default thickness of the underline for links will be either:
99
// - 1px
10-
// - 0.0625rem if it's thicker than 1px because the user has changed the text
11-
// size in their browser
12-
$link-underline-thickness: unquote("max(1px, .0625rem)") !default;
10+
// - 0.0625rem if it's thicker than 1px because the user has changed the text
11+
// size in their browser
12+
$link-underline-thickness: string.unquote("max(1px, .0625rem)") !default;
1313

1414
// Offset of link underlines from text baseline
1515
// The default is 3px expressed as ems, as calculated against the default body
@@ -22,9 +22,11 @@ $link-underline-offset: 0.1578em !default;
2222
// - 0.1875rem, if it's thicker than 3px because the user has changed the text
2323
// size in their browser
2424
// - 0.12em (relative to the link's text size)
25-
$link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
25+
$link-hover-decoration-thickness: string.unquote(
26+
"max(3px, .1875rem, .12em)"
27+
) !default;
2628

27-
// Ensures links have an underline decoration by default - needed to meet
29+
// Ensures links have an underline decoration by default - needed to meet
2830
// WCAG SC 1.4.1
2931
@mixin link-decoration {
3032
text-decoration: underline;
@@ -60,7 +62,7 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
6062
}
6163

6264
// Default link styles
63-
//
65+
// -------------------
6466
// Defines: default unvisited, visited, hover, and active.
6567
// TODO: @trallard to improve focus styles in subsequent PR
6668
@mixin link-style-default {
@@ -92,7 +94,7 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
9294
}
9395

9496
// Text link styles
95-
//
97+
// ----------------
9698
// Makes links use the muted text colour and removes the underline.
9799
// Use this mixin for navigation bar links.
98100
@mixin link-style-text {
@@ -108,7 +110,7 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
108110
}
109111

110112
// Sidebar and TOC links
111-
//
113+
// ---------------------
112114
// Makes links use the muted text colour and removes the underline.
113115
// Use this mixin for navigation the primary sidebar and table of contents.
114116
// Active and hover should work together rather than one overriding the other.
@@ -137,7 +139,7 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
137139
}
138140

139141
// Sidebar current page link styles
140-
//
142+
// --------------------------------
141143
// Adds a vertical line on the left hand side of the link to indicate that
142144
// it's the current page. Note this is distinct from an active state.
143145
// Used on the primary sidebar and the TOC.
@@ -163,7 +165,7 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
163165
}
164166

165167
// Navigation bar current page link styles
166-
//
168+
// ---------------------------------------
167169
// Adds a bottom underline, this leaves enough space for the hover state without
168170
// cluttering the navbar.
169171
// We want the side box shadow to have the same thickness as the hover underline
@@ -179,7 +181,7 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
179181
}
180182

181183
// Navigation bar icon links hover styles
182-
//
184+
// --------------------------------------
183185
// Adds a bottom box-shadow - since there is no text we cannot use text-decoration
184186
// We want the side box shadow to have the same thickness as the hover underline
185187
@mixin icon-navbar-hover {
@@ -195,15 +197,13 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
195197
}
196198
}
197199

198-
/*
199-
Mixin for links in the header (and the More dropdown toggle).
200+
// Mixin for links in the header (and the More dropdown toggle).
200201

201-
The mixin assumes it will be applied to some element X with a markup structure
202-
like: X > .nav-link, or X > .dropdown-toggle.
202+
// The mixin assumes it will be applied to some element X with a markup structure
203+
// like: X > .nav-link, or X > .dropdown-toggle.
203204

204-
It also assumes X.current is how the app annotates which item in the header nav
205-
corresponds to the section in the docs that the user is currently reading.
206-
*/
205+
// It also assumes X.current is how the app annotates which item in the header nav
206+
// corresponds to the section in the docs that the user is currently reading.
207207
@mixin header-link {
208208
// Target the child and not the parent because we want the underline in the
209209
// mobile sidebar to only span the width of the text not the entire row/line.

src/pydata_sphinx_theme/assets/styles/base/_base.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,51 +71,51 @@ a {
7171
}
7272
}
7373

74-
.heading-style {
74+
%heading-style {
7575
margin: 2.75rem 0 1.05rem;
7676
font-family: var(--pst-font-family-heading);
7777
font-weight: var(--pst-font-weight-heading);
7878
line-height: 1.15;
7979
}
8080

8181
h1 {
82-
@extend .heading-style;
82+
@extend %heading-style;
8383

8484
margin-top: 0;
8585
font-size: var(--pst-font-size-h1);
8686
color: var(--pst-heading-color);
8787
}
8888

8989
h2 {
90-
@extend .heading-style;
90+
@extend %heading-style;
9191

9292
font-size: var(--pst-font-size-h2);
9393
color: var(--pst-heading-color);
9494
}
9595

9696
h3 {
97-
@extend .heading-style;
97+
@extend %heading-style;
9898

9999
font-size: var(--pst-font-size-h3);
100100
color: var(--pst-heading-color);
101101
}
102102

103103
h4 {
104-
@extend .heading-style;
104+
@extend %heading-style;
105105

106106
font-size: var(--pst-font-size-h4);
107107
color: var(--pst-heading-color);
108108
}
109109

110110
h5 {
111-
@extend .heading-style;
111+
@extend %heading-style;
112112

113113
font-size: var(--pst-font-size-h5);
114114
color: var(--pst-color-text-base);
115115
}
116116

117117
h6 {
118-
@extend .heading-style;
118+
@extend %heading-style;
119119

120120
font-size: var(--pst-font-size-h6);
121121
color: var(--pst-color-text-base);
@@ -207,7 +207,7 @@ pre {
207207
}
208208

209209
// Focus ring
210-
//
210+
// ----------
211211
// Note: The Bootstrap stylesheet provides the focus ring (customized by this
212212
// theme via Sass variables in _bootstrap.scss) in some cases. This rule covers
213213
// all other cases.

src/pydata_sphinx_theme/assets/styles/content/_api.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ dl > dt > a:has(.viewcode-link) {
134134
// the API selector
135135
// from https://github.com/pradyunsg/furo/blob/main/src/furo/assets/styles/content/_api.sass#L6)
136136
dl[class]:not(.option-list, .field-list, .footnote, .glossary, .simple) {
137-
//increase margin bottom after the dl elements
137+
// increase margin bottom after the dl elements
138138
margin-bottom: 3rem;
139139

140140
dd {

src/pydata_sphinx_theme/assets/styles/content/_quotes.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ blockquote {
2929
color: var(--pst-color-inline-code-links);
3030
}
3131

32-
//hack to make the text in the blockquote selectable
32+
// hack to make the text in the blockquote selectable
3333
&::before {
3434
z-index: -1;
3535
}

src/pydata_sphinx_theme/assets/styles/content/_tables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ td {
4747
.table {
4848
@include table-colors;
4949

50-
--bs-table-bg: transparent; //background
50+
--bs-table-bg: transparent; // background
5151
--bs-table-color: var(
5252
--pst-color-text-base
5353
); // ensure text and bullets are visible

src/pydata_sphinx_theme/assets/styles/extensions/_ablog.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737

3838
// The ablog cloud should move horizontally
3939
&.ablog-cloud {
40-
flex-direction: row;
41-
flex-flow: wrap;
40+
flex-flow: row wrap;
4241
gap: 0.5rem;
4342

4443
// Vertical-align tag clouds

0 commit comments

Comments
 (0)