Allow different link colors per tenant

Just like we did with SCSS variables, we use the --anchor-color CSS
variable and, if it isn't defined, we use the --brand CSS variable
instead.
This commit is contained in:
Javi Martín
2022-10-16 20:40:47 +02:00
parent 36a1b2cdc2
commit af040fcc2b
5 changed files with 43 additions and 16 deletions

View File

@@ -5,9 +5,12 @@
// `.tenant-public` selector. // `.tenant-public` selector.
// //
// You can use CSS variables to customize the colors. Here's an example // You can use CSS variables to customize the colors. Here's an example
// changing the brand and main header colors for just the main tenant. // changing the brand, links and main header colors for just the main
// tenant.
// //
// .tenant-public { // .tenant-public {
// --anchor-color: #372;
// --anchor-color-hover: #137;
// --brand: #153; // --brand: #153;
// --brand-secondary: #173a00; // --brand-secondary: #173a00;
// --main-header: #351; // --main-header: #351;
@@ -15,8 +18,8 @@
// //
// Some colors default to another color, so you don't have to change // Some colors default to another color, so you don't have to change
// both colors if you'd like them to be the same. For instance, the // both colors if you'd like them to be the same. For instance, the
// `--main-header` color will use the `--brand` color if `--main-header` // `--main-header` and `--anchor-color` colors will use the `--brand`
// is not defined. // color if `--main-header` or `--anchor-color` are not defined.
// //
// If, for instance, you're using a light color for the main header when // If, for instance, you're using a light color for the main header when
// the default color is a dark one, you should also change the text // the default color is a dark one, you should also change the text

View File

@@ -95,10 +95,7 @@ p {
} }
a { a {
&:hover, @include link;
&:active {
text-decoration: underline;
}
} }
a, a,
@@ -134,8 +131,15 @@ button,
.button.hollow { .button.hollow {
@include normal-selection; @include normal-selection;
@include anchor-color;
border: 1px solid; border: 1px solid;
color: $anchor-color;
&:hover,
&:focus {
$hover-color: scale-color($anchor-color, $lightness: $button-hollow-hover-lightness);
color: $hover-color;
color: var(--anchor-color-hover, $hover-color);
}
} }
.button.hollow.error { .button.hollow.error {
@@ -769,7 +773,7 @@ body > header,
width: auto; width: auto;
&:hover { &:hover {
color: $anchor-color; @include anchor-color;
} }
&.is-active { &.is-active {
@@ -938,8 +942,8 @@ footer {
.categories a, .categories a,
.geozone a { .geozone a {
@include anchor-color;
background: $highlight; background: $highlight;
color: $anchor-color;
&:hover, &:hover,
&.is-active { &.is-active {

View File

@@ -40,23 +40,35 @@
color: $color; color: $color;
margin-bottom: 0; margin-bottom: 0;
@if $color == $brand { @if $color == $anchor-color {
@include anchor-color;
} @else if $color == $brand {
@include brand-color; @include brand-color;
} }
&:hover, &:hover,
&:focus { &:focus {
color: scale-color($color, $lightness: $button-hollow-hover-lightness); $hover-color: scale-color($color, $lightness: $button-hollow-hover-lightness);
color: $hover-color;
@if $color == $anchor-color {
color: var(--anchor-color-hover, $hover-color);
}
} }
} }
@mixin link { @mixin link {
color: $anchor-color; @include anchor-color;
cursor: pointer; cursor: pointer;
&:hover,
&:active,
&:focus {
@include anchor-color-hover;
}
&:hover, &:hover,
&:active { &:active {
color: $anchor-color-hover;
text-decoration: underline; text-decoration: underline;
} }
} }
@@ -65,7 +77,7 @@
color: inherit; color: inherit;
&:hover { &:hover {
color: $anchor-color; @include anchor-color;
} }
} }

View File

@@ -86,6 +86,14 @@
@include text-color($brand-secondary, brand-secondary); @include text-color($brand-secondary, brand-secondary);
} }
@mixin anchor-color {
@include text-color($anchor-color, [anchor-color, brand]);
}
@mixin anchor-color-hover {
@include text-color($anchor-color-hover, anchor-color-hover);
}
%brand-background { %brand-background {
@include brand-background; @include brand-background;
} }

View File

@@ -1516,7 +1516,7 @@ $font-awesome-icons: (
&:hover, &:hover,
&:focus { &:focus {
color: $anchor-color-hover; @include anchor-color-hover;
text-decoration: none; text-decoration: none;
} }