bulma/sass/helpers/color.scss

345 lines
8.4 KiB
SCSS
Raw Normal View History

2024-03-21 16:11:54 +00:00
@use "../utilities/css-variables" as cv;
@use "../utilities/derived-variables" as dv;
@use "../utilities/initial-variables" as iv;
$digits: (
"00",
"05",
"10",
"15",
"20",
"25",
"30",
"35",
"40",
"45",
"50",
"55",
"60",
"65",
"70",
"75",
"80",
"85",
"90",
"95",
"100"
);
.#{iv.$helpers-has-prefix}background {
background-color: cv.getVar("background");
}
@each $name, $color in dv.$colors {
$background: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
2024-07-06 14:42:36 +00:00
#{cv.getVar($name, "", "-l")}
2024-03-21 16:11:54 +00:00
);
$color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
2024-07-06 14:42:36 +00:00
#{cv.getVar($name, "", "-l")}
2024-03-21 16:11:54 +00:00
);
2024-07-06 14:42:36 +00:00
.#{iv.$helpers-has-prefix}text-#{$name} {
2024-03-21 16:11:54 +00:00
color: $color !important;
}
2024-07-06 14:42:36 +00:00
.#{iv.$helpers-has-prefix}background-#{$name} {
2024-03-21 16:11:54 +00:00
background-color: $background !important;
}
// Invert
.#{iv.$helpers-has-prefix}text-#{$name}-invert {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-invert {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
// On Scheme
.#{iv.$helpers-has-prefix}text-#{$name}-on-scheme {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-on-scheme-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-on-scheme {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-on-scheme-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
// Light
.#{iv.$helpers-has-prefix}text-#{$name}-light {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-light-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-light {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-light-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}text-#{$name}-light-invert {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-light-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-light-invert {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-light-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
// Dark
.#{iv.$helpers-has-prefix}text-#{$name}-dark {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-dark-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-dark {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-dark-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}text-#{$name}-dark-invert {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-dark-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-dark-invert {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-dark-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
// Soft/Bold
.#{iv.$helpers-has-prefix}text-#{$name}-soft {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("soft-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-soft {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("soft-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}text-#{$name}-bold {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("bold-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-bold {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("bold-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}text-#{$name}-soft-invert {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("soft-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-soft-invert {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("soft-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}text-#{$name}-bold-invert {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("bold-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-bold-invert {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar("bold-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
@each $digit in $digits {
.#{iv.$helpers-has-prefix}text-#{$name}-#{$digit} {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-#{$digit}-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-#{$digit} {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-#{$digit}-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}text-#{$name}-#{$digit}-invert {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-#{$digit}-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
.#{iv.$helpers-has-prefix}background-#{$name}-#{$digit}-invert {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
#{cv.getVar($name, "", "-#{$digit}-invert-l")}
) !important;
2024-03-21 16:11:54 +00:00
}
}
// Hover
a.#{iv.$helpers-has-prefix}text-#{$name},
button.#{iv.$helpers-has-prefix}text-#{$name},
#{iv.$helpers-has-prefix}text-#{$name}.is-hoverable {
&:hover,
&:focus-visible {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
calc(
#{cv.getVar($name, "", "-l")} + #{cv.getVar("hover-color-l-delta")}
2024-03-21 16:11:54 +00:00
)
2024-07-06 14:42:36 +00:00
) !important;
2024-03-21 16:11:54 +00:00
}
&:active {
2024-07-06 14:42:36 +00:00
color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
calc(
#{cv.getVar($name, "", "-l")} + #{cv.getVar("active-color-l-delta")}
2024-03-21 16:11:54 +00:00
)
2024-07-06 14:42:36 +00:00
) !important;
2024-03-21 16:11:54 +00:00
}
}
a.#{iv.$helpers-has-prefix}background-#{$name},
button.#{iv.$helpers-has-prefix}background-#{$name},
#{iv.$helpers-has-prefix}background-#{$name}.is-hoverable {
&:hover,
&:focus-visible {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
calc(
#{cv.getVar($name, "", "-l")} +
#{cv.getVar("hover-background-l-delta")}
2024-03-21 16:11:54 +00:00
)
2024-07-06 14:42:36 +00:00
) !important;
2024-03-21 16:11:54 +00:00
}
&:active {
2024-07-06 14:42:36 +00:00
background-color: hsl(
#{cv.getVar($name, "", "-h")},
#{cv.getVar($name, "", "-s")},
calc(
#{cv.getVar($name, "", "-l")} +
#{cv.getVar("active-background-l-delta")}
2024-03-21 16:11:54 +00:00
)
2024-07-06 14:42:36 +00:00
) !important;
2024-03-21 16:11:54 +00:00
}
}
// Palettes
.#{iv.$helpers-prefix}palette-#{$name} {
--h: #{cv.getVar($name, "", "-h")};
--s: #{cv.getVar($name, "", "-s")};
--l: #{cv.getVar($name, "", "-l")};
--color: hsl(var(--h), var(--s), var(--l));
@each $digit in $digits {
--#{$digit}-l: #{cv.getVar($name, "", "-#{$digit}-l")};
--color-#{$digit}: hsl(var(--h), var(--s), var(--#{$digit}-l));
}
}
}
@each $name, $shade in dv.$shades {
.#{iv.$helpers-has-prefix}text-#{$name} {
color: $shade !important;
}
.#{iv.$helpers-has-prefix}background-#{$name} {
background-color: $shade !important;
}
}
.#{iv.$helpers-has-prefix}text-current {
color: currentColor !important;
}
.#{iv.$helpers-has-prefix}text-inherit {
color: inherit !important;
}
.#{iv.$helpers-has-prefix}background-current {
background-color: currentColor !important;
}
.#{iv.$helpers-has-prefix}background-inherit {
background-color: inherit !important;
}