Skip to content

Commit

Permalink
Rename purple to pink (#263)
Browse files Browse the repository at this point in the history
* Rename purple to pink

* Cleanup
  • Loading branch information
pokey authored Sep 6, 2021
1 parent 8488e91 commit 2ad4abe
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@
"highContrast": "#f0b800"
}
},
"cursorless.colors.purple": {
"description": "Color to use for purple symbols",
"cursorless.colors.pink": {
"description": "Color to use for pink symbols",
"type": "object",
"default": {
"dark": "#de25ff",
Expand Down Expand Up @@ -199,7 +199,7 @@
"yellow": {
"type": "boolean"
},
"purple": {
"pink": {
"type": "boolean"
}
},
Expand All @@ -208,7 +208,7 @@
"green": true,
"red": true,
"yellow": true,
"purple": true
"pink": true
},
"additionalProperties": false
},
Expand Down Expand Up @@ -265,7 +265,7 @@
"yellow": {
"type": "number"
},
"purple": {
"pink": {
"type": "number"
}
},
Expand All @@ -274,7 +274,7 @@
"green": 1,
"red": 1,
"yellow": 1,
"purple": 1
"pink": 1
},
"additionalProperties": false
},
Expand Down
50 changes: 39 additions & 11 deletions src/canonicalizeTargets.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
import { PartialTarget, ScopeType } from "./typings/Types";
import {
PartialPrimitiveTarget,
PartialTarget,
ScopeType,
} from "./typings/Types";
import update from "immutability-helper";
import { transformPrimitiveTargets } from "./util/targetUtils";
import { HatStyleName } from "./core/constants";
import { flow } from "lodash";

const scopeTypeAliasToCanonicalName: Record<string, ScopeType> = {
const SCOPE_TYPE_CANONICALIZATION_MAPPING: Record<string, ScopeType> = {
arrowFunction: "anonymousFunction",
dictionary: "map",
regex: "regularExpression",
};

const COLOR_CANONICALIZATION_MAPPING: Record<string, HatStyleName> = {
purple: "pink",
};

const canonicalizeScopeTypes = (
target: PartialPrimitiveTarget
): PartialPrimitiveTarget =>
target.modifier?.type === "containingScope"
? update(target, {
modifier: {
scopeType: (scopeType: string) =>
SCOPE_TYPE_CANONICALIZATION_MAPPING[scopeType] ?? scopeType,
},
})
: target;

const canonicalizeColors = (
target: PartialPrimitiveTarget
): PartialPrimitiveTarget =>
target.mark?.type === "decoratedSymbol"
? update(target, {
mark: {
symbolColor: (symbolColor: string) =>
COLOR_CANONICALIZATION_MAPPING[symbolColor] ?? symbolColor,
},
})
: target;

export default function canonicalizeTargets(partialTargets: PartialTarget[]) {
return transformPrimitiveTargets(partialTargets, (target) =>
target.modifier?.type === "containingScope"
? update(target, {
modifier: {
scopeType: (scopeType) =>
scopeTypeAliasToCanonicalName[scopeType] ?? scopeType,
},
})
: target
return transformPrimitiveTargets(
partialTargets,
flow(canonicalizeScopeTypes, canonicalizeColors)
);
}
2 changes: 1 addition & 1 deletion src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const HAT_COLORS = [
"blue",
"green",
"red",
"pink",
"yellow",
"purple",
] as const;

export const HAT_NON_DEFAULT_SHAPES = [
Expand Down

0 comments on commit 2ad4abe

Please sign in to comment.