@dloizides/marketing-astro-kit 1.12.0 → 1.14.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 +47 -0
- package/package.json +13 -6
- package/src/ContactCard.astro +124 -0
- package/src/contactCard/CardActions.astro +20 -0
- package/src/contactCard/CardBack.astro +31 -0
- package/src/contactCard/CardBrand.astro +25 -0
- package/src/contactCard/CardContacts.astro +22 -0
- package/src/contactCard/CardContactsVariant.ts +5 -0
- package/src/contactCard/CardDialog.astro +16 -0
- package/src/contactCard/CardForm.ts +5 -0
- package/src/contactCard/CardFront.astro +27 -0
- package/src/contactCard/CardIcon.astro +12 -0
- package/src/contactCard/CardIconName.ts +7 -0
- package/src/contactCard/CardIdentity.astro +14 -0
- package/src/contactCard/CardLinkKind.ts +6 -0
- package/src/contactCard/CardPortrait.astro +14 -0
- package/src/contactCard/CardQr.astro +24 -0
- package/src/contactCard/CardSave.astro +45 -0
- package/src/contactCard/CardShare.astro +32 -0
- package/src/contactCard/CardTurn.astro +15 -0
- package/src/contactCard/CardTwoSided.astro +48 -0
- package/src/contactCard/CardValues.astro +12 -0
- package/src/contactCard/ContactCardLayout.ts +7 -0
- package/src/contactCard/ContactPhotoType.ts +5 -0
- package/src/contactCard/InstallRoute.ts +6 -0
- package/src/contactCard/cardIcons.ts +12 -0
- package/src/contactCard/cardLinks.ts +43 -0
- package/src/contactCard/checks.ts +28 -0
- package/src/contactCard/chooseInstall.ts +21 -0
- package/src/contactCard/contactCard.css +69 -0
- package/src/contactCard/cssRaw.d.ts +4 -0
- package/src/contactCard/index.ts +20 -0
- package/src/contactCard/layouts.css +106 -0
- package/src/contactCard/manifest.ts +37 -0
- package/src/contactCard/motion/FlipMotion.ts +5 -0
- package/src/contactCard/motion/OpenLanding.ts +6 -0
- package/src/contactCard/motion/OpenMotion.ts +11 -0
- package/src/contactCard/motion/QrMotion.ts +7 -0
- package/src/contactCard/motion/SaveMotion.ts +7 -0
- package/src/contactCard/motion/ShareMode.ts +7 -0
- package/src/contactCard/motion/TiltMotion.ts +10 -0
- package/src/contactCard/motion/beatTable.ts +144 -0
- package/src/contactCard/motion/beats.ts +43 -0
- package/src/contactCard/motion/cardMotion.ts +70 -0
- package/src/contactCard/motion/easings.ts +9 -0
- package/src/contactCard/motion/holdDuringOpen.ts +22 -0
- package/src/contactCard/motion/mountFlip.ts +64 -0
- package/src/contactCard/motion/mountMotion.ts +33 -0
- package/src/contactCard/motion/mountOpenMark.ts +23 -0
- package/src/contactCard/motion/mountQrTurn.ts +86 -0
- package/src/contactCard/motion/mountSave.ts +26 -0
- package/src/contactCard/motion/mountShare.ts +57 -0
- package/src/contactCard/motion/mountTilt.ts +84 -0
- package/src/contactCard/motion/openCss.ts +18 -0
- package/src/contactCard/motion/orientationAccess.ts +36 -0
- package/src/contactCard/motion/parts.ts +25 -0
- package/src/contactCard/motion/playBeats.ts +21 -0
- package/src/contactCard/motion/sides.ts +33 -0
- package/src/contactCard/motion/tiltLights.ts +14 -0
- package/src/contactCard/motion/tiltPose.ts +59 -0
- package/src/contactCard/motion/twoSidedBeats.ts +37 -0
- package/src/contactCard/motion.css +44 -0
- package/src/contactCard/mount.ts +76 -0
- package/src/contactCard/phone.ts +11 -0
- package/src/contactCard/qrSvg.ts +54 -0
- package/src/contactCard/share.css +16 -0
- package/src/contactCard/twoSided.css +43 -0
- package/src/contactCard/types.ts +52 -0
- package/src/contactCard/vCard.ts +48 -0
- package/src/contactCard/vCardLines.ts +33 -0
- package/src/motionController/createMotionController.ts +11 -9
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { MotionState, createMotionController } from '../../motionController';
|
|
2
|
+
import { EASINGS } from './easings';
|
|
3
|
+
import { listenOrientation } from './orientationAccess';
|
|
4
|
+
import { partSelector } from './parts';
|
|
5
|
+
import { TiltMotion } from './TiltMotion';
|
|
6
|
+
import { dragToUnit, gammaToUnit, tiltPose } from './tiltPose';
|
|
7
|
+
|
|
8
|
+
const START_PX = 8;
|
|
9
|
+
const RETURN_MS = 600;
|
|
10
|
+
const SENSOR_SHOWS_LIGHT = 0.1;
|
|
11
|
+
const TILTING = 'data-tilting';
|
|
12
|
+
|
|
13
|
+
function partFinder(card: HTMLElement): (part: string) => HTMLElement[] {
|
|
14
|
+
const layer = card.querySelector<HTMLElement>('[data-part="tilt"]') ?? card;
|
|
15
|
+
return (part) => (part === 'card' ? [layer] : Array.from(card.querySelectorAll<HTMLElement>(partSelector(part))));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function swallowNextClick(card: HTMLElement, signal?: AbortSignal): void {
|
|
19
|
+
const stopClick = (event: Event): void => {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
event.stopPropagation();
|
|
22
|
+
};
|
|
23
|
+
card.addEventListener('click', stopClick, { capture: true, once: true, signal });
|
|
24
|
+
setTimeout(() => card.removeEventListener('click', stopClick, { capture: true }), 0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function easeBack(find: (part: string) => HTMLElement[], tiltMotion: TiltMotion): void {
|
|
28
|
+
const restPose = tiltPose(tiltMotion, 0);
|
|
29
|
+
Object.entries(restPose).forEach(([part, transform]) => find(part).forEach((element) => {
|
|
30
|
+
const from = element.style.transform !== '' ? element.style.transform : transform;
|
|
31
|
+
element.animate?.([{ transform: from }, { transform }], { duration: RETURN_MS, easing: EASINGS['settle'] });
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Leans the card with a sideways drag or the motion sensor (asked for on iOS); still under reduced motion. */
|
|
36
|
+
export function mountTilt(card: HTMLElement, tiltMotion: TiltMotion, signal?: AbortSignal): void {
|
|
37
|
+
if (tiltMotion === TiltMotion.None) return;
|
|
38
|
+
const find = partFinder(card);
|
|
39
|
+
const moving = Object.keys(tiltPose(tiltMotion, 1)).flatMap(find);
|
|
40
|
+
const drag = { unit: 0, pointer: null as number | null, startX: 0, active: false, sensing: false, gammaAtLoad: null as number | null };
|
|
41
|
+
const apply = (): void => Object.entries(tiltPose(tiltMotion, drag.unit)).forEach(([part, transform]) => find(part).forEach((element) => { element.style.transform = transform; }));
|
|
42
|
+
const rest = (): void => {
|
|
43
|
+
Object.assign(drag, { unit: 0, active: false, sensing: false });
|
|
44
|
+
moving.forEach((element) => { element.style.transform = ''; });
|
|
45
|
+
card.removeAttribute(TILTING);
|
|
46
|
+
};
|
|
47
|
+
const controller = createMotionController({ target: card, onFrame: apply, onStill: rest, canRun: () => drag.active || drag.sensing, signal });
|
|
48
|
+
const settle = (): void => { rest(); controller.sync(); };
|
|
49
|
+
const running = (): boolean => controller.getState() === MotionState.Running;
|
|
50
|
+
card.addEventListener('pointerdown', (event) => {
|
|
51
|
+
if (drag.pointer !== null) return;
|
|
52
|
+
drag.pointer = event.pointerId;
|
|
53
|
+
drag.startX = event.clientX;
|
|
54
|
+
}, { signal });
|
|
55
|
+
card.addEventListener('pointermove', (event) => {
|
|
56
|
+
if (event.pointerId !== drag.pointer) return;
|
|
57
|
+
const dx = event.clientX - drag.startX;
|
|
58
|
+
if (!drag.active && Math.abs(dx) > START_PX && running()) {
|
|
59
|
+
drag.active = true;
|
|
60
|
+
card.setAttribute(TILTING, '');
|
|
61
|
+
controller.sync();
|
|
62
|
+
}
|
|
63
|
+
if (drag.active) drag.unit = dragToUnit(dx);
|
|
64
|
+
}, { signal });
|
|
65
|
+
const end = (event: PointerEvent): void => {
|
|
66
|
+
if (event.pointerId !== drag.pointer) return;
|
|
67
|
+
drag.pointer = null;
|
|
68
|
+
if (!drag.active) return;
|
|
69
|
+
swallowNextClick(card, signal);
|
|
70
|
+
easeBack(find, tiltMotion);
|
|
71
|
+
settle();
|
|
72
|
+
};
|
|
73
|
+
signal?.addEventListener('abort', settle, { once: true });
|
|
74
|
+
card.addEventListener('pointerup', end, { signal });
|
|
75
|
+
card.addEventListener('pointercancel', end, { signal });
|
|
76
|
+
listenOrientation(card, (event) => {
|
|
77
|
+
if (event.gamma === null || drag.active || !running()) return;
|
|
78
|
+
drag.gammaAtLoad ??= event.gamma;
|
|
79
|
+
drag.unit = gammaToUnit(event.gamma, drag.gammaAtLoad);
|
|
80
|
+
drag.sensing = true;
|
|
81
|
+
card.toggleAttribute(TILTING, Math.abs(drag.unit) > SENSOR_SHOWS_LIGHT);
|
|
82
|
+
controller.sync();
|
|
83
|
+
}, running, signal);
|
|
84
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { partSelector } from './parts';
|
|
2
|
+
import { openingBeats } from './twoSidedBeats';
|
|
3
|
+
|
|
4
|
+
/** The opening as CSS animations scoped to the option, played only when motion is allowed; `''` for `none`. */
|
|
5
|
+
export function buildOpenCss(openMotion: string, openLands?: string): string {
|
|
6
|
+
const beats = openingBeats(openMotion, openLands);
|
|
7
|
+
if (beats.length === 0) return '';
|
|
8
|
+
const scope = `.tmk-card[data-open-motion="${openMotion}"]`;
|
|
9
|
+
const byPart = new Map<string, string[]>();
|
|
10
|
+
const frames = beats.map((beat, index) => {
|
|
11
|
+
const name = `tmk-card-${openMotion}-${index}`;
|
|
12
|
+
const selector = partSelector(beat.part);
|
|
13
|
+
byPart.set(selector, [...(byPart.get(selector) ?? []), `${name} ${beat.lengthMs}ms ${beat.easing} ${beat.atMs}ms backwards`]);
|
|
14
|
+
return `@keyframes ${name}{from{${beat.property}:${beat.from}}to{${beat.property}:${beat.to}}}`;
|
|
15
|
+
});
|
|
16
|
+
const rules = Array.from(byPart, ([selector, animations]) => `${scope} ${selector}{animation:${animations.join(',')}}`);
|
|
17
|
+
return `@media (prefers-reduced-motion:no-preference){${frames.join('')}${rules.join('')}}`;
|
|
18
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const GRANTED = 'granted';
|
|
2
|
+
const CONTROLS = 'a,button,input,select,textarea,dialog';
|
|
3
|
+
|
|
4
|
+
interface OrientationGlobal {
|
|
5
|
+
DeviceOrientationEvent?: { requestPermission?: unknown };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type AskPermission = () => Promise<string>;
|
|
9
|
+
|
|
10
|
+
function askFunction(): AskPermission | null | undefined {
|
|
11
|
+
const orientation = (window as OrientationGlobal).DeviceOrientationEvent;
|
|
12
|
+
if (orientation === undefined) return undefined;
|
|
13
|
+
const ask = orientation.requestPermission;
|
|
14
|
+
return typeof ask === 'function' ? (ask.bind(orientation) as AskPermission) : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function tappedControl(event: Event): boolean {
|
|
18
|
+
return event.target instanceof Element && event.target.closest(CONTROLS) !== null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Listens to the motion sensor; where the browser asks first (iOS), asks on the first tap on the card outside its controls. */
|
|
22
|
+
export function listenOrientation(card: HTMLElement, onTurn: (event: DeviceOrientationEvent) => void, canAsk: () => boolean, signal?: AbortSignal): void {
|
|
23
|
+
const ask = askFunction();
|
|
24
|
+
if (ask === undefined) return;
|
|
25
|
+
const listen = (): void => window.addEventListener('deviceorientation', onTurn, { signal });
|
|
26
|
+
if (ask === null) {
|
|
27
|
+
listen();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const askOnTap = (event: Event): void => {
|
|
31
|
+
if (tappedControl(event) || !canAsk()) return;
|
|
32
|
+
card.removeEventListener('click', askOnTap);
|
|
33
|
+
ask().then((state) => { if (state === GRANTED && signal?.aborted !== true) listen(); }).catch((error: unknown) => console.warn(error));
|
|
34
|
+
};
|
|
35
|
+
card.addEventListener('click', askOnTap, { signal });
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const CONTACTS = '[data-part="contacts"]';
|
|
2
|
+
const SPECIAL: Readonly<Record<string, string>> = {
|
|
3
|
+
photo: '[data-part="portrait"]',
|
|
4
|
+
name1: '[data-part="name"]>span:first-child',
|
|
5
|
+
name2: '[data-part="name"]>span:last-child',
|
|
6
|
+
home: '[data-part="install"]',
|
|
7
|
+
qrBtn: '[data-part="show-qr"]',
|
|
8
|
+
listPanel: CONTACTS,
|
|
9
|
+
qrPanel: '[data-part="qr-panel"]',
|
|
10
|
+
back: '[data-part="qr-back"]',
|
|
11
|
+
rule4: `${CONTACTS}>a:last-child::after`,
|
|
12
|
+
};
|
|
13
|
+
const ROW = /^row(\d)$/;
|
|
14
|
+
const RULE = /^rule(\d)$/;
|
|
15
|
+
|
|
16
|
+
const kebab = (part: string): string => part.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
17
|
+
|
|
18
|
+
/** The CSS selector, inside the card, of a part named in the motion spec. */
|
|
19
|
+
export function partSelector(part: string): string {
|
|
20
|
+
const row = ROW.exec(part)?.[1];
|
|
21
|
+
if (row !== undefined) return `${CONTACTS}>a:nth-child(${row})>*`;
|
|
22
|
+
const rule = RULE.exec(part)?.[1];
|
|
23
|
+
if (SPECIAL[part] === undefined && rule !== undefined) return `${CONTACTS}>a:nth-child(${rule})::before`;
|
|
24
|
+
return SPECIAL[part] ?? `[data-part="${kebab(part)}"]`;
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Beat } from './beats';
|
|
2
|
+
|
|
3
|
+
export type PartFinder = (part: string) => Element[];
|
|
4
|
+
|
|
5
|
+
/** Plays beats as Web Animations; the first beat of each part and property holds its start, later ones hold their end. */
|
|
6
|
+
export function playBeats(beats: readonly Beat[], find: PartFinder): Animation[] {
|
|
7
|
+
const started = new Set<string>();
|
|
8
|
+
return beats.flatMap((beat) => find(beat.part).flatMap((element, index) => {
|
|
9
|
+
if (typeof element.animate !== 'function') return [];
|
|
10
|
+
const key = `${beat.part}|${index}|${beat.property}`;
|
|
11
|
+
const fill: FillMode = started.has(key) ? 'forwards' : 'both';
|
|
12
|
+
started.add(key);
|
|
13
|
+
const frames = [{ [beat.property]: beat.from }, { [beat.property]: beat.to }];
|
|
14
|
+
return [element.animate(frames, { delay: beat.atMs, duration: beat.lengthMs, easing: beat.easing, fill })];
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Cancels every animation still holding a value. */
|
|
19
|
+
export function cancelAll(animations: readonly Animation[]): void {
|
|
20
|
+
animations.forEach((animation) => animation.cancel());
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const NOT_A_SIDE = '[data-part="qr-back"],[data-part="qr-panel"],[data-part="save-live"],[data-part="edge"],dialog,script,style,template';
|
|
2
|
+
const HALF = 2;
|
|
3
|
+
|
|
4
|
+
/** Every element of the card that turns, leaving out Save contact and whatever holds it. */
|
|
5
|
+
export function sidesAround(root: Element, save: Element): HTMLElement[] {
|
|
6
|
+
return Array.from(root.children).flatMap((child) => {
|
|
7
|
+
if (child === save || !(child instanceof HTMLElement) || child.matches(NOT_A_SIDE)) return [];
|
|
8
|
+
return child.contains(save) ? sidesAround(child, save) : [child];
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Turns every side around one shared centre, so they move as one card. */
|
|
13
|
+
export function shareOrigin(card: HTMLElement, sides: readonly HTMLElement[]): void {
|
|
14
|
+
const frame = card.getBoundingClientRect();
|
|
15
|
+
const centreX = frame.left + frame.width / HALF;
|
|
16
|
+
const centreY = frame.top + Math.min(frame.height, window.innerHeight) / HALF;
|
|
17
|
+
sides.forEach((side) => {
|
|
18
|
+
const box = side.getBoundingClientRect();
|
|
19
|
+
side.style.transformOrigin = `${centreX - box.left}px ${centreY - box.top}px`;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Places a hidden side over a box of the card, so showing it moves nothing. */
|
|
24
|
+
export function cover(card: HTMLElement, side: HTMLElement, box: DOMRect): void {
|
|
25
|
+
const frame = card.getBoundingClientRect();
|
|
26
|
+
Object.assign(side.style, { top: `${box.top - frame.top}px`, left: `${box.left - frame.left}px`, width: `${box.width}px`, height: `${box.height}px` });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Marks a side hidden (inert, invisible) or shown. */
|
|
30
|
+
export function setSide(side: HTMLElement, hidden: boolean): void {
|
|
31
|
+
side.toggleAttribute('inert', hidden);
|
|
32
|
+
side.toggleAttribute('data-side-hidden', hidden);
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TiltMotion } from './TiltMotion';
|
|
2
|
+
|
|
3
|
+
const EDGE_LIGHT = new Set<string>([TiltMotion.CardLeans, TiltMotion.DeepLayers]);
|
|
4
|
+
const HEX_LIGHT = new Set<string>([TiltMotion.PortraitLeans, TiltMotion.LayersDrift, TiltMotion.GoldGloss]);
|
|
5
|
+
|
|
6
|
+
/** Which light layers a tilt option needs drawn into the card. */
|
|
7
|
+
export function tiltLights(tiltMotion: TiltMotion): { edge: boolean; hex: boolean; sweep: boolean; gloss: boolean } {
|
|
8
|
+
return {
|
|
9
|
+
edge: EDGE_LIGHT.has(tiltMotion),
|
|
10
|
+
hex: HEX_LIGHT.has(tiltMotion),
|
|
11
|
+
sweep: tiltMotion === TiltMotion.LightSweeps,
|
|
12
|
+
gloss: tiltMotion === TiltMotion.GoldGloss,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TiltMotion } from './TiltMotion';
|
|
2
|
+
|
|
3
|
+
const DRAG_PX = 90;
|
|
4
|
+
const SENSOR_DEG = 20;
|
|
5
|
+
const DIGITS = 3;
|
|
6
|
+
const LEAN = { perspective: 900, tiltX: 3, turnY: 11, shrink: 0.07, light: 190 };
|
|
7
|
+
const FACE = { perspective: 400, turnY: 34, grow: 0.06, light: 46 };
|
|
8
|
+
const DRIFT = { photo: 14, name: -9, role: -5, mark: 5, light: 46 };
|
|
9
|
+
const SWEEP = { perspective: 900, tiltX: 3, turnY: 6, travel: 100 };
|
|
10
|
+
const GLOSS = { travel: 180, light: 46 };
|
|
11
|
+
const DEEP = { perspective: 700, tiltX: 4, turnY: 16, shrink: 0.05, photo: 18, name: -10, role: -6, light: 190 };
|
|
12
|
+
|
|
13
|
+
const round = (value: number): number => Number(value.toFixed(DIGITS)) || 0;
|
|
14
|
+
const shiftX = (px: number): string => `translateX(${round(px)}px)`;
|
|
15
|
+
const shiftShare = (percent: number): string => `translateX(${round(percent)}%)`;
|
|
16
|
+
const clampUnit = (value: number): number => Math.max(-1, Math.min(1, value));
|
|
17
|
+
|
|
18
|
+
/** A sideways drag as -1..1, full at 90 px. */
|
|
19
|
+
export function dragToUnit(dx: number): number {
|
|
20
|
+
return clampUnit(dx / DRAG_PX);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A sensor gamma as -1..1, full 20 degrees from the angle at load. */
|
|
24
|
+
export function gammaToUnit(gamma: number, gammaAtLoad: number): number {
|
|
25
|
+
return clampUnit((gamma - gammaAtLoad) / SENSOR_DEG);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function lean(view: { perspective: number; tiltX: number; turnY: number; shrink?: number }, unit: number): string {
|
|
29
|
+
const size = Math.abs(unit);
|
|
30
|
+
const scale = view.shrink === undefined ? '' : ` scale(${round(1 - view.shrink * size)})`;
|
|
31
|
+
return `perspective(${view.perspective}px) rotateX(${round(view.tiltX * size)}deg) rotateY(${round(view.turnY * unit)}deg)${scale}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function lightPose(tiltMotion: TiltMotion, unit: number): Record<string, string> | null {
|
|
35
|
+
if (tiltMotion === TiltMotion.LightSweeps) {
|
|
36
|
+
return { card: lean(SWEEP, unit), sweepBand: shiftShare(SWEEP.travel * unit), backBand: shiftShare(-SWEEP.travel * unit) };
|
|
37
|
+
}
|
|
38
|
+
if (tiltMotion === TiltMotion.GoldGloss) return { saveGloss: shiftShare(GLOSS.travel * unit), hexBand: shiftX(GLOSS.light * unit) };
|
|
39
|
+
if (tiltMotion !== TiltMotion.DeepLayers) return null;
|
|
40
|
+
const name = shiftX(DEEP.name * unit);
|
|
41
|
+
return { card: lean(DEEP, unit), photo: shiftX(DEEP.photo * unit), name1: name, name2: name, role: shiftX(DEEP.role * unit), edgeLight: shiftX(DEEP.light * unit) };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The transform of every moving part for a lean of -1 (full left) to 1 (full right). */
|
|
45
|
+
export function tiltPose(tiltMotion: TiltMotion, unit: number): Record<string, string> {
|
|
46
|
+
const light = lightPose(tiltMotion, unit);
|
|
47
|
+
if (light !== null) return light;
|
|
48
|
+
const size = Math.abs(unit);
|
|
49
|
+
if (tiltMotion === TiltMotion.CardLeans) {
|
|
50
|
+
return { card: lean(LEAN, unit), edgeLight: shiftX(LEAN.light * unit) };
|
|
51
|
+
}
|
|
52
|
+
if (tiltMotion === TiltMotion.PortraitLeans) {
|
|
53
|
+
return { photo: `perspective(${FACE.perspective}px) rotateY(${round(FACE.turnY * unit)}deg) scale(${round(1 + FACE.grow * size)})`, hexBand: shiftX(FACE.light * unit) };
|
|
54
|
+
}
|
|
55
|
+
if (tiltMotion !== TiltMotion.LayersDrift) return {};
|
|
56
|
+
const name = shiftX(DRIFT.name * unit);
|
|
57
|
+
const mark = shiftX(DRIFT.mark * unit);
|
|
58
|
+
return { photo: shiftX(DRIFT.photo * unit), name1: name, name2: name, role: shiftX(DRIFT.role * unit), mark, wordmark: mark, hexBand: shiftX(DRIFT.light * unit) };
|
|
59
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { beatsFor, type Beat } from './beats';
|
|
2
|
+
import { OpenLanding } from './OpenLanding';
|
|
3
|
+
import { OpenMotion } from './OpenMotion';
|
|
4
|
+
|
|
5
|
+
const POP = 'cubic-bezier(0.34,1.4,0.64,1)';
|
|
6
|
+
const TURN_TO_FRONT = 'flip|transform|rotateY(180deg)|rotateY(0deg)|700|500|settle';
|
|
7
|
+
|
|
8
|
+
export const TWO_SIDED_BEATS: Readonly<Record<string, readonly string[]>> = {
|
|
9
|
+
[OpenMotion.TileGrows]: [
|
|
10
|
+
'tilt|opacity|0|1|300|120|enter',
|
|
11
|
+
'tilt|transform|scale(0.28)|scale(1)|300|400|glide',
|
|
12
|
+
'turn|opacity|0|1|1000|200|enter',
|
|
13
|
+
],
|
|
14
|
+
[OpenMotion.MoonOpens]: [
|
|
15
|
+
'tilt|clip-path|circle(12% at 50% 50%)|circle(75% at 50% 50%)|300|600|glide',
|
|
16
|
+
'turn|opacity|0|1|800|200|enter',
|
|
17
|
+
],
|
|
18
|
+
[OpenMotion.TurnsFaceUp]: [
|
|
19
|
+
'tilt|transform|perspective(1200px) rotateX(70deg)|perspective(1200px) rotateX(0deg)|400|700|settle',
|
|
20
|
+
'tilt|opacity|0|1|400|200|enter',
|
|
21
|
+
'turn|opacity|0|1|1000|200|enter',
|
|
22
|
+
],
|
|
23
|
+
[OpenMotion.PassRises]: [
|
|
24
|
+
`tilt|transform|translateY(60%)|translateY(0%)|300|600|${POP}`,
|
|
25
|
+
'tilt|opacity|0|1|300|160|enter',
|
|
26
|
+
'turn|opacity|0|1|800|200|enter',
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** The beats of an opening, with the turn to the front when tile-grows lands that way. */
|
|
31
|
+
export function openingBeats(openMotion: string, openLands: string = OpenLanding.TurnToFront): Beat[] {
|
|
32
|
+
const lines = TWO_SIDED_BEATS[openMotion];
|
|
33
|
+
if (lines === undefined) return beatsFor(openMotion);
|
|
34
|
+
const turnsToFront = openMotion === String(OpenMotion.TileGrows) && openLands === String(OpenLanding.TurnToFront);
|
|
35
|
+
const landing = turnsToFront ? [TURN_TO_FRONT] : [];
|
|
36
|
+
return beatsFor('', [...lines, ...landing]);
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.tmk-card{touch-action:pan-y}
|
|
2
|
+
.tmk-card [data-side-hidden]{visibility:hidden}
|
|
3
|
+
.tmk-card[data-open-motion]:not([data-open-motion='none']) .tmk-card-name span{display:inline-block}
|
|
4
|
+
.tmk-card[data-layout='name'][data-open-motion] .tmk-card-name span,.tmk-card[data-layout='framed'][data-open-motion] .tmk-card-name span{display:block}
|
|
5
|
+
.tmk-card[data-open-motion='written-in'] .tmk-card-name{overflow:hidden}
|
|
6
|
+
|
|
7
|
+
.tmk-card-mark{display:block;flex:none;width:32px;height:32px}
|
|
8
|
+
.tmk-card-mark svg{display:block;width:100%;height:100%}
|
|
9
|
+
.tmk-card-wordmark{display:block;margin-left:8px}
|
|
10
|
+
|
|
11
|
+
.tmk-card .tmk-card-save{position:relative;z-index:2;overflow:hidden}
|
|
12
|
+
.tmk-card-save-icon{position:relative;display:grid;flex:none;overflow:hidden}
|
|
13
|
+
.tmk-card-save-icon>*{display:grid;grid-area:1/1;place-items:center}
|
|
14
|
+
.tmk-card-mini{flex:none;width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:square;transform-box:fill-box;transform-origin:center}
|
|
15
|
+
.tmk-card-tick,.tmk-card-cube path,.tmk-card [data-part='ready-text']{opacity:0}
|
|
16
|
+
.tmk-card-cube path{transform-box:fill-box}
|
|
17
|
+
.tmk-card-tick-cover{width:26px;height:22px;background:var(--card-accent);transform:translateX(26px)}
|
|
18
|
+
.tmk-card-save-words{display:grid}
|
|
19
|
+
.tmk-card-save-words>*{grid-area:1/1}
|
|
20
|
+
.tmk-card-wipe{position:absolute;inset:0;overflow:hidden;background:var(--card-on-accent);color:var(--card-accent);transform:translateX(-100%)}
|
|
21
|
+
.tmk-card-wipe-in{display:flex;align-items:center;justify-content:inherit;gap:inherit;height:100%;padding:inherit;transform:translateX(100%)}
|
|
22
|
+
.tmk-card-live{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
23
|
+
|
|
24
|
+
.tmk-card-qr-words{display:grid}
|
|
25
|
+
.tmk-card-qr-words>*{grid-area:1/1}
|
|
26
|
+
.tmk-card [data-part='qr-close']{opacity:0}
|
|
27
|
+
|
|
28
|
+
.tmk-card .tmk-card-qr-side{position:absolute;inset:0;z-index:1;display:grid;grid-template-rows:minmax(0,1fr);place-items:center;gap:12px;background:var(--card-bg)}
|
|
29
|
+
.tmk-card .tmk-card-qr-back{grid-template-rows:minmax(0,1fr) auto;padding:16px;border:1px solid var(--card-accent);border-radius:var(--card-radius);background:var(--card-raised)}
|
|
30
|
+
.tmk-card-qr-side .tmk-card-qr{display:grid;place-items:center;width:100%;height:100%;min-height:0}
|
|
31
|
+
.tmk-card .tmk-card-qr-side .tmk-card-qr svg{width:auto;height:100%;min-width:0;max-width:100%;margin:0}
|
|
32
|
+
.tmk-card-qr-back .tmk-card-button{width:100%}
|
|
33
|
+
|
|
34
|
+
.tmk-card-edge{position:absolute;inset:0;z-index:3;padding:2px;overflow:hidden;opacity:0;pointer-events:none;transition:opacity 360ms cubic-bezier(0.2,0,0,1) 200ms;-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude}
|
|
35
|
+
.tmk-card-edge>span,.tmk-card-hex-light>span{position:absolute;top:0;bottom:0;left:50%;width:120px;margin-left:-60px;background:linear-gradient(90deg,transparent,var(--card-accent),transparent)}
|
|
36
|
+
.tmk-card-portrait{position:relative}
|
|
37
|
+
.tmk-card-hex-light{position:absolute;inset:0;overflow:hidden;clip-path:var(--tmk-card-hex);opacity:0;pointer-events:none;mix-blend-mode:soft-light;transition:opacity 360ms cubic-bezier(0.2,0,0,1) 200ms}
|
|
38
|
+
.tmk-card-hex-light>span{width:40px;margin-left:-20px}
|
|
39
|
+
.tmk-card[data-tilting] :is(.tmk-card-edge,.tmk-card-hex-light){opacity:1;transition-duration:200ms;transition-delay:0s}
|
|
40
|
+
|
|
41
|
+
.tmk-card-sweep{position:absolute;inset:0;z-index:3;overflow:hidden;opacity:0;pointer-events:none;mix-blend-mode:soft-light;transition:opacity 360ms cubic-bezier(0.2,0,0,1) 200ms}
|
|
42
|
+
.tmk-card-sweep>span{position:absolute;top:-10%;bottom:-10%;left:20%;width:60%;background:linear-gradient(100deg,transparent 20%,var(--card-accent) 50%,transparent 80%)}
|
|
43
|
+
.tmk-card-gloss{position:absolute;top:0;bottom:0;left:30%;z-index:1;width:40%;opacity:0;pointer-events:none;mix-blend-mode:soft-light;background:linear-gradient(100deg,transparent,var(--card-on-accent),transparent);transition:opacity 360ms cubic-bezier(0.2,0,0,1) 200ms}
|
|
44
|
+
.tmk-card[data-tilting] :is(.tmk-card-sweep,.tmk-card-gloss){opacity:1;transition-duration:200ms;transition-delay:0s}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { InstallRoute } from './InstallRoute';
|
|
2
|
+
import { chooseInstallRoute, isAppleMobile } from './chooseInstall';
|
|
3
|
+
import { mountCardMotion } from './motion/mountMotion';
|
|
4
|
+
|
|
5
|
+
const MOUNTED_ATTRIBUTE = 'data-card-mounted';
|
|
6
|
+
const INSTALLED_QUERY = '(display-mode: standalone)';
|
|
7
|
+
|
|
8
|
+
interface InstallPromptEvent extends Event {
|
|
9
|
+
prompt: () => Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isInstallPromptEvent(event: Event): event is InstallPromptEvent {
|
|
13
|
+
return 'prompt' in event && typeof event.prompt === 'function';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function openDialog(card: HTMLElement, name: string, opener: HTMLElement): void {
|
|
17
|
+
const dialog = card.querySelector<HTMLDialogElement>(`[data-card-dialog="${name}"]`);
|
|
18
|
+
if (dialog === null) return;
|
|
19
|
+
dialog.addEventListener('close', () => opener.focus(), { once: true });
|
|
20
|
+
dialog.showModal();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function showInstallHelp(card: HTMLElement, route: InstallRoute, opener: HTMLElement): void {
|
|
24
|
+
card.querySelectorAll<HTMLElement>('[data-install-route]').forEach((help) => {
|
|
25
|
+
help.hidden = help.dataset['installRoute'] !== route;
|
|
26
|
+
});
|
|
27
|
+
openDialog(card, 'install', opener);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function setHidden(buttons: HTMLElement[], hidden: boolean): void {
|
|
31
|
+
buttons.forEach((button) => { button.hidden = hidden; });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function takeUnmountedCards(root: ParentNode, signal?: AbortSignal): HTMLElement[] {
|
|
35
|
+
if (signal?.aborted === true) return [];
|
|
36
|
+
const cards = Array.from(root.querySelectorAll<HTMLElement>(`[data-contact-card]:not([${MOUNTED_ATTRIBUTE}])`));
|
|
37
|
+
cards.forEach((card) => card.setAttribute(MOUNTED_ATTRIBUTE, 'true'));
|
|
38
|
+
signal?.addEventListener('abort', () => cards.forEach((card) => {
|
|
39
|
+
card.removeAttribute(MOUNTED_ATTRIBUTE);
|
|
40
|
+
setHidden(Array.from(card.querySelectorAll<HTMLElement>('[data-card-qr],[data-card-install]')), true);
|
|
41
|
+
}), { once: true });
|
|
42
|
+
return cards;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function mountInstall(cards: HTMLElement[], signal?: AbortSignal): void {
|
|
46
|
+
let offer: InstallPromptEvent | null = null;
|
|
47
|
+
const buttons = cards.flatMap((card) =>
|
|
48
|
+
Array.from(card.querySelectorAll<HTMLElement>('[data-card-install]'), (button) => ({ card, button })),
|
|
49
|
+
);
|
|
50
|
+
const hideButtons = (): void => setHidden(buttons.map(({ button }) => button), true);
|
|
51
|
+
|
|
52
|
+
setHidden(buttons.map(({ button }) => button), window.matchMedia(INSTALLED_QUERY).matches);
|
|
53
|
+
window.addEventListener('appinstalled', hideButtons, { signal });
|
|
54
|
+
window.addEventListener('beforeinstallprompt', (event) => {
|
|
55
|
+
if (!isInstallPromptEvent(event)) return;
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
offer = event;
|
|
58
|
+
}, { signal });
|
|
59
|
+
buttons.forEach(({ card, button }) => button.addEventListener('click', () => {
|
|
60
|
+
const route = chooseInstallRoute({ hasPrompt: offer !== null, isApple: isAppleMobile(navigator) });
|
|
61
|
+
if (route !== InstallRoute.Prompt) showInstallHelp(card, route, button);
|
|
62
|
+
offer?.prompt().catch((error: unknown) => console.warn(error));
|
|
63
|
+
offer = null;
|
|
64
|
+
}, { signal }));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Wires every `[data-contact-card]` once: motion, Show my QR and Add to home screen; `signal` removes the listeners. */
|
|
68
|
+
export function mountContactCards(root: ParentNode = document, signal?: AbortSignal): void {
|
|
69
|
+
const cards = takeUnmountedCards(root, signal);
|
|
70
|
+
if (cards.length === 0) return;
|
|
71
|
+
cards.forEach((card) => {
|
|
72
|
+
mountCardMotion(card, signal);
|
|
73
|
+
setHidden(Array.from(card.querySelectorAll<HTMLElement>('[data-card-qr]')), false);
|
|
74
|
+
});
|
|
75
|
+
mountInstall(cards, signal);
|
|
76
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { optionError } from './checks';
|
|
2
|
+
|
|
3
|
+
const SEPARATORS = /[\s.-]/g;
|
|
4
|
+
const INTERNATIONAL_NUMBER = /^\+[1-9]\d{6,14}$/;
|
|
5
|
+
|
|
6
|
+
/** Returns a phone number as `+` and digits for `tel:` links and contact files; throws unless it is international. */
|
|
7
|
+
export function toDialNumber(phone: string): string {
|
|
8
|
+
const dialNumber = phone.replace(SEPARATORS, '');
|
|
9
|
+
if (!INTERNATIONAL_NUMBER.test(dialNumber)) throw optionError('phone', 'must be an international number starting with +');
|
|
10
|
+
return dialNumber;
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import createQrCode from 'qrcode-generator';
|
|
2
|
+
import { optionError, requireHttpsUrl, requireText } from './checks';
|
|
3
|
+
|
|
4
|
+
const ERROR_CORRECTION_LEVEL = 'M';
|
|
5
|
+
const AUTO_TYPE_NUMBER = 0;
|
|
6
|
+
const QUIET_ZONE_MODULES = 4;
|
|
7
|
+
const DEFAULT_DARK_COLOR = '#000000';
|
|
8
|
+
const DEFAULT_LIGHT_COLOR = '#ffffff';
|
|
9
|
+
const HEX_COLOR_PATTERN = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
10
|
+
|
|
11
|
+
export interface QrSvgOptions {
|
|
12
|
+
url: string;
|
|
13
|
+
title: string;
|
|
14
|
+
darkColor?: string;
|
|
15
|
+
lightColor?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function requireHexColor(value: string, field: string): string {
|
|
19
|
+
if (!HEX_COLOR_PATTERN.test(value)) throw optionError(field, 'must be a 3 or 6 digit hex colour');
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function escapeMarkup(text: string): string {
|
|
24
|
+
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function rowPath(cells: string, row: number): string {
|
|
28
|
+
return Array.from(cells.matchAll(/1+/g), (run) => {
|
|
29
|
+
const width = String(run[0].length);
|
|
30
|
+
return `M${String(run.index + QUIET_ZONE_MODULES)} ${String(row + QUIET_ZONE_MODULES)}h${width}v1h-${width}z`;
|
|
31
|
+
}).join('');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function darkRows(text: string): string[] {
|
|
35
|
+
const qr = createQrCode(AUTO_TYPE_NUMBER, ERROR_CORRECTION_LEVEL);
|
|
36
|
+
qr.addData(text);
|
|
37
|
+
qr.make();
|
|
38
|
+
const indexes = Array.from({ length: qr.getModuleCount() }, (_cell, index) => index);
|
|
39
|
+
return indexes.map((row) => indexes.map((column) => (qr.isDark(row, column) ? '1' : '0')).join(''));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Returns a standalone SVG of the URL's QR code with its quiet zone, for a page or a print file. */
|
|
43
|
+
export function buildQrSvg(options: QrSvgOptions): string {
|
|
44
|
+
const title = escapeMarkup(requireText(options.title, 'title'));
|
|
45
|
+
const dark = requireHexColor(options.darkColor ?? DEFAULT_DARK_COLOR, 'darkColor');
|
|
46
|
+
const light = requireHexColor(options.lightColor ?? DEFAULT_LIGHT_COLOR, 'lightColor');
|
|
47
|
+
const rows = darkRows(requireHttpsUrl(options.url, 'url'));
|
|
48
|
+
const size = String(rows.length + QUIET_ZONE_MODULES + QUIET_ZONE_MODULES);
|
|
49
|
+
return (
|
|
50
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${size} ${size}" role="img" shape-rendering="crispEdges">` +
|
|
51
|
+
`<title>${title}</title><rect width="100%" height="100%" fill="${light}"/>` +
|
|
52
|
+
`<path fill="${dark}" d="${rows.map(rowPath).join('')}"/></svg>`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.tmk-card-share{position:fixed;inset:0;width:100%;max-width:none;height:100%;max-height:none;margin:0;padding:max(16px,env(safe-area-inset-top)) 16px max(16px,env(safe-area-inset-bottom));border:0;background:var(--card-bg);color:var(--card-text)}
|
|
2
|
+
.tmk-card-share::backdrop{background:var(--card-bg)}
|
|
3
|
+
.tmk-card-share-in{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;width:100%;max-width:480px;min-height:100%;margin:0 auto;text-align:center}
|
|
4
|
+
.tmk-card-share-qr{width:min(100%,max(240px,min(70vw,100svh - 340px)));box-sizing:content-box;max-width:calc(100% - 24px);aspect-ratio:1;padding:12px;border-radius:var(--card-radius);background:var(--tmk-card-share-paper,Canvas);color-scheme:light}
|
|
5
|
+
.tmk-card-share-qr svg{display:block;width:100%;height:100%}
|
|
6
|
+
.tmk-card-share-name{color:var(--card-heading);font-size:24px;font-weight:600;line-height:1.2;overflow-wrap:anywhere}
|
|
7
|
+
.tmk-card-share-role{color:var(--card-soft);font-size:15px}
|
|
8
|
+
.tmk-card-share .tmk-card-button{width:100%;min-height:48px}
|
|
9
|
+
.tmk-card-share-face{flex:none;width:96px;height:110px;clip-path:var(--tmk-card-hex);background:var(--card-accent)}
|
|
10
|
+
.tmk-card-share-face img{display:block;width:100%;height:100%;object-fit:cover;clip-path:var(--tmk-card-hex);transform:scale(0.95)}
|
|
11
|
+
.tmk-card-share-brand{width:auto;height:32px}
|
|
12
|
+
.tmk-card-share[data-share='white-sheet'],.tmk-card-share[data-share='white-sheet']::backdrop{color-scheme:light;background:var(--tmk-card-share-paper,Canvas);color:var(--tmk-card-share-ink,CanvasText)}
|
|
13
|
+
.tmk-card-share[data-share='white-sheet'] .tmk-card-share-qr{width:min(100%,76vh);padding:0}
|
|
14
|
+
.tmk-card-share[data-share='night-frame'] .tmk-card-share-qr{padding:20px;background:var(--card-raised);outline:2px solid var(--card-accent);outline-offset:6px}
|
|
15
|
+
@media (prefers-reduced-motion:no-preference){.tmk-card-share[open]{animation:tmk-card-share-in 200ms cubic-bezier(0.2,0,0,1)}}
|
|
16
|
+
@keyframes tmk-card-share-in{from{opacity:0}to{opacity:1}}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.tmk-card[data-card-form='two-sided']{--tmk-card-stage-h:clamp(400px,100svh - 152px,520px);--tmk-card-stage-w:calc(var(--tmk-card-stage-h) * 54 / 85.6);display:grid;grid-template-columns:min(100%,var(--tmk-card-stage-w));justify-content:center;align-content:start;gap:12px;padding:12px 16px 16px}
|
|
2
|
+
.tmk-card-stage{position:relative;width:100%;height:var(--tmk-card-stage-h);aspect-ratio:var(--tmk-card-aspect,54/85.6);perspective:1200px}
|
|
3
|
+
.tmk-card-tilt,.tmk-card-flip{position:relative;width:100%;height:100%;transform-style:preserve-3d}
|
|
4
|
+
.tmk-card-flip[data-face='back']{transform:rotateY(180deg)}
|
|
5
|
+
.tmk-card-face{position:absolute;inset:0;overflow:auto;padding:20px;border:1px solid var(--card-accent);border-radius:var(--card-radius);background:var(--card-raised);box-shadow:var(--tmk-card-shadow,none);backface-visibility:hidden;-webkit-backface-visibility:hidden;container-type:inline-size}
|
|
6
|
+
.tmk-card-front{display:grid;grid-template-columns:minmax(0,1fr) 88px;grid-template-areas:'id photo' 'list list';align-content:start;gap:16px 12px}
|
|
7
|
+
.tmk-card-front .tmk-card-identity{grid-area:id;min-width:0}
|
|
8
|
+
.tmk-card-front .tmk-card-name{font-size:clamp(26px,8.4cqi,30px);line-height:1.15;overflow-wrap:anywhere}
|
|
9
|
+
.tmk-card-front .tmk-card-name span{display:block}
|
|
10
|
+
.tmk-card-front .tmk-card-role{display:-webkit-box;margin-top:6px;overflow:hidden;font-size:15px;overflow-wrap:anywhere;-webkit-box-orient:vertical;-webkit-line-clamp:2}
|
|
11
|
+
.tmk-card-front .tmk-card-portrait{grid-area:photo;width:88px;height:100px;aspect-ratio:auto}
|
|
12
|
+
.tmk-card-front .tmk-card-rows{grid-area:list;min-width:0}
|
|
13
|
+
.tmk-card-front .tmk-card-rows a{position:relative;display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-areas:'icon label' 'icon value';align-content:center;column-gap:10px;min-height:52px;border-top:1px solid var(--card-line)}
|
|
14
|
+
.tmk-card-front .tmk-card-rows a:last-child{border-bottom:1px solid var(--card-line)}
|
|
15
|
+
.tmk-card-front .tmk-card-rows .tmk-card-icon{grid-area:icon}
|
|
16
|
+
.tmk-card-front .tmk-card-label{grid-area:label;font-size:13px}
|
|
17
|
+
.tmk-card-front .tmk-card-value{grid-area:value;font-size:16px}
|
|
18
|
+
.tmk-card-back{display:grid;place-items:center;transform:rotateY(180deg)}
|
|
19
|
+
.tmk-card-lockup{display:flex;align-items:center;justify-content:center}
|
|
20
|
+
.tmk-card-back .tmk-card-mark{width:96px;height:96px}
|
|
21
|
+
.tmk-card-back-logo{display:block;width:auto;height:96px}
|
|
22
|
+
.tmk-card-turn{position:absolute;right:8px;bottom:8px;z-index:4;display:grid;place-items:center;width:44px;height:44px;padding:0;border:1px solid var(--card-edge);border-radius:50%;background:var(--card-raised);color:var(--card-text);transform:translateZ(1px)}
|
|
23
|
+
.tmk-card-side{display:flex;flex-direction:column;gap:8px;padding-bottom:4px}
|
|
24
|
+
.tmk-card-side .tmk-card-save{margin-bottom:4px}
|
|
25
|
+
.tmk-card-face .tmk-card-sweep>span{left:50%;width:140px;margin-left:-70px;background:linear-gradient(90deg,transparent,color-mix(in srgb,var(--card-accent) 18%,transparent),transparent)}
|
|
26
|
+
.tmk-card-face .tmk-card-sweep{border-radius:var(--card-radius)}
|
|
27
|
+
|
|
28
|
+
@media (max-height:551px){
|
|
29
|
+
.tmk-card[data-card-form='two-sided'] .tmk-card-side .tmk-card-save{position:sticky;bottom:0}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (min-width:1024px){
|
|
33
|
+
.tmk-card[data-card-form='two-sided']{grid-template-columns:560px 280px;align-content:center;column-gap:48px}
|
|
34
|
+
.tmk-card-stage{width:560px;height:auto;aspect-ratio:var(--tmk-card-aspect-wide,85.6/54)}
|
|
35
|
+
.tmk-card-side{align-self:center}
|
|
36
|
+
.tmk-card-side .tmk-card-save{min-height:64px}
|
|
37
|
+
.tmk-card-front{grid-template-columns:140px minmax(0,1fr);grid-template-areas:'photo id' 'photo list';column-gap:24px}
|
|
38
|
+
.tmk-card-front .tmk-card-portrait{width:140px;height:160px}
|
|
39
|
+
.tmk-card-front .tmk-card-name{font-size:40px}
|
|
40
|
+
.tmk-card-front .tmk-card-role{font-size:18px}
|
|
41
|
+
.tmk-card-back .tmk-card-mark{width:120px;height:120px}
|
|
42
|
+
.tmk-card-back-logo{height:120px}
|
|
43
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface ContactCardPerson {
|
|
2
|
+
givenName: string;
|
|
3
|
+
familyName: string;
|
|
4
|
+
role: string;
|
|
5
|
+
phone: string;
|
|
6
|
+
email: string;
|
|
7
|
+
website: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ContactCardImage {
|
|
11
|
+
src: string;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ContactCardBrand extends ContactCardImage {
|
|
17
|
+
href: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ContactCardPortrait extends ContactCardImage {
|
|
22
|
+
alt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ContactCardLabels {
|
|
26
|
+
save: string;
|
|
27
|
+
call: string;
|
|
28
|
+
email: string;
|
|
29
|
+
website: string;
|
|
30
|
+
contacts: string;
|
|
31
|
+
install: string;
|
|
32
|
+
showQr: string;
|
|
33
|
+
qrTitle: string;
|
|
34
|
+
installTitle: string;
|
|
35
|
+
appleSteps: string[];
|
|
36
|
+
menuHint: string;
|
|
37
|
+
close: string;
|
|
38
|
+
hideQr: string;
|
|
39
|
+
ready: string;
|
|
40
|
+
/** The two-sided card's turn button and face names; required when `cardForm` is `two-sided`. */
|
|
41
|
+
turnToBack?: string;
|
|
42
|
+
turnToFront?: string;
|
|
43
|
+
cardFront?: string;
|
|
44
|
+
cardBack?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A brand mark from @dloizides/logo-kit: a mode's intro and still markup, plus its wordmark. */
|
|
48
|
+
export interface ContactCardBrandMarkup {
|
|
49
|
+
intro: string;
|
|
50
|
+
still: string;
|
|
51
|
+
wordmark?: { html: string; css: string } | null;
|
|
52
|
+
}
|