import rwpLogo from "~assets/brand/replaywebpage-icon-color.svg"; import webrecorderLockupColor from "~assets/brand/webrecorder-lockup-color.svg"; import btAngleDoubleDown from "~assets/icons/chevron-double-down.svg"; import btAngleDoubleUp from "~assets/icons/chevron-double-up.svg"; import fabGithub from "@fortawesome/fontawesome-free/svgs/brands/github.svg"; import fasDownload from "@fortawesome/fontawesome-free/svgs/solid/download.svg"; import { clickOnSpacebarPress } from "./misc"; import { LitElement, html, css, nothing } from "lit"; import { tsToDate } from "./pageutils"; import prettyBytes from "pretty-bytes"; import { property } from "lit/decorators.js"; import type { ItemType } from "./types"; import { dateTimeFormatter } from "./utils/dateTimeFormatter"; // =========================================================================== export class RWPEmbedReceipt extends LitElement { @property({ type: Object }) collInfo: | ItemType | null | Record = null; @property({ type: String }) ts: string | null = null; @property({ type: String }) url: string | null = null; @property({ type: Boolean }) active = false; // @ts-expect-error - TS2611 - 'renderRoot' is defined as a property in class 'LitElement', but is overridden here in 'RWPEmbedReceipt' as an accessor. get renderRoot() { return this; } static get embedStyles() { return css` rwp-embed-receipt { display: flex; flex-direction: column; } .icon { vertical-align: text-top; } #embed-dropdown { max-height: calc(100vh - 50px); padding-top: 0; margin-top: -0.5rem; display: block; z-index: 1; pointer-events: none; transition: all 0.3s linear; transform-origin: left top; transform: scaleY(0); transition: all 300ms cubic-bezier(0.15, 0, 0.1, 1); filter: drop-shadow(0px 8px 4px rgba(0, 0, 0, 0.15)); } .dropdown.is-active #embed-dropdown { transform: scaleY(1); } .embed-info-container { width: 100%; display: flex !important; justify-content: center; } button.embed-info { padding: 0; background-color: white; justify-content: space-between; max-width: 40rem; width: calc(100% - 1rem); height: 42px; border-color: #d1d5da; border-width: 1px; border-style: solid; border-radius: 999px; display: flex; align-items: center; text-overflow: ellipsis; filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.15)); transition-duration: 50ms; transition-timing-function: ease-out; cursor: pointer; z-index: 2; } button.embed-info:active { color: initial; } button.embed-info:hover { filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.2)); transform: scale(1.01); } button.embed-info:hover:active { transform: translateY(0.25rem); } .embed-info-buttontext { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-grow: 1; text-align: start; font-size: 13px; } .embed-info-drop { font-size: 14px; padding: 1rem; padding-top: 2rem; max-width: 38rem; max-height: 42rem; width: calc(100% - 2rem); border-top-right-radius: 0px; border-top-left-radius: 0px; pointer-events: auto; overflow-y: auto; } .embed-info-drop > p { font-size: 14px; color: black; } .embed-info-drop > h2 { margin-bottom: 0.25rem; font-size: 16px; font-weight: bold; text-transform: none; letter-spacing: 0; color: #24292e; } .embed-info-drop-statscontainer > h3 { font-size: 12px; color: #394146; } .embed-info-drop-statscontainer > p { font-size: 14px; color: black; } .embed-info-drop a { word-break: break-all; } .embed-info-drop .show-hash { word-break: break-all; font-family: monospace; } .embed-info-drop .show-key { text-overflow: ellipsis; overflow: hidden; whitespace: nowrap; font-family: monospace; } .embed-logo { margin: 0.5rem; line-height: 0.5rem; } `; } render() { const { numValid = 0, numInvalid = 0, domain, certFingerprint, datapackageHash, publicKey, software, } = this.collInfo?.verify ?? {}; const sourceUrl = this.collInfo?.sourceUrl; const certFingerprintUrl = certFingerprint ? `https://crt.sh/?q=${certFingerprint}` : ""; const dateStr = this.ts ? dateTimeFormatter.format(tsToDate(this.ts) as Date) : ""; return html` `; } // @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7006 - Parameter 'event' implicitly has an 'any' type. onEmbedDrop(event) { event.stopPropagation(); this.active = !this.active; } } customElements.define("rwp-embed-receipt", RWPEmbedReceipt);