8 lines
1.4 KiB
JavaScript
8 lines
1.4 KiB
JavaScript
import {normalisePalette} from './organisation-palette-model.mjs';
|
|
const el=(tag,text)=>{const n=document.createElement(tag);if(text!==undefined)n.textContent=text;return n;};
|
|
export function createOrganisationPalette({colors,homeWorld}={}){
|
|
if(!document.querySelector('link[data-organisation-palette]')){const link=el('link');link.rel='stylesheet';link.href=new URL('./organisation-palette.css',import.meta.url).href;link.dataset.organisationPalette='';document.head.append(link);}
|
|
const root=el('fieldset');root.className='organisation-palette';root.append(el('legend','House colours'));const art=el('img');art.src='https://cp.dunerealms.com/dmpaint/icon.png';art.alt='';art.width=150;art.height=150;root.append(art);const paint=el('div');paint.className='organisation-paint-circles';const inputs={},initial=normalisePalette(colors,homeWorld);
|
|
for(const [key,title]of [['primary','Primary'],['secondary','Secondary'],['trim','Trim']]){const label=el('label',title),input=el('input');input.type='color';input.name='houseColor_'+key;input.value=initial[key];input.setAttribute('aria-label',title+' house colour');label.prepend(input);paint.append(label);inputs[key]=input;}
|
|
root.append(paint,el('p','Your shared colours for clan heraldry and the clan/company sash.'));return {root,value:()=>normalisePalette(Object.fromEntries(Object.entries(inputs).map(([k,input])=>[k,input.value])),homeWorld)};
|
|
}
|

Staff