Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Mar 1, 2024
1 parent ac84155 commit dde5a84
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions public/lang-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,16 @@ Description: Categorical values should have an even distribution around the hue

Natural Language: (std(speed(sort(colors, x => lch.h(x)), => )) < 10 or std(speed(sort(colors, x => lch.h(x) + 180 % 360), => )) < 10)

Palettes that will fail this test:

- #ffb9ba, #67de25, #25d4c3, #724dd6, #6d0e44 with a #fff background



Palettes that will pass this test:

- #ffc5b8, #00dec1, #006095, #b7d119, #6e0074 with a #fff background


Program:

Expand Down
5 changes: 5 additions & 0 deletions src/lib/ColorLint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import BackgroundContrast from "./lints/background-contrast";
import CatOrderSimilarity from "./lints/cat-order-similarity";
import ColorBlindness from "./lints/color-blindness";
import ColorNameDiscriminability, { getName } from "./lints/name-discrim";
import EvenDistribution from "./lints/even-distribution";
import Fair from "./lints/fair";
import Gamut from "./lints/in-gamut";
import MaxColors from "./lints/max-colors";
Expand Down Expand Up @@ -59,6 +60,10 @@ test("ColorLint - UglyColors", () => {
autoTest(UglyColors);
});

test("ColorLint - EvenDistribution", () => {
autoTest(EvenDistribution);
});

test("ColorLint - Fair Nominal", () => {
autoTest(Fair[0]);
});
Expand Down
4 changes: 4 additions & 0 deletions src/lib/__snapshots__/ColorLint.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ exports[`ColorLint - ColorNameDiscriminability 1`] = `"The following pairs of co

exports[`ColorLint - ColorNameDiscriminability 2`] = `"The following pairs of colors have the same name: #5260d1 and #005ebe"`;

exports[`ColorLint - EvenDistribution 1`] = `"This palette does not evenly distribute the colors around its range correctly. Try making the spacing between the colors more regular to resolve this issue. "`;

exports[`ColorLint - EvenDistribution 2`] = `"This palette does not evenly distribute the colors around its range correctly. Try making the spacing between the colors more regular to resolve this issue. "`;

exports[`ColorLint - Fair Nominal 1`] = `"This palette is unfair (meaning that some values may unduely stand out). Note that this check is naturally at odds with color blind friendly palettes. Maximum chroma range: 80, maximum luminance range: 50."`;

exports[`ColorLint - Fair Nominal 2`] = `"This palette is unfair (meaning that some values may unduely stand out). Note that this check is naturally at odds with color blind friendly palettes. Maximum chroma range: 80, maximum luminance range: 50."`;
Expand Down
10 changes: 10 additions & 0 deletions src/lib/__snapshots__/LintDocs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,16 @@ Description: Categorical values should have an even distribution around the hue
Natural Language: (std(speed(sort(colors, x => lch.h(x)), => )) < 10 or std(speed(sort(colors, x => lch.h(x) + 180 % 360), => )) < 10)
Palettes that will fail this test:
- #ffb9ba, #67de25, #25d4c3, #724dd6, #6d0e44 with a #fff background
Palettes that will pass this test:
- #ffc5b8, #00dec1, #006095, #b7d119, #6e0074 with a #fff background
Program:
Expand Down
2 changes: 2 additions & 0 deletions src/lib/lints/affects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ theseAffects.forEach((affect) => {
failMessage: `This palette has colors which are highly saturated and light, which may not be appropriate for a ${affect} palette.`,
id: `saturated-${affect}-built-in`,
blameMode: "single",
expectedPassingTests: [],
expectedFailingTests: [],
};
lints.push(lint);
});
Expand Down
6 changes: 6 additions & 0 deletions src/lib/lints/even-distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@ const lint: CustomLint = {
failMessage: `This palette does not evenly distribute the colors around its range correctly. Try making the spacing between the colors more regular to resolve this issue. `,
id: "even-colors-built-in",
blameMode: "none",
expectedPassingTests: [
makePalFromString(["#ffc5b8", "#00dec1", "#006095", "#b7d119", "#6e0074"]),
],
expectedFailingTests: [
makePalFromString(["#ffb9ba", "#67de25", "#25d4c3", "#724dd6", "#6d0e44"]),
],
};
export default lint;

0 comments on commit dde5a84

Please sign in to comment.