UNPKG

@kit-data-manager/pid-component

Version:

The PID-Component is a web component that can be used to evaluate and display FAIR Digital Objects, PIDs, ORCiDs, and possibly other identifiers in a user-friendly way. It is easily extensible to support other identifier types.

92 lines (86 loc) 6.88 kB
/*! * * Copyright 2024 Karlsruhe Institute of Technology. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import { p as proxyCustomElement, H, h, c as Host } from './p-b3fbcf6f.js'; class HSLColor { constructor(hue, sat, lum) { this.hue = hue; this.sat = sat; this.lum = lum; } static async generateColor(text) { if (window.crypto && window.crypto.subtle) { const hashBuffer = await window.crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)); const hashArray = Array.from(new Uint8Array(hashBuffer)); const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); const hue = (parseInt(hashHex, 16) % 36000) / 100; const lum = (parseInt(hashHex, 16) % 450) / 10; const sat = (parseInt(hashHex, 16) % 250) / 10; return new HSLColor(hue, 50 + sat, 30 + lum); } else { const hexText = text .split('') .map(c => c.charCodeAt(0).toString(16)) .join(''); const hue = (parseInt(hexText, 36) % 36000) / 100; const lum = (parseInt(hexText, 36) % 450) / 10; const sat = (parseInt(hexText, 36) % 250) / 10; return new HSLColor(hue, 50 + sat, 30 + lum); } } toString() { return `hsl(${this.hue}, ${this.sat}%, ${this.lum}%)`; } } const colorHighlightCss = "*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:\"\"}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.static{position:static}.m-0{margin:0}.inline-block{display:inline-block}.p-0{padding:0}.align-baseline{vertical-align:baseline}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-bold{font-weight:700}.leading-none{line-height:1}"; const ColorHighlightStyle0 = colorHighlightCss; const ColorHighlight$1 = proxyCustomElement(class ColorHighlight extends H { constructor() { super(); this.__registerHost(); } async componentWillLoad() { this.color = await HSLColor.generateColor(this.text); } render() { return (h(Host, { key: '50b6e91f4e98be29cfa37552eb799883aeb49c9e' }, h("span", { key: 'ddd3968827d1fb00684f7df0c9f8198271fd779e', style: { color: 'hsl(' + this.color.hue + ',' + this.color.sat + '%,' + this.color.lum + '%)', }, class: `m-0 p-0 inline-block align-baseline font-mono font-bold leading-none` }, this.text))); } static get style() { return ColorHighlightStyle0; } }, [0, "color-highlight", { "text": [1], "color": [32] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["color-highlight"]; components.forEach(tagName => { switch (tagName) { case "color-highlight": if (!customElements.get(tagName)) { customElements.define(tagName, ColorHighlight$1); } break; } }); } const ColorHighlight = ColorHighlight$1; const defineCustomElement = defineCustomElement$1; export { ColorHighlight, defineCustomElement }; //# sourceMappingURL=color-highlight.js.map