mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 22:27:32 +00:00
feat(release): show the iOS and Android apps in the 5.2.1 notice, the account settings and the user menu
The release notice moves to 5.2.1 and gets a tile across the release column with the App Store and Google Play cards, each with a QR code that opens the store page. The headliner, intro, footnote and note texts are shorter so the tile fits, in every locale. Settings > Account shows the same store cards in its right column, except inside the native app itself. The user menu footer adds round links to Patreon, Ko-fi and Buy Me a Coffee beside Discord, left out on managed installs and in the native apps like every donation link.
This commit is contained in:
@@ -544,9 +544,9 @@ describe('Navbar styling and menu details', () => {
|
||||
|
||||
const discord = screen.getByTitle('Discord');
|
||||
fireEvent.mouseEnter(discord);
|
||||
expect(discord.style.background).toBe('rgba(88, 101, 242, 0.125)');
|
||||
expect(discord.style.background).toBe('rgba(88, 101, 242, 0.15)');
|
||||
fireEvent.mouseLeave(discord);
|
||||
expect(discord.style.background).toBe('var(--bg-tertiary)');
|
||||
expect(discord.style.background).toBe('');
|
||||
|
||||
expect(document.querySelector('img[src="/text-light.svg"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useCollapseOnOverflow } from '../../hooks/useCollapseOnOverflow'
|
||||
import { openMailInbox } from '../MailIngest/mailInboxOpener'
|
||||
import { useMailInboxShell } from '../MailIngest/useMailInboxShell'
|
||||
import MailInboxDialog from '../MailIngest/MailInboxDialog'
|
||||
import UserMenuFooter from './UserMenuFooter'
|
||||
|
||||
const ADDON_ICONS: Record<string, LucideIcon> = { CalendarDays, Briefcase, Globe, Compass, Bookmark }
|
||||
|
||||
@@ -311,7 +312,7 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
{userMenuOpen && createPortal(
|
||||
<>
|
||||
<div style={{ position: 'fixed', inset: 0, zIndex: 9998 }} role="presentation" onClick={() => setUserMenuOpen(false)} />
|
||||
<div className="trek-menu-enter w-52 rounded-xl shadow-xl border overflow-hidden bg-surface-card border-edge" style={{ position: 'fixed', top: 'var(--nav-h)', insetInlineEnd: 8, zIndex: 9999 }}>
|
||||
<div className="trek-menu-enter w-60 rounded-xl shadow-xl border overflow-hidden bg-surface-card border-edge" style={{ position: 'fixed', top: 'var(--nav-h)', insetInlineEnd: 8, zIndex: 9999 }}>
|
||||
<div className="px-4 py-3 border-b border-edge-secondary">
|
||||
<p className="text-sm font-medium text-content">{user.username}</p>
|
||||
<p className="text-xs truncate text-content-muted">{user.email}</p>
|
||||
@@ -368,23 +369,7 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
<LogOut className="w-4 h-4" />
|
||||
{t('nav.logout')}
|
||||
</button>
|
||||
{appVersion && (
|
||||
<div className="px-4 pt-2 pb-2.5 text-center border-t border-edge-secondary" style={{ marginTop: 4 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6 }}>
|
||||
<div style={{ display: 'inline-flex', alignItems: 'center', gap: 5, background: 'var(--bg-tertiary)', borderRadius: 99, padding: '4px 12px' }}>
|
||||
<img src={dark ? '/text-light.svg' : '/text-dark.svg'} alt="TREK" style={{ height: 10, opacity: 0.5 }} />
|
||||
<span style={{ fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, color: 'var(--text-faint)' }}>v{appVersion}</span>
|
||||
</div>
|
||||
<a href="https://discord.gg/NhZBDSd4qW" target="_blank" rel="noopener noreferrer"
|
||||
style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 24, height: 24, borderRadius: 99, background: 'var(--bg-tertiary)', transition: 'background 0.15s' }}
|
||||
onMouseEnter={e => e.currentTarget.style.background = '#5865F220'}
|
||||
onMouseLeave={e => e.currentTarget.style.background = 'var(--bg-tertiary)'}
|
||||
title="Discord">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="var(--text-faint)"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/></svg>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{appVersion && <UserMenuFooter appVersion={appVersion} dark={dark} managed={!!managed} />}
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// FE-MENUFOOT-001 to FE-MENUFOOT-004
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { fireEvent, render, screen } from '../../../tests/helpers/render';
|
||||
import { isNativeApp } from '../../native/platform';
|
||||
import UserMenuFooter from './UserMenuFooter';
|
||||
|
||||
vi.mock('../../native/platform', () => ({ isNativeApp: vi.fn(() => false) }));
|
||||
|
||||
function titles(): string[] {
|
||||
return [...document.querySelectorAll('a[title]')].map((a) => a.getAttribute('title') ?? '');
|
||||
}
|
||||
|
||||
describe('UserMenuFooter', () => {
|
||||
it('FE-MENUFOOT-001: shows the version and the three support links beside Discord', () => {
|
||||
render(<UserMenuFooter appVersion="5.2.1" dark={false} managed={false} />);
|
||||
expect(screen.getByText('v5.2.1')).toBeInTheDocument();
|
||||
expect(document.querySelector('img[src="/text-dark.svg"]')).not.toBeNull();
|
||||
expect(titles()).toEqual(['Patreon', 'Ko-fi', 'Buy Me a Coffee', 'Discord']);
|
||||
expect(screen.getByTitle('Ko-fi')).toHaveAttribute('href', 'https://ko-fi.com/mauriceboe');
|
||||
expect(screen.getByTitle('Buy Me a Coffee')).toHaveAttribute('href', 'https://buymeacoffee.com/mauriceboe');
|
||||
expect(screen.getByTitle('Patreon')).toHaveAttribute('href', 'https://www.patreon.com/cw/mauriceboe');
|
||||
});
|
||||
|
||||
it('FE-MENUFOOT-002: a managed install keeps only Discord', () => {
|
||||
render(<UserMenuFooter appVersion="5.2.1" dark managed />);
|
||||
expect(titles()).toEqual(['Discord']);
|
||||
expect(document.querySelector('img[src="/text-light.svg"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('FE-MENUFOOT-003: the native app shows no donation link', () => {
|
||||
vi.mocked(isNativeApp).mockReturnValueOnce(true);
|
||||
render(<UserMenuFooter appVersion="5.2.1" dark={false} managed={false} />);
|
||||
expect(titles()).toEqual(['Discord']);
|
||||
});
|
||||
|
||||
it('FE-MENUFOOT-004: hovering a link washes it in its brand colour and leaving clears it', () => {
|
||||
render(<UserMenuFooter appVersion="5.2.1" dark={false} managed={false} />);
|
||||
const kofi = screen.getByTitle('Ko-fi');
|
||||
fireEvent.mouseEnter(kofi);
|
||||
expect(kofi.style.background).toBe('rgba(255, 94, 91, 0.15)');
|
||||
fireEvent.mouseLeave(kofi);
|
||||
expect(kofi.style.background).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
import { Coffee, Heart } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { donationsShown } from '../../utils/donations';
|
||||
import { PATREON_PATH, PATREON_URL } from '../shared/PatreonIcon';
|
||||
|
||||
const DISCORD_PATH =
|
||||
'M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z';
|
||||
|
||||
interface FooterLink {
|
||||
title: string;
|
||||
href: string;
|
||||
/** The brand's colour, as a faint wash behind the icon on hover. */
|
||||
tint: string;
|
||||
icon: React.ReactNode;
|
||||
}
|
||||
|
||||
function brandSvg(path: string): React.ReactNode {
|
||||
return (
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
||||
<path d={path} />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
const DISCORD: FooterLink = {
|
||||
title: 'Discord',
|
||||
href: 'https://discord.gg/NhZBDSd4qW',
|
||||
tint: '#5865F2', // Discord's brand colour
|
||||
icon: brandSvg(DISCORD_PATH),
|
||||
};
|
||||
|
||||
const SUPPORT: FooterLink[] = [
|
||||
{
|
||||
title: 'Patreon',
|
||||
href: PATREON_URL,
|
||||
tint: '#ff424d', // Patreon's brand colour
|
||||
icon: brandSvg(PATREON_PATH),
|
||||
},
|
||||
{
|
||||
title: 'Ko-fi',
|
||||
href: 'https://ko-fi.com/mauriceboe',
|
||||
tint: '#ff5e5b', // Ko-fi's brand colour
|
||||
icon: <Heart size={12} strokeWidth={2.4} aria-hidden="true" />,
|
||||
},
|
||||
{
|
||||
title: 'Buy Me a Coffee',
|
||||
href: 'https://buymeacoffee.com/mauriceboe',
|
||||
tint: '#ffdd00', // Buy Me a Coffee's brand colour
|
||||
icon: <Coffee size={12} strokeWidth={2.4} aria-hidden="true" />,
|
||||
},
|
||||
];
|
||||
|
||||
interface Props {
|
||||
appVersion: string;
|
||||
dark: boolean;
|
||||
/** A centrally administered install: its users are not the ones to ask for support. */
|
||||
managed: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The foot of the user menu: the running version, then the round links to the
|
||||
* community and, where donations may be shown, the three ways to support TREK.
|
||||
*/
|
||||
export default function UserMenuFooter({ appVersion, dark, managed }: Props): React.ReactElement {
|
||||
const links = !managed && donationsShown() ? [...SUPPORT, DISCORD] : [DISCORD];
|
||||
return (
|
||||
<div className="mt-1 flex items-center justify-center gap-1.5 border-t border-edge-secondary px-3 pb-2.5 pt-2">
|
||||
<div className="inline-flex items-center gap-[5px] rounded-full bg-surface-tertiary px-2.5 py-1">
|
||||
<img src={dark ? '/text-light.svg' : '/text-dark.svg'} alt="TREK" className="h-2.5 opacity-50" />
|
||||
<span
|
||||
className="font-semibold text-content-faint"
|
||||
style={{ fontSize: 'calc(10px * var(--fs-scale-caption, 1))' }}
|
||||
>
|
||||
v{appVersion}
|
||||
</span>
|
||||
</div>
|
||||
{links.map((link) => (
|
||||
<a
|
||||
key={link.title}
|
||||
href={link.href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={link.title}
|
||||
aria-label={link.title}
|
||||
className="grid h-6 w-6 flex-none place-items-center rounded-full bg-surface-tertiary text-content-faint transition-colors"
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.background = `${link.tint}26`;
|
||||
e.currentTarget.style.color = 'var(--text-primary)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.background = '';
|
||||
e.currentTarget.style.color = '';
|
||||
}}
|
||||
>
|
||||
{link.icon}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// FE-COMP-ACCOUNT-APPS-001 to FE-COMP-ACCOUNT-APPS-002
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { buildSettings, buildUser } from '../../../tests/helpers/factories';
|
||||
import { server } from '../../../tests/helpers/msw/server';
|
||||
import { render, screen } from '../../../tests/helpers/render';
|
||||
import { resetAllStores, seedStore } from '../../../tests/helpers/store';
|
||||
import { isNativeApp } from '../../native/platform';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
import { useSettingsStore } from '../../store/settingsStore';
|
||||
import AccountTab from './AccountTab';
|
||||
|
||||
vi.mock('../../sync/syncTriggers', () => ({ registerSyncTriggers: vi.fn(), unregisterSyncTriggers: vi.fn() }));
|
||||
vi.mock('../../native/platform', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import('../../native/platform')>()),
|
||||
isNativeApp: vi.fn(() => false),
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
resetAllStores();
|
||||
server.use(http.get('/api/auth/app-config', () => HttpResponse.json({ version: '5.2.1', mfa_enabled: false })));
|
||||
seedStore(useAuthStore, { user: buildUser({ username: 'testuser', role: 'user' }), isAuthenticated: true });
|
||||
seedStore(useSettingsStore, { settings: buildSettings() });
|
||||
});
|
||||
|
||||
describe('AccountTab app stores', () => {
|
||||
it('FE-COMP-ACCOUNT-APPS-001: in a browser it offers both app stores with their QR codes', () => {
|
||||
render(<AccountTab />);
|
||||
expect(screen.getByText('TREK app')).toBeInTheDocument();
|
||||
expect(screen.getByText('Scan a code with your phone, then connect the app to this server.')).toBeInTheDocument();
|
||||
expect(document.querySelectorAll('a.asc-card')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('FE-COMP-ACCOUNT-APPS-002: inside the app itself there is nothing to download', () => {
|
||||
vi.mocked(isNativeApp).mockReturnValue(true);
|
||||
render(<AccountTab />);
|
||||
expect(screen.queryByText('TREK app')).toBeNull();
|
||||
expect(document.querySelector('a.asc-card')).toBeNull();
|
||||
vi.mocked(isNativeApp).mockReturnValue(false);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useId } from 'react'
|
||||
import { User, Save, Lock, KeyRound, AlertTriangle, Shield, Camera, Trash2, Copy, Download, Printer, ShieldCheck } from 'lucide-react'
|
||||
import { User, Save, Lock, KeyRound, AlertTriangle, Shield, Camera, Trash2, Copy, Download, Printer, ShieldCheck, Smartphone } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import Section from './Section'
|
||||
import PasskeysSection from './PasskeysSection'
|
||||
@@ -12,6 +12,8 @@ import { EditorField, GRID_2, INPUT, PANEL } from '../shared/dialogParts'
|
||||
import { SETTINGS_BUTTON, SETTINGS_BUTTON_DANGER, SETTINGS_BUTTON_PRIMARY, SettingRow, SettingRows, SettingsHint, StatusPill, SettingsColumns } from './settingsKit'
|
||||
import { stripTrailingSlashes, useAccountSettings } from './useAccountSettings'
|
||||
import AccountDemoLock from './AccountDemoLock'
|
||||
import AppStoreCards from '../shared/AppStoreCards'
|
||||
import { isNativeApp } from '../../native/platform'
|
||||
|
||||
/** The small turning ring a button shows while its request is on the way. */
|
||||
const SPINNER = 'h-3.5 w-3.5 flex-none animate-spin rounded-full border-2 border-current border-t-transparent'
|
||||
@@ -366,6 +368,13 @@ export default function AccountTab(): React.ReactElement {
|
||||
|
||||
{/* Passkeys */}
|
||||
<PasskeysSection demoMode={demoMode} />
|
||||
|
||||
{/* Where to get the phone app; inside the app itself there is nothing to fetch. */}
|
||||
{!isNativeApp() && (
|
||||
<Section title={t('settings.apps.title')} icon={Smartphone} hint={t('settings.apps.hint')}>
|
||||
<AppStoreCards />
|
||||
</Section>
|
||||
)}
|
||||
</>}
|
||||
/>
|
||||
</AccountDemoLock>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// FE-RN-001 to FE-RN-020
|
||||
// FE-RN-001 to FE-RN-022
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { render, screen } from '../../../tests/helpers/render';
|
||||
@@ -295,4 +295,23 @@ describe('ReleaseNoticeModal', () => {
|
||||
expect(document.querySelectorAll('.rn-vis-route-stop')).toHaveLength(5);
|
||||
expect(document.querySelector('.rn-vis-route-line')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('FE-RN-021: an apps block draws one tile with its title and both store cards', () => {
|
||||
renderModal(withRelease({ apps: { titleKey: 'rel.apps.title' } }));
|
||||
const tile = document.querySelector('.rn-apps');
|
||||
expect(tile).toHaveTextContent('rel.apps.title');
|
||||
const stores = tile?.querySelectorAll('a.asc-card') ?? [];
|
||||
expect([...stores].map((a) => a.getAttribute('href'))).toEqual([
|
||||
'https://apps.apple.com/app/id6831237775',
|
||||
'https://play.google.com/store/apps/details?id=com.liketrek.trek',
|
||||
]);
|
||||
// On the release column, which is dark in either theme.
|
||||
expect(tile?.querySelector('.asc-row')).toHaveClass('asc-dark');
|
||||
});
|
||||
|
||||
it('FE-RN-022: without an apps block there is no apps tile', () => {
|
||||
renderModal();
|
||||
expect(document.querySelector('.rn-apps')).toBeNull();
|
||||
expect(document.querySelector('.asc-card')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ArrowRight, Heart, Infinity as InfinityIcon, ShieldCheck, X } from 'luc
|
||||
import React from 'react';
|
||||
import { useTranslation } from '../../i18n/TranslationContext.js';
|
||||
import type { SystemNoticeDTO } from '../../store/systemNoticeStore.js';
|
||||
import AppStoreCards from '../shared/AppStoreCards';
|
||||
import { PATREON_PATH } from '../shared/PatreonIcon';
|
||||
import { ReleaseFeatureVisual } from './ReleaseNoticeVisuals.js';
|
||||
import './releaseNotice.css';
|
||||
@@ -127,6 +128,16 @@ export function ReleaseNoticeModal({ notice, visible, onDismiss, onCTA, onSecond
|
||||
{withSponsorLink(t(release.introKey))}
|
||||
</p>
|
||||
|
||||
{release.apps && (
|
||||
<div className="rn-apps">
|
||||
<div className="rn-feature-shine" aria-hidden="true" />
|
||||
<div className="rn-apps-text">
|
||||
<div className="rn-feature-title">{t(release.apps.titleKey)}</div>
|
||||
</div>
|
||||
<AppStoreCards tone="dark" className="rn-apps-stores" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="rn-features-head">
|
||||
<span className="rn-features-label">{t(release.featuresLabelKey)}</span>
|
||||
<span className="rn-features-rule" aria-hidden="true" />
|
||||
|
||||
@@ -647,3 +647,28 @@
|
||||
.rn-sponsor:hover {
|
||||
text-decoration-color: currentColor;
|
||||
}
|
||||
|
||||
/* ── The apps: one tile across the column, the text beside the store cards ── */
|
||||
|
||||
.rn-apps {
|
||||
position: relative;
|
||||
margin-top: 22px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 22px;
|
||||
padding: 16px 16px 16px 20px;
|
||||
border-radius: 20px;
|
||||
background: linear-gradient(160deg, oklch(1 0 0 / 0.1) 0%, oklch(1 0 0 / 0.045) 62%);
|
||||
border: 1px solid oklch(1 0 0 / 0.13);
|
||||
box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.16), 0 12px 28px -16px oklch(0 0 0 / 0.7);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.rn-apps-text { position: relative; flex: 1 1 200px; min-width: 0; }
|
||||
|
||||
.rn-apps-stores { position: relative; flex: 0 1 520px; min-width: 0; }
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.rn-apps { flex-direction: column; align-items: stretch; }
|
||||
.rn-apps-stores { flex-basis: auto; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// FE-APPSTORE-001 to FE-APPSTORE-003
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { render } from '../../../tests/helpers/render';
|
||||
import AppStoreCards from './AppStoreCards';
|
||||
|
||||
describe('AppStoreCards', () => {
|
||||
it('FE-APPSTORE-001: links both stores in a new tab, each with its QR code', () => {
|
||||
render(<AppStoreCards />);
|
||||
const cards = [...document.querySelectorAll<HTMLAnchorElement>('a.asc-card')];
|
||||
expect(cards.map((a) => a.href)).toEqual([
|
||||
'https://apps.apple.com/app/id6831237775',
|
||||
'https://play.google.com/store/apps/details?id=com.liketrek.trek',
|
||||
]);
|
||||
for (const a of cards) {
|
||||
expect(a).toHaveAttribute('target', '_blank');
|
||||
expect(a).toHaveAttribute('rel', 'noopener noreferrer');
|
||||
expect(a.querySelector('.asc-qr path')?.getAttribute('d')).toMatch(/^M0 0\.5h7/);
|
||||
}
|
||||
});
|
||||
|
||||
it('FE-APPSTORE-002: names each store and translates the lines around it', () => {
|
||||
render(<AppStoreCards />);
|
||||
const [ios, android] = document.querySelectorAll('a.asc-card');
|
||||
expect(ios).toHaveTextContent('Download on the');
|
||||
expect(ios).toHaveTextContent('App Store');
|
||||
expect(ios).toHaveTextContent('iPhone and iPad');
|
||||
expect(android).toHaveTextContent('Get it on');
|
||||
expect(android).toHaveTextContent('Google Play');
|
||||
expect(android).toHaveTextContent('Phone and tablet');
|
||||
});
|
||||
|
||||
it('FE-APPSTORE-003: the dark tone marks the row, the theme tone does not', () => {
|
||||
const { unmount } = render(<AppStoreCards tone="dark" className="x" />);
|
||||
expect(document.querySelector('.asc-row')).toHaveClass('asc-dark', 'x');
|
||||
unmount();
|
||||
render(<AppStoreCards />);
|
||||
expect(document.querySelector('.asc-row')).not.toHaveClass('asc-dark');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from '../../i18n/TranslationContext.js';
|
||||
import './appStoreCards.css';
|
||||
|
||||
/**
|
||||
* The two app stores TREK is in, each as a card with its QR code: scanned with a
|
||||
* phone it opens the store page, clicked it opens it here. The README draws the
|
||||
* same cards. The QR codes are generated from the store addresses below (qrcode,
|
||||
* margin 0, level M); regenerate them if an address changes.
|
||||
*/
|
||||
const APP_STORES = [
|
||||
{
|
||||
id: 'ios',
|
||||
href: 'https://apps.apple.com/app/id6831237775',
|
||||
store: 'App Store',
|
||||
captionKey: 'settings.apps.downloadOn',
|
||||
devicesKey: 'settings.apps.iosDevices',
|
||||
logo: 'M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701',
|
||||
qrSize: 29,
|
||||
qr: 'M0 0.5h7m2 0h1m2 0h1m2 0h5m2 0h7M0 1.5h1m5 0h1m3 0h3m4 0h1m2 0h1m1 0h1m5 0h1M0 2.5h1m1 0h3m1 0h1m1 0h1m5 0h1m1 0h1m3 0h1m1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.5h1m1 0h3m1 0h1m1 0h2m1 0h1m6 0h1m4 0h1m1 0h2M0 26.5h1m1 0h3m1 0h1m1 0h1m1 0h1m1 0h1m2 0h1m3 0h2m1 0h6M0 27.5h1m5 0h1m2 0h3m3 0h1m2 0h1m1 0h2m1 0h3m1 0h1M0 28.5h7m1 0h2m1 0h1m3 0h2m1 0h2m1 0h1m2 0h1m1 0h1',
|
||||
},
|
||||
{
|
||||
id: 'android',
|
||||
href: 'https://play.google.com/store/apps/details?id=com.liketrek.trek',
|
||||
store: 'Google Play',
|
||||
captionKey: 'settings.apps.getItOn',
|
||||
devicesKey: 'settings.apps.androidDevices',
|
||||
logo: 'M22.018 13.298l-3.919 2.218-3.515-3.493 3.543-3.521 3.891 2.202a1.49 1.49 0 0 1 0 2.594zM1.337.924a1.486 1.486 0 0 0-.112.568v21.017c0 .217.045.419.124.6l11.155-11.087L1.337.924zm12.207 10.065l3.258-3.238L3.45.195a1.466 1.466 0 0 0-.946-.179l11.04 10.973zm0 2.067l-11 10.933c.298.036.612-.016.906-.183l13.324-7.54-3.23-3.21z',
|
||||
qrSize: 37,
|
||||
qr: 'M0 0.5h7m2 0h1m3 0h1m1 0h1m2 0h1m1 0h3m1 0h2m4 0h7M0 1.5h1m5 0h1m4 0h1m2 0h1m2 0h3m5 0h4m1 0h1m5 0h1M0 2.5h1m1 0h3m1 0h1m1 0h2m2 0h5m2 0h4m1 0h1m1 0h1m3 0h1m1 0h3m1 0h1M0 3.5h1m1 0h3m1 0h1m1 0h2m1 0h1m1 0h1m2 0h5m1 0h1m2 0h2m3 0h1m1 0h3m1 0h1M0 4.5h1m1 0h3m1 0h1m1 0h2m3 0h1m4 0h3m1 0h2m1 0h1m2 0h1m1 0h1m1 0h3m1 0h1M0 5.5h1m5 0h1m1 0h6m4 0h1m3 0h1m2 0h4m1 0h1m5 0h1M0 6.5h7m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1m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0h4m3 0h2m4 0h1m6 0h1m4 0h1M0 26.5h1m2 0h1m1 0h2m3 0h1m1 0h3m5 0h1m2 0h2m1 0h2m2 0h2m2 0h3M0 27.5h1m1 0h3m3 0h2m6 0h1m4 0h1m1 0h1m2 0h7m2 0h1M0 28.5h1m1 0h1m1 0h1m1 0h1m1 0h2m1 0h2m1 0h1m2 0h1m4 0h4m1 0h9M8 29.5h6m2 0h2m1 0h3m1 0h1m3 0h2m3 0h2m1 0h1M0 30.5h7m2 0h1m5 0h3m2 0h2m4 0h1m1 0h1m1 0h1m1 0h1m1 0h1m1 0h1M0 31.5h1m5 0h1m1 0h1m1 0h6m1 0h8m1 0h3m3 0h2m1 0h1M0 32.5h1m1 0h3m1 0h1m1 0h2m1 0h1m1 0h1m1 0h2m2 0h1m1 0h1m2 0h9m1 0h1m1 0h1M0 33.5h1m1 0h3m1 0h1m1 0h1m2 0h1m1 0h3m2 0h1m1 0h3m1 0h2m3 0h2m1 0h1m1 0h2M0 34.5h1m1 0h3m1 0h1m1 0h1m3 0h1m2 0h2m2 0h1m1 0h2m2 0h5m4 0h1m1 0h1M0 35.5h1m5 0h1m5 0h1m1 0h2m2 0h7m3 0h3m1 0h1m3 0h1M0 36.5h7m1 0h1m1 0h1m1 0h1m1 0h2m1 0h1m1 0h1m3 0h4m2 0h2m1 0h5',
|
||||
},
|
||||
] as const;
|
||||
|
||||
interface Props {
|
||||
/** `dark` for a surface that stays dark in either theme, like the release modal. */
|
||||
tone?: 'theme' | 'dark';
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export default function AppStoreCards({ tone = 'theme', className }: Props): React.ReactElement {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className={['asc-row', tone === 'dark' ? 'asc-dark' : '', className ?? ''].filter(Boolean).join(' ')}>
|
||||
{APP_STORES.map((s) => (
|
||||
<a key={s.id} className="asc-card" href={s.href} target="_blank" rel="noopener noreferrer">
|
||||
<span className="asc-qr" aria-hidden="true">
|
||||
<svg viewBox={`0 0 ${s.qrSize} ${s.qrSize}`} shapeRendering="crispEdges">
|
||||
<path className="asc-qr-dots" d={s.qr} />
|
||||
</svg>
|
||||
</span>
|
||||
<span className="asc-text">
|
||||
<span className="asc-caption">
|
||||
<svg className="asc-logo" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d={s.logo} />
|
||||
</svg>
|
||||
{t(s.captionKey)}
|
||||
</span>
|
||||
<span className="asc-store">{s.store}</span>
|
||||
<span className="asc-devices">{t(s.devicesKey)}</span>
|
||||
</span>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/* The store cards: a QR code on its white tile, the store's mark and name beside it.
|
||||
The theme tone follows the appearance tokens; .asc-dark is for a surface that is
|
||||
dark in either theme (the release modal). */
|
||||
|
||||
.asc-row {
|
||||
display: grid;
|
||||
/* Always side by side: two compact cards read as one row of stores. */
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.asc-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
padding: 8px 12px 8px 8px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid var(--border-faint);
|
||||
background: var(--bg-card);
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
transition:
|
||||
transform 160ms ease,
|
||||
border-color 160ms ease,
|
||||
box-shadow 160ms ease;
|
||||
}
|
||||
.asc-card:hover {
|
||||
transform: translateY(-1px);
|
||||
border-color: var(--border-primary);
|
||||
box-shadow: 0 10px 24px -14px rgb(0 0 0 / 0.35); /* a neutral lift shadow */
|
||||
}
|
||||
.asc-card:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* A QR code needs its light quiet zone in either theme to scan. */
|
||||
.asc-qr {
|
||||
flex: none;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
padding: 5px;
|
||||
border-radius: 10px;
|
||||
background: #ffffff; /* a QR code needs a white quiet zone to scan */
|
||||
border: 1px solid var(--border-faint);
|
||||
}
|
||||
.asc-qr svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
.asc-qr-dots {
|
||||
fill: none;
|
||||
stroke: #0f172a;
|
||||
} /* QR modules stay dark on their white tile */
|
||||
|
||||
.asc-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.asc-caption {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: calc(10.5px * var(--fs-scale-caption, 1));
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.asc-logo {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
flex: none;
|
||||
fill: currentColor;
|
||||
}
|
||||
.asc-store {
|
||||
margin-top: 2px;
|
||||
font-size: calc(16px * var(--fs-scale-subtitle, 1));
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.asc-devices {
|
||||
margin-top: 2px;
|
||||
font-size: calc(10.5px * var(--fs-scale-caption, 1));
|
||||
color: var(--text-muted);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.asc-dark .asc-card {
|
||||
background: linear-gradient(160deg, oklch(1 0 0 / 0.1) 0%, oklch(1 0 0 / 0.045) 62%);
|
||||
border-color: oklch(1 0 0 / 0.13);
|
||||
color: #f5f5f7; /* the release modal is dark in either theme */
|
||||
box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.16);
|
||||
}
|
||||
.asc-dark .asc-card:hover {
|
||||
border-color: oklch(1 0 0 / 0.26);
|
||||
}
|
||||
.asc-dark .asc-qr {
|
||||
border-color: transparent;
|
||||
}
|
||||
.asc-dark .asc-store {
|
||||
color: #f5f5f7;
|
||||
} /* the release modal is dark in either theme */
|
||||
.asc-dark .asc-caption,
|
||||
.asc-dark .asc-devices {
|
||||
color: oklch(1 0 0 / 0.6);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.asc-card {
|
||||
transition: none;
|
||||
}
|
||||
.asc-card:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user