Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scss/_defs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT

// sizes
$em: (18 / 16) * 1rem;
$em: calc(18 / 16) * 1rem;
$spacing: 18px;

// fonts
Expand Down
15 changes: 7 additions & 8 deletions scss/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ label {
input[type="submit"],
input[type="reset"],
button {
background: darken($white, 5);
color: darken($gray, 25);
background: safe-adjust-lightness($white, -5);
color: safe-adjust-lightness($gray, -25);
cursor: pointer;
display: inline;
margin-bottom: $em;
Expand All @@ -71,16 +71,15 @@ button {
text-align: center;

&:hover {
background: darken($white, 15);
background: safe-adjust-lightness($white, -15);
color: $black;
}

&[disabled] {
background: darken($white, 10);
color: darken($gray, 10);
background: safe-adjust-lightness($white, -10);
color: safe-adjust-lightness($gray, -10);
cursor: not-allowed;
}

}

input[type="submit"],
Expand All @@ -89,8 +88,8 @@ button[type="submit"] {
color: $white;

&:hover {
background: darken($blue, 15);
color: darken($white, 25);
background: safe-adjust-lightness($blue, -15);
color: safe-adjust-lightness($white, -25);
}
}

Expand Down
14 changes: 14 additions & 0 deletions scss/_functions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: Copyright (c) 2015-2025 Yegor Bugayenko
// SPDX-License-Identifier: MIT

@use "sass:color";

/// Adjusts lightness of a color by a percentage.
/// Positive `$percent` lightens, negative darkens.
///
/// @param {Color} $color - Base color.
/// @param {Number} $percent - Percent to adjust lightness (e.g. 15 or -15).
/// @return {Color} - Modified color.
@function safe-adjust-lightness($color, $percent) {
@return color.adjust($color, $lightness: $percent * 1%);
}
4 changes: 2 additions & 2 deletions scss/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ html {
body {
@extend %sans-serif;
background: $white;
color: lighten($black, 10);
color: safe-adjust-lightness($black, 10);
padding: 2 * $spacing;
}

Expand Down Expand Up @@ -62,7 +62,7 @@ footer {

article {
background: $white;
border: 1px solid lighten($black, 85);
border: 1px solid safe-adjust-lightness($black, 85);
}

nav {
Expand Down
4 changes: 2 additions & 2 deletions scss/_pre.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ output {
}

pre {
border-left: .1 * $em solid lighten($green, 25);
border-left: .1 * $em solid safe-adjust-lightness($green, 25);
line-height: 1.4 * $em;
overflow: auto;
padding-left: $spacing;
Expand All @@ -29,7 +29,7 @@ pre {

code,
kbd {
background: lighten($green, 60);
background: safe-adjust-lightness($green, 60);
border-radius: .2 * $spacing;
color: $green;
display: inline-block;
Expand Down
4 changes: 2 additions & 2 deletions scss/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ th {

thead th {
border-bottom: .12 * $em solid $gray;
border-left: .06 * $em solid lighten($black, 80);
border-left: .06 * $em solid safe-adjust-lightness($black, 80);
padding-bottom: .35 * $em;

&:first-child {
Expand All @@ -27,7 +27,7 @@ thead th {

tbody tr {
&:hover {
background-color: lighten($black, 98);
background-color: safe-adjust-lightness($black, 98);
}
}

Expand Down
1 change: 1 addition & 0 deletions scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT

@import 'defs';
@import 'functions';
@import 'common';
@import 'tables';
@import 'forms';
Expand Down
Loading