File: _deprecated.scss

package info (click to toggle)
r-cran-bslib 0.9.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,412 kB
  • sloc: javascript: 13,349; makefile: 33; sh: 23
file content (29 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/////////////////////////////////////////////////////////////////
// bslib's version=4 leverages BS5's color-contrast() instead of
// color-yiq(), but it's in case someone happens to use it in their
// own Sass, we define it, and throw deprecation warnings if used
/////////////////////////////////////////////////////////////////

@if variable-exists("yiq-contrasted-threshold") or
    variable-exists("yiq-text-dark") or
    variable-exists("yiq-text-light") {
  @warn "color-yiq() is deprecated, use color-contrast() instead"
}
$yiq-contrasted-threshold: 150 !default;
$yiq-text-dark:  black !default;
$yiq-text-light:  white !default;
@function color-yiq($color, $dark: $yiq-text-dark, $light: $yiq-text-light) {
  @warn "color-yiq() is deprecated. Use color-contrast() instead.";

  $r: red($color);
  $g: green($color);
  $b: blue($color);

  $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;

  @if ($yiq >= $yiq-contrasted-threshold) {
    @return $dark;
  } @else {
    @return $light;
  }
}