@vtex/ads-stories 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +12 -4
- package/dist/cdn/vtex-ads-stories.js +309 -2
- package/dist/cdn/vtex-ads-stories.js.map +1 -1
- package/dist/cjs/index.cjs +612 -25
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +6 -5
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/cjs/react.d.cts +1 -4
- package/dist/esm/index.d.ts +6 -5
- package/dist/esm/index.js +612 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.d.ts +1 -4
- package/package.json +2 -1
- package/src/components/card/card.ts +233 -0
- package/src/components/card/index.ts +2 -0
- package/src/components/icons/LICENSE +21 -0
- package/src/components/icons/assets/close.svg +1 -0
- package/src/components/icons/assets/collapse.svg +1 -0
- package/src/components/icons/assets/expand.svg +1 -0
- package/src/components/icons/assets/pause-fill.svg +1 -0
- package/src/components/icons/assets/play-fill.svg +1 -0
- package/src/components/icons/assets/speaker-high-fill.svg +1 -0
- package/src/components/icons/assets/speaker-x-fill.svg +1 -0
- package/src/components/icons/index.ts +36 -0
- package/src/components/player/index.ts +2 -0
- package/src/components/player/player.ts +379 -0
- package/src/raw.d.ts +5 -0
- package/src/react.ts +1 -4
- package/src/story/story.ts +89 -27
- package/src/types.ts +14 -0
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/story/story.ts"],"sourcesContent":["export { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from \"./story\";\n","export const TAG_NAME = \"vtex-ads-story\";\n\n// Keeps the module importable where HTMLElement doesn't exist (SSR, Node).\nconst BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;\n\nconst styles = `\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n`;\n\nconst DEFAULT_NAME = \"world\";\n\nexport class VtexAdsStoryElement extends BaseElement {\n static get observedAttributes() {\n return [\"name\"];\n }\n\n get name(): string {\n return this.getAttribute(\"name\")?.trim() ?? \"\";\n }\n\n set name(value: string) {\n this.setAttribute(\"name\", value);\n }\n\n private render() {\n const container = this.shadowRoot?.querySelector(\"[part='root']\");\n if (!container) return;\n\n // textContent keeps the name as plain text (no HTML injection).\n container.textContent = `Hello ${this.name || DEFAULT_NAME}!`;\n }\n\n connectedCallback() {\n if (!this.shadowRoot) {\n const root = this.attachShadow({ mode: \"open\" });\n root.innerHTML = `<style>${styles}</style><div part=\"root\"></div>`;\n }\n\n this.upgradeProperty(\"name\");\n this.render();\n }\n\n // A property set before the element is defined (e.g. while the CDN script\n // loads) becomes an own property that shadows the class getter/setter.\n // Remove it and set it again so it goes through the setter.\n private upgradeProperty(prop: \"name\") {\n if (!Object.prototype.hasOwnProperty.call(this, prop)) return;\n\n const value = this[prop];\n Reflect.deleteProperty(this, prop);\n this[prop] = value;\n }\n\n attributeChangedCallback() {\n this.render();\n }\n}\n\n// Types `document.createElement(\"vtex-ads-story\")` and `querySelector` results\n// as VtexAdsStoryElement in any TypeScript project, no framework needed.\ndeclare global {\n interface HTMLElementTagNameMap {\n \"vtex-ads-story\": VtexAdsStoryElement;\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAW;AAAxB;AAGA,IAAM,eAAkC,gBAAW,gBAAX,YAA0B;AAElE,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQf,IAAM,eAAe;AAEd,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACnD,WAAW,qBAAqB;AAC9B,WAAO,CAAC,MAAM;AAAA,EAChB;AAAA,EAEA,IAAI,OAAe;AApBrB,QAAAA,KAAA;AAqBI,YAAO,MAAAA,MAAA,KAAK,aAAa,MAAM,MAAxB,gBAAAA,IAA2B,WAA3B,YAAqC;AAAA,EAC9C;AAAA,EAEA,IAAI,KAAK,OAAe;AACtB,SAAK,aAAa,QAAQ,KAAK;AAAA,EACjC;AAAA,EAEQ,SAAS;AA5BnB,QAAAA;AA6BI,UAAM,aAAYA,MAAA,KAAK,eAAL,gBAAAA,IAAiB,cAAc;AACjD,QAAI,CAAC,UAAW;AAGhB,cAAU,cAAc,SAAS,KAAK,QAAQ,YAAY;AAAA,EAC5D;AAAA,EAEA,oBAAoB;AAClB,QAAI,CAAC,KAAK,YAAY;AACpB,YAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAC/C,WAAK,YAAY,UAAU,MAAM;AAAA,IACnC;AAEA,SAAK,gBAAgB,MAAM;AAC3B,SAAK,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKQ,gBAAgB,MAAc;AACpC,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,IAAI,EAAG;AAEvD,UAAM,QAAQ,KAAK,IAAI;AACvB,YAAQ,eAAe,MAAM,IAAI;AACjC,SAAK,IAAI,IAAI;AAAA,EACf;AAAA,EAEA,2BAA2B;AACzB,SAAK,OAAO;AAAA,EACd;AACF;AAUO,SAAS,uBAAuB;AACrC,MAAI,OAAO,mBAAmB,YAAa;AAC3C,MAAI,eAAe,IAAI,QAAQ,EAAG;AAElC,iBAAe,OAAO,UAAU,mBAAmB;AACrD;","names":["_a"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg","../../src/components/icons/index.ts","../../src/components/card/card.ts","../../src/components/player/player.ts","../../src/story/story.ts"],"sourcesContent":["export { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from \"./story\";\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M245.66,146.34a8,8,0,0,1-11.32,11.32L216,139.31l-18.34,18.35a8,8,0,0,1-11.32-11.32L204.69,128l-18.35-18.34a8,8,0,0,1,11.32-11.32L216,116.69l18.34-18.35a8,8,0,0,1,11.32,11.32L227.31,128ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm97.15-54.15a8,8,0,0,0-10-.16l-65.57,51A4,4,0,0,0,80,79.84v96.32a4,4,0,0,0,1.55,3.15l65.57,51a8,8,0,0,0,9,.56,8.29,8.29,0,0,0,3.91-7.18V32.25A8.27,8.27,0,0,0,157.12,25.85Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z\"/></svg>\n","/*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */\n\n// SVG files as downloaded from Phosphor: regular weight, or the weight in the\n// file name. They are bundled as text: `?raw` is handled by Vite in dev and\n// tests, and by the raw plugin in tsup.config.ts.\nimport close from \"./assets/close.svg?raw\";\nimport collapse from \"./assets/collapse.svg?raw\";\nimport expand from \"./assets/expand.svg?raw\";\nimport pause from \"./assets/pause-fill.svg?raw\";\nimport play from \"./assets/play-fill.svg?raw\";\nimport soundOff from \"./assets/speaker-x-fill.svg?raw\";\nimport soundOn from \"./assets/speaker-high-fill.svg?raw\";\n\nexport const icons = {\n close,\n collapse,\n expand,\n pause,\n play,\n soundOff,\n soundOn,\n};\n\nexport type IconName = keyof typeof icons;\n\n/** Renders a bundled icon. It is decorative: name the control around it. */\nexport function createIcon(name: IconName) {\n const template = document.createElement(\"template\");\n template.innerHTML = icons[name];\n\n const svg = template.content.firstElementChild as SVGSVGElement;\n svg.classList.add(\"icon\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.setAttribute(\"focusable\", \"false\");\n return svg;\n}\n","import { createIcon } from \"../icons\";\nimport type { StoryMedia } from \"../../types\";\n\nexport const cardStyles = `\n .card {\n position: relative;\n box-sizing: border-box;\n width: calc(500px * 9 / 16);\n height: 500px;\n overflow: hidden;\n border-radius: var(--vtex-ads-story-radius, 20px);\n background: #000;\n }\n\n /* The card's button covers it. The focus ring goes on the card, since the\n card's overflow would clip the button's own. */\n .card-open {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n }\n\n .card-open:focus-visible {\n outline: none;\n }\n\n .card:has(> .card-open:focus-visible) {\n outline: auto;\n }\n\n .poster,\n .video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .play {\n position: absolute;\n top: 50%;\n left: 50%;\n display: grid;\n width: 66px;\n height: 66px;\n place-items: center;\n border-radius: 50%;\n background:\n linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),\n rgba(255, 255, 255, 0.15);\n backdrop-filter: blur(2px);\n box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);\n transform: translate(-50%, -50%);\n transition:\n opacity 0.3s ease,\n transform 0.3s ease;\n }\n\n /* The icon's triangle is 18px tall and already sits slightly right of its\n box, so it looks centered in the circle. */\n .play .icon {\n width: 22px;\n height: 22px;\n color: #fff;\n }\n\n /* Sound on/off, at the top right of the card (as in the prototype). */\n .card-sound {\n position: absolute;\n top: 22px;\n right: 12px;\n z-index: 1;\n display: grid;\n width: 28px;\n height: 28px;\n place-items: center;\n padding: 0;\n border: 0;\n background: transparent;\n color: #fff;\n cursor: pointer;\n filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));\n }\n\n .card-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* With a mouse, the play button shows only on hover or keyboard focus.\n Touch screens have no hover, so it stays visible there. */\n @media (hover: hover) and (pointer: fine) {\n .play {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.9);\n }\n\n .card:hover .play,\n .card-open:focus-visible .play {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n`;\n\nexport interface CardOptions {\n /** Accessible name of the card. */\n label: string;\n /** Called on click, Enter or Space. */\n onSelect: () => void;\n /** Accessible names of the sound button, shown when the card has a video. */\n soundOnLabel: string;\n soundOffLabel: string;\n}\n\n// Only absolute http(s) URLs reach the DOM. Relative and protocol-relative\n// ones (\"/a.jpg\", \"//host/a.jpg\") don't parse without a base, so they're out.\nfunction httpUrl(value: string | undefined) {\n if (!value) return null;\n try {\n const { protocol } = new URL(value);\n return protocol === \"https:\" || protocol === \"http:\" ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction prefersReducedMotion() {\n return (\n globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false\n );\n}\n\n/**\n * Plays a video. A blocked play is ignored: the cover or the paused state\n * stays.\n */\nexport function playVideo(video: HTMLVideoElement) {\n video.play()?.catch(() => undefined);\n}\n\nfunction createVideo(src: string, poster: string | null) {\n const video = document.createElement(\"video\");\n video.className = \"video\";\n // Muted and inline is what browsers, iOS included, allow to autoplay.\n video.muted = true;\n video.setAttribute(\"muted\", \"\");\n video.setAttribute(\"playsinline\", \"\");\n video.loop = true;\n video.preload = \"metadata\";\n // No autoplay for people who asked for reduced motion.\n video.autoplay = !prefersReducedMotion();\n if (poster) video.poster = poster;\n video.src = src;\n\n // If the video can't load, the cover underneath stays.\n video.addEventListener(\"error\", () => video.remove());\n return video;\n}\n\n/** Sound on/off for the card's video, which starts muted. */\nfunction createSoundButton(video: HTMLVideoElement, options: CardOptions) {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"card-sound\";\n\n function sync() {\n button.setAttribute(\n \"aria-label\",\n video.muted ? options.soundOnLabel : options.soundOffLabel,\n );\n button.replaceChildren(createIcon(video.muted ? \"soundOff\" : \"soundOn\"));\n }\n\n video.addEventListener(\"volumechange\", sync);\n // Without the video, the cover stays and there is no sound to control.\n video.addEventListener(\"error\", () => button.remove());\n button.addEventListener(\"click\", () => {\n video.muted = !video.muted;\n });\n\n sync();\n return button;\n}\n\n/**\n * A 9:16 card with the Story cover and, with a media_url, the video looping\n * muted over it. With options, a button with a play icon in the middle covers\n * the card, and a card with a video gets a sound button. The sound button is\n * beside the card's button, not inside it: a button can't contain another.\n */\nexport function createCard(story: StoryMedia, options?: CardOptions) {\n const card = document.createElement(\"div\");\n card.className = \"card\";\n\n const posterUrl = httpUrl(story.poster_url);\n if (posterUrl) {\n const poster = document.createElement(\"img\");\n poster.className = \"poster\";\n poster.alt = \"\";\n poster.src = posterUrl;\n card.append(poster);\n }\n\n const mediaUrl = httpUrl(story.media_url);\n const video = mediaUrl ? createVideo(mediaUrl, posterUrl) : null;\n if (video) card.append(video);\n\n if (options) {\n const open = document.createElement(\"button\");\n open.type = \"button\";\n open.className = \"card-open\";\n open.setAttribute(\"aria-label\", options.label);\n\n const play = document.createElement(\"span\");\n play.className = \"play\";\n play.setAttribute(\"aria-hidden\", \"true\");\n play.append(createIcon(\"play\"));\n open.append(play);\n open.addEventListener(\"click\", options.onSelect);\n\n card.append(open);\n if (video) card.append(createSoundButton(video, options));\n }\n\n return card;\n}\n","import { createCard, playVideo } from \"../card\";\nimport { createIcon, type IconName } from \"../icons\";\nimport type { StoryMedia } from \"../../types\";\n\n// The player is a <dialog> shown in the top layer, so no store z-index,\n// overflow or transform can hide or move it.\n//\n// Mini: a manual popover (non-modal, the page stays usable), with the card at\n// the bottom right and the controls above it. Without popover support it is a\n// non-modal dialog, fixed with a high z-index.\n// Expanded: a modal dialog (showModal), so the browser makes the page behind\n// it inert. The card is centered over a dark backdrop, with the controls at\n// the top right of the screen. On narrow screens it fills the screen.\nexport const playerStyles = `\n .player {\n position: fixed;\n inset: auto 16px 16px auto;\n z-index: 2147483000;\n box-sizing: border-box;\n width: calc(min(587px, 100vh - 80px) * 9 / 16);\n height: min(587px, 100vh - 80px);\n margin: 0;\n padding: 0;\n overflow: visible;\n border: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n animation: player-in 0.25s ease;\n }\n\n /* A <dialog> shown as a popover has no open attribute, which the browser\n hides by default. */\n .player:popover-open {\n display: block;\n }\n\n /* Switching modes shows the dialog again; only the first opening fades in. */\n .player[data-switched] {\n animation: none;\n }\n\n .player::backdrop {\n background: transparent;\n }\n\n .player-frame {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .player .card {\n width: 100%;\n height: 100%;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);\n }\n\n .player .card:has(.video) {\n cursor: pointer;\n }\n\n /* Play/pause reuses the card's glass .play button, as a real button. */\n .player-toggle {\n padding: 0;\n border: 0;\n color: #fff;\n font: inherit;\n cursor: pointer;\n }\n\n .player[data-paused] .player-toggle,\n .player-toggle:focus-visible {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n\n /* On touch, tapping the video pauses it; the button shows while paused. */\n @media (hover: none) {\n .player:not([data-paused]) .player-toggle {\n opacity: 0;\n }\n }\n\n .player-sound {\n position: absolute;\n top: 12px;\n right: 12px;\n z-index: 1;\n border-color: transparent;\n background: rgba(0, 0, 0, 0.3);\n }\n\n .player-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* Above the card: on narrow screens the expanded card can cover them. */\n .player-controls {\n position: absolute;\n right: 0;\n bottom: calc(100% + 8px);\n z-index: 1;\n display: flex;\n gap: 8px;\n }\n\n .player-button {\n display: grid;\n width: 36px;\n height: 36px;\n place-items: center;\n padding: 0;\n border: 1px solid rgba(133, 133, 133, 0.3);\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.32);\n backdrop-filter: blur(5px);\n color: #fff;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n .player-button:hover {\n background: rgba(0, 0, 0, 0.55);\n }\n\n .player-button .icon {\n width: 18px;\n height: 18px;\n }\n\n .player[data-expanded] {\n inset: 0;\n display: grid;\n width: 100%;\n max-width: none;\n height: 100%;\n max-height: none;\n place-items: center;\n background: rgba(0, 0, 0, 0.85);\n animation: none;\n }\n\n .player[data-expanded] .player-frame {\n width: calc(min(78vh, 720px) * 9 / 16);\n height: min(78vh, 720px);\n }\n\n .player[data-expanded] .player-controls {\n position: fixed;\n top: 24px;\n right: 24px;\n bottom: auto;\n }\n\n .player[data-expanded] .player-button {\n width: 40px;\n height: 40px;\n }\n\n @media (max-width: 576px) {\n .player {\n right: 12px;\n width: 220px;\n height: 391px;\n }\n\n .player[data-expanded] {\n background: #000;\n }\n\n /* The video stays 9:16 and centered; the rest of the screen is black. */\n .player[data-expanded] .player-frame {\n width: min(100vw, 100vh * 9 / 16);\n height: min(100vh, 100vw * 16 / 9);\n }\n\n .player[data-expanded] .card {\n border-radius: 0;\n }\n\n /* Below the sound button, at the top right of the video. Placed in the\n video frame, not the screen: the frame is centered, so on screens\n taller than 9:16 its top is below the screen's. */\n .player[data-expanded] .player-controls {\n position: absolute;\n top: 60px;\n right: 12px;\n }\n }\n\n @keyframes player-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .player {\n animation: none;\n }\n }\n`;\n\nexport interface PlayerOptions {\n /** Accessible name of the player. */\n label: string;\n /** Accessible names of the buttons. */\n expandLabel: string;\n collapseLabel: string;\n closeLabel: string;\n playLabel: string;\n pauseLabel: string;\n soundOnLabel: string;\n soundOffLabel: string;\n onClose: () => void;\n}\n\nfunction createButton(className: string, label: string, icon: IconName) {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = `player-button ${className}`;\n button.setAttribute(\"aria-label\", label);\n button.append(createIcon(icon));\n return button;\n}\n\nfunction supportsPopover(player: HTMLDialogElement) {\n return typeof player.showPopover === \"function\";\n}\n\n/** Shows the player as the mini player. It must already be in the page. */\nexport function showPlayer(player: HTMLDialogElement) {\n if (supportsPopover(player)) player.showPopover();\n else player.show();\n}\n\n/** Plays the player's video, if it has one. */\nexport function playPlayer(player: HTMLDialogElement) {\n const video = player.querySelector(\"video\");\n if (video) playVideo(video);\n}\n\n/**\n * Play/pause in the middle of the video and sound on/off at its top right.\n * Clicking the video also plays or pauses it. The buttons follow the video's\n * own events, so a blocked autoplay shows as paused.\n */\nfunction addVideoControls(\n player: HTMLDialogElement,\n card: HTMLElement,\n video: HTMLVideoElement,\n options: PlayerOptions,\n) {\n // Not a .player-button: it keeps the card's larger glass look.\n const toggle = document.createElement(\"button\");\n toggle.type = \"button\";\n toggle.className = \"play player-toggle\";\n const sound = createButton(\"player-sound\", \"\", \"soundOff\");\n\n function syncPlayback() {\n player.toggleAttribute(\"data-paused\", video.paused);\n toggle.setAttribute(\n \"aria-label\",\n video.paused ? options.playLabel : options.pauseLabel,\n );\n toggle.replaceChildren(createIcon(video.paused ? \"play\" : \"pause\"));\n }\n\n function syncSound() {\n sound.setAttribute(\n \"aria-label\",\n video.muted ? options.soundOnLabel : options.soundOffLabel,\n );\n sound.replaceChildren(createIcon(video.muted ? \"soundOff\" : \"soundOn\"));\n }\n\n function togglePlayback() {\n if (video.paused) playVideo(video);\n else video.pause();\n }\n\n video.addEventListener(\"play\", syncPlayback);\n video.addEventListener(\"pause\", syncPlayback);\n video.addEventListener(\"volumechange\", syncSound);\n // Without the video, the cover stays and there is nothing to control.\n video.addEventListener(\"error\", () => {\n toggle.remove();\n sound.remove();\n delete player.dataset.paused;\n });\n\n toggle.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n togglePlayback();\n });\n sound.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n video.muted = !video.muted;\n });\n card.addEventListener(\"click\", () => {\n if (video.isConnected) togglePlayback();\n });\n\n syncPlayback();\n syncSound();\n card.append(toggle, sound);\n}\n\n/**\n * The Story player. It opens as the mini player (see showPlayer); expand\n * switches to the expanded view, a modal dialog, and back. Clicking the\n * backdrop of the expanded view or pressing Escape in it closes the player.\n * The video starts muted (see playPlayer).\n */\nexport function createPlayer(story: StoryMedia, options: PlayerOptions) {\n const player = document.createElement(\"dialog\");\n player.className = \"player\";\n player.setAttribute(\"popover\", \"manual\");\n player.setAttribute(\"aria-label\", options.label);\n\n const frame = document.createElement(\"div\");\n frame.className = \"player-frame\";\n\n const controls = document.createElement(\"div\");\n controls.className = \"player-controls\";\n\n const expand = createButton(\"player-expand\", options.expandLabel, \"expand\");\n const close = createButton(\"player-close\", options.closeLabel, \"close\");\n controls.append(expand, close);\n\n let expanded = false;\n\n // A dialog can't be shown as a popover and as a modal at the same time, so\n // switching modes hides it first, the same way it was shown.\n function hide() {\n if (!expanded && supportsPopover(player)) player.hidePopover();\n else player.close();\n }\n\n expand.addEventListener(\"click\", () => {\n hide();\n expanded = !expanded;\n player.toggleAttribute(\"data-expanded\", expanded);\n player.dataset.switched = \"\";\n expand.setAttribute(\n \"aria-label\",\n expanded ? options.collapseLabel : options.expandLabel,\n );\n expand.replaceChildren(createIcon(expanded ? \"collapse\" : \"expand\"));\n\n if (expanded) player.showModal();\n else showPlayer(player);\n expand.focus();\n });\n\n close.addEventListener(\"click\", options.onClose);\n\n // Clicks on the backdrop of the expanded view reach the dialog itself.\n player.addEventListener(\"click\", (event) => {\n if (expanded && event.target === player) options.onClose();\n });\n\n // Escape on a modal dialog would only hide it: close the player instead.\n player.addEventListener(\"cancel\", (event) => {\n event.preventDefault();\n options.onClose();\n });\n\n const card = createCard(story);\n const video = card.querySelector(\"video\");\n if (video) addVideoControls(player, card, video, options);\n\n frame.append(controls, card);\n player.append(frame);\n return player;\n}\n","import { cardStyles, createCard, playVideo } from \"../components/card\";\nimport {\n createPlayer,\n playerStyles,\n playPlayer,\n showPlayer,\n} from \"../components/player\";\nimport type { StoryMedia } from \"../types\";\n\nexport const TAG_NAME = \"vtex-ads-story\";\n\n// Keeps the module importable where HTMLElement doesn't exist (SSR, Node).\nconst BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;\n\nconst styles = `\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n ${cardStyles}\n ${playerStyles}\n`;\n\n// Temporary: rendered until the element reads Stories from the ad API.\nconst PLACEHOLDER_STORY: StoryMedia = {\n poster_url: \"https://dummyimage.com/1080x1920/e31c57/fff\",\n media_url: \"https://samplelib.com/mp4/sample-10s-vp9.mp4\",\n};\n\n// Temporary: fixed texts until the store can set them by attribute.\nconst LABELS = {\n watch: \"Assistir vídeo\",\n player: \"Vídeo\",\n expand: \"Expandir vídeo\",\n collapse: \"Reduzir vídeo\",\n close: \"Fechar vídeo\",\n play: \"Reproduzir vídeo\",\n pause: \"Pausar vídeo\",\n soundOn: \"Ativar som\",\n soundOff: \"Desativar som\",\n};\n\nexport class VtexAdsStoryElement extends BaseElement {\n private player: HTMLDialogElement | null = null;\n\n private readonly onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") this.closePlayer();\n };\n\n private render() {\n const container = this.shadowRoot?.querySelector(\".root\");\n if (!container) return;\n\n container.replaceChildren(\n createCard(PLACEHOLDER_STORY, {\n label: LABELS.watch,\n soundOnLabel: LABELS.soundOn,\n soundOffLabel: LABELS.soundOff,\n onSelect: () => this.openPlayer(),\n }),\n );\n }\n\n private cardVideo() {\n return this.shadowRoot?.querySelector<HTMLVideoElement>(\n \".root .card video\",\n );\n }\n\n private openPlayer() {\n if (this.player || !this.shadowRoot) return;\n\n this.player = createPlayer(PLACEHOLDER_STORY, {\n label: LABELS.player,\n expandLabel: LABELS.expand,\n collapseLabel: LABELS.collapse,\n closeLabel: LABELS.close,\n playLabel: LABELS.play,\n pauseLabel: LABELS.pause,\n soundOnLabel: LABELS.soundOn,\n soundOffLabel: LABELS.soundOff,\n onClose: () => this.closePlayer(),\n });\n this.shadowRoot.append(this.player);\n showPlayer(this.player);\n // While the player is open, the card behind it stops on its cover.\n this.cardVideo()?.pause();\n playPlayer(this.player);\n document.addEventListener(\"keydown\", this.onKeyDown);\n\n this.player.querySelector<HTMLElement>(\".player-close\")?.focus();\n }\n\n // `removed`: the element is leaving the page, so there is no card to give\n // focus back to or to resume playing (it would play out of sight).\n private closePlayer({ removed = false } = {}) {\n if (!this.player) return;\n\n document.removeEventListener(\"keydown\", this.onKeyDown);\n this.player.remove();\n this.player = null;\n if (removed) return;\n\n const video = this.cardVideo();\n if (video?.autoplay) playVideo(video);\n\n this.shadowRoot?.querySelector<HTMLElement>(\".root .card-open\")?.focus();\n }\n\n connectedCallback() {\n if (!this.shadowRoot) {\n const root = this.attachShadow({ mode: \"open\" });\n root.innerHTML = `<style>${styles}</style><div class=\"root\"></div>`;\n }\n\n this.render();\n }\n\n disconnectedCallback() {\n this.closePlayer({ removed: true });\n }\n}\n\n// Types `document.createElement(\"vtex-ads-story\")` and `querySelector` results\n// as VtexAdsStoryElement in any TypeScript project, no framework needed.\ndeclare global {\n interface HTMLElementTagNameMap {\n \"vtex-ads-story\": VtexAdsStoryElement;\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;;;ACaO,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,SAAS,WAAW,MAAgB;AACzC,QAAM,WAAW,SAAS,cAAc,UAAU;AAClD,WAAS,YAAY,MAAM,IAAI;AAE/B,QAAM,MAAM,SAAS,QAAQ;AAC7B,MAAI,UAAU,IAAI,MAAM;AACxB,MAAI,aAAa,eAAe,MAAM;AACtC,MAAI,aAAa,aAAa,OAAO;AACrC,SAAO;AACT;;;AChCO,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,EAAE,MAAM,OAAO,CAAC;AAC/C,WAAK,YAAY,UAAU,MAAM;AAAA,IACnC;AAEA,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,uBAAuB;AACrB,SAAK,YAAY,EAAE,SAAS,KAAK,CAAC;AAAA,EACpC;AACF;AAUO,SAAS,uBAAuB;AACrC,MAAI,OAAO,mBAAmB,YAAa;AAC3C,MAAI,eAAe,IAAI,QAAQ,EAAG;AAElC,iBAAe,OAAO,UAAU,mBAAmB;AACrD;","names":["_a","_a"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
declare const TAG_NAME = "vtex-ads-story";
|
|
2
2
|
declare const BaseElement: typeof HTMLElement;
|
|
3
3
|
declare class VtexAdsStoryElement extends BaseElement {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
set name(value: string);
|
|
4
|
+
private player;
|
|
5
|
+
private readonly onKeyDown;
|
|
7
6
|
private render;
|
|
7
|
+
private cardVideo;
|
|
8
|
+
private openPlayer;
|
|
9
|
+
private closePlayer;
|
|
8
10
|
connectedCallback(): void;
|
|
9
|
-
|
|
10
|
-
attributeChangedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
11
12
|
}
|
|
12
13
|
declare global {
|
|
13
14
|
interface HTMLElementTagNameMap {
|
package/dist/cjs/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react.ts"],"sourcesContent":["/**\n * React JSX types for <vtex-ads-story>. Types only: the JS output is empty.\n *\n * Opt in once per project, so non-React projects never need @types/react:\n *\n * import type {} from \"@vtex/ads-stories/react\";\n *\n * or add \"@vtex/ads-stories/react\" to `compilerOptions.types` in tsconfig.\n */\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\nimport type { VtexAdsStoryElement } from \"./story\";\n\nexport type VtexAdsStoryProps = DetailedHTMLProps<\n HTMLAttributes<VtexAdsStoryElement>,\n VtexAdsStoryElement\n
|
|
1
|
+
{"version":3,"sources":["../../src/react.ts"],"sourcesContent":["/**\n * React JSX types for <vtex-ads-story>. Types only: the JS output is empty.\n *\n * Opt in once per project, so non-React projects never need @types/react:\n *\n * import type {} from \"@vtex/ads-stories/react\";\n *\n * or add \"@vtex/ads-stories/react\" to `compilerOptions.types` in tsconfig.\n */\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\nimport type { VtexAdsStoryElement } from \"./story\";\n\nexport type VtexAdsStoryProps = DetailedHTMLProps<\n HTMLAttributes<VtexAdsStoryElement>,\n VtexAdsStoryElement\n>;\n\ndeclare module \"react\" {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n \"vtex-ads-story\": VtexAdsStoryProps;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/cjs/react.d.cts
CHANGED
|
@@ -11,10 +11,7 @@ import { VtexAdsStoryElement } from './index.cjs';
|
|
|
11
11
|
* or add "@vtex/ads-stories/react" to `compilerOptions.types` in tsconfig.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
type VtexAdsStoryProps = DetailedHTMLProps<HTMLAttributes<VtexAdsStoryElement>, VtexAdsStoryElement
|
|
15
|
-
/** Name shown in the greeting; falls back to "world" when empty. */
|
|
16
|
-
name?: string;
|
|
17
|
-
};
|
|
14
|
+
type VtexAdsStoryProps = DetailedHTMLProps<HTMLAttributes<VtexAdsStoryElement>, VtexAdsStoryElement>;
|
|
18
15
|
declare module "react" {
|
|
19
16
|
namespace JSX {
|
|
20
17
|
interface IntrinsicElements {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
declare const TAG_NAME = "vtex-ads-story";
|
|
2
2
|
declare const BaseElement: typeof HTMLElement;
|
|
3
3
|
declare class VtexAdsStoryElement extends BaseElement {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
set name(value: string);
|
|
4
|
+
private player;
|
|
5
|
+
private readonly onKeyDown;
|
|
7
6
|
private render;
|
|
7
|
+
private cardVideo;
|
|
8
|
+
private openPlayer;
|
|
9
|
+
private closePlayer;
|
|
8
10
|
connectedCallback(): void;
|
|
9
|
-
|
|
10
|
-
attributeChangedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
11
12
|
}
|
|
12
13
|
declare global {
|
|
13
14
|
interface HTMLElementTagNameMap {
|