Skip to content

Commit

Permalink
fix: maximize contrast of dark texts on light backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
json-derulo committed Oct 25, 2023
1 parent 6085acc commit b69dff7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions projects/material-css-vars/src/lib/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ $text: (
--light-disabled-text: rgba(var(--light-disabled-text-no-rgb)),
--light-dividers: rgba(var(--light-dividers-no-rgb)),
--light-focused: rgba(var(--light-focused-no-rgb)),
--dark-text-contrast: #000000,
--light-text-contrast: var(--light-primary-text),
) !default;

$default-light-theme: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ interface Color {
})
export class MaterialCssVarsService {
private static CONTRAST_PREFIX = "contrast-";
private static DARK_TEXT_VAR = "--dark-primary-text";
private static LIGHT_TEXT_VAR = "--light-primary-text";
private static DARK_TEXT_VAR = "--dark-text-contrast";
private static LIGHT_TEXT_VAR = "--light-text-contrast";
// This should be readonly from the outside
cfg: MaterialCssVariablesConfig;
primary = "#03a9f4";
Expand Down
4 changes: 2 additions & 2 deletions projects/material-css-vars/src/test/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("integration", () => {
fixture.detectChanges();

expect(getButtonComputedStyle(fixture).color).toEqual(
"rgba(0, 0, 0, 0.87)",
"rgb(0, 0, 0)",
);
});

Expand Down Expand Up @@ -97,7 +97,7 @@ describe("integration", () => {
fixture.detectChanges();

expect(getButtonComputedStyle(fixture).color).toEqual(
"rgba(0, 0, 0, 0.87)",
"rgb(0, 0, 0)",
);
});
});
Expand Down

0 comments on commit b69dff7

Please sign in to comment.