اللون الأساسي
خذ اللون الذي role فيه primary، وإلا أول لون في colors. لا ألوان للجهة؟ أبقِ ألوانك.
لا تكتب نصًا بلون الجهة على خلفيتك دون فحص التباين: كثير من ألوان الشعارات أفتح من أن تُقرأ على الأبيض. الأسلم أن يكون لون الجهة خلفية، ولون النص أبيض أو داكن حسب التباين.
اللون ونصه
brand-swatch.js
/** The brand's main colour and a text colour that reads on it. */export function brandSwatch(brand) { const main = brand.colors.find((c) => c.role === 'primary') ?? brand.colors[0]; if (!main) return null; // no colours: keep your own return { background: main.hex, text: readableOn(main.hex), source: brand.colorsSource };}/** White or near-black, whichever contrasts more with `hex` (WCAG). */function readableOn(hex) { const [r, g, b] = [1, 3, 5].map((i) => { const c = parseInt(hex.slice(i, i + 2), 16) / 255; return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4; }); const l = 0.2126 * r + 0.7152 * g + 0.0722 * b; return 1.05 / (l + 0.05) >= (l + 0.05) / 0.05 ? '#ffffff' : '#111111';}للطباعة
حين تحتاج قيم CMYK أو Pantone، فهي في identityColors لا في colors، وتأتي من دليل هوية الجهة كما هو.