Skip to content

Commit

Permalink
Update _contrast.scss
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Jul 14, 2024
1 parent 3a053ae commit 801e94b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/scss/utils/_contrast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// ----------------------------------------------------------------------------
// A function to determine if you need a light or dark text color
// on a specific background for readability.
// ----------------------------------------------------------------------------

@function color_contrast($background-color) {
@if (lightness($background-color) > 50%) {
Expand All @@ -33,6 +34,7 @@


// Contrast Checker
// ----------------------------------------------------------------------------
// A function to calculate the contrast ratio between two colors, which is
// useful for accessibility considerations.
// ----------------------------------------------------------------------------
Expand All @@ -43,9 +45,11 @@
@return contrast-ratio($color1, $color2);
}


// Color Contrast Ratio
// ----------------------------------------------------------------------------
// Calculates the contrast ratio between two colors, useful for accessibility
// checks.
// checks.
// ----------------------------------------------------------------------------

@function hue_contrast_ratio($color_name1, $color_name2) {
Expand All @@ -67,6 +71,7 @@
// ----------------------------------------------------------------------------
// A function to dynamically determine whether to use light or dark text
// based on the background color for better readability.
// ----------------------------------------------------------------------------

@function color_contrast_dynamic($background-color_name) {
$background-color: hue-color($background-color_name);
Expand All @@ -78,8 +83,8 @@
}



// Contrast Text Color
// ----------------------------------------------------------------------------
// Generates a contrasting text color (black or white) based on the background color.
// ----------------------------------------------------------------------------

Expand All @@ -98,10 +103,12 @@
}
}


// Accessibility Mixin
// ----------------------------------------------------------------------------
// A mixin to ensure text color contrasts well with its background for
// accessibility.
// ----------------------------------------------------------------------------

@mixin accessible_text_color($background_color_name) {
$background-color: hue_color($background_color_name);
Expand All @@ -113,6 +120,7 @@
// ----------------------------------------------------------------------------
// Determines a readable color (light or dark) for text overlays on any
// background.
// ----------------------------------------------------------------------------

@function hue_readable_overlay($background_color_name) {
$background_color: hue_color($background_color_name);
Expand Down

0 comments on commit 801e94b

Please sign in to comment.