Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Feb 14, 2024
1 parent 549d45d commit c76ef32
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 88 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ First time you start it up you should also run `yarn prep data`

# User study burn down

- [ ] Make deactivation story make sense in new context
- [ ] Get most of the lints converted
- [ ] Tour?
- [ ] roles, palette level semantics
- [ ] Design adjustments for smaller screens
- [ ] Language Docs??
- [x] Get most of the lints converted
- [x] Make lints fast / non blocking as much as possible

# Language todos
Expand Down
6 changes: 3 additions & 3 deletions src/lib/lint-language/lint-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ const getOp =
}
const allParamsFound = x.params.every((key) => key in node);
const noExtraParams = Object.keys(node).every(
(key) => x.params.includes(key) || key === x.primaryKey
(key) => (x.params as string[]).includes(key) || key === x.primaryKey
);
const allowedParamsMessage = x.params.length
? `Allowed params are ${x.params.map((x) => `"${x}"`).join(", ")}`
Expand Down Expand Up @@ -909,11 +909,11 @@ export class LLMap extends LLNode {
// implicitly ignore the pass back i guess?
switch (this.type) {
case "map":
return { result: children.map(evalFunc), env };
return { result: children.map(evalFunc) as RawValues[], env };
case "filter":
return { result: children.filter(evalFunc), env };
case "sort":
const childrenCopy = [...children].map(evalFunc);
const childrenCopy = [...children].map(evalFunc) as RawValues[];
childrenCopy.sort();
return { result: childrenCopy, env };
case "reverse":
Expand Down
76 changes: 0 additions & 76 deletions src/lib/lints/fair.ts
Original file line number Diff line number Diff line change
@@ -1,86 +1,10 @@
// import { Color } from "../Color";
// import { ColorLint } from "./ColorLint";
// import type { TaskType } from "./ColorLint";
// import { extent } from "../utils";
import { JSONToPrettyString } from "../utils";
import type { CustomLint } from "../CustomLint";

// magic numbers supplied by the paper
const cRangeUnfair = 80;
const lRangeUnfair = 50;

// const identifyUnfair = (
// colors: Color[],
// threshold: number,
// channel: number
// ) => {
// const channelRange = extent(colors.map((x) => x.toChannels()[channel]));
// const outOfBoundColors = colors.filter(
// (x) => x.toChannels()[channel] > channelRange[0] + threshold
// );
// return outOfBoundColors;
// };

// const fairMessage = (outOfBandL: Color[], outOfBandC: Color[]) => {
// const lPass = outOfBandL.length === 0;
// const cPass = outOfBandC.length === 0;
// if (lPass && cPass) {
// return "";
// }
// const baseMessage = `This palette is unfair (meaning that some values may unduely stand out).`;
// const lMsg = lPass
// ? ""
// : `The following colors have a luminance value that is out of range: ${outOfBandL
// .map((x) => x.toHex())
// .join(", ")}.`;
// const cMsg = cPass
// ? ""
// : `The following colors have a chroma value that is out of range: ${outOfBandC
// .map((x) => x.toHex())
// .join(", ")}.`;
// return `${baseMessage} ${lMsg} ${cMsg}`;
// };

// class FairBase extends ColorLint<any, number> {
// name = "Fair";
// group = "design";
// // hasParam = true;
// level: "error" | "warning" = "warning";

// description: string = `Do the colors stand out equally? A color palette is described as fair if both chroma and luminance ranges are below a certain threshold and unfair if one of them is above a certain threshold. For sequential and diverging palettes, only the chroma range is considered.`;
// buildMessage(): string {
// const { outOfBandL, outOfBandC } = this.checkData;
// return fairMessage(outOfBandL, outOfBandC);
// }
// }

// class FairSequential extends FairBase {
// taskTypes = ["sequential", "diverging"] as TaskType[];

// _runCheck() {
// const { colors } = this.palette;
// const outOfBandL = identifyUnfair(colors, lRangeUnfair, 0);
// return {
// passCheck: outOfBandL.length === 0,
// data: { outOfBandL, outOfBandC: [] },
// };
// }
// }

// class FairNominal extends FairBase {
// taskTypes = ["categorical"] as TaskType[];

// _runCheck() {
// const { colors } = this.palette;
// const outOfBandL = identifyUnfair(colors, lRangeUnfair, 0);
// const outOfBandC = identifyUnfair(colors, cRangeUnfair, 1);
// return {
// passCheck: !outOfBandL.length && !outOfBandC.length,
// data: { outOfBandL, outOfBandC },
// };
// }
// }

const lRangePredicate = {
"<": {
left: { extent: { sort: "colors", varb: "x", func: { "lch.l": "x" } } },
Expand Down
9 changes: 2 additions & 7 deletions src/lib/lints/size-discrim.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// import { Color } from "../Color";
// import { ColorLint } from "./ColorLint";
// import type { TaskType } from "./ColorLint";

import { JSONToPrettyString } from "../utils";
import type { CustomLint } from "../CustomLint";
// based on
// https://github.com/connorgr/d3-jnd/blob/master/src/jnd.js

Expand Down Expand Up @@ -31,9 +29,6 @@ function jndLabInterval(p: pType, s: sType) {
return nd(pVal, sVal);
}

import { JSONToPrettyString } from "../utils";
import type { CustomLint } from "../CustomLint";

const lints: CustomLint[] = ["Thin", "Medium", "Wide"].map((key) => {
const p = "default";
const s = key as keyof typeof sMap;
Expand Down

0 comments on commit c76ef32

Please sign in to comment.