색 고르기 편집기Color picker editor
색 칸은 색 네모와 색 코드를 보여 주고, 편집할 때는 브라우저의 색 고르기가 열려요. 색을 고르면 바로 확정돼요.The color cell shows a swatch and its code, and editing opens the browser’s color picker. Picking a color commits at once.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<button type="button" id="edit">첫 색 편집</button>
<button type="button" id="reset">처음 색으로</button>
</div>
<div id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(api));// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko, en) => document.documentElement.dataset.lang === 'en' ? en : ko;
// 폰처럼 손가락으로 쓰는 화면인지 알려 줘요.
const coarse = () => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
// 칸 안의 내용은 기본으로 세로 가운데가 아니에요. .mxg-cell-center 상자에 넣으면 가운데에 와요.
const centered = (el) => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// 칸에는 색 네모와 색 코드를 보여 주고, 편집기는 브라우저의 색 고르기 입력칸(<input type="color">)이에요.
const swatch = () => {
let box;
let text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// 올바른 색 코드일 때만 스타일에 넣어서, 이상한 글자가 CSS로 들어가지 못하게 해요.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() { },
};
};
const colorEditor = () => {
let input;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute('aria-label', L(`${ctx.row.label} 색 고르기`, `Pick a color for ${ctx.row.label}`));
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// 편집을 시작하자마자 색 고르기 창이 열리게 해요(브라우저가 막으면 입력칸만 보여요).
try {
input.showPicker();
}
catch {
/* 사용자 동작 없이는 열 수 없는 브라우저면 건너뛰어요 */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options = {
columns: [
{ id: 'label', title: '이름', width: 130 },
{
id: 'color',
title: '색(더블클릭)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say = () => { };
export function setup(api, log) {
say = log;
log({
ko: '색 칸을 더블클릭해서 색을 골라 보세요. 고르면 바로 확정돼요.',
en: 'Double-click a color cell and pick a color. It is confirmed as soon as you pick.',
});
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api) => api.startEdit(1, 'color'),
reset: (api) => {
api.updateRows([
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
]);
say({ ko: '처음 색으로 되돌렸어요.', en: 'Back to the first color.' });
},
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>색 고르기 편집기</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="edit">첫 색 편집</button>
<button type="button" id="reset">처음 색으로</button>
</div>
<div id="grid" style="height: 260px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko, en) => document.documentElement.dataset.lang === 'en' ? en : ko;
// 폰처럼 손가락으로 쓰는 화면인지 알려 줘요.
const coarse = () => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
// 칸 안의 내용은 기본으로 세로 가운데가 아니에요. .mxg-cell-center 상자에 넣으면 가운데에 와요.
const centered = (el) => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// 칸에는 색 네모와 색 코드를 보여 주고, 편집기는 브라우저의 색 고르기 입력칸(<input type="color">)이에요.
const swatch = () => {
let box;
let text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// 올바른 색 코드일 때만 스타일에 넣어서, 이상한 글자가 CSS로 들어가지 못하게 해요.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() { },
};
};
const colorEditor = () => {
let input;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute('aria-label', L(`${ctx.row.label} 색 고르기`, `Pick a color for ${ctx.row.label}`));
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// 편집을 시작하자마자 색 고르기 창이 열리게 해요(브라우저가 막으면 입력칸만 보여요).
try {
input.showPicker();
}
catch {
/* 사용자 동작 없이는 열 수 없는 브라우저면 건너뛰어요 */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
const options = {
columns: [
{ id: 'label', title: '이름', width: 130 },
{
id: 'color',
title: '색(더블클릭)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say = () => { };
function setup(api, log) {
say = log;
log({
ko: '색 칸을 더블클릭해서 색을 골라 보세요. 고르면 바로 확정돼요.',
en: 'Double-click a color cell and pick a color. It is confirmed as soon as you pick.',
});
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
const actions = {
edit: (api) => api.startEdit(1, 'color'),
reset: (api) => {
api.updateRows([
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
]);
say({ ko: '처음 색으로 되돌렸어요.', en: 'Back to the first color.' });
},
};
options.ariaLabel = "색 고르기 편집기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(api));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.edit(api)}
>첫 색 편집</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.reset(api)}
>처음 색으로</button>
</div>
<Grid style={{ height: 260 }} ref={gridRef} options={options} />
</>
);
}import type { CellEditorAdapter, CellRendererAdapter, GridApi, GridOptions } from '@maxgrid/react';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export type LogText = string | { ko: string; en: string };
// 폰처럼 손가락으로 쓰는 화면인지 알려 줘요.
const coarse = (): boolean => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
export interface Row {
id: number;
label: string;
color: string;
}
// 칸 안의 내용은 기본으로 세로 가운데가 아니에요. .mxg-cell-center 상자에 넣으면 가운데에 와요.
const centered = (el: HTMLElement): HTMLElement => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// 칸에는 색 네모와 색 코드를 보여 주고, 편집기는 브라우저의 색 고르기 입력칸(<input type="color">)이에요.
const swatch = (): CellRendererAdapter<Row> => {
let box: HTMLSpanElement;
let text: Text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// 올바른 색 코드일 때만 스타일에 넣어서, 이상한 글자가 CSS로 들어가지 못하게 해요.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() {},
};
};
const colorEditor = (): CellEditorAdapter<Row> => {
let input: HTMLInputElement;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute(
'aria-label',
L(`${ctx.row.label} 색 고르기`, `Pick a color for ${ctx.row.label}`),
);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// 편집을 시작하자마자 색 고르기 창이 열리게 해요(브라우저가 막으면 입력칸만 보여요).
try {
input.showPicker();
} catch {
/* 사용자 동작 없이는 열 수 없는 브라우저면 건너뛰어요 */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'label', title: '이름', width: 130 },
{
id: 'color',
title: '색(더블클릭)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log({
ko: '색 칸을 더블클릭해서 색을 골라 보세요. 고르면 바로 확정돼요.',
en: 'Double-click a color cell and pick a color. It is confirmed as soon as you pick.',
});
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'color'),
reset: (api: GridApi<Row>) => {
api.updateRows([
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
]);
say({ ko: '처음 색으로 되돌렸어요.', en: 'Back to the first color.' });
},
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.edit(api)">첫 색 편집</button>
<button type="button" :disabled="!api" @click="api && actions.reset(api)">처음 색으로</button>
</div>
<Grid style="height: 260px" :options="options" @ready="onReady" />
</template>import type { CellEditorAdapter, CellRendererAdapter, GridApi, GridOptions } from '@maxgrid/vue';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export type LogText = string | { ko: string; en: string };
// 폰처럼 손가락으로 쓰는 화면인지 알려 줘요.
const coarse = (): boolean => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
export interface Row {
id: number;
label: string;
color: string;
}
// 칸 안의 내용은 기본으로 세로 가운데가 아니에요. .mxg-cell-center 상자에 넣으면 가운데에 와요.
const centered = (el: HTMLElement): HTMLElement => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// 칸에는 색 네모와 색 코드를 보여 주고, 편집기는 브라우저의 색 고르기 입력칸(<input type="color">)이에요.
const swatch = (): CellRendererAdapter<Row> => {
let box: HTMLSpanElement;
let text: Text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// 올바른 색 코드일 때만 스타일에 넣어서, 이상한 글자가 CSS로 들어가지 못하게 해요.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() {},
};
};
const colorEditor = (): CellEditorAdapter<Row> => {
let input: HTMLInputElement;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute(
'aria-label',
L(`${ctx.row.label} 색 고르기`, `Pick a color for ${ctx.row.label}`),
);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// 편집을 시작하자마자 색 고르기 창이 열리게 해요(브라우저가 막으면 입력칸만 보여요).
try {
input.showPicker();
} catch {
/* 사용자 동작 없이는 열 수 없는 브라우저면 건너뛰어요 */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'label', title: '이름', width: 130 },
{
id: 'color',
title: '색(더블클릭)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log({
ko: '색 칸을 더블클릭해서 색을 골라 보세요. 고르면 바로 확정돼요.',
en: 'Double-click a color cell and pick a color. It is confirmed as soon as you pick.',
});
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'color'),
reset: (api: GridApi<Row>) => {
api.updateRows([
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
]);
say({ ko: '처음 색으로 되돌렸어요.', en: 'Back to the first color.' });
},
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.edit(api)"
>첫 색 편집</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.reset(api)"
>처음 색으로</button>
</div>
<mx-grid style="height: 260px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { CellEditorAdapter, CellRendererAdapter, GridApi, GridOptions } from '@maxgrid/angular';
// 예제 틀이 알려 주는 페이지 언어(ko/en)에 맞는 문구를 골라요.
const L = (ko: string, en: string): string =>
document.documentElement.dataset.lang === 'en' ? en : ko;
export type LogText = string | { ko: string; en: string };
// 폰처럼 손가락으로 쓰는 화면인지 알려 줘요.
const coarse = (): boolean => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
export interface Row {
id: number;
label: string;
color: string;
}
// 칸 안의 내용은 기본으로 세로 가운데가 아니에요. .mxg-cell-center 상자에 넣으면 가운데에 와요.
const centered = (el: HTMLElement): HTMLElement => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// 칸에는 색 네모와 색 코드를 보여 주고, 편집기는 브라우저의 색 고르기 입력칸(<input type="color">)이에요.
const swatch = (): CellRendererAdapter<Row> => {
let box: HTMLSpanElement;
let text: Text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// 올바른 색 코드일 때만 스타일에 넣어서, 이상한 글자가 CSS로 들어가지 못하게 해요.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() {},
};
};
const colorEditor = (): CellEditorAdapter<Row> => {
let input: HTMLInputElement;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute(
'aria-label',
L(`${ctx.row.label} 색 고르기`, `Pick a color for ${ctx.row.label}`),
);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// 편집을 시작하자마자 색 고르기 창이 열리게 해요(브라우저가 막으면 입력칸만 보여요).
try {
input.showPicker();
} catch {
/* 사용자 동작 없이는 열 수 없는 브라우저면 건너뛰어요 */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'label', title: '이름', width: 130 },
{
id: 'color',
title: '색(더블클릭)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log({
ko: '색 칸을 더블클릭해서 색을 골라 보세요. 고르면 바로 확정돼요.',
en: 'Double-click a color cell and pick a color. It is confirmed as soon as you pick.',
});
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'color'),
reset: (api: GridApi<Row>) => {
api.updateRows([
{ id: 1, label: '대표 색', color: '#1a56c4' },
{ id: 2, label: '성공', color: '#1a7f37' },
{ id: 3, label: '주의', color: '#bf8700' },
{ id: 4, label: '위험', color: '#cf222e' },
]);
say({ ko: '처음 색으로 되돌렸어요.', en: 'Back to the first color.' });
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<button type="button" id="edit">Edit first color</button>
<button type="button" id="reset">Back to start</button>
</div>
<div id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(api));// Tells whether the screen is finger-driven, like a phone.
const coarse = () => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
// Cell content is not vertically centered by default. Putting it in a .mxg-cell-center box centers it.
const centered = (el) => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// The cell shows a color square and the color code; the editor is the browser's color input (<input type="color">).
const swatch = () => {
let box;
let text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// Only a valid color code goes into the style, so odd text cannot enter the CSS.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() { },
};
};
const colorEditor = () => {
let input;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute('aria-label', `Pick a color for ${ctx.row.label}`);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// Open the color picker as soon as editing starts (if the browser blocks it, only the input is shown).
try {
input.showPicker();
}
catch {
/* skip in browsers that cannot open it without a user gesture */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options = {
columns: [
{ id: 'label', title: 'Name', width: 130 },
{
id: 'color',
title: 'Color (double-click)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say = () => { };
export function setup(api, log) {
say = log;
log('Double-click a color cell and pick a color. It is confirmed as soon as you pick.');
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api) => api.startEdit(1, 'color'),
reset: (api) => {
api.updateRows([
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
]);
say('Back to the first color.');
},
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Color picker editor</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="edit">Edit first color</button>
<button type="button" id="reset">Back to start</button>
</div>
<div id="grid" style="height: 260px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// Tells whether the screen is finger-driven, like a phone.
const coarse = () => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
// Cell content is not vertically centered by default. Putting it in a .mxg-cell-center box centers it.
const centered = (el) => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// The cell shows a color square and the color code; the editor is the browser's color input (<input type="color">).
const swatch = () => {
let box;
let text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// Only a valid color code goes into the style, so odd text cannot enter the CSS.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() { },
};
};
const colorEditor = () => {
let input;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute('aria-label', `Pick a color for ${ctx.row.label}`);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// Open the color picker as soon as editing starts (if the browser blocks it, only the input is shown).
try {
input.showPicker();
}
catch {
/* skip in browsers that cannot open it without a user gesture */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
const options = {
columns: [
{ id: 'label', title: 'Name', width: 130 },
{
id: 'color',
title: 'Color (double-click)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say = () => { };
function setup(api, log) {
say = log;
log('Double-click a color cell and pick a color. It is confirmed as soon as you pick.');
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
const actions = {
edit: (api) => api.startEdit(1, 'color'),
reset: (api) => {
api.updateRows([
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
]);
say('Back to the first color.');
},
};
options.ariaLabel = "Color picker editor";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('edit').addEventListener('click', () => actions.edit(api));
document.getElementById('reset').addEventListener('click', () => actions.reset(api));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.edit(api)}
>Edit first color</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.reset(api)}
>Back to start</button>
</div>
<Grid style={{ height: 260 }} ref={gridRef} options={options} />
</>
);
}import type { CellEditorAdapter, CellRendererAdapter, GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
// Tells whether the screen is finger-driven, like a phone.
const coarse = (): boolean => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
export interface Row {
id: number;
label: string;
color: string;
}
// Cell content is not vertically centered by default. Putting it in a .mxg-cell-center box centers it.
const centered = (el: HTMLElement): HTMLElement => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// The cell shows a color square and the color code; the editor is the browser's color input (<input type="color">).
const swatch = (): CellRendererAdapter<Row> => {
let box: HTMLSpanElement;
let text: Text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// Only a valid color code goes into the style, so odd text cannot enter the CSS.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() {},
};
};
const colorEditor = (): CellEditorAdapter<Row> => {
let input: HTMLInputElement;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute('aria-label', `Pick a color for ${ctx.row.label}`);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// Open the color picker as soon as editing starts (if the browser blocks it, only the input is shown).
try {
input.showPicker();
} catch {
/* skip in browsers that cannot open it without a user gesture */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'label', title: 'Name', width: 130 },
{
id: 'color',
title: 'Color (double-click)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log('Double-click a color cell and pick a color. It is confirmed as soon as you pick.');
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'color'),
reset: (api: GridApi<Row>) => {
api.updateRows([
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
]);
say('Back to the first color.');
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.edit(api)">Edit first color</button>
<button type="button" :disabled="!api" @click="api && actions.reset(api)">Back to start</button>
</div>
<Grid style="height: 260px" :options="options" @ready="onReady" />
</template>import type { CellEditorAdapter, CellRendererAdapter, GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
// Tells whether the screen is finger-driven, like a phone.
const coarse = (): boolean => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
export interface Row {
id: number;
label: string;
color: string;
}
// Cell content is not vertically centered by default. Putting it in a .mxg-cell-center box centers it.
const centered = (el: HTMLElement): HTMLElement => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// The cell shows a color square and the color code; the editor is the browser's color input (<input type="color">).
const swatch = (): CellRendererAdapter<Row> => {
let box: HTMLSpanElement;
let text: Text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// Only a valid color code goes into the style, so odd text cannot enter the CSS.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() {},
};
};
const colorEditor = (): CellEditorAdapter<Row> => {
let input: HTMLInputElement;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute('aria-label', `Pick a color for ${ctx.row.label}`);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// Open the color picker as soon as editing starts (if the browser blocks it, only the input is shown).
try {
input.showPicker();
} catch {
/* skip in browsers that cannot open it without a user gesture */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'label', title: 'Name', width: 130 },
{
id: 'color',
title: 'Color (double-click)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log('Double-click a color cell and pick a color. It is confirmed as soon as you pick.');
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'color'),
reset: (api: GridApi<Row>) => {
api.updateRows([
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
]);
say('Back to the first color.');
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.edit(api)"
>Edit first color</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.reset(api)"
>Back to start</button>
</div>
<mx-grid style="height: 260px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { CellEditorAdapter, CellRendererAdapter, GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
// Tells whether the screen is finger-driven, like a phone.
const coarse = (): boolean => window.matchMedia('(pointer: coarse), (max-width: 480px)').matches;
export interface Row {
id: number;
label: string;
color: string;
}
// Cell content is not vertically centered by default. Putting it in a .mxg-cell-center box centers it.
const centered = (el: HTMLElement): HTMLElement => {
const box = document.createElement('div');
box.className = 'mxg-cell-center';
el.append(box);
return box;
};
// The cell shows a color square and the color code; the editor is the browser's color input (<input type="color">).
const swatch = (): CellRendererAdapter<Row> => {
let box: HTMLSpanElement;
let text: Text;
return {
mount(el, ctx) {
box = document.createElement('span');
box.setAttribute('aria-hidden', 'true');
box.style.cssText =
'display: inline-block; width: 14px; height: 14px; margin-right: 8px; border-radius: 3px; border: 1px solid var(--mxg-border); vertical-align: middle;';
text = document.createTextNode('');
centered(el).append(box, text);
this.update(ctx);
},
update(ctx) {
// Only a valid color code goes into the style, so odd text cannot enter the CSS.
box.style.background = /^#[0-9a-f]{6}$/i.test(ctx.text) ? ctx.text : 'transparent';
text.data = ctx.text;
},
destroy() {},
};
};
const colorEditor = (): CellEditorAdapter<Row> => {
let input: HTMLInputElement;
return {
mount(el, ctx) {
input = document.createElement('input');
input.type = 'color';
input.value = /^#[0-9a-f]{6}$/i.test(String(ctx.value)) ? String(ctx.value) : '#000000';
input.style.cssText =
'width: 100%; height: 100%; box-sizing: border-box; border: 0; padding: 2px 6px; background: transparent;';
input.setAttribute('aria-label', `Pick a color for ${ctx.row.label}`);
input.addEventListener('change', () => ctx.commit());
el.append(input);
},
getValue: () => input.value,
focus() {
input.focus();
// Open the color picker as soon as editing starts (if the browser blocks it, only the input is shown).
try {
input.showPicker();
} catch {
/* skip in browsers that cannot open it without a user gesture */
}
},
setError(message) {
input.title = message ?? '';
},
destroy: () => input.remove(),
};
};
export const options: GridOptions<Row> = {
columns: [
{ id: 'label', title: 'Name', width: 130 },
{
id: 'color',
title: 'Color (double-click)',
width: 170,
editable: true,
cellRenderer: swatch,
cellEditor: colorEditor,
},
],
rows: [
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
],
rowKey: 'id',
saveMode: 'none',
...(coarse() ? { rowHeight: 44 } : {}),
};
let say: (message: LogText) => void = () => {};
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
log('Double-click a color cell and pick a color. It is confirmed as soon as you pick.');
return api.on('editCommitted', (e) => {
const row = api.getRowByKey(e.rowKey);
log(`${row?.label ?? e.rowKey}: ${String(e.oldValue)} → ${String(e.newValue)}`);
});
}
export const actions = {
edit: (api: GridApi<Row>) => api.startEdit(1, 'color'),
reset: (api: GridApi<Row>) => {
api.updateRows([
{ id: 1, label: 'Primary', color: '#1a56c4' },
{ id: 2, label: 'Success', color: '#1a7f37' },
{ id: 3, label: 'Warning', color: '#bf8700' },
{ id: 4, label: 'Danger', color: '#cf222e' },
]);
say('Back to the first color.');
},
};