@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,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
import CardActions from './CardActions.astro';
|
|
3
|
+
import CardBack from './CardBack.astro';
|
|
4
|
+
import CardFront from './CardFront.astro';
|
|
5
|
+
import type { CardLink } from './cardLinks';
|
|
6
|
+
import CardSave from './CardSave.astro';
|
|
7
|
+
import CardTurn from './CardTurn.astro';
|
|
8
|
+
import { requireText } from './checks';
|
|
9
|
+
import type { ContactCardMotion } from './motion/cardMotion';
|
|
10
|
+
import { OpenLanding } from './motion/OpenLanding';
|
|
11
|
+
import { OpenMotion } from './motion/OpenMotion';
|
|
12
|
+
import { tiltLights } from './motion/tiltLights';
|
|
13
|
+
import type { ContactCardBrand, ContactCardBrandMarkup, ContactCardLabels, ContactCardPerson, ContactCardPortrait } from './types';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
person: ContactCardPerson;
|
|
17
|
+
portrait: ContactCardPortrait;
|
|
18
|
+
brand: ContactCardBrand;
|
|
19
|
+
markup?: ContactCardBrandMarkup | undefined;
|
|
20
|
+
labels: ContactCardLabels;
|
|
21
|
+
links: CardLink[];
|
|
22
|
+
saveProps: Parameters<typeof CardSave>[0];
|
|
23
|
+
motion: ContactCardMotion;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { person, portrait, brand, markup, labels, links, saveProps, motion } = Astro.props;
|
|
27
|
+
const toBack = requireText(labels.turnToBack ?? '', 'labels.turnToBack');
|
|
28
|
+
const toFront = requireText(labels.turnToFront ?? '', 'labels.turnToFront');
|
|
29
|
+
const frontLabel = requireText(labels.cardFront ?? '', 'labels.cardFront');
|
|
30
|
+
const backLabel = requireText(labels.cardBack ?? '', 'labels.cardBack');
|
|
31
|
+
const lights = tiltLights(motion.tiltMotion);
|
|
32
|
+
const onBack = motion.openMotion === OpenMotion.TileGrows && motion.openLands === OpenLanding.Back;
|
|
33
|
+
---
|
|
34
|
+
<section class="tmk-card-stage" aria-roledescription="card" aria-label={`${person.givenName} ${person.familyName}`} data-part="stage" data-testid="card-stage">
|
|
35
|
+
<div class="tmk-card-tilt" data-part="tilt">
|
|
36
|
+
<div class="tmk-card-flip" data-part="flip" data-face={onBack ? 'back' : 'front'}>
|
|
37
|
+
<CardFront person={person} portrait={portrait} links={links} contactsLabel={labels.contacts} faceLabel={frontLabel} hexLight={lights.hex} sweep={lights.sweep} hidden={onBack} />
|
|
38
|
+
<CardBack brand={brand} markup={markup} animated={motion.openMotion !== OpenMotion.None} faceLabel={backLabel} sweep={lights.sweep} hidden={!onBack} />
|
|
39
|
+
</div>
|
|
40
|
+
{lights.edge && <span class="tmk-card-edge" aria-hidden="true" data-part="edge"><span data-part="edge-light"></span></span>}
|
|
41
|
+
<CardTurn toBack={toBack} toFront={toFront} onBack={onBack} />
|
|
42
|
+
</div>
|
|
43
|
+
</section>
|
|
44
|
+
<div class="tmk-card-side" data-part="side">
|
|
45
|
+
<CardSave {...saveProps} />
|
|
46
|
+
<CardActions labels={labels} />
|
|
47
|
+
</div>
|
|
48
|
+
<span class="tmk-card-live" aria-live="polite" data-part="turn-live"></span>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { CardLink } from './cardLinks';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
links: CardLink[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { links } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
<ul class="tmk-card-values" data-part="values" data-testid="card-values">
|
|
11
|
+
{links.map((link) => <li>{link.value}</li>)}
|
|
12
|
+
</ul>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CardIconName } from './CardIconName';
|
|
2
|
+
import { CardLinkKind } from './CardLinkKind';
|
|
3
|
+
|
|
4
|
+
export const CARD_ICONS: Readonly<Record<CardIconName | CardLinkKind, string>> = {
|
|
5
|
+
[CardIconName.Save]: '<circle cx="9.5" cy="8" r="4"/><path d="M2.5 20.5c0-4 3-6.5 7-6.5 1.6 0 3 .4 4.2 1.1M18 14v7M14.5 17.5h7"/>',
|
|
6
|
+
[CardLinkKind.Call]: '<path d="M5 3h4l1.8 4.8-2.3 1.7a12 12 0 0 0 6 6l1.7-2.3L21 15v4a2 2 0 0 1-2.2 2A17 17 0 0 1 3 5.2 2 2 0 0 1 5 3Z"/>',
|
|
7
|
+
[CardLinkKind.Email]: '<rect x="3" y="5" width="18" height="14" rx="1.5"/><path d="m3.5 6.5 8.5 6.5 8.5-6.5"/>',
|
|
8
|
+
[CardLinkKind.Website]: '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c2.6 2.6 3.8 5.6 3.8 9S14.6 18.4 12 21c-2.6-2.6-3.8-5.6-3.8-9S9.4 5.6 12 3Z"/>',
|
|
9
|
+
[CardIconName.Install]: '<rect x="6" y="2.5" width="12" height="19" rx="2"/><path d="M12 8v7M8.8 11.8 12 15l3.2-3.2"/>',
|
|
10
|
+
[CardIconName.Turn]: '<path d="M4 12a8 8 0 0 1 14-5.3M20 12a8 8 0 0 1-14 5.3"/><path d="M18.5 3v4h-4M5.5 21v-4h4"/>',
|
|
11
|
+
[CardIconName.Qr]: '<rect x="3.5" y="3.5" width="6.5" height="6.5"/><rect x="14" y="3.5" width="6.5" height="6.5"/><rect x="3.5" y="14" width="6.5" height="6.5"/><path d="M14 14h2.5v2.5M20.5 14v2.5M14 20.5h2.5M20.5 20.5h-1.5"/>',
|
|
12
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CardLinkKind } from './CardLinkKind';
|
|
2
|
+
import { optionError, requireEmail, requireHttpsUrl } from './checks';
|
|
3
|
+
import { ContactCardLayout } from './ContactCardLayout';
|
|
4
|
+
import { toDialNumber } from './phone';
|
|
5
|
+
import type { ContactCardLabels, ContactCardPerson } from './types';
|
|
6
|
+
|
|
7
|
+
const LAYOUTS = [ContactCardLayout.Portrait, ContactCardLayout.Name, ContactCardLayout.Framed, ContactCardLayout.Honeycomb];
|
|
8
|
+
const SAVE_HREF_PATTERN = /^(?:https:\/\/|\/(?![/\\]))\S+$/;
|
|
9
|
+
|
|
10
|
+
export interface CardLink {
|
|
11
|
+
kind: CardLinkKind;
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
href: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function websiteText(href: string): string {
|
|
18
|
+
const { host, pathname } = new URL(href);
|
|
19
|
+
return `${host}${pathname}`.replace(/\/$/, '');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Returns the call, email and website links in card order; throws naming the first bad field. */
|
|
23
|
+
export function buildCardLinks(person: ContactCardPerson, labels: Pick<ContactCardLabels, CardLinkKind>): CardLink[] {
|
|
24
|
+
const website = requireHttpsUrl(person.website, 'website');
|
|
25
|
+
return [
|
|
26
|
+
{ kind: CardLinkKind.Call, label: labels.call, value: person.phone, href: `tel:${toDialNumber(person.phone)}` },
|
|
27
|
+
{ kind: CardLinkKind.Email, label: labels.email, value: person.email, href: `mailto:${requireEmail(person.email)}` },
|
|
28
|
+
{ kind: CardLinkKind.Website, label: labels.website, value: websiteText(website), href: website },
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Returns the layout; throws listing the allowed ones, because a typo would render an unstyled card. */
|
|
33
|
+
export function requireCardLayout(layout: string): ContactCardLayout {
|
|
34
|
+
const known = LAYOUTS.find((item) => String(item) === layout);
|
|
35
|
+
if (known === undefined) throw optionError('layout', `must be one of ${LAYOUTS.join(', ')}`);
|
|
36
|
+
return known;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Returns the address of the contact file; throws unless it is an https URL or a path on this site. */
|
|
40
|
+
export function requireSaveHref(href: string): string {
|
|
41
|
+
if (!SAVE_HREF_PATTERN.test(href)) throw optionError('saveHref', 'must be an https URL or a path starting with /');
|
|
42
|
+
return href;
|
|
43
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const ERROR_PREFIX = 'contactCard:';
|
|
2
|
+
const HTTPS_PROTOCOL = 'https:';
|
|
3
|
+
const EMAIL_PATTERN = /^[\w.+-]+@[\w-]+(?:\.[\w-]+)+$/;
|
|
4
|
+
|
|
5
|
+
/** Returns the error every contact card builder throws for a bad option. */
|
|
6
|
+
export function optionError(field: string, problem: string): Error {
|
|
7
|
+
return new Error(`${ERROR_PREFIX} ${field} ${problem}`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Returns the trimmed text; throws naming the field when it is blank. */
|
|
11
|
+
export function requireText(value: string, field: string): string {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if (trimmed === '') throw optionError(field, 'must not be blank');
|
|
14
|
+
return trimmed;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Returns the URL in its normalised, percent-encoded form; throws naming the field unless it is https. */
|
|
18
|
+
export function requireHttpsUrl(value: string, field: string): string {
|
|
19
|
+
const url = URL.canParse(value) ? new URL(value) : null;
|
|
20
|
+
if (url?.protocol !== HTTPS_PROTOCOL) throw optionError(field, 'must be an https URL');
|
|
21
|
+
return url.href;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Returns the address unchanged; throws unless it is one email address. */
|
|
25
|
+
export function requireEmail(email: string): string {
|
|
26
|
+
if (!EMAIL_PATTERN.test(email)) throw optionError('email', 'must be one email address');
|
|
27
|
+
return email;
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InstallRoute } from './InstallRoute';
|
|
2
|
+
|
|
3
|
+
const APPLE_MOBILE_PATTERN = /iPhone|iPad|iPod/;
|
|
4
|
+
const MAC_PATTERN = /Macintosh/;
|
|
5
|
+
|
|
6
|
+
export interface InstallState {
|
|
7
|
+
hasPrompt: boolean;
|
|
8
|
+
isApple: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Returns true on an iPhone or iPad; an iPad reports itself as a Mac, but only the iPad has touch points. */
|
|
12
|
+
export function isAppleMobile(device: Pick<Navigator, 'userAgent' | 'maxTouchPoints'>): boolean {
|
|
13
|
+
if (APPLE_MOBILE_PATTERN.test(device.userAgent)) return true;
|
|
14
|
+
return MAC_PATTERN.test(device.userAgent) && device.maxTouchPoints > 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Returns the browser's own prompt when it offered one, else the help that fits the device. */
|
|
18
|
+
export function chooseInstallRoute(state: InstallState): InstallRoute {
|
|
19
|
+
if (state.hasPrompt) return InstallRoute.Prompt;
|
|
20
|
+
return state.isApple ? InstallRoute.AppleSteps : InstallRoute.MenuHint;
|
|
21
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
.tmk-card{
|
|
2
|
+
--tmk-card-hex:polygon(50% 0,100% 25%,100% 75%,50% 100%,0 75%,0 25%);
|
|
3
|
+
--card-bg:var(--tmk-card-bg,var(--paper,Canvas));
|
|
4
|
+
--card-raised:var(--tmk-card-raised,var(--bg-tint,var(--card-bg)));
|
|
5
|
+
--card-fill:var(--tmk-card-fill,var(--tmk-card-raised,var(--bg-tint,color-mix(in srgb,var(--card-text) 8%,var(--card-bg)))));
|
|
6
|
+
--card-text:var(--tmk-card-text,var(--ink,CanvasText));
|
|
7
|
+
--card-heading:var(--tmk-card-heading,var(--card-text));
|
|
8
|
+
--card-soft:var(--tmk-card-text-soft,var(--muted,var(--card-text)));
|
|
9
|
+
--card-line:var(--tmk-card-line,var(--hairline,currentColor));
|
|
10
|
+
--card-edge:var(--tmk-card-edge,var(--card-soft));
|
|
11
|
+
--card-accent:var(--tmk-card-accent,var(--accent,LinkText));
|
|
12
|
+
--card-on-accent:var(--tmk-card-on-accent,var(--card-bg));
|
|
13
|
+
--card-radius:var(--tmk-card-radius,6px);
|
|
14
|
+
position:relative;
|
|
15
|
+
display:flex;
|
|
16
|
+
flex-direction:column;
|
|
17
|
+
min-height:100vh;
|
|
18
|
+
min-height:100svh;
|
|
19
|
+
padding:12px max(16px,(100% - 480px)/2) 16px;
|
|
20
|
+
background:var(--card-bg);
|
|
21
|
+
color:var(--card-text);
|
|
22
|
+
font-family:var(--tmk-card-font,inherit);
|
|
23
|
+
font-size:16px;
|
|
24
|
+
font-weight:400;
|
|
25
|
+
line-height:1.4;
|
|
26
|
+
}
|
|
27
|
+
.tmk-card,.tmk-card *,.tmk-card *::before,.tmk-card *::after{box-sizing:border-box}
|
|
28
|
+
.tmk-card :where(h1,h2,p,ul,ol,button){margin:0;font:inherit;letter-spacing:normal}
|
|
29
|
+
.tmk-card :where(a,button){color:inherit;text-decoration:none}
|
|
30
|
+
.tmk-card :where(button){cursor:pointer}
|
|
31
|
+
.tmk-card [hidden]{display:none!important}
|
|
32
|
+
.tmk-card :focus-visible{outline:2px solid var(--card-accent);outline-offset:2px}
|
|
33
|
+
|
|
34
|
+
.tmk-card-brand{display:flex;align-items:center;min-height:44px}
|
|
35
|
+
.tmk-card-brand img{display:block;width:auto;height:32px}
|
|
36
|
+
.tmk-card .tmk-card-name{color:var(--card-heading);font-weight:500;letter-spacing:-.01em;overflow-wrap:break-word;hyphens:auto}
|
|
37
|
+
.tmk-card .tmk-card-role{color:var(--card-soft);font-weight:500;line-height:var(--tmk-card-role-line-height,1.3);text-wrap:balance}
|
|
38
|
+
.tmk-card-icon{flex:none;width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:square;stroke-linejoin:miter}
|
|
39
|
+
|
|
40
|
+
.tmk-card-portrait{flex:none;width:112px;aspect-ratio:112/128;padding:2px;background:var(--card-accent);clip-path:var(--tmk-card-hex)}
|
|
41
|
+
.tmk-card-portrait div{height:100%;overflow:hidden;background:var(--card-fill);clip-path:var(--tmk-card-hex)}
|
|
42
|
+
.tmk-card-portrait img{display:block;width:100%;height:100%;object-fit:cover;transform:scale(var(--tmk-card-portrait-scale,1));transform-origin:var(--tmk-card-portrait-origin,50% 50%);-webkit-mask-image:var(--tmk-card-portrait-mask,none);mask-image:var(--tmk-card-portrait-mask,none)}
|
|
43
|
+
|
|
44
|
+
.tmk-card-save{display:flex;align-items:center;justify-content:center;gap:10px;min-height:56px;border-radius:var(--card-radius);background:var(--card-accent);color:var(--card-on-accent);font-size:20px;font-weight:600}
|
|
45
|
+
.tmk-card-actions{display:flex;flex-wrap:wrap;gap:8px}
|
|
46
|
+
.tmk-card .tmk-card-button{display:flex;align-items:center;justify-content:center;gap:6px;min-height:48px;padding:0 6px;border:1px solid var(--card-edge);border-radius:var(--card-radius);background:none;font-weight:500;white-space:nowrap}
|
|
47
|
+
.tmk-card-button .tmk-card-icon{width:20px;height:20px}
|
|
48
|
+
.tmk-card-install{flex:1}
|
|
49
|
+
|
|
50
|
+
.tmk-card .tmk-card-values{padding:0;list-style:none;font-size:17px;line-height:1.45}
|
|
51
|
+
.tmk-card-values li{overflow-wrap:anywhere}
|
|
52
|
+
.tmk-card-rows a{display:flex;align-items:center;min-height:48px}
|
|
53
|
+
.tmk-card-rows .tmk-card-label{color:var(--card-soft)}
|
|
54
|
+
.tmk-card-value{min-width:0;font-size:17px;font-weight:500;overflow-wrap:anywhere}
|
|
55
|
+
.tmk-card-value,.tmk-card-values{font-variant-numeric:tabular-nums}
|
|
56
|
+
|
|
57
|
+
.tmk-card-dialog{width:min(400px,100vw - 32px);max-width:none;max-height:calc(100dvh - 32px);margin:auto;padding:20px;overflow:auto;border:1px solid var(--card-accent);border-radius:var(--card-radius);background:var(--card-raised);color:var(--card-text)}
|
|
58
|
+
.tmk-card-dialog::backdrop{background:rgb(0 0 0/.7)}
|
|
59
|
+
.tmk-card .tmk-card-dialog h2{margin-bottom:16px;color:var(--card-heading);font-size:22px;font-weight:500;line-height:1.25}
|
|
60
|
+
.tmk-card .tmk-card-dialog ol{padding-left:1.25em}
|
|
61
|
+
.tmk-card-dialog li+li{margin-top:8px}
|
|
62
|
+
.tmk-card-dialog .tmk-card-button{width:100%;margin-top:20px}
|
|
63
|
+
.tmk-card-qr svg{display:block;width:min(100%,100dvh - 190px);min-width:160px;margin:0 auto}
|
|
64
|
+
.tmk-card-qr rect{fill:var(--tmk-card-qr-light,#fff)}
|
|
65
|
+
.tmk-card-qr path{fill:var(--tmk-card-qr-dark,#000)}
|
|
66
|
+
|
|
67
|
+
@media (display-mode:standalone){
|
|
68
|
+
.tmk-card .tmk-card-install{display:none}
|
|
69
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { CardForm } from './CardForm';
|
|
2
|
+
export { ContactCardLayout } from './ContactCardLayout';
|
|
3
|
+
export { ContactPhotoType } from './ContactPhotoType';
|
|
4
|
+
export { buildContactCardManifest } from './manifest';
|
|
5
|
+
export type { ContactCardManifestOptions } from './manifest';
|
|
6
|
+
export { toDialNumber } from './phone';
|
|
7
|
+
export { buildQrSvg } from './qrSvg';
|
|
8
|
+
export type { QrSvgOptions } from './qrSvg';
|
|
9
|
+
export type { ContactCardBrand, ContactCardBrandMarkup, ContactCardLabels, ContactCardPerson, ContactCardPortrait } from './types';
|
|
10
|
+
export { DEFAULT_CARD_MOTION, resolveCardMotion } from './motion/cardMotion';
|
|
11
|
+
export type { ContactCardMotion, ContactCardMotionInput } from './motion/cardMotion';
|
|
12
|
+
export { FlipMotion } from './motion/FlipMotion';
|
|
13
|
+
export { OpenLanding } from './motion/OpenLanding';
|
|
14
|
+
export { OpenMotion } from './motion/OpenMotion';
|
|
15
|
+
export { QrMotion } from './motion/QrMotion';
|
|
16
|
+
export { SaveMotion } from './motion/SaveMotion';
|
|
17
|
+
export { ShareMode } from './motion/ShareMode';
|
|
18
|
+
export { TiltMotion } from './motion/TiltMotion';
|
|
19
|
+
export { buildVCard } from './vCard';
|
|
20
|
+
export type { ContactPhoto, VCardOptions } from './vCard';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
.tmk-card[data-layout='portrait']{text-align:center}
|
|
2
|
+
.tmk-card[data-layout='portrait'] .tmk-card-brand{align-self:center;margin-right:var(--tmk-card-brand-offset,0)}
|
|
3
|
+
.tmk-card[data-layout='portrait'] .tmk-card-disc{display:grid;place-items:center;align-self:center;width:148px;height:148px;margin:6px 0 10px;border:1px solid var(--card-accent);border-radius:50%;background:var(--card-raised)}
|
|
4
|
+
.tmk-card[data-layout='portrait'] .tmk-card-portrait{width:124px;padding:0;background:none}
|
|
5
|
+
.tmk-card[data-layout='portrait'] .tmk-card-main{display:flex;flex:1;flex-direction:column}
|
|
6
|
+
.tmk-card[data-layout='portrait'] .tmk-card-name{font-size:32px;line-height:var(--tmk-card-name-line-height,1.2)}
|
|
7
|
+
.tmk-card[data-layout='portrait'] .tmk-card-role{margin:4px 0 14px;font-size:17px}
|
|
8
|
+
.tmk-card[data-layout='portrait'] .tmk-card-tiles{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:8px 0 12px}
|
|
9
|
+
.tmk-card[data-layout='portrait'] .tmk-card-tiles a{display:grid;justify-items:center;align-content:center;gap:2px;min-height:60px;border-radius:var(--card-radius);background:var(--card-fill);font-weight:500}
|
|
10
|
+
.tmk-card[data-layout='portrait'] .tmk-card-actions{margin-top:auto}
|
|
11
|
+
|
|
12
|
+
.tmk-card[data-layout='name'] .tmk-card-identity{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:8px;margin:14px 0 18px}
|
|
13
|
+
.tmk-card[data-layout='name'] .tmk-card-name{font-size:clamp(34px,11vw,50px);font-weight:400;line-height:var(--tmk-card-name-line-height,1.2);letter-spacing:-.025em}
|
|
14
|
+
.tmk-card[data-layout='name'] .tmk-card-name span,.tmk-card[data-layout='framed'] .tmk-card-name span{display:block}
|
|
15
|
+
.tmk-card[data-layout='name'] .tmk-card-portrait{width:92px}
|
|
16
|
+
.tmk-card[data-layout='name'] .tmk-card-role{grid-column:1/-1;margin-top:14px;font-size:18px}
|
|
17
|
+
.tmk-card[data-layout='name'] .tmk-card-save{justify-content:flex-start;padding:0 18px}
|
|
18
|
+
.tmk-card[data-layout='name'] .tmk-card-rows{margin:14px 0}
|
|
19
|
+
.tmk-card[data-layout='name'] .tmk-card-rows a{position:relative;min-height:56px}
|
|
20
|
+
.tmk-card[data-layout='name'] .tmk-card-rows a::before,.tmk-card[data-layout='name'] .tmk-card-rows a:last-child::after{content:'';position:absolute;top:0;right:0;left:0;border-top:1px solid var(--card-line);transform-origin:0 50%}
|
|
21
|
+
.tmk-card[data-layout='name'] .tmk-card-rows a:last-child::after{top:auto;bottom:0}
|
|
22
|
+
.tmk-card[data-layout='name'] .tmk-card-rows .tmk-card-icon{display:none}
|
|
23
|
+
.tmk-card[data-layout='name'] .tmk-card-label{flex:none;min-width:80px;padding-right:8px}
|
|
24
|
+
.tmk-card[data-layout='name'] .tmk-card-actions{margin-top:auto}
|
|
25
|
+
|
|
26
|
+
.tmk-card[data-layout='framed'] .tmk-card-frame{display:flex;flex-direction:column;min-height:420px;padding:12px 16px 6px;border:1px solid var(--card-accent);border-radius:var(--card-radius);background:var(--card-raised)}
|
|
27
|
+
.tmk-card[data-layout='framed'] .tmk-card-identity{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;column-gap:8px;margin:auto 0}
|
|
28
|
+
.tmk-card[data-layout='framed'] .tmk-card-name{font-size:clamp(26px,8vw,38px);line-height:var(--tmk-card-name-line-height,1.2)}
|
|
29
|
+
.tmk-card[data-layout='framed'] .tmk-card-portrait{width:100px}
|
|
30
|
+
.tmk-card[data-layout='framed'] .tmk-card-role{grid-column:1/-1;margin-top:10px;font-size:17px}
|
|
31
|
+
.tmk-card[data-layout='framed'] .tmk-card-rows a{display:grid;grid-template-columns:22px minmax(0,1fr);align-content:center;column-gap:14px;min-height:54px;border-top:1px solid var(--card-line)}
|
|
32
|
+
.tmk-card[data-layout='framed'] .tmk-card-rows .tmk-card-icon{grid-row:1/3;align-self:center;color:var(--card-accent)}
|
|
33
|
+
.tmk-card[data-layout='framed'] .tmk-card-label{font-size:15px;line-height:1.25}
|
|
34
|
+
.tmk-card[data-layout='framed'] .tmk-card-value{line-height:1.25}
|
|
35
|
+
.tmk-card[data-layout='framed'] .tmk-card-actions{margin-top:12px}
|
|
36
|
+
.tmk-card[data-layout='framed'] .tmk-card-save{flex:1 0 100%}
|
|
37
|
+
|
|
38
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-identity{margin:8px 0 14px}
|
|
39
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-name{font-size:36px;line-height:var(--tmk-card-name-line-height,1.2)}
|
|
40
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-role{margin-top:4px;font-size:17px}
|
|
41
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-comb{--w:min(106px,(100vw - 42px)/3);--g:5px;--h:calc(var(--w)*1.1547);position:relative;align-self:center;width:calc(var(--w)*3 + var(--g)*2);height:calc(var(--h)*1.75 + var(--g))}
|
|
42
|
+
.tmk-card[data-layout='honeycomb'] :is(.tmk-card-portrait,.tmk-card-save,.tmk-card-tiles a){position:absolute;width:var(--w);height:var(--h);aspect-ratio:auto;border-radius:0;clip-path:var(--tmk-card-hex)}
|
|
43
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-portrait{top:0;left:calc((var(--w) + var(--g))/2)}
|
|
44
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-save{--hex-fill:var(--card-accent);top:0;left:calc((var(--w) + var(--g))*1.5);flex-direction:column;gap:2px;font-size:18px;line-height:1.1;text-align:center}
|
|
45
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-save span{max-width:4.5em}
|
|
46
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-tiles a{--hex-fill:var(--card-fill);top:calc(var(--h)*.75 + var(--g));left:0;display:grid;justify-items:center;align-content:center;gap:4px;background:var(--card-fill);font-size:17px;font-weight:500}
|
|
47
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-tiles a:nth-child(2){left:calc(var(--w) + var(--g))}
|
|
48
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-tiles a:nth-child(3){left:calc((var(--w) + var(--g))*2)}
|
|
49
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-comb a:focus-visible{outline:none}
|
|
50
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-comb a:focus-visible::before,.tmk-card[data-layout='honeycomb'] .tmk-card-comb a:focus-visible::after{content:'';position:absolute;z-index:-1;clip-path:var(--tmk-card-hex)}
|
|
51
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-comb a:focus-visible::before{inset:4px;background:currentColor}
|
|
52
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-comb a:focus-visible::after{inset:7px;background:var(--hex-fill)}
|
|
53
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-values{margin:14px 0 12px}
|
|
54
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-actions{margin-top:auto}
|
|
55
|
+
|
|
56
|
+
@media (min-width:1024px){
|
|
57
|
+
.tmk-card[data-layout]{display:grid;justify-content:center;padding:12px 16px 16px}
|
|
58
|
+
.tmk-card[data-layout] .tmk-card-brand img{height:40px}
|
|
59
|
+
|
|
60
|
+
.tmk-card[data-layout='portrait']{grid-template-columns:320px 440px;grid-template-rows:1fr auto auto 1fr;column-gap:80px;text-align:left}
|
|
61
|
+
.tmk-card[data-layout='portrait'] .tmk-card-brand{grid-area:2/1;justify-self:center;margin-bottom:24px}
|
|
62
|
+
.tmk-card[data-layout='portrait'] .tmk-card-disc{grid-area:3/1;width:320px;height:320px;margin:0}
|
|
63
|
+
.tmk-card[data-layout='portrait'] .tmk-card-portrait{width:268px}
|
|
64
|
+
.tmk-card[data-layout='portrait'] .tmk-card-main{grid-area:2/2/4;justify-content:center}
|
|
65
|
+
.tmk-card[data-layout='portrait'] .tmk-card-name{font-size:48px}
|
|
66
|
+
.tmk-card[data-layout='portrait'] .tmk-card-role{margin:8px 0 28px;font-size:20px}
|
|
67
|
+
.tmk-card[data-layout='portrait'] .tmk-card-tiles{margin:12px 0 20px}
|
|
68
|
+
.tmk-card[data-layout='portrait'] .tmk-card-values{margin-bottom:24px;font-size:18px}
|
|
69
|
+
.tmk-card[data-layout='portrait'] .tmk-card-actions{margin-top:0}
|
|
70
|
+
|
|
71
|
+
.tmk-card[data-layout='name']{grid-template-columns:minmax(0,600px) 400px;align-content:center;column-gap:80px}
|
|
72
|
+
.tmk-card[data-layout='name'] .tmk-card-brand{grid-column:1/-1;justify-self:start;margin-bottom:40px}
|
|
73
|
+
.tmk-card[data-layout='name'] .tmk-card-identity{grid-column:1/-1;margin:0 0 48px}
|
|
74
|
+
.tmk-card[data-layout='name'] .tmk-card-name{font-size:120px}
|
|
75
|
+
.tmk-card[data-layout='name'] .tmk-card-portrait{grid-area:1/2/3;width:224px}
|
|
76
|
+
.tmk-card[data-layout='name'] .tmk-card-role{grid-column:1;margin-top:20px;font-size:24px}
|
|
77
|
+
.tmk-card[data-layout='name'] .tmk-card-save{grid-area:3/1;align-self:start;justify-self:start;min-width:360px;min-height:64px;font-size:22px}
|
|
78
|
+
.tmk-card[data-layout='name'] .tmk-card-rows{grid-area:3/2/5;margin:0}
|
|
79
|
+
.tmk-card[data-layout='name'] .tmk-card-actions{grid-area:4/1;align-self:end;margin:0}
|
|
80
|
+
|
|
81
|
+
.tmk-card[data-layout='framed']{grid-template-columns:minmax(0,680px) 280px;align-content:center;column-gap:48px}
|
|
82
|
+
.tmk-card[data-layout='framed'] .tmk-card-frame{min-height:440px;padding:32px 40px 24px}
|
|
83
|
+
.tmk-card[data-layout='framed'] .tmk-card-identity{margin:auto 0 24px;column-gap:32px}
|
|
84
|
+
.tmk-card[data-layout='framed'] .tmk-card-name{font-size:56px}
|
|
85
|
+
.tmk-card[data-layout='framed'] .tmk-card-portrait{grid-area:1/2/3;width:168px}
|
|
86
|
+
.tmk-card[data-layout='framed'] .tmk-card-role{grid-column:1;align-self:start;font-size:19px}
|
|
87
|
+
.tmk-card[data-layout='framed'] .tmk-card-rows{display:grid;grid-template-columns:repeat(3,auto);justify-content:space-between;column-gap:16px;padding-top:12px;border-top:1px solid var(--card-line)}
|
|
88
|
+
.tmk-card[data-layout='framed'] .tmk-card-rows a{grid-template-columns:minmax(0,auto);border:0}
|
|
89
|
+
.tmk-card[data-layout='framed'] .tmk-card-rows .tmk-card-icon{display:none}
|
|
90
|
+
.tmk-card[data-layout='framed'] .tmk-card-actions{flex-flow:column nowrap;align-self:center;margin:0}
|
|
91
|
+
.tmk-card[data-layout='framed'] .tmk-card-save{flex:none;min-height:64px}
|
|
92
|
+
|
|
93
|
+
.tmk-card[data-layout='honeycomb']{grid-template-columns:minmax(0,480px) auto;grid-template-rows:1fr auto auto auto auto 1fr;column-gap:64px}
|
|
94
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-brand{grid-row:2;justify-self:start;margin-bottom:40px}
|
|
95
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-identity{grid-row:3;margin:0 0 24px}
|
|
96
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-name{font-size:56px;line-height:var(--tmk-card-name-line-height,1.2)}
|
|
97
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-role{margin-top:12px;font-size:20px}
|
|
98
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-values{grid-row:4;margin:0 0 32px;font-size:19px}
|
|
99
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-actions{grid-row:5;margin:0}
|
|
100
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-comb{--w:min(182px,14.22vw);--g:7px;grid-area:1/2/7}
|
|
101
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-save{gap:6px;font-size:26px}
|
|
102
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-comb .tmk-card-icon{width:32px;height:32px}
|
|
103
|
+
.tmk-card[data-layout='honeycomb'] .tmk-card-tiles a{font-size:20px}
|
|
104
|
+
|
|
105
|
+
.tmk-card:not([data-layout='portrait']) .tmk-card-install{flex:none}
|
|
106
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { buildManifest } from '@dloizides/pwa-sw';
|
|
2
|
+
import type { BuiltManifest, ManifestIcon } from '@dloizides/pwa-sw';
|
|
3
|
+
import { optionError } from './checks';
|
|
4
|
+
|
|
5
|
+
const CARD_PATH_PATTERN = /^\/(?:[\w-]+\/)+$/;
|
|
6
|
+
const DEFAULT_LANG = 'en';
|
|
7
|
+
const CARD_ORIENTATION = 'any';
|
|
8
|
+
const CARD_CATEGORIES = ['business'];
|
|
9
|
+
|
|
10
|
+
export interface ContactCardManifestOptions {
|
|
11
|
+
cardPath: string;
|
|
12
|
+
name: string;
|
|
13
|
+
shortName: string;
|
|
14
|
+
description: string;
|
|
15
|
+
themeColor: string;
|
|
16
|
+
backgroundColor: string;
|
|
17
|
+
icons: ManifestIcon[];
|
|
18
|
+
lang?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builds the web manifest of one person's card, so each card installs as its own app and opens on that card.
|
|
23
|
+
* @param options `cardPath` must start and end with `/`: a scope without the last slash also covers longer names.
|
|
24
|
+
*/
|
|
25
|
+
export function buildContactCardManifest(options: ContactCardManifestOptions): BuiltManifest {
|
|
26
|
+
const { cardPath, lang = DEFAULT_LANG, ...branding } = options;
|
|
27
|
+
if (!CARD_PATH_PATTERN.test(cardPath)) throw optionError('cardPath', 'must be a path that starts and ends with /');
|
|
28
|
+
return buildManifest({
|
|
29
|
+
...branding,
|
|
30
|
+
lang,
|
|
31
|
+
id: cardPath,
|
|
32
|
+
startUrl: cardPath,
|
|
33
|
+
scope: cardPath,
|
|
34
|
+
orientation: CARD_ORIENTATION,
|
|
35
|
+
categories: [...CARD_CATEGORIES],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** How the card opens after a scan; the last four grow, open, turn or rise into the two-sided card. */
|
|
2
|
+
export const enum OpenMotion {
|
|
3
|
+
None = 'none',
|
|
4
|
+
MarkFirst = 'mark-first',
|
|
5
|
+
MarkLands = 'mark-lands',
|
|
6
|
+
WrittenIn = 'written-in',
|
|
7
|
+
TileGrows = 'tile-grows',
|
|
8
|
+
MoonOpens = 'moon-opens',
|
|
9
|
+
TurnsFaceUp = 'turns-face-up',
|
|
10
|
+
PassRises = 'pass-rises',
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What leans or shines when the phone tilts or a finger drags the card. */
|
|
2
|
+
export const enum TiltMotion {
|
|
3
|
+
None = 'none',
|
|
4
|
+
CardLeans = 'card-leans',
|
|
5
|
+
PortraitLeans = 'portrait-leans',
|
|
6
|
+
LayersDrift = 'layers-drift',
|
|
7
|
+
LightSweeps = 'light-sweeps',
|
|
8
|
+
GoldGloss = 'gold-gloss',
|
|
9
|
+
DeepLayers = 'deep-layers',
|
|
10
|
+
}
|