Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
c94c7bd
Add sass-true for sass unit testing and add a test script
thisisdano Jan 27, 2021
26c4686
Add a function to output errors as strings for testing, and apply to …
thisisdano Jan 27, 2021
1c74d64
Start to create some sass unit tests
thisisdano Jan 27, 2021
bd2944c
Clarify function by using $custom-color instead of $color
thisisdano Jan 27, 2021
a55b923
Rewrite get-color-token-assignment() to be simpler and provide more r…
thisisdano Jan 27, 2021
2de9e0d
Reorganize luminance ranges be be clearer, and move linearly from low…
thisisdano Jan 27, 2021
9a0f516
Disallow transparent in grade calculations
thisisdano Jan 27, 2021
07ebd7d
[see details]
thisisdano Jan 27, 2021
7e325c2
Update tests to reflect current get-color-grade() output
thisisdano Jan 27, 2021
3090bf3
Add simple functions for checking color tokens and returning errors
thisisdano Jan 27, 2021
a2c5b62
Clarify custom-color-assignment function
thisisdano Jan 27, 2021
a2e46d5
Clarify decompose() function
thisisdano Jan 27, 2021
06a73d7
[see details]
thisisdano Jan 27, 2021
acdfb77
Add a magic-number() function
thisisdano Jan 28, 2021
62f4b58
Use color function in set-text-from-bg()
thisisdano Jan 28, 2021
1cd7d94
Clarify get-token-from-bg() and remove get-color-from-bg() to preserv…
thisisdano Jan 28, 2021
1a95023
Move magic numbners out of funcs and into vars
thisisdano Jan 28, 2021
9955628
Sketch out basic function flow
thisisdano Jan 28, 2021
da35d44
Assure that decompose function processes all color tokens properly
thisisdano Jan 28, 2021
b323868
Complete link color picker and tests
thisisdano Feb 1, 2021
72a95c1
Add context text to banner functions
thisisdano Feb 1, 2021
a4972cc
Add context to get-color-token-from-bg()
thisisdano Feb 1, 2021
211d0b4
Comment and simplify functions
thisisdano Feb 2, 2021
482225f
Add context to components
thisisdano Feb 2, 2021
60b2b87
Add is-accessible-magic-number() tests
thisisdano Feb 2, 2021
2dc3a6a
Add color-variant() tests
thisisdano Feb 2, 2021
420a7e6
Use calculate-grade() instead of color-grade(); build out tests
thisisdano Feb 2, 2021
5879889
Use get-color-token-from-bg() in get-link-tokens-from-bg()
thisisdano Feb 2, 2021
15b16a8
Write get-color-token-from-bg() tests
thisisdano Feb 2, 2021
35b0629
Add transparency tests
thisisdano Feb 2, 2021
426a973
Improve grade function names
thisisdano Feb 2, 2021
4d34915
Rename sass tests to exclude from standard tests
thisisdano Feb 2, 2021
af777de
Improve common error function; make color functions more efficient
thisisdano Feb 2, 2021
37593af
Merge branch 'jm-color-contrast-3906' into dw-color-functions
thisisdano Feb 2, 2021
13e915d
Add more docs to get-link-tokens-from-bg()
thisisdano Feb 2, 2021
a4dc2b0
Remove unnecessary decompose tasks
thisisdano Feb 2, 2021
f10d252
Normalize color token function names
thisisdano Feb 2, 2021
b923d0f
Update color-token-grade() name
thisisdano Feb 2, 2021
dcdd5ef
[see details]
thisisdano Feb 2, 2021
4ee8e66
Use `default` for identifier primary link setting
thisisdano Feb 2, 2021
21f7dfd
Use default link hover if accessible token value == default
thisisdano Feb 2, 2021
b52b0a1
[see details]
thisisdano Feb 2, 2021
593db16
Properly set default values
thisisdano Feb 2, 2021
a514e33
Use defaults for set-link function and mixin
thisisdano Feb 2, 2021
47559aa
Add settings for body bg and text/reverse
thisisdano Feb 3, 2021
2ba5244
Add settings for alert text and link colors
thisisdano Feb 3, 2021
ee70d2c
Use settings and autoformat on body element
thisisdano Feb 3, 2021
b5f1696
Use defaults in get-color function
thisisdano Feb 3, 2021
c19844d
Use consistent treatment for alert links
thisisdano Feb 3, 2021
a799cc5
Use defaults in set-text mixins
thisisdano Feb 3, 2021
a219c38
Allow "default" to be passed as a background color
thisisdano Feb 3, 2021
84db44c
Use default for breadcrumb background
thisisdano Feb 3, 2021
9276e21
Add a function to grab common project defaults
thisisdano Feb 3, 2021
eeaef37
Remove props from functions if duplicate defaults
thisisdano Feb 3, 2021
693a67a
Fix broken test
thisisdano Feb 3, 2021
610958e
Pass a `for` prop to improve error messaging
thisisdano Feb 3, 2021
02a7e2d
Fix alert content
thisisdano Feb 3, 2021
fa9b8b8
Use mixin instead of setting bg and text separately
thisisdano Feb 3, 2021
8c93557
Pick the best color token instead of the preferred, if none match
thisisdano Feb 3, 2021
5fa117b
Respect $theme-show-compile-warnings
thisisdano Feb 3, 2021
3cae33a
Update tests and add more WCAG level testing
thisisdano Feb 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Write get-color-token-from-bg() tests
  • Loading branch information
thisisdano committed Feb 2, 2021
commit 15b16a8cb0723a7c9eb1d9713d94f43d96d0019a
51 changes: 44 additions & 7 deletions spec/unit/sass/tests.scss
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,43 @@ $this-function: "theme-grade()";
}
}

$this-function: "get-color-token-from-bg()";
@include describe("[function] #{$this-function}") {
@include it("Returns the default from light bg.") {
$test: get-color-token-from-bg("white");
$expect: "ink";
@include assert-equal($test, $expect);
}
@include it("Returns the default reverse from dark bg.") {
$test: get-color-token-from-bg("ink");
$expect: "white";
@include assert-equal($test, $expect);
}
@include it(
"Returns custom hex theme color, calculating proper custom grade"
) {
$test: get-color-token-from-bg(
"gray-80",
"gray-40",
"accent-warm-lightest"
);
$expect: "accent-warm-lightest";
@include assert-equal($test, $expect);
}
@include it(
"[LOOK FOR WARNING] Return non-accessible combination with preferred and WARNING."
) {
$test: get-color-token-from-bg(
"white",
"accent-warm-lightest",
"gray-10",
$context: "get-color-token-from-bg(): Failing contrast"
);
$expect: "accent-warm-lightest";
@include assert-equal($test, $expect);
}
}

$this-function: "get-link-tokens-from-bg()";
@include describe("[function] #{$this-function}") {
@include it("Returns the standard defaults from light bg.") {
Expand Down Expand Up @@ -440,7 +477,7 @@ $this-function: "get-link-tokens-from-bg()";
$test: get-link-tokens-from-bg(
"black",
"white",
$context: "Test: No hover possible (white)"
$context: "get-link-tokens-from-bg(): No hover possible (white)"
);
$expect: "white", "white";
@include assert-equal($test, $expect);
Expand All @@ -451,7 +488,7 @@ $this-function: "get-link-tokens-from-bg()";
$test: get-link-tokens-from-bg(
"white",
"black",
$context: "Test: No hover possible (black)"
$context: "get-link-tokens-from-bg(): No hover possible (black)"
);
$expect: "black", "black";
@include assert-equal($test, $expect);
Expand All @@ -463,7 +500,7 @@ $this-function: "get-link-tokens-from-bg()";
"white",
"accent-warm-light",
"gray-10",
$context: "Test: Failing contrast"
$context: "get-link-tokens-from-bg(): Failing contrast"
);
$expect: "accent-warm-light", "accent-warm";
@include assert-equal($test, $expect);
Expand Down Expand Up @@ -506,22 +543,22 @@ $this-function: "is-accessible-magic-number()";

$this-function: "color-variant()";
@include describe("[function] #{$this-function}") {
@include it("Returns `vivid` it's a vivid system token.") {
@include it("Returns `vivid` if it's a vivid system token.") {
$test: color-variant("red-50v");
$expect: "vivid";
@include assert-equal($test, $expect);
}
@include it("Returns `vivid` it's a vivid theme token.") {
@include it("Returns `vivid` if it's a vivid theme token.") {
$test: color-variant("primary-vivid");
$expect: "vivid";
@include assert-equal($test, $expect);
}
@include it("Returns false it's a standard system token.") {
@include it("Returns false if it's a standard system token.") {
$test: color-variant("red-50");
$expect: false;
@include assert-equal($test, $expect);
}
@include it("Returns false it's a standard theme token.") {
@include it("Returns false if it's a standard theme token.") {
$test: color-variant("warning");
$expect: false;
@include assert-equal($test, $expect);
Expand Down