Skip to content

Commit

Permalink
Publish 2024-06-06
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderby committed Jun 6, 2024
1 parent 59a800d commit 2b5c017
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 112 deletions.
30 changes: 30 additions & 0 deletions elements/locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,33 @@ export const country = (() => {
// const hCountries = ['US', 'GB', 'CA', 'AU', 'DE', 'NL', 'FR'];
// export const isHCountry = hCountries.includes(country);
export const isHCountry = true;

export const isEUCountry = [
'AT',
'BE',
'BG',
'CY',
'CZ',
'DK',
'DE',
'EE',
'EL',
'ES',
'FI',
'FR',
'HR',
'IE',
'IT',
'LT',
'LU',
'LV',
'HU',
'MT',
'NL',
'PL',
'PT',
'RO',
'SE',
'SI',
'SK',
].includes(country);
191 changes: 191 additions & 0 deletions elements/pay-tiers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
// @ts-check

import {clicker} from './stats.js';
import {
createHTMLElement as html,
} from './utils.js';

const payURL = '/support-us';

const htmlText = `
<section class="pr">
<h2 class="heading">Pay for using <span class="heading__darkreader">Dark Reader</span></h4>
<div class="tiers">
<label class="tier">
<input type="radio" name="tier" value="regular" checked>
<span class="tier__desc">Regular use</span>
<span class="tier__connect"></span>
<span class="tier__price">$4.99</span>
</label>
<label class="tier">
<input type="radio" name="tier" value="discount">
<span class="tier__desc">Occasional use</span>
<span class="tier__connect"></span>
<span class="tier__price">$1.99</span>
</label>
<label class="tier">
<input type="radio" name="tier" value="corporate">
<span class="tier__desc">Corporate users</span>
<span class="tier__connect"></span>
<span class="tier__price">$9.99/yr</span>
</label>
</div>
<a class="button-link" href="${payURL}" target="_blank" rel="noopener">
<span class="button-link__text">Proceed</span>
</a>
</section>
`;

const cssText = `
:host {
width: 16rem;
}
.pr {
width: 100%;
}
.heading {
color: var(--color-highlight);
font-size: 1.05rem;
font-weight: bold;
margin: 0;
position: relative;
text-align: left;
-webkit-text-stroke: 0.0625rem;
text-transform: uppercase;
white-space: nowrap;
width: 100%;
}
.heading__darkreader {
}
/*
.heading::before {
background-image: url("/images/icon-256.png");
background-position: center;
background-repeat: no-repeat;
background-size: contain;
content: "";
display: inline-block;
height: 2.75rem;
left: 0;
position: absolute;
top: 0;
width: 2.75rem;
}
*/
.tiers {
align-items: stretch;
display: flex;
flex-direction: column;
gap: 0.25rem;
width: 100%;
}
.tier {
align-items: center;
cursor: pointer;
display: inline-flex;
flex-direction: row;
gap: 0.25rem;
position: relative;
width: 100%;
}
.tier input {
display: none;
}
.tier::before {
background-color: transparent;
border: 1px solid var(--color-control);
border-radius: 50%;
box-sizing: border-box;
content: "";
display: inline-block;
flex: none;
height: 1rem;
line-height: 1rem;
text-align: center;
width: 1rem;
}
.tier:has(:checked)::before {
background-color: var(--color-control);
}
.tier:has(:checked)::after {
background-color: transparent;
border-left: 2px solid white;
border-bottom: 2px solid white;
content: "";
flex: none;
height: 0.25rem;
left: 0.175rem;
position: absolute;
top: 0.375rem;
transform-origin: 50% 50%;
transform: rotate(-45deg);
width: 0.5rem;
}
.tier:has(:checked) {
color: white;
}
.tier__desc {
display: inline-block;
flex: none;
}
.tier__connect {
border-bottom: 1px dotted var(--color-text);
display: inline-block;
flex: auto;
height: 0;
opacity: 0.5;
width: 100%;
}
.tier__price {
display: inline-block;
flex: none;
font-weight: bold;
justify-self: flex-end;
}
.button-link {
align-items: center;
background-color: var(--color-control);
border-radius: 1.25rem;
box-shadow: 0 0 0 0.0625rem hsla(0, 0%, 100%, 0), 0 0 0 var(--color-text);
color: white;
display: inline-flex;
flex-direction: row;
height: 2.5rem;
justify-content: center;
margin-top: 0.25rem;
text-decoration: none;
transition: box-shadow 250ms;
width: 100%
}
.button-link:hover {
box-shadow: 0 0 0 0.0625rem hsla(0, 0%, 100%, 1), 0 0 0.75rem var(--color-text);
}
.button-link__text {
display: inline-block;
font-size: 1.25rem;
font-weight: bold;
-webkit-text-stroke: 0.0625rem;
text-transform: uppercase;
transform: skewX(-10deg);
}
`;

class PayTiersElement extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({mode: 'open'});
const style = html('style', {}, cssText);
shadowRoot.append(style);
style.insertAdjacentHTML('afterend', htmlText);

const buttonLink = /** @type {HTMLAnchorElement} */(shadowRoot.querySelector('.button-link'));
clicker(buttonLink, 'd-side-btn');

shadowRoot.querySelector('.tiers')?.addEventListener('change', () => {
const {value} = /** @type {HTMLInputElement} */(shadowRoot.querySelector('[name="tier"]:checked'));
buttonLink.href = `${payURL}#tier-${value}`;
});
}
}

customElements.define('darkreader-pay-tiers', PayTiersElement);
41 changes: 13 additions & 28 deletions elements/sponsors-right.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @ts-check

import './sponsors-graph.js';
import {isHCountry} from './locales.js';
import './pay-tiers.js';
import {country, isEUCountry, isHCountry} from './locales.js';
import {clicker} from './stats.js';
import {
createHTMLElement as html,
Expand All @@ -15,7 +16,6 @@ const isEdge = navigator.userAgent.includes('Edg');
const isSafari = navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrom');
const language = navigator.language || 'en';

const outlineFilter = 'drop-shadow(0.0625rem 0 0 hsla(0, 0%, 100%, 1)) drop-shadow(-0.0625rem 0 0 hsla(0, 0%, 100%, 1)) drop-shadow(0 0.0625rem 0 hsla(0, 0%, 100%, 1)) drop-shadow(0 -0.0625rem 0 hsla(0, 0%, 100%, 1))';
const buttonIcon = `<span class="b-icon${isEdge ? ' b-icon--edge' : isSafari ? ' b-icon--safari' : ''}"></span>`;

const htmlText = `
Expand All @@ -30,7 +30,7 @@ const htmlText = `
</span>
</a>
<a class="text-link ht" href="${hnURL}" target="_blank" rel="noopener">
Save <span class="ht-usd">$$$</span> when you shop online
Save <span class="ht-currency">$$$</span> when you shop online
</a>
<a class="button-link hb" href="${hnURL}" target="_blank" rel="noopener">
${buttonIcon}
Expand Down Expand Up @@ -75,30 +75,7 @@ const htmlText = `
-->
</section>
<section class="pr">
<h4 class="pr-heading">Pay for using Dark Reader</h4>
<div class="pr-rates">
<label class="pr-rate">
<input type="radio" name="rate" value="rate-regular" checked>
<span class="pr-rate-desc">Regular use</span>
<span class="pr-rate-connect"></span>
<span class="pr-rate-price">$4.99</span>
</label>
<label class="pr-rate">
<input type="radio" name="rate" value="rate-reduced">
<span class="pr-rate-desc">Occasional use</span>
<span class="pr-rate-connect"></span>
<span class="pr-rate-price">$1.99</span>
</label>
<label class="pr-rate">
<input type="radio" name="rate" value="rate-corp">
<span class="pr-rate-desc">Corporate users</span>
<span class="pr-rate-connect"></span>
<span class="pr-rate-price">$9.99/yr</span>
</label>
</div>
<a class="button-link pb" href="${payURL}" target="_blank" rel="noopener">
<span class="button-link-text">Proceed</span>
</a>
<darkreader-pay-tiers></darkreader-pay-tiers>
</section>
<section class="nr">
<h2 class="nr-heading">Not sponsored by</h2>
Expand Down Expand Up @@ -134,6 +111,8 @@ const htmlText = `
</section>
`;

const outlineFilter = 'drop-shadow(0.0625rem 0 0 hsla(0, 0%, 100%, 1)) drop-shadow(-0.0625rem 0 0 hsla(0, 0%, 100%, 1)) drop-shadow(0 0.0625rem 0 hsla(0, 0%, 100%, 1)) drop-shadow(0 -0.0625rem 0 hsla(0, 0%, 100%, 1))';

const cssText = `
a {
color: var(--color-text);
Expand Down Expand Up @@ -250,7 +229,7 @@ section {
text-align: center;
width: 100%;
}
.ht-usd {
.ht-currency {
color: #53b378;
}
.hb {
Expand Down Expand Up @@ -535,6 +514,12 @@ class BackersSideElement extends HTMLElement {
clicker(qs('.nr-logo-github'), 'gh-side-ns');

shadowRoot.host.classList.toggle('c-h', isHCountry);
const currency = qs('.ht-currency');
if (isEUCountry) {
currency.textContent = '€€€';
} else if (country === 'GB') {
currency.textContent = '£££';
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions elements/sponsors-top.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const appleHTMLText = `
const uaSupportHTMLText = `
<div class="support-ua">
<a href="https://bank.gov.ua/en/about/humanitarian-aid-to-ukraine" target="_blank" rel="noopener">
<strong>Support Ukraine</strong>
<strong>Humanitarian aid to Ukraine</strong>
(official link)
</a>
</div>
Expand Down Expand Up @@ -139,8 +139,8 @@ a:hover {
flex-direction: row;
justify-content: stretch;
}
.up + .up {
border-top: 0.0625rem solid var(--color-control);
.up:not(:last-child) {
border-bottom: 0.0625rem solid var(--color-control);
}
.up-logo-link {
box-shadow: 0 0 0 0.0625rem hsla(0, 0%, 100%, 0), 0 0 0 var(--color-text);
Expand Down
8 changes: 4 additions & 4 deletions support-us/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<meta property="og:image" content="https://darkreader.org/images/icon-256.png">
<meta property="og:description" content="Support our work on Dark Reader browser extension.">
<link rel="stylesheet" href="style.css">
<script src="script.js" defer></script>
<script src="script.js" type="module"></script>
</head>

<body>
Expand All @@ -28,15 +28,15 @@ <h2>

<p class="radio-group tiers">
<label class="radio-button">
<input type="radio" name="tier" value="tier-regular" checked>
<input type="radio" name="tier" value="regular" checked>
Regular User
</label>
<label class="radio-button">
<input type="radio" name="tier" value="tier-corporate">
<input type="radio" name="tier" value="corporate">
Corporate Users
</label>
<label class="radio-button">
<input type="radio" name="tier" value="tier-discount">
<input type="radio" name="tier" value="discount">
Discount %
</label>
</p>
Expand Down
Loading

0 comments on commit 2b5c017

Please sign in to comment.