@whatsaaaa/design-system 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +51 -0
- package/README.md +150 -2
- package/assets/building-blocks/apple-touch-icon.png +0 -0
- package/assets/building-blocks/favicon-16.png +0 -0
- package/assets/building-blocks/favicon-32.png +0 -0
- package/assets/building-blocks/favicon.ico +0 -0
- package/assets/building-blocks/favicon.svg +1 -0
- package/assets/building-blocks/icon-192.png +0 -0
- package/assets/building-blocks/icon-512.png +0 -0
- package/assets/building-blocks/lockup-dark.svg +1 -0
- package/assets/building-blocks/lockup-light.svg +1 -0
- package/assets/building-blocks/mark-mono.svg +1 -0
- package/assets/building-blocks/mark-on-dark.svg +1 -0
- package/assets/building-blocks/mark-on-light.svg +1 -0
- package/assets/building-blocks/mark.svg +1 -0
- package/assets/building-blocks/readme-header.png +0 -0
- package/assets/building-blocks/readme-header.svg +1 -0
- package/assets/building-blocks/social-card.png +0 -0
- package/assets/building-blocks/social-card.svg +1 -0
- package/assets/building-blocks/wordmark-dark.svg +1 -0
- package/assets/building-blocks/wordmark-light.svg +1 -0
- package/assets/dotfiles/apple-touch-icon.png +0 -0
- package/assets/dotfiles/favicon-16.png +0 -0
- package/assets/dotfiles/favicon-32.png +0 -0
- package/assets/dotfiles/favicon.ico +0 -0
- package/assets/dotfiles/favicon.svg +1 -0
- package/assets/dotfiles/icon-192.png +0 -0
- package/assets/dotfiles/icon-512.png +0 -0
- package/assets/dotfiles/lockup-dark.svg +1 -0
- package/assets/dotfiles/lockup-light.svg +1 -0
- package/assets/dotfiles/mark-mono.svg +1 -0
- package/assets/dotfiles/mark-on-dark.svg +1 -0
- package/assets/dotfiles/mark-on-light.svg +1 -0
- package/assets/dotfiles/mark.svg +1 -0
- package/assets/dotfiles/readme-header.png +0 -0
- package/assets/dotfiles/readme-header.svg +1 -0
- package/assets/dotfiles/social-card.png +0 -0
- package/assets/dotfiles/social-card.svg +1 -0
- package/assets/dotfiles/wordmark-dark.svg +1 -0
- package/assets/dotfiles/wordmark-light.svg +1 -0
- package/assets/form-builder/apple-touch-icon.png +0 -0
- package/assets/form-builder/favicon-16.png +0 -0
- package/assets/form-builder/favicon-32.png +0 -0
- package/assets/form-builder/favicon.ico +0 -0
- package/assets/form-builder/favicon.svg +1 -0
- package/assets/form-builder/icon-192.png +0 -0
- package/assets/form-builder/icon-512.png +0 -0
- package/assets/form-builder/lockup-dark.svg +1 -0
- package/assets/form-builder/lockup-light.svg +1 -0
- package/assets/form-builder/mark-mono.svg +1 -0
- package/assets/form-builder/mark-on-dark.svg +1 -0
- package/assets/form-builder/mark-on-light.svg +1 -0
- package/assets/form-builder/mark.svg +1 -0
- package/assets/form-builder/readme-header.png +0 -0
- package/assets/form-builder/readme-header.svg +1 -0
- package/assets/form-builder/social-card.png +0 -0
- package/assets/form-builder/social-card.svg +1 -0
- package/assets/form-builder/wordmark-dark.svg +1 -0
- package/assets/form-builder/wordmark-light.svg +1 -0
- package/assets/manifest.json +541 -0
- package/assets/whatsaaaa/apple-touch-icon.png +0 -0
- package/assets/whatsaaaa/favicon-16.png +0 -0
- package/assets/whatsaaaa/favicon-32.png +0 -0
- package/assets/whatsaaaa/favicon.ico +0 -0
- package/assets/whatsaaaa/favicon.svg +1 -0
- package/assets/whatsaaaa/icon-192.png +0 -0
- package/assets/whatsaaaa/icon-512.png +0 -0
- package/assets/whatsaaaa/lockup-dark.svg +1 -0
- package/assets/whatsaaaa/lockup-light.svg +1 -0
- package/assets/whatsaaaa/mark-mono.svg +1 -0
- package/assets/whatsaaaa/mark-on-dark.svg +1 -0
- package/assets/whatsaaaa/mark-on-light.svg +1 -0
- package/assets/whatsaaaa/mark.svg +1 -0
- package/assets/whatsaaaa/pose-blink-dark.svg +1 -0
- package/assets/whatsaaaa/pose-blink-light.svg +1 -0
- package/assets/whatsaaaa/pose-idle-dark.svg +1 -0
- package/assets/whatsaaaa/pose-idle-light.svg +1 -0
- package/assets/whatsaaaa/pose-lost-dark.svg +1 -0
- package/assets/whatsaaaa/pose-lost-light.svg +1 -0
- package/assets/whatsaaaa/pose-shout-dark.svg +1 -0
- package/assets/whatsaaaa/pose-shout-light.svg +1 -0
- package/assets/whatsaaaa/pose-wag-left-dark.svg +1 -0
- package/assets/whatsaaaa/pose-wag-left-light.svg +1 -0
- package/assets/whatsaaaa/pose-wag-right-dark.svg +1 -0
- package/assets/whatsaaaa/pose-wag-right-light.svg +1 -0
- package/assets/whatsaaaa/readme-header.png +0 -0
- package/assets/whatsaaaa/readme-header.svg +1 -0
- package/assets/whatsaaaa/social-card.png +0 -0
- package/assets/whatsaaaa/social-card.svg +1 -0
- package/assets/whatsaaaa/wordmark-dark.svg +1 -0
- package/assets/whatsaaaa/wordmark-light.svg +1 -0
- package/dist/color.d.ts +5 -0
- package/dist/color.js +7 -0
- package/dist/css/base.css +50 -0
- package/dist/css/callout.css +64 -0
- package/dist/css/code.css +50 -0
- package/dist/css/ghost.css +93 -0
- package/dist/css/icons.css +8 -0
- package/dist/css/prose.css +320 -0
- package/dist/css/terminal.css +424 -0
- package/dist/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-italic.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/inter.OFL.txt +93 -0
- package/dist/fonts/jetbrains-mono-latin-ext-wght-italic.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-latin-wght-italic.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/jetbrains-mono.OFL.txt +93 -0
- package/dist/fonts.css +85 -0
- package/dist/ghost/bubble.d.ts +16 -0
- package/dist/ghost/bubble.js +50 -0
- package/dist/ghost/glyphs.d.ts +12 -0
- package/dist/ghost/glyphs.js +19 -0
- package/dist/ghost/index.d.ts +57 -0
- package/dist/ghost/index.js +227 -0
- package/dist/identity/ghost.d.ts +28 -0
- package/dist/identity/ghost.js +129 -0
- package/dist/identity/marks.d.ts +48 -0
- package/dist/identity/marks.js +52 -0
- package/dist/identity/sprite.d.ts +43 -0
- package/dist/identity/sprite.js +100 -0
- package/dist/index.css +1404 -0
- package/dist/shiki/index.d.ts +20 -0
- package/dist/shiki/index.js +64 -0
- package/dist/shortcuts/index.d.ts +62 -0
- package/dist/shortcuts/index.js +169 -0
- package/dist/shortcuts/init.js +2 -0
- package/dist/theme/index.d.ts +24 -0
- package/dist/theme/index.js +60 -0
- package/dist/theme/init.js +2 -0
- package/dist/tokens.css +537 -0
- package/dist/tokens.d.ts +194 -0
- package/dist/tokens.js +336 -0
- package/dist/vitepress-config/index.d.ts +16 -0
- package/dist/vitepress-config/index.js +36 -0
- package/dist/vitepress-config/markdown.d.ts +6 -0
- package/dist/vitepress-config/markdown.js +50 -0
- package/dist/vitepress-config/types.d.ts +16 -0
- package/dist/vitepress-config/types.js +1 -0
- package/docs/usage.md +226 -0
- package/licenses/README.md +10 -0
- package/licenses/departure-mono.OFL.txt +93 -0
- package/licenses/rose-pine-palette.LICENSE +21 -0
- package/package.json +162 -3
- package/src/vitepress/Layout.vue +77 -0
- package/src/vitepress/components/Crumb.vue +32 -0
- package/src/vitepress/components/NavGhost.vue +23 -0
- package/src/vitepress/components/NotFound.vue +22 -0
- package/src/vitepress/components/StatusLine.vue +128 -0
- package/src/vitepress/env.d.ts +2 -0
- package/src/vitepress/index.ts +34 -0
- package/src/vitepress/path.ts +19 -0
- package/src/vitepress/styles/doc.css +385 -0
- package/src/vitepress/styles/home.css +47 -0
- package/src/vitepress/styles/layout.css +97 -0
- package/src/vitepress/styles/nav.css +441 -0
- package/src/vitepress/styles/search.css +55 -0
- package/src/vitepress/styles/sidebar.css +173 -0
- package/src/vitepress/styles/vars.css +204 -0
- package/src/vitepress/support.ts +15 -0
- package/src/vitepress/theme.d.ts +8 -0
- package/tokens/contrast.json +271 -0
- package/tokens/core.tokens.json +743 -0
- package/tokens/palette.tokens.json +222 -0
- package/tokens/theme-dark.tokens.json +146 -0
- package/tokens/theme-light.tokens.json +146 -0
- package/tokens/whatsaaaa.resolver.json +43 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Sprite } from './sprite.ts';
|
|
2
|
+
/** Marks are drawn in a 64 x 64 box: four units per sprite pixel. */
|
|
3
|
+
export declare const MARK_BOX = 64;
|
|
4
|
+
/** Corner radius of the tile in that box. */
|
|
5
|
+
export declare const TILE_RADIUS = 14;
|
|
6
|
+
/**
|
|
7
|
+
* The cuts of a mark.
|
|
8
|
+
* - `tile`: on its dark rounded tile, the same in both themes. Favicons and avatars.
|
|
9
|
+
* - `on-dark` and `on-light`: free, for a dark or a light background.
|
|
10
|
+
* - `mono`: free, in `currentColor`.
|
|
11
|
+
*/
|
|
12
|
+
export type MarkCut = 'tile' | 'on-dark' | 'on-light' | 'mono';
|
|
13
|
+
export interface MarkColors {
|
|
14
|
+
tile: string;
|
|
15
|
+
/** Body and love element on the tile and on dark backgrounds. */
|
|
16
|
+
dark: {
|
|
17
|
+
body: string;
|
|
18
|
+
love: string;
|
|
19
|
+
};
|
|
20
|
+
/** Body and love element on light backgrounds. */
|
|
21
|
+
light: {
|
|
22
|
+
body: string;
|
|
23
|
+
love: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface MarkOptions {
|
|
27
|
+
cut: MarkCut;
|
|
28
|
+
colors: MarkColors;
|
|
29
|
+
/**
|
|
30
|
+
* What the love element becomes in one color: a `hole` in the body, as the ghost's tongue
|
|
31
|
+
* sits inside its mouth, or `ink` like the body, as a project's love element stands alone.
|
|
32
|
+
*/
|
|
33
|
+
monoLove: 'hole' | 'ink';
|
|
34
|
+
}
|
|
35
|
+
/** The inside of a mark's `<svg>`: the tile if the cut has one, then the sprite. */
|
|
36
|
+
export declare function markBody(rows: Sprite, { cut, colors, monoLove }: MarkOptions): string;
|
|
37
|
+
/** A standalone SVG document with a title, so it is announced when used as an image. */
|
|
38
|
+
export declare function svgDocument(width: number, height: number, body: string, title: string): string;
|
|
39
|
+
/** A mark as a standalone SVG document. */
|
|
40
|
+
export declare function markSvg(rows: Sprite, title: string, options: MarkOptions): string;
|
|
41
|
+
/**
|
|
42
|
+
* The tile mark drawn for one raster size, on whole pixels.
|
|
43
|
+
* A sprite pixel takes as many screen pixels as fit, and the sprite is centered on the tile.
|
|
44
|
+
* `square` fills the whole image, for the touch icon that iOS masks itself.
|
|
45
|
+
*/
|
|
46
|
+
export declare function rasterMarkSvg(rows: Sprite, size: number, colors: MarkColors, { square }?: {
|
|
47
|
+
square?: boolean;
|
|
48
|
+
}): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { spritePaths } from "./sprite.js";
|
|
2
|
+
/** Marks are drawn in a 64 x 64 box: four units per sprite pixel. */
|
|
3
|
+
export const MARK_BOX = 64;
|
|
4
|
+
/** Corner radius of the tile in that box. */
|
|
5
|
+
export const TILE_RADIUS = 14;
|
|
6
|
+
const path = (d, fill) => (d ? `<path d="${d}" fill="${fill}"/>` : '');
|
|
7
|
+
/** The inside of a mark's `<svg>`: the tile if the cut has one, then the sprite. */
|
|
8
|
+
export function markBody(rows, { cut, colors, monoLove }) {
|
|
9
|
+
const { body, love } = spritePaths(rows, { px: MARK_BOX / 16 });
|
|
10
|
+
const tile = cut === 'tile'
|
|
11
|
+
? `<rect width="${MARK_BOX}" height="${MARK_BOX}" rx="${TILE_RADIUS}" fill="${colors.tile}"/>`
|
|
12
|
+
: '';
|
|
13
|
+
let sprite;
|
|
14
|
+
if (cut === 'mono') {
|
|
15
|
+
sprite = path(monoLove === 'ink' ? body + love : body, 'currentColor');
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const ink = cut === 'on-light' ? colors.light : colors.dark;
|
|
19
|
+
sprite = path(body, ink.body) + path(love, ink.love);
|
|
20
|
+
}
|
|
21
|
+
// crisp edges keep sprite pixels sharp at sizes that are not a multiple of 16
|
|
22
|
+
return `${tile}<g shape-rendering="crispEdges">${sprite}</g>`;
|
|
23
|
+
}
|
|
24
|
+
const escape = (text) => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
25
|
+
/** A standalone SVG document with a title, so it is announced when used as an image. */
|
|
26
|
+
export function svgDocument(width, height, body, title) {
|
|
27
|
+
const label = escape(title);
|
|
28
|
+
return (`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" role="img" aria-label="${label}">` +
|
|
29
|
+
`<title>${label}</title>${body}</svg>\n`);
|
|
30
|
+
}
|
|
31
|
+
/** A mark as a standalone SVG document. */
|
|
32
|
+
export function markSvg(rows, title, options) {
|
|
33
|
+
return svgDocument(MARK_BOX, MARK_BOX, markBody(rows, options), title);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The tile mark drawn for one raster size, on whole pixels.
|
|
37
|
+
* A sprite pixel takes as many screen pixels as fit, and the sprite is centered on the tile.
|
|
38
|
+
* `square` fills the whole image, for the touch icon that iOS masks itself.
|
|
39
|
+
*/
|
|
40
|
+
export function rasterMarkSvg(rows, size, colors, { square = false } = {}) {
|
|
41
|
+
const px = Math.floor(size / 16);
|
|
42
|
+
if (px < 1)
|
|
43
|
+
throw new Error(`A mark needs at least 16 px, got ${size}`);
|
|
44
|
+
const offset = (size - px * 16) / 2;
|
|
45
|
+
if (!Number.isInteger(offset))
|
|
46
|
+
throw new Error(`A ${size} px mark cannot be centered on whole pixels`);
|
|
47
|
+
const radius = square ? 0 : Math.round((size * TILE_RADIUS) / MARK_BOX);
|
|
48
|
+
const { body, love } = spritePaths(rows, { px, x: offset, y: offset });
|
|
49
|
+
return (`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${size} ${size}" width="${size}" height="${size}">` +
|
|
50
|
+
`<rect width="${size}" height="${size}" rx="${radius}" fill="${colors.tile}"/>` +
|
|
51
|
+
`<g shape-rendering="crispEdges">${path(body, colors.dark.body)}${path(love, colors.dark.love)}</g></svg>`);
|
|
52
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A 16 x 16 sprite, one string per row.
|
|
3
|
+
* `B` is the body, `T` the love element (the ghost's tongue), `_` a hole in the body, `.` empty.
|
|
4
|
+
*/
|
|
5
|
+
export type Sprite = readonly string[];
|
|
6
|
+
/** Sprites are drawn on a 16 x 16 grid, so at 16 px one sprite pixel is one screen pixel. */
|
|
7
|
+
export declare const GRID = 16;
|
|
8
|
+
export interface SpritePaths {
|
|
9
|
+
/** Path data of the body, or an empty string. */
|
|
10
|
+
body: string;
|
|
11
|
+
/** Path data of the love element, or an empty string. */
|
|
12
|
+
love: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SpritePlacement {
|
|
15
|
+
/** Size of one sprite pixel. */
|
|
16
|
+
px?: number;
|
|
17
|
+
/** Where the grid's top left corner goes. */
|
|
18
|
+
x?: number;
|
|
19
|
+
y?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Path data for a sprite: one path per color, as runs of whole pixels.
|
|
23
|
+
* One path per color means neighbouring pixels never show a seam between them when scaled.
|
|
24
|
+
*/
|
|
25
|
+
export declare function spritePaths(rows: Sprite, { px, x, y }?: SpritePlacement): SpritePaths;
|
|
26
|
+
export interface SpriteBounds {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
}
|
|
32
|
+
/** The box the drawn pixels occupy, so a sprite can sit in a line of text without its margin. */
|
|
33
|
+
export declare function spriteBounds(rows: Sprite): SpriteBounds;
|
|
34
|
+
/**
|
|
35
|
+
* Checks a sprite against the rules every mark of the family follows.
|
|
36
|
+
* Returns the problems found, in words. An empty list means the sprite is fine.
|
|
37
|
+
*
|
|
38
|
+
* - every sprite: 16 rows of 16 cells, only the four known cells, one empty pixel around the
|
|
39
|
+
* edge so nothing touches the rounded corners of the tile
|
|
40
|
+
* - a project sprite: no holes, and exactly one love element, which hangs below the body
|
|
41
|
+
* - the ghost: exactly one tongue, or none in the one pose that has its mouth shut
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkSprite(rows: Sprite, kind: 'ghost' | 'project'): string[];
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/** Sprites are drawn on a 16 x 16 grid, so at 16 px one sprite pixel is one screen pixel. */
|
|
2
|
+
export const GRID = 16;
|
|
3
|
+
/**
|
|
4
|
+
* Path data for a sprite: one path per color, as runs of whole pixels.
|
|
5
|
+
* One path per color means neighbouring pixels never show a seam between them when scaled.
|
|
6
|
+
*/
|
|
7
|
+
export function spritePaths(rows, { px = 1, x = 0, y = 0 } = {}) {
|
|
8
|
+
const paths = { B: '', T: '' };
|
|
9
|
+
rows.forEach((row, rowIndex) => {
|
|
10
|
+
let column = 0;
|
|
11
|
+
while (column < row.length) {
|
|
12
|
+
const cell = row[column];
|
|
13
|
+
let run = 1;
|
|
14
|
+
while (row[column + run] === cell)
|
|
15
|
+
run++;
|
|
16
|
+
if (cell === 'B' || cell === 'T')
|
|
17
|
+
paths[cell] += `M${x + column * px} ${y + rowIndex * px}h${run * px}v${px}h${-run * px}z`;
|
|
18
|
+
column += run;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return { body: paths.B, love: paths.T };
|
|
22
|
+
}
|
|
23
|
+
/** The box the drawn pixels occupy, so a sprite can sit in a line of text without its margin. */
|
|
24
|
+
export function spriteBounds(rows) {
|
|
25
|
+
let [left, top, right, bottom] = [GRID, GRID, 0, 0];
|
|
26
|
+
rows.forEach((row, y) => {
|
|
27
|
+
for (let x = 0; x < row.length; x++) {
|
|
28
|
+
if (row[x] === '.')
|
|
29
|
+
continue;
|
|
30
|
+
left = Math.min(left, x);
|
|
31
|
+
right = Math.max(right, x + 1);
|
|
32
|
+
top = Math.min(top, y);
|
|
33
|
+
bottom = Math.max(bottom, y + 1);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return { x: left, y: top, width: right - left, height: bottom - top };
|
|
37
|
+
}
|
|
38
|
+
/** Counts the groups of `cell` pixels that touch each other by an edge. */
|
|
39
|
+
function countRegions(rows, cell) {
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
let regions = 0;
|
|
42
|
+
for (let y = 0; y < rows.length; y++) {
|
|
43
|
+
for (let x = 0; x < rows[y].length; x++) {
|
|
44
|
+
if (rows[y][x] !== cell || seen.has(`${x},${y}`))
|
|
45
|
+
continue;
|
|
46
|
+
regions++;
|
|
47
|
+
const queue = [[x, y]];
|
|
48
|
+
while (queue.length > 0) {
|
|
49
|
+
const [cx, cy] = queue.pop();
|
|
50
|
+
if (rows[cy]?.[cx] !== cell || seen.has(`${cx},${cy}`))
|
|
51
|
+
continue;
|
|
52
|
+
seen.add(`${cx},${cy}`);
|
|
53
|
+
queue.push([cx + 1, cy], [cx - 1, cy], [cx, cy + 1], [cx, cy - 1]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return regions;
|
|
58
|
+
}
|
|
59
|
+
const lastRowWith = (rows, cell) => rows.reduce((last, row, y) => (row.includes(cell) ? y : last), -1);
|
|
60
|
+
/**
|
|
61
|
+
* Checks a sprite against the rules every mark of the family follows.
|
|
62
|
+
* Returns the problems found, in words. An empty list means the sprite is fine.
|
|
63
|
+
*
|
|
64
|
+
* - every sprite: 16 rows of 16 cells, only the four known cells, one empty pixel around the
|
|
65
|
+
* edge so nothing touches the rounded corners of the tile
|
|
66
|
+
* - a project sprite: no holes, and exactly one love element, which hangs below the body
|
|
67
|
+
* - the ghost: exactly one tongue, or none in the one pose that has its mouth shut
|
|
68
|
+
*/
|
|
69
|
+
export function checkSprite(rows, kind) {
|
|
70
|
+
const problems = [];
|
|
71
|
+
if (rows.length !== GRID)
|
|
72
|
+
problems.push(`has ${rows.length} rows, needs ${GRID}`);
|
|
73
|
+
rows.forEach((row, y) => {
|
|
74
|
+
if (row.length !== GRID)
|
|
75
|
+
problems.push(`row ${y + 1} has ${row.length} cells, needs ${GRID}`);
|
|
76
|
+
const unknown = row.replace(/[.BT_]/g, '');
|
|
77
|
+
if (unknown)
|
|
78
|
+
problems.push(`row ${y + 1} has unknown cells "${unknown}"`);
|
|
79
|
+
});
|
|
80
|
+
if (problems.length > 0)
|
|
81
|
+
return problems;
|
|
82
|
+
const edge = [rows[0], rows[GRID - 1], ...rows.map((row) => row[0] + row[GRID - 1])].join('');
|
|
83
|
+
if (edge.replace(/\./g, '') !== '')
|
|
84
|
+
problems.push('draws on the outermost pixels, keep them empty');
|
|
85
|
+
if (lastRowWith(rows, 'B') === -1)
|
|
86
|
+
problems.push('has no body pixels (B)');
|
|
87
|
+
const loveElements = countRegions(rows, 'T');
|
|
88
|
+
if (kind === 'project') {
|
|
89
|
+
if (rows.some((row) => row.includes('_')))
|
|
90
|
+
problems.push('uses holes (_), which only the ghost has. Leave the pixels empty (.)');
|
|
91
|
+
if (loveElements !== 1)
|
|
92
|
+
problems.push(`has ${loveElements} love elements (T), needs exactly one`);
|
|
93
|
+
else if (lastRowWith(rows, 'T') <= lastRowWith(rows, 'B'))
|
|
94
|
+
problems.push('needs its love element (T) to hang below the body (B)');
|
|
95
|
+
}
|
|
96
|
+
else if (loveElements > 1) {
|
|
97
|
+
problems.push(`has ${loveElements} tongues (T), needs one at most`);
|
|
98
|
+
}
|
|
99
|
+
return problems;
|
|
100
|
+
}
|