mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 17:26:24 +00:00
Polish native cloud plans and trial presentation [skip ci]
This commit is contained in:
+57
-105
@@ -151,12 +151,11 @@ const I = {
|
||||
globe: 'M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M2 12h20M12 2a15 15 0 0 1 0 20 15 15 0 0 1 0-20',
|
||||
image:
|
||||
'M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM8.5 10a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zM21 15l-5-5L5 21',
|
||||
spark: 'M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z',
|
||||
mail: 'M4 5h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM3 7l9 6 9-6',
|
||||
people:
|
||||
'M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75',
|
||||
shield: 'M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10',
|
||||
check: 'M20 6 9 17l-5-5',
|
||||
cross: 'M6 6l12 12M18 6 6 18',
|
||||
lock: 'M6 11h12a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM8 11V8a4 4 0 0 1 8 0v3',
|
||||
key: 'M7.5 20a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9zM10.7 12.3 21 2M16 7l3 3M14 9l2 2',
|
||||
alert: 'M12 21.5a9.5 9.5 0 1 0 0-19 9.5 9.5 0 0 0 0 19zM12 7.5v5.5M12 16.5h.01',
|
||||
@@ -315,7 +314,7 @@ function showWelcome(opts: { back?: boolean } = {}): void {
|
||||
const perk = (glyph: string, title: string, sub: string) =>
|
||||
el('div', {}, el('i', {}, icon(glyph, 17)), el('span', {}, el('b', {}, title), el('small', {}, sub)));
|
||||
|
||||
const trial = el('span', { className: 'trial-badge', hidden: true }, icon(I.spark, 12), t('native.trial.badge'));
|
||||
const trial = el('span', { className: 'trial-badge', hidden: true }, t('native.trial.badge'));
|
||||
const discover = el('button', { type: 'button', className: 'cta discover' }, t('native.welcome.discover'), trial);
|
||||
discover.addEventListener('click', () => {
|
||||
void tap();
|
||||
@@ -668,7 +667,7 @@ interface CloudPlan {
|
||||
yearlyCents?: number;
|
||||
currency?: 'EUR' | 'USD';
|
||||
aiDocuments: number;
|
||||
aiDocumentLimit?: 0 | null;
|
||||
aiDocumentLimit?: number | null;
|
||||
aiAssistant?: 'planned' | 'included' | 'unavailable';
|
||||
bookingMailImport?: boolean;
|
||||
storageGb: number;
|
||||
@@ -685,7 +684,7 @@ const SAMPLE_PLANS: CloudPlan[] = [
|
||||
{
|
||||
id: 'start',
|
||||
name: 'Start',
|
||||
monthlyCents: 499,
|
||||
monthlyCents: 599,
|
||||
yearlyCents: 4899,
|
||||
currency: 'USD',
|
||||
aiDocuments: 0,
|
||||
@@ -695,7 +694,7 @@ const SAMPLE_PLANS: CloudPlan[] = [
|
||||
{
|
||||
id: 'plus',
|
||||
name: 'Plus',
|
||||
monthlyCents: 999,
|
||||
monthlyCents: 1199,
|
||||
yearlyCents: 9900,
|
||||
currency: 'USD',
|
||||
aiDocuments: 100,
|
||||
@@ -793,22 +792,32 @@ async function loadOffer(list: CloudPlans): Promise<Offer> {
|
||||
};
|
||||
}
|
||||
|
||||
/** The plan the picker starts on and marks: the smallest one with AI documents, the one most trips want. */
|
||||
function recommendedPlan(plans: CloudPlan[]): CloudPlan | undefined {
|
||||
return plans.find((p) => p.aiDocuments > 0) ?? plans[0];
|
||||
}
|
||||
function planFeatures(plan: CloudPlan): HTMLLIElement[] {
|
||||
const row = (label: string, value: string, glyph: string, unavailable = false) =>
|
||||
el(
|
||||
'li',
|
||||
{ className: unavailable ? 'spec off' : 'spec' },
|
||||
el('i', {}, icon(glyph, 16)),
|
||||
el('b', {}, label),
|
||||
el('bdi', {}, value)
|
||||
);
|
||||
const feature = (label: string, included: boolean) =>
|
||||
row(
|
||||
label,
|
||||
t(included ? 'native.plans.included' : 'native.plans.notIncluded'),
|
||||
included ? I.check : I.cross,
|
||||
!included
|
||||
);
|
||||
|
||||
/** The kind of trip each plan is for: a weekend away, a round trip, a long journey, the whole world. */
|
||||
const TRIPS: Record<string, { titleKey: string; textKey: string }> = {
|
||||
start: { titleKey: 'native.trip.start.title', textKey: 'native.trip.start.text' },
|
||||
basis: { titleKey: 'native.trip.basis.title', textKey: 'native.trip.basis.text' },
|
||||
plus: { titleKey: 'native.trip.plus.title', textKey: 'native.trip.plus.text' },
|
||||
pro: { titleKey: 'native.trip.pro.title', textKey: 'native.trip.pro.text' },
|
||||
};
|
||||
/** A plan's trip, its title and one line; a plan the app does not know keeps its own name. */
|
||||
function tripOf(plan: CloudPlan): { title: string; text: string } {
|
||||
const trip = TRIPS[plan.id];
|
||||
return trip ? { title: t(trip.titleKey), text: t(trip.textKey) } : { title: plan.name, text: '' };
|
||||
const storage = plan.storageGb >= 1000 ? `${count(plan.storageGb / 1000)} TB` : `${count(plan.storageGb)} GB`;
|
||||
const aiDocuments = plan.aiDocumentLimit === null || (plan.aiDocumentLimit ?? plan.aiDocuments) > 0;
|
||||
return [
|
||||
row(t('native.plans.storage'), storage, I.image),
|
||||
feature(t('native.plans.aiLabel'), aiDocuments),
|
||||
feature(t('native.plans.assistant'), plan.aiAssistant === 'included'),
|
||||
feature(t('native.plans.mailImport'), plan.bookingMailImport === true),
|
||||
row(t('native.plans.unlimitedSub'), t('native.plans.unlimited'), I.people),
|
||||
];
|
||||
}
|
||||
|
||||
function per(interval: 'month' | 'year'): string {
|
||||
@@ -828,7 +837,7 @@ let resumeRestore: (() => void) | null = null;
|
||||
let watchingTransactions = false;
|
||||
/** Where the camera stood on the plan chosen last, for the screens that follow it. */
|
||||
let chosenCamera: Camera = cameraForPlan(1);
|
||||
/** The plan chosen last, so coming back to the plans finds it still chosen. */
|
||||
/** Restore a choice when returning from setup. A fresh entry opens Plus. */
|
||||
let chosenPlanId: string | null = null;
|
||||
let chosenInterval: 'month' | 'year' = 'month';
|
||||
|
||||
@@ -898,9 +907,6 @@ function showPlans(opts: { back?: boolean } = {}): void {
|
||||
|
||||
const tiers = el('div', { className: 'tiers', role: 'radiogroup', hidden: true });
|
||||
tiers.setAttribute('aria-label', t('native.plans.title'));
|
||||
const title = el('h1', {});
|
||||
const text = el('p', {});
|
||||
const trip = el('div', { className: 'trip' }, title, text);
|
||||
|
||||
const monthBtn = el('button', { type: 'button', role: 'radio' }, t('native.plans.monthly'));
|
||||
const yearBtn = el('button', { type: 'button', role: 'radio' }, t('native.plans.yearly'));
|
||||
@@ -919,18 +925,18 @@ function showPlans(opts: { back?: boolean } = {}): void {
|
||||
const equals = el('div', { className: 'equals' });
|
||||
const trial = el('p', { className: 'trial-price', hidden: true });
|
||||
const pricebox = el('div', { className: 'pricebox' }, cycle, price, equals, trial);
|
||||
const specs = el('div', { className: 'specs' });
|
||||
const specs = el('ul', { className: 'specs', role: 'list' });
|
||||
const foot = el('div', { className: 'pad', hidden: true });
|
||||
const legal = el('p', { className: 'legal' });
|
||||
|
||||
const loading = el('div', { className: 'loading' }, el('span', { className: 'spin' }));
|
||||
const details = el('div', { className: 'stack', hidden: true }, trip, pricebox, specs);
|
||||
const details = el('div', { className: 'stack', hidden: true }, pricebox, specs);
|
||||
const choose = el('button', { type: 'button', className: 'cta', hidden: true });
|
||||
const dock = el('div', { className: 'dock' }, choose);
|
||||
|
||||
const screen = show(
|
||||
'plain',
|
||||
chosenCamera,
|
||||
opts.back ? chosenCamera : cameraForPlan(1),
|
||||
{
|
||||
back: () => showWelcome({ back: true }),
|
||||
content: [el('div', { className: 'pad lift' }, tiers, loading, details), foot, dock],
|
||||
@@ -977,20 +983,11 @@ function showPlans(opts: { back?: boolean } = {}): void {
|
||||
yearBtn.setAttribute('aria-checked', String(interval === 'year'));
|
||||
cycle.dataset.year = String(interval === 'year');
|
||||
|
||||
const { title: tripTitle, text: tripText } = tripOf(plan);
|
||||
const recommended = recommendedPlan(plans)?.id === plan.id;
|
||||
title.replaceChildren(
|
||||
tripTitle,
|
||||
...(recommended ? [el('span', { className: 'badge' }, t('native.plans.recommended'))] : [])
|
||||
);
|
||||
text.textContent = tripText;
|
||||
text.hidden = !tripText;
|
||||
|
||||
const { label, buyable, freeTrial } = interval === 'month' ? month : year;
|
||||
// No price yet (orders not open): the plan shows without one rather than with an empty one.
|
||||
price.hidden = !label;
|
||||
// An introductory offer states the free period and renewal price together.
|
||||
price.hidden = !label || freeTrial;
|
||||
pricePer.textContent = per(interval);
|
||||
if (label) paintPrice(label, animate);
|
||||
if (label && !freeTrial) paintPrice(label, animate);
|
||||
|
||||
// Without a price in either period (orders not open yet) the switch would choose between nothing.
|
||||
pricebox.hidden = !month.label && !year.label;
|
||||
@@ -1011,51 +1008,10 @@ function showPlans(opts: { back?: boolean } = {}): void {
|
||||
? trialCancellation()
|
||||
: t(onPlay ? 'native.plans.legalAndroid' : 'native.plans.legal');
|
||||
|
||||
const gb = plan.storageGb >= 1000 ? `${count(plan.storageGb / 1000)} TB` : `${count(plan.storageGb)} GB`;
|
||||
const notIncluded = t('native.plans.aiNone');
|
||||
const included = t('native.plans.included');
|
||||
const assistant = plan.aiAssistant === 'included';
|
||||
const tile = (glyph: string, big: string, small: string, off = false) =>
|
||||
el(
|
||||
'span',
|
||||
{ className: off ? 'spec off' : 'spec' },
|
||||
el('i', {}, icon(glyph, 17)),
|
||||
el('span', {}, el('b', {}, big), el('small', {}, small))
|
||||
);
|
||||
specs.replaceChildren(
|
||||
tile(I.image, gb, t('native.plans.storageFairUse')),
|
||||
plan.aiDocuments > 0
|
||||
? tile(
|
||||
I.spark,
|
||||
plan.aiDocumentLimit === null
|
||||
? t('native.plans.unlimited')
|
||||
: t('native.plans.aiPerMonth', { n: count(plan.aiDocuments) }),
|
||||
t('native.plans.aiLabel')
|
||||
)
|
||||
: tile(I.spark, notIncluded, t('native.plans.aiLabel'), true),
|
||||
tile(
|
||||
I.spark,
|
||||
assistant ? included : plan.aiAssistant === 'planned' ? t('native.plans.planned') : notIncluded,
|
||||
t('native.plans.assistant'),
|
||||
!assistant
|
||||
),
|
||||
tile(
|
||||
I.mail,
|
||||
plan.bookingMailImport ? included : notIncluded,
|
||||
t('native.plans.mailImport'),
|
||||
!plan.bookingMailImport
|
||||
),
|
||||
el(
|
||||
'span',
|
||||
{ className: 'spec wide' },
|
||||
el('i', {}, icon(I.people, 17)),
|
||||
el('span', {}, el('b', {}, t('native.plans.unlimited')), el('small', {}, t('native.plans.unlimitedSub'))),
|
||||
el('em', {}, t('native.plans.inEveryPlan'))
|
||||
)
|
||||
);
|
||||
specs.replaceChildren(...planFeatures(plan));
|
||||
|
||||
choose.hidden = !buyable;
|
||||
choose.textContent = t('native.plans.choose', { trip: tripTitle });
|
||||
choose.textContent = t('native.plans.choose', { plan: plan.name });
|
||||
chosenCamera = cameraForPlan(index);
|
||||
chosenPlanId = plan.id;
|
||||
chosenInterval = interval;
|
||||
@@ -1108,7 +1064,9 @@ function showPlans(opts: { back?: boolean } = {}): void {
|
||||
}
|
||||
offer = await loadOffer(list);
|
||||
plans = list.plans;
|
||||
selectedId = plans.find((p) => p.id === chosenPlanId)?.id ?? recommendedPlan(plans)?.id ?? null;
|
||||
const previousId = opts.back ? chosenPlanId : null;
|
||||
selectedId =
|
||||
plans.find((p) => p.id === previousId)?.id ?? plans.find((p) => p.id === 'plus')?.id ?? plans[0]?.id ?? null;
|
||||
tiers.replaceChildren(
|
||||
...plans.map((p) => {
|
||||
const b = el('button', { type: 'button', role: 'radio', dataset: { plan: p.id } }, p.name);
|
||||
@@ -1360,25 +1318,25 @@ function showClaim(
|
||||
void tap();
|
||||
showPlans({ back: true });
|
||||
});
|
||||
const planPrice = !priceLabel
|
||||
? null
|
||||
: opts.freeTrial
|
||||
? el('small', {}, trialPrice(priceLabel, interval))
|
||||
: el('small', { dir: 'ltr' }, `${priceLabel} ${per(interval)}`);
|
||||
const planRow = el(
|
||||
'div',
|
||||
{ className: 'plan-row' },
|
||||
el(
|
||||
'span',
|
||||
{},
|
||||
el('b', {}, plan.name),
|
||||
...(priceLabel
|
||||
? [
|
||||
opts.freeTrial
|
||||
? el('small', {}, trialPrice(priceLabel, interval))
|
||||
: el('small', { dir: 'ltr' }, `${priceLabel} ${per(interval)}`),
|
||||
]
|
||||
: [])
|
||||
),
|
||||
el('span', {}, el('b', {}, plan.name), planPrice),
|
||||
// A purchase already made is not a choice any more.
|
||||
...(bought ? [] : [change])
|
||||
);
|
||||
const error = notice('');
|
||||
const checkoutDock = el(
|
||||
'div',
|
||||
{ className: 'dock' },
|
||||
submit,
|
||||
el('p', { className: 'fine' }, opts.freeTrial ? trialCancellation() : t('native.claim.renews'))
|
||||
);
|
||||
const form = el(
|
||||
'form',
|
||||
{ className: 'pad form', noValidate: true },
|
||||
@@ -1405,15 +1363,7 @@ function showClaim(
|
||||
{
|
||||
back: () => showPlans({ back: true }),
|
||||
overlay: [card.node],
|
||||
content: [
|
||||
form,
|
||||
el(
|
||||
'div',
|
||||
{ className: 'dock' },
|
||||
submit,
|
||||
el('p', { className: 'fine' }, opts.freeTrial ? trialCancellation() : t('native.claim.renews'))
|
||||
),
|
||||
],
|
||||
content: [form, checkoutDock],
|
||||
},
|
||||
opts
|
||||
);
|
||||
@@ -1527,6 +1477,8 @@ function showClaim(
|
||||
const outcome = await iap.purchase(productIdFor(plan.id, interval), trialRenewalPrice);
|
||||
if (outcome.kind === 'offer-changed') {
|
||||
restore();
|
||||
planPrice?.remove();
|
||||
checkoutDock.hidden = true;
|
||||
setNotice(error, t('native.trial.changed'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -320,14 +320,14 @@ input {
|
||||
overflow: hidden;
|
||||
background: var(--sea);
|
||||
margin-bottom: -1px;
|
||||
height: min(300px, 36svh);
|
||||
height: max(calc(var(--safe-top) + 68px), min(252px, 30svh));
|
||||
}
|
||||
.hero.tall {
|
||||
height: min(320px, 38svh);
|
||||
}
|
||||
.hero.welcome {
|
||||
height: min(376px, 44.5svh);
|
||||
min-height: 250px;
|
||||
height: min(352px, 42svh);
|
||||
min-height: 236px;
|
||||
}
|
||||
.hero .scenery {
|
||||
position: absolute;
|
||||
@@ -529,7 +529,7 @@ input {
|
||||
}
|
||||
.push {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
min-height: clamp(10px, 2svh, 16px);
|
||||
}
|
||||
h1 {
|
||||
margin: 0;
|
||||
@@ -632,28 +632,34 @@ h1 {
|
||||
position: relative;
|
||||
padding-inline: 16px;
|
||||
}
|
||||
.trial-badge {
|
||||
position: absolute;
|
||||
inset-block-start: -10px;
|
||||
inset-inline-end: 10px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
max-inline-size: calc(100% - 20px);
|
||||
padding: 3px 8px;
|
||||
.trial-badge,
|
||||
.trial-price {
|
||||
border: 1px solid #bee3d7;
|
||||
border-radius: 999px;
|
||||
background: #e7f6ef;
|
||||
color: #195247;
|
||||
}
|
||||
.trial-badge {
|
||||
position: absolute;
|
||||
inset-block-start: 0;
|
||||
inset-inline: 0;
|
||||
inline-size: max-content;
|
||||
max-inline-size: calc(100% - 20px);
|
||||
margin-inline: auto;
|
||||
padding: 3px 8px;
|
||||
border-radius: 999px;
|
||||
box-shadow: 0 2px 6px #11182720;
|
||||
font: 700 11px/1.4 var(--text-face);
|
||||
transform: translateY(calc(-100% + 6px));
|
||||
}
|
||||
.trial-price {
|
||||
margin: 6px 12px 0;
|
||||
color: #195247;
|
||||
margin: 8px 6px 0;
|
||||
padding: 10px 6px;
|
||||
border-radius: 12px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.cta2 {
|
||||
min-height: 52px;
|
||||
@@ -742,33 +748,6 @@ h1 {
|
||||
color: var(--ink);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
.trip {
|
||||
min-width: 0;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.trip h1 {
|
||||
font-size: 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.trip p {
|
||||
margin: 6px 0 0;
|
||||
color: var(--text);
|
||||
font-size: 14px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.badge {
|
||||
font-family: var(--text-face);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
padding: 4px 10px;
|
||||
border-radius: 999px;
|
||||
background: var(--dark);
|
||||
color: #fff;
|
||||
}
|
||||
.pricebox {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -850,64 +829,52 @@ h1 {
|
||||
display: none;
|
||||
}
|
||||
.specs {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.spec {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
padding: 10px 12px;
|
||||
border-radius: 14px;
|
||||
margin: 0;
|
||||
padding: 0 12px;
|
||||
list-style: none;
|
||||
border-radius: 16px;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 0 1px var(--line);
|
||||
}
|
||||
.spec {
|
||||
display: grid;
|
||||
grid-template-columns: 28px minmax(0, 1.6fr) minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 44px;
|
||||
padding-block: 8px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.spec + .spec {
|
||||
border-block-start: 1px solid var(--line-soft);
|
||||
}
|
||||
.spec i {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
flex: none;
|
||||
border-radius: 10px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 8px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--sand);
|
||||
color: var(--dark);
|
||||
}
|
||||
.spec b {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
white-space: nowrap;
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.spec small {
|
||||
display: block;
|
||||
font-size: 11.5px;
|
||||
color: var(--muted);
|
||||
font-weight: 600;
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
.spec bdi {
|
||||
justify-self: end;
|
||||
text-align: end;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
}
|
||||
.spec.off {
|
||||
color: #626672;
|
||||
}
|
||||
.spec.off i {
|
||||
color: var(--faint);
|
||||
}
|
||||
.spec.off b {
|
||||
color: var(--muted);
|
||||
}
|
||||
.spec.wide {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.spec.wide em {
|
||||
margin-inline-start: auto;
|
||||
font-style: normal;
|
||||
font-size: 11.5px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
background: var(--sand);
|
||||
padding: 4px 9px;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
background: #f0f1f3;
|
||||
color: inherit;
|
||||
}
|
||||
.legal {
|
||||
margin: 2px 0 0;
|
||||
|
||||
Reference in New Issue
Block a user