-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Style each moving platform with a different color
- Loading branch information
1 parent
8230c5a
commit 072bbd1
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { getLineColors } from "../platform-colors" | ||
|
||
describe("getLineColor", () => { | ||
it("returns correct match for DC-8 and ER-2", () => { | ||
const platforms = ["DC-8", "ER-2"] | ||
const result = [ | ||
"match", | ||
["get", "platform_name"], | ||
"DC-8", | ||
"#F1EEF6", | ||
"ER-2", | ||
"#BDC9E1", | ||
"#1a9b8c", | ||
] | ||
expect(getLineColors(platforms)).toEqual(result) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const flightColors = platforms => { | ||
const colors = ["#F1EEF6", "#BDC9E1", "#74A9CF", "#2B8CBE", "#045A8D"] | ||
return platforms.map((i, index) => [i, colors[index]]) | ||
} | ||
|
||
export const getLineColors = platforms => { | ||
const colors = flightColors(platforms) | ||
return [ | ||
"match", | ||
["get", "platform_name"], | ||
...colors.flatMap(i => i), | ||
"#1a9b8c", // this is a fallback color | ||
] | ||
} |