2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{R as e,r as m}from"./index-DwChlhAQ.js";import{S as u,p as y}from"./prism-CQZeCw5w.js";import{s as h}from"./scss-BCrErVeE.js";import{U as f}from"./index-DNmTxl-i.js";const b="_title_daft4_1",g="_table_daft4_20",C="_importsnippet_daft4_125",i={title:b,table:g,importsnippet:C};u.registerLanguage("scss",h);const d=t=>t.replace(/\/_/,"/").replace(/\.scss$/,""),_=t=>{const[a,l]=m.useState(!1);let c;m.useEffect(()=>{c&&clearTimeout(c),c=setTimeout(()=>{l(!1)},1500)},[a]);const n=async({partial:s})=>{const r=`@import "@reuters-graphics/graphics-components/scss/colours/${d(s)}";`;await navigator.clipboard.writeText(r),l(!0)};return e.createElement("button",{className:"copy-btn",onClick:()=>n(t)},e.createElement("span",{className:"material-symbols-outlined"},"content_copy"),a&&e.createElement("span",{className:"copy-tag"},"Copied"))},N=({included:t=!1,partial:a="thematic/_tr.scss"})=>t?e.createElement("div",{className:i.importsnippet},e.createElement("p",null,"Included")):e.createElement("div",{className:i.importsnippet},e.createElement(u,{language:"scss",style:y},`// global.scss
|
|
@import "@reuters-graphics/graphics-components/scss/colours/${d(a)}";`),e.createElement(_,{partial:a})),p=t=>{const a=async l=>{const c=l.wrap?`var(${l.children})`:l.children;await navigator.clipboard.writeText(c),l.setCopied(!0)};return e.createElement("button",{className:"copy-btn",onClick:()=>a(t)},e.createElement("span",{className:"material-symbols-outlined"},"content_copy"),t.children,t.copied&&e.createElement("div",{className:"copy-tag"},"Copied"))},T=t=>{const[a,l]=m.useState(!1);let c;m.useEffect(()=>{c&&clearTimeout(c),c=setTimeout(()=>{l(!1)},1e3)},[a]);const n={...t,copied:a,setCopied:l};return t.column===0?e.createElement("div",{className:"swatch-container"},e.createElement("div",{className:"swatch",style:{backgroundColor:t.children}}),e.createElement("span",null,e.createElement(p,{...n},t.children))):t.children.map(s=>e.createElement("div",{key:s},e.createElement(p,{...n,wrap:!0},s)))},v=t=>e.createElement("td",null,e.createElement(T,{...t},t.children)),k=t=>e.createElement("tr",null,t.children.map((a,l)=>e.createElement(v,{...t,column:l,key:l},a))),w=t=>e.createElement("th",null,t.children),H=({title:t=null,body:a,copyable:l,mdnLink:c=null,included:n=!1,partial:s})=>{const r=["Colour","CSS variable"];return e.createElement(f,null,e.createElement("div",{className:i.title},t),e.createElement(N,{included:n,partial:s}),e.createElement("table",{className:i.table},e.createElement("thead",null,e.createElement("tr",null,r.map(o=>e.createElement(w,{key:o},o)))),e.createElement("tbody",null,a.map((o,E)=>e.createElement(k,{title:t,header:r,body:a,copyable:l,mdnLink:c,key:E},o)))))};export{H as C};
|