mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-27 15:40:36 +08:00
Playwright is more flexible and has better developer experience than Cypress.
We add end to end tests covering:
- project source browsing
- tree view
- commit list view
- commit view
- routing
- hash based
- history API based
- clipboard copy paste functionality
- seed view
- project search
- landing page view
- settings
Co-authored-by: Sebastian Martinez <me@sebastinez.dev>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
43 lines
1002 B
TypeScript
43 lines
1002 B
TypeScript
import type { ColorName } from "chalk";
|
|
|
|
import chalk from "chalk";
|
|
|
|
const PADDING_WIDTH = 12;
|
|
|
|
// The order here is important, we want successive prefixes to have
|
|
// high contrast.
|
|
const availableColors: ColorName[] = [
|
|
"blue",
|
|
"yellowBright",
|
|
"greenBright",
|
|
"gray",
|
|
"green",
|
|
"blueBright",
|
|
"redBright",
|
|
"white",
|
|
"yellow",
|
|
"red",
|
|
"magenta",
|
|
"cyan",
|
|
];
|
|
|
|
const assignedColors: Record<string, ColorName> = {};
|
|
|
|
export function make(label: string): string {
|
|
if (assignedColors[label] === undefined) {
|
|
const color = availableColors.pop();
|
|
if (!color) {
|
|
throw new Error("We're out of colors. 🤷");
|
|
}
|
|
|
|
assignedColors[label] = color;
|
|
}
|
|
|
|
// We reset colors at the beginning of each line to avoid styles from previous
|
|
// lines messing up prefix colors. This is noticable in rust stack traces
|
|
// where the `in` and `with` keywords have a white background color.
|
|
return chalk.reset[assignedColors[label]](
|
|
`${label.padEnd(PADDING_WIDTH)} | `,
|
|
);
|
|
}
|