|
| 1 | +// @ts-check |
| 2 | + |
| 3 | +import {country, isHCountry} from './locales.js'; |
| 4 | +import { |
| 5 | + createHTMLElement as html, |
| 6 | + $, |
| 7 | +} from './utils.js'; |
| 8 | +import {clicker} from './stats.js'; |
| 9 | + |
| 10 | +const jumpURL = 'https://apps.apple.com/us/app/money-jump-13th-ave-madness/id6744975454'; |
| 11 | +const jumpTryURL = 'https://darkreader.ltd/moneyjump/try/'; |
| 12 | + |
| 13 | +const htmlText = ` |
| 14 | +<section class="container"> |
| 15 | + <i class="jump-icon"></i> |
| 16 | + <section class="content"> |
| 17 | + <div class="label">Celebrate <span class="dark-reader">Halloween</span> with us</div> |
| 18 | + <div class="description"> |
| 19 | + Try the funny game that we made! |
| 20 | + </div> |
| 21 | + <div class="links"> |
| 22 | + <a class="badge-link" href="${jumpURL}" target="_blank" rel="noopener" data-s="jump-top-badge"> |
| 23 | + <img src="/images/app-store-badge.svg"> |
| 24 | + </a> |
| 25 | + <a class="text-link" href="${jumpTryURL}" target="_blank" rel="noopener" data-s="jump-try-text"> |
| 26 | + Play in browser |
| 27 | + </a> |
| 28 | + </div> |
| 29 | + </section> |
| 30 | +</section>`; |
| 31 | + |
| 32 | +const cssText = ` |
| 33 | +.container { |
| 34 | + align-items: center; |
| 35 | + display: flex; |
| 36 | + flex-direction: row; |
| 37 | + gap: 1rem; |
| 38 | + justify-content: center; |
| 39 | + padding-top: 0; |
| 40 | +} |
| 41 | +:host { |
| 42 | + container-type: inline-size; |
| 43 | + width: 100%; |
| 44 | +} |
| 45 | +.jump-icon { |
| 46 | + background-image: url(/images/icons/icon-jump-256.png); |
| 47 | + background-position: center; |
| 48 | + background-repeat: no-repeat; |
| 49 | + background-size: cover; |
| 50 | + display: inline-block; |
| 51 | + height: 8rem; |
| 52 | + margin-top: 0.5rem; |
| 53 | + width: 8rem; |
| 54 | +} |
| 55 | +.content { |
| 56 | + color: var(--color-text); |
| 57 | + display: flex; |
| 58 | + flex-direction: column; |
| 59 | + gap: 0.5rem; |
| 60 | +} |
| 61 | +.label { |
| 62 | + color: var(--color-highlight); |
| 63 | + font-size: 1.35rem; |
| 64 | + font-weight: bold; |
| 65 | + line-height: 1; |
| 66 | + -webkit-text-stroke: 0.0625rem; |
| 67 | +} |
| 68 | +.description { |
| 69 | + font-size: 1.1rem; |
| 70 | + font-weight: bold; |
| 71 | +} |
| 72 | +.links { |
| 73 | + align-items: center; |
| 74 | + display: flex; |
| 75 | + flex-direction: row; |
| 76 | + gap: 0.75rem; |
| 77 | +} |
| 78 | +.badge-link { |
| 79 | + display: inline-block; |
| 80 | +} |
| 81 | +.badge-link img { |
| 82 | + display: inline-block; |
| 83 | + width: 10rem; |
| 84 | +} |
| 85 | +.text-link { |
| 86 | + color: var(--color-text); |
| 87 | + transition: color 250ms; |
| 88 | +} |
| 89 | +.text-link:hover { |
| 90 | + color: white; |
| 91 | +} |
| 92 | +@container (width >= 28rem) { |
| 93 | +} |
| 94 | +`; |
| 95 | + |
| 96 | +class JumpTopShortElement extends HTMLElement { |
| 97 | + constructor() { |
| 98 | + super(); |
| 99 | + const shadowRoot = this.attachShadow({mode: 'open'}); |
| 100 | + |
| 101 | + const style = html('style', {}, cssText); |
| 102 | + shadowRoot.append(style); |
| 103 | + style.insertAdjacentHTML('afterend', htmlText); |
| 104 | + |
| 105 | + if (this.hasAttribute('side')) { |
| 106 | + shadowRoot.querySelectorAll('[data-s]').forEach((node) => { |
| 107 | + const s = node.getAttribute('data-s') ?? ''; |
| 108 | + node.setAttribute('data-s', s.replace('-top-', '-side-')); |
| 109 | + }); |
| 110 | + } |
| 111 | + |
| 112 | + $(shadowRoot).find('[data-s]').each((node) => clicker(node, node.getAttribute('data-s') ?? '')); |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +customElements.define('darkreader-jump-top-short', JumpTopShortElement); |
0 commit comments