@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.13.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `./contactCard`: the logic of a digital business card. `buildVCard(options)` returns a vCard 3.0 file (escaped, folded at 75 octets, CRLF, optional JPEG or PNG photo), `buildContactCardManifest(options)` a web manifest that installs one person's card as its own app, `buildQrSvg(options)` a QR code as standalone SVG, `toDialNumber(phone)` the number for a `tel:` link. A bad option throws, so it fails the build.
|
|
8
|
+
- `./ContactCard.astro`: the card itself, in four layouts (`portrait`, `name`, `framed`, `honeycomb`), with Save contact, call, email and website links, a QR dialog and Add to home screen.
|
|
9
|
+
- Dependencies `@dloizides/pwa-sw` (manifest builder) and `qrcode-generator`.
|
|
10
|
+
- `ContactCard.astro` motion: a `motion` prop with four settings (`openMotion`, `tiltMotion`, `qrMotion`, `saveMotion`), each with `none` and three options, recommended ones by default, stills under reduced motion. The settings are written to `data-open-motion`, `data-tilt-motion`, `data-qr-motion` and `data-save-motion`; `data-tilting` marks a lean.
|
|
11
|
+
- `ContactCard.astro` `brandMarkup` prop: a `@dloizides/logo-kit` mark drawn in on open.
|
|
12
|
+
- `ContactCardLabels` gains the required `hideQr` and `ready`.
|
|
13
|
+
- `--tmk-card-name-line-height` (default 1.2) and `--tmk-card-role-line-height` (default 1.3).
|
|
14
|
+
- `createMotionController` takes an optional `signal`; aborting it stops the frame loop and removes its listeners and observer. Without a signal it behaves as before.
|
|
15
|
+
|
|
3
16
|
## 1.12.0
|
|
4
17
|
|
|
5
18
|
### Added
|
package/README.md
CHANGED
|
@@ -304,3 +304,50 @@ The Astro build (Rollup) only needs the Vite alias — types are not required fo
|
|
|
304
304
|
`@dloizides/marketing-astro-kit/motionController` exports `createMotionController(options): { getState, sync }`. It runs `onFrame(deltaMs)` only while the page is visible and `target` is in view, and calls `onStill()` under `prefers-reduced-motion`. `forceStill` and `canRun` add host conditions; call `sync()` when they change. `watchReducedMotion: false` reads the preference once. The function references no module scope, so `HeroBackdrop` carries its source in an `is:inline` script.
|
|
305
305
|
|
|
306
306
|
`@dloizides/marketing-astro-kit/scrollFade` exports `createScrollFade({ belowLevel, switchShare }): { opacity, isBelow }` and `heroProgress(scrollY, heroHeight)`. `heroProgress` is 1 at the top of the page and 0 once the hero has scrolled away; `opacity(progress)` runs from 1 down to `belowLevel`; `isBelow(progress)` is true once less than `switchShare` of the hero is on screen.
|
|
307
|
+
|
|
308
|
+
## Contact card
|
|
309
|
+
|
|
310
|
+
`@dloizides/marketing-astro-kit/contactCard` builds the files behind a digital business card. Call it at build time, from a static endpoint or page frontmatter.
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
import { buildContactCardManifest, buildQrSvg, buildVCard } from '@dloizides/marketing-astro-kit/contactCard';
|
|
314
|
+
|
|
315
|
+
const vcf = buildVCard({ givenName, familyName, organisation, role, phone, email, website });
|
|
316
|
+
const manifest = buildContactCardManifest({ cardPath: '/card/sam/', name, shortName, description, themeColor, backgroundColor, icons });
|
|
317
|
+
const qr = buildQrSvg({ url: 'https://example.test/card/sam/', title: 'QR code of this card' });
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
- `phone` is international (`+44 20 7946 0958`); `website` and the QR `url` are https.
|
|
321
|
+
- `photo` is `{ type: ContactPhotoType.Jpeg, base64 }`, JPEG or PNG only.
|
|
322
|
+
- `cardPath` ends with `/` and is the app's id, start URL and scope, so serve the page at that exact path.
|
|
323
|
+
- Serve the files as `text/vcard` and `application/manifest+json`.
|
|
324
|
+
|
|
325
|
+
### The card (`ContactCard.astro`)
|
|
326
|
+
|
|
327
|
+
```astro
|
|
328
|
+
<ContactCard
|
|
329
|
+
layout="name"
|
|
330
|
+
person={{ givenName, familyName, role, phone, email, website }}
|
|
331
|
+
brand={{ src, width, height, href: '/', label: 'Example Works, home' }}
|
|
332
|
+
portrait={{ src, width, height, alt }}
|
|
333
|
+
labels={labels}
|
|
334
|
+
saveHref="/card/sam.vcf"
|
|
335
|
+
cardUrl="https://example.test/card/sam/"
|
|
336
|
+
motion={{ openMotion: 'tile-grows', openLands: 'turn-to-front', flipMotion: 'turn-over', tiltMotion: 'light-sweeps', qrMotion: 'list-turns', saveMotion: 'tick', shareMode: 'face-above' }}
|
|
337
|
+
brandMarkup={{ intro, still, wordmark }}
|
|
338
|
+
/>
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
- `layout` is `portrait`, `name` (default), `framed` or `honeycomb`. All four show the same information.
|
|
342
|
+
- `labels` is `ContactCardLabels`: every visible text, including the iPhone steps and the browser menu hint. `hideQr` (the Show my QR button while the QR is open) and `ready` (said and shown after Save contact, e.g. "Contact ready") are required.
|
|
343
|
+
- The card fills the screen and renders the page's `h1`. Give it a page without a site header.
|
|
344
|
+
- Save contact, call, email and website work without JavaScript. The QR and install buttons are hidden without it.
|
|
345
|
+
- Add to home screen uses the browser's prompt when offered, else shows help. It is hidden inside the installed app and right after installing; a browser tab opened later cannot tell.
|
|
346
|
+
- Colours: `--tmk-card-bg`, `-raised`, `-fill`, `-text`, `-heading`, `-text-soft`, `-line`, `-edge`, `-accent`, `-on-accent`. Also `--tmk-card-font`, `--tmk-card-radius`, `--tmk-card-qr-dark` and `--tmk-card-qr-light`. Set them on `:root`.
|
|
347
|
+
- Portrait crop: `--tmk-card-portrait-scale`, `-origin` and `-mask`.
|
|
348
|
+
- Line heights: `--tmk-card-name-line-height` (default `1.2`) and `--tmk-card-role-line-height` (default `1.3`), in every layout and while motion runs. Raise them for fonts with tall ascenders or descenders.
|
|
349
|
+
- `cardForm`: `two-sided` (default) draws a business-card shaped card, front = name, role, portrait and contacts, back = the `brandMarkup` logo only (no link), with Save contact and the actions beside it, never on the card; a tap outside its links, the turn button, Enter or Space turns it. `page` is the full page card that follows `layout`. Two-sided needs `labels.turnToBack`, `turnToFront`, `cardFront`, `cardBack`; size comes from `--tmk-card-aspect` (portrait) and `--tmk-card-aspect-wide` (1024 px and up).
|
|
350
|
+
- `motion` has seven settings; each left out takes the recommended one shown above, and an unknown value throws at build time. `openMotion`: `none`, `mark-first`, `mark-lands`, `written-in`, and for the two-sided card `tile-grows`, `moon-opens`, `turns-face-up`, `pass-rises`. `openLands` (tile-grows only): `turn-to-front`, `front`, `back`. `flipMotion`: `none`, `turn-over` (560 ms, a tap mid-turn reverses it). `tiltMotion`: `none`, `card-leans`, `portrait-leans`, `layers-drift`, `light-sweeps`, `gold-gloss`, `deep-layers` (the motion sensor drives it; iOS asks for it on the first tap on the card outside its buttons and links; a drag always works). `qrMotion`: `none`, `turn-over`, `cube-turn`, `list-turns`. `saveMotion`: `none`, `tick`, `light-crosses`, `cube-closes`. `shareMode`: `none`, `white-sheet`, `night-frame`, `face-above`; any value but `none` makes Show my QR open a still, full-screen code view that keeps the screen awake where the browser allows (Screen Wake Lock), and `qrMotion` then has nothing to turn. Under `prefers-reduced-motion` each shows its still end state. Show my QR and Add to home screen cannot be tapped until the opening has shown them. A sideways drag tilts the card and never follows a link it started on.
|
|
351
|
+
- `brandMarkup` is a mark from `@dloizides/logo-kit` (`intro` and `still` markup, optional `wordmark` `{ html, css }`); the opening draws it in. Without it the `brand` image is used.
|
|
352
|
+
- Data attributes: the card carries `data-layout`, `data-open-motion`, `data-tilt-motion`, `data-qr-motion` and `data-save-motion`; `data-tilting` is set while it leans. `data-part` names each part the motion moves.
|
|
353
|
+
- `mountContactCards(root, signal)` wires the buttons and the motion; aborting the signal removes every listener, frame loop and timer.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dloizides/marketing-astro-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Reusable, themeable Astro marketing sections for product sites — a Free-vs-Pro pricing comparison table, a trust / credibility section (security cards, customer-logo + testimonial placeholders, discreet built-by), a client-side \"try it\" demo shell, a meeting request form posting to a contact endpoint, and an SEO guides/content-hub card + frontmatter schema. Data-driven via a shared TypeScript schema; themed entirely through the host site's CSS custom properties.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"files": [
|
|
38
38
|
"src",
|
|
39
39
|
"!src/**/*.test.ts",
|
|
40
|
+
"!src/**/*.test-util.ts",
|
|
40
41
|
"README.md",
|
|
41
42
|
"CHANGELOG.md"
|
|
42
43
|
],
|
|
@@ -64,15 +65,20 @@
|
|
|
64
65
|
"./dateField": "./src/dateField/index.ts",
|
|
65
66
|
"./motionController": "./src/motionController/index.ts",
|
|
66
67
|
"./scrollFade": "./src/scrollFade/index.ts",
|
|
67
|
-
"./logoIntro": "./src/logoIntro/index.ts"
|
|
68
|
+
"./logoIntro": "./src/logoIntro/index.ts",
|
|
69
|
+
"./ContactCard.astro": "./src/ContactCard.astro",
|
|
70
|
+
"./contactCard": "./src/contactCard/index.ts"
|
|
68
71
|
},
|
|
69
72
|
"scripts": {
|
|
70
73
|
"test": "vitest run",
|
|
71
|
-
"lint": "eslint src/bookingEmbed src/dateField src/meetingRequest src/motionController src/scrollFade src/logoIntro --ext .ts",
|
|
72
|
-
"typecheck": "tsc --noEmit -p ."
|
|
74
|
+
"lint": "eslint src/bookingEmbed src/dateField src/meetingRequest src/motionController src/scrollFade src/logoIntro src/contactCard --ext .ts",
|
|
75
|
+
"typecheck": "tsc --noEmit -p .",
|
|
76
|
+
"prepublishOnly": "npm run typecheck && npm run lint && npm test"
|
|
73
77
|
},
|
|
74
78
|
"dependencies": {
|
|
75
|
-
"@
|
|
79
|
+
"@dloizides/pwa-sw": "^1.11.0",
|
|
80
|
+
"@lucasmarkes/hairline": "0.3.0",
|
|
81
|
+
"qrcode-generator": "^2.0.4"
|
|
76
82
|
},
|
|
77
83
|
"devDependencies": {
|
|
78
84
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
@@ -80,6 +86,7 @@
|
|
|
80
86
|
"eslint": "^8.57.1",
|
|
81
87
|
"eslint-plugin-sonarjs": "^3.0.7",
|
|
82
88
|
"jsdom": "^25.0.1",
|
|
89
|
+
"jsqr": "^1.4.0",
|
|
83
90
|
"typescript": "^5.9.3",
|
|
84
91
|
"vitest": "^2.1.9"
|
|
85
92
|
},
|
|
@@ -88,6 +95,6 @@
|
|
|
88
95
|
},
|
|
89
96
|
"sideEffects": false,
|
|
90
97
|
"engines": {
|
|
91
|
-
"node": ">=18.
|
|
98
|
+
"node": ">=18.17.0"
|
|
92
99
|
}
|
|
93
100
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
import './contactCard/contactCard.css';
|
|
3
|
+
import './contactCard/layouts.css';
|
|
4
|
+
import './contactCard/motion.css';
|
|
5
|
+
import './contactCard/share.css';
|
|
6
|
+
import './contactCard/twoSided.css';
|
|
7
|
+
import CardActions from './contactCard/CardActions.astro';
|
|
8
|
+
import CardBrand from './contactCard/CardBrand.astro';
|
|
9
|
+
import CardContacts from './contactCard/CardContacts.astro';
|
|
10
|
+
import { CardContactsVariant } from './contactCard/CardContactsVariant';
|
|
11
|
+
import CardDialog from './contactCard/CardDialog.astro';
|
|
12
|
+
import CardIdentity from './contactCard/CardIdentity.astro';
|
|
13
|
+
import { buildCardLinks, requireCardLayout, requireSaveHref } from './contactCard/cardLinks';
|
|
14
|
+
import CardPortrait from './contactCard/CardPortrait.astro';
|
|
15
|
+
import CardQr from './contactCard/CardQr.astro';
|
|
16
|
+
import CardSave from './contactCard/CardSave.astro';
|
|
17
|
+
import CardShare from './contactCard/CardShare.astro';
|
|
18
|
+
import CardTwoSided from './contactCard/CardTwoSided.astro';
|
|
19
|
+
import { CardForm } from './contactCard/CardForm';
|
|
20
|
+
import CardValues from './contactCard/CardValues.astro';
|
|
21
|
+
import { optionError, requireHttpsUrl } from './contactCard/checks';
|
|
22
|
+
import { ContactCardLayout } from './contactCard/ContactCardLayout';
|
|
23
|
+
import { InstallRoute } from './contactCard/InstallRoute';
|
|
24
|
+
import { motionAttributes, resolveCardMotion, type ContactCardMotionInput } from './contactCard/motion/cardMotion';
|
|
25
|
+
import { buildOpenCss } from './contactCard/motion/openCss';
|
|
26
|
+
import { OpenMotion } from './contactCard/motion/OpenMotion';
|
|
27
|
+
import { ShareMode } from './contactCard/motion/ShareMode';
|
|
28
|
+
import { tiltLights } from './contactCard/motion/tiltLights';
|
|
29
|
+
import { buildQrSvg } from './contactCard/qrSvg';
|
|
30
|
+
import type { ContactCardBrand, ContactCardBrandMarkup, ContactCardLabels, ContactCardPerson, ContactCardPortrait } from './contactCard/types';
|
|
31
|
+
|
|
32
|
+
interface Props {
|
|
33
|
+
/** `two-sided` (default) or `page`, the full page card that follows `layout`. */
|
|
34
|
+
cardForm?: `${CardForm}`;
|
|
35
|
+
layout?: `${ContactCardLayout}`;
|
|
36
|
+
person: ContactCardPerson;
|
|
37
|
+
brand: ContactCardBrand;
|
|
38
|
+
portrait: ContactCardPortrait;
|
|
39
|
+
labels: ContactCardLabels;
|
|
40
|
+
/** Address of the person's `.vcf` file. */
|
|
41
|
+
saveHref: string;
|
|
42
|
+
/** Full https address of this card, carried by the QR. */
|
|
43
|
+
cardUrl: string;
|
|
44
|
+
/** The motion and share settings; each left out takes its recommended option. */
|
|
45
|
+
motion?: ContactCardMotionInput;
|
|
46
|
+
/** The mark from @dloizides/logo-kit, drawn in on open; the brand image is used without it. */
|
|
47
|
+
brandMarkup?: ContactCardBrandMarkup;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const { person, brand, portrait, labels } = Astro.props;
|
|
51
|
+
const layout = requireCardLayout(Astro.props.layout ?? ContactCardLayout.Name);
|
|
52
|
+
const saveHref = requireSaveHref(Astro.props.saveHref);
|
|
53
|
+
const cardUrl = requireHttpsUrl(Astro.props.cardUrl, 'cardUrl');
|
|
54
|
+
const links = buildCardLinks(person, labels);
|
|
55
|
+
const qrSvg = buildQrSvg({ url: cardUrl, title: labels.qrTitle });
|
|
56
|
+
const motion = resolveCardMotion(Astro.props.motion);
|
|
57
|
+
const cardForm = Astro.props.cardForm ?? CardForm.TwoSided;
|
|
58
|
+
if (cardForm !== CardForm.TwoSided && cardForm !== CardForm.Page) throw optionError('cardForm', 'must be two-sided or page');
|
|
59
|
+
const twoSided = cardForm === CardForm.TwoSided;
|
|
60
|
+
const openCss = buildOpenCss(motion.openMotion, motion.openLands);
|
|
61
|
+
const brandProps = { brand, markup: Astro.props.brandMarkup, animated: motion.openMotion !== OpenMotion.None };
|
|
62
|
+
const lights = tiltLights(motion.tiltMotion);
|
|
63
|
+
const portraitProps = { portrait, light: lights.hex };
|
|
64
|
+
const saveProps = { href: saveHref, label: labels.save, readyLabel: labels.ready, saveMotion: motion.saveMotion, gloss: lights.gloss };
|
|
65
|
+
const shareProps = { shareMode: motion.shareMode, qrSvg, cardUrl, title: labels.qrTitle, closeLabel: labels.hideQr, person, portrait, brand };
|
|
66
|
+
---
|
|
67
|
+
<div class="tmk-card" data-contact-card data-card-form={cardForm} data-layout={twoSided ? undefined : layout} {...motionAttributes(motion)} data-testid="card">
|
|
68
|
+
{openCss !== '' && <style is:inline set:html={openCss} />}
|
|
69
|
+
{twoSided && <CardTwoSided {...{ person, portrait, brand, markup: Astro.props.brandMarkup, labels, links, saveProps, motion }} />}
|
|
70
|
+
{!twoSided && layout === ContactCardLayout.Portrait && (
|
|
71
|
+
<CardBrand {...brandProps} />
|
|
72
|
+
<div class="tmk-card-disc"><CardPortrait {...portraitProps} /></div>
|
|
73
|
+
<div class="tmk-card-main">
|
|
74
|
+
<CardIdentity person={person} />
|
|
75
|
+
<CardSave {...saveProps} />
|
|
76
|
+
<CardContacts links={links} label={labels.contacts} variant={CardContactsVariant.Tiles} />
|
|
77
|
+
<CardValues links={links} />
|
|
78
|
+
<CardActions labels={labels} />
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
81
|
+
{!twoSided && layout === ContactCardLayout.Name && (
|
|
82
|
+
<CardBrand {...brandProps} />
|
|
83
|
+
<CardIdentity person={person}><CardPortrait {...portraitProps} /></CardIdentity>
|
|
84
|
+
<CardSave {...saveProps} />
|
|
85
|
+
<CardContacts links={links} label={labels.contacts} variant={CardContactsVariant.Rows} />
|
|
86
|
+
<CardActions labels={labels} />
|
|
87
|
+
)}
|
|
88
|
+
{!twoSided && layout === ContactCardLayout.Framed && (
|
|
89
|
+
<div class="tmk-card-frame" data-part="frame">
|
|
90
|
+
<CardBrand {...brandProps} />
|
|
91
|
+
<CardIdentity person={person}><CardPortrait {...portraitProps} /></CardIdentity>
|
|
92
|
+
<CardContacts links={links} label={labels.contacts} variant={CardContactsVariant.Rows} />
|
|
93
|
+
</div>
|
|
94
|
+
<CardActions labels={labels}><CardSave {...saveProps} /></CardActions>
|
|
95
|
+
)}
|
|
96
|
+
{!twoSided && layout === ContactCardLayout.Honeycomb && (
|
|
97
|
+
<CardBrand {...brandProps} />
|
|
98
|
+
<CardIdentity person={person} />
|
|
99
|
+
<div class="tmk-card-comb" data-part="comb">
|
|
100
|
+
<CardPortrait {...portraitProps} />
|
|
101
|
+
<CardSave {...saveProps} />
|
|
102
|
+
<CardContacts links={links} label={labels.contacts} variant={CardContactsVariant.Tiles} />
|
|
103
|
+
</div>
|
|
104
|
+
<CardValues links={links} />
|
|
105
|
+
<CardActions labels={labels} />
|
|
106
|
+
)}
|
|
107
|
+
{motion.shareMode === ShareMode.None
|
|
108
|
+
? <CardQr qrSvg={qrSvg} cardUrl={cardUrl} title={labels.qrTitle} hideLabel={labels.hideQr} qrMotion={motion.qrMotion} />
|
|
109
|
+
: <CardShare {...shareProps} />}
|
|
110
|
+
{!twoSided && lights.edge && <span class="tmk-card-edge" aria-hidden="true" data-part="edge"><span data-part="edge-light"></span></span>}
|
|
111
|
+
{!twoSided && lights.sweep && <span class="tmk-card-sweep" aria-hidden="true" data-part="sweep"><span data-part="sweep-band"></span></span>}
|
|
112
|
+
<CardDialog name="install" title={labels.installTitle} closeLabel={labels.close}>
|
|
113
|
+
<ol data-install-route={InstallRoute.AppleSteps} data-testid="card-install-steps" hidden>
|
|
114
|
+
{labels.appleSteps.map((step) => <li>{step}</li>)}
|
|
115
|
+
</ol>
|
|
116
|
+
<p data-install-route={InstallRoute.MenuHint} data-testid="card-install-hint" hidden>{labels.menuHint}</p>
|
|
117
|
+
</CardDialog>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<script>
|
|
121
|
+
import { mountContactCards } from './contactCard/mount';
|
|
122
|
+
|
|
123
|
+
mountContactCards();
|
|
124
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import CardIcon from './CardIcon.astro';
|
|
3
|
+
import { CardIconName } from './CardIconName';
|
|
4
|
+
import type { ContactCardLabels } from './types';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
labels: ContactCardLabels;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { labels } = Astro.props;
|
|
11
|
+
---
|
|
12
|
+
<div class="tmk-card-actions" data-part="actions">
|
|
13
|
+
<slot />
|
|
14
|
+
<button class="tmk-card-button tmk-card-install" type="button" aria-haspopup="dialog" hidden data-card-install data-part="install" data-testid="card-install">
|
|
15
|
+
<CardIcon name={CardIconName.Install} /><span>{labels.install}</span>
|
|
16
|
+
</button>
|
|
17
|
+
<button class="tmk-card-button" type="button" aria-expanded="false" hidden data-card-qr data-part="show-qr" data-testid="card-show-qr">
|
|
18
|
+
<CardIcon name={CardIconName.Qr} /><span class="tmk-card-qr-words"><span data-part="qr-open">{labels.showQr}</span><span data-part="qr-close" aria-hidden="true">{labels.hideQr}</span></span>
|
|
19
|
+
</button>
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ContactCardBrand, ContactCardBrandMarkup } from './types';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
brand: ContactCardBrand;
|
|
6
|
+
markup?: ContactCardBrandMarkup | undefined;
|
|
7
|
+
animated: boolean;
|
|
8
|
+
faceLabel: string;
|
|
9
|
+
sweep: boolean;
|
|
10
|
+
hidden: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { brand, markup, animated, faceLabel, sweep, hidden } = Astro.props;
|
|
14
|
+
const wordmark = markup?.wordmark ?? null;
|
|
15
|
+
const wordmarkCss = animated && wordmark !== null ? `@media (prefers-reduced-motion:no-preference){${wordmark.css}}` : '';
|
|
16
|
+
---
|
|
17
|
+
<div class="tmk-card-face tmk-card-back" role="group" aria-label={faceLabel} data-part="back" data-testid="card-back" inert={hidden}>
|
|
18
|
+
<div class="tmk-card-lockup">
|
|
19
|
+
{markup === undefined ? (
|
|
20
|
+
<img class="tmk-card-back-logo" src={brand.src} width={brand.width} height={brand.height} alt="" data-part="mark" />
|
|
21
|
+
) : (
|
|
22
|
+
<>
|
|
23
|
+
<span class="tmk-card-mark" aria-hidden="true" data-part="mark" data-logo-intro={animated ? '' : undefined} set:html={animated ? markup.intro : markup.still} />
|
|
24
|
+
{animated && <template data-mark-still set:html={markup.still} />}
|
|
25
|
+
{wordmark !== null && <span class="tmk-card-wordmark" aria-hidden="true" data-part="wordmark" set:html={wordmark.html} />}
|
|
26
|
+
{wordmarkCss !== '' && <style is:inline set:html={wordmarkCss} />}
|
|
27
|
+
</>
|
|
28
|
+
)}
|
|
29
|
+
</div>
|
|
30
|
+
{sweep && <span class="tmk-card-sweep" aria-hidden="true" data-part="back-sweep"><span data-part="back-band"></span></span>}
|
|
31
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ContactCardBrand, ContactCardBrandMarkup } from './types';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
brand: ContactCardBrand;
|
|
6
|
+
markup?: ContactCardBrandMarkup | undefined;
|
|
7
|
+
animated: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { brand, markup, animated } = Astro.props;
|
|
11
|
+
const wordmark = markup?.wordmark ?? null;
|
|
12
|
+
const wordmarkCss = animated && wordmark !== null ? `@media (prefers-reduced-motion:no-preference){${wordmark.css}}` : '';
|
|
13
|
+
---
|
|
14
|
+
<a class="tmk-card-brand" href={brand.href} aria-label={brand.label} data-part="brand" data-testid="card-brand">
|
|
15
|
+
{markup === undefined ? (
|
|
16
|
+
<img src={brand.src} width={brand.width} height={brand.height} alt="" data-part="mark" />
|
|
17
|
+
) : (
|
|
18
|
+
<>
|
|
19
|
+
<span class="tmk-card-mark" aria-hidden="true" data-part="mark" data-logo-intro={animated ? '' : undefined} set:html={animated ? markup.intro : markup.still} />
|
|
20
|
+
{animated && <template data-mark-still set:html={markup.still} />}
|
|
21
|
+
{wordmark !== null && <span class="tmk-card-wordmark" aria-hidden="true" data-part="wordmark" set:html={wordmark.html} />}
|
|
22
|
+
{wordmarkCss !== '' && <style is:inline set:html={wordmarkCss} />}
|
|
23
|
+
</>
|
|
24
|
+
)}
|
|
25
|
+
</a>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import CardIcon from './CardIcon.astro';
|
|
3
|
+
import { CardContactsVariant } from './CardContactsVariant';
|
|
4
|
+
import type { CardLink } from './cardLinks';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
links: CardLink[];
|
|
8
|
+
label: string;
|
|
9
|
+
variant: CardContactsVariant;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { links, label, variant } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
<nav class={`tmk-card-${variant}`} aria-label={label} data-part="contacts">
|
|
15
|
+
{links.map((link) => (
|
|
16
|
+
<a href={link.href} data-part={link.kind} data-testid={`card-${link.kind}`}>
|
|
17
|
+
<CardIcon name={link.kind} />
|
|
18
|
+
<span class="tmk-card-label">{link.label}</span>
|
|
19
|
+
{variant === CardContactsVariant.Rows && <span class="tmk-card-value">{link.value}</span>}
|
|
20
|
+
</a>
|
|
21
|
+
))}
|
|
22
|
+
</nav>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string;
|
|
5
|
+
closeLabel: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { name, title, closeLabel } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
<dialog class="tmk-card-dialog" aria-label={title} data-card-dialog={name} data-part={`${name}-dialog`} data-testid={`card-${name}-dialog`}>
|
|
11
|
+
<h2>{title}</h2>
|
|
12
|
+
<slot />
|
|
13
|
+
<form method="dialog">
|
|
14
|
+
<button class="tmk-card-button" type="submit" autofocus data-testid={`card-${name}-close`}>{closeLabel}</button>
|
|
15
|
+
</form>
|
|
16
|
+
</dialog>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
import CardContacts from './CardContacts.astro';
|
|
3
|
+
import { CardContactsVariant } from './CardContactsVariant';
|
|
4
|
+
import CardIdentity from './CardIdentity.astro';
|
|
5
|
+
import type { CardLink } from './cardLinks';
|
|
6
|
+
import CardPortrait from './CardPortrait.astro';
|
|
7
|
+
import type { ContactCardPerson, ContactCardPortrait } from './types';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
person: ContactCardPerson;
|
|
11
|
+
portrait: ContactCardPortrait;
|
|
12
|
+
links: CardLink[];
|
|
13
|
+
contactsLabel: string;
|
|
14
|
+
faceLabel: string;
|
|
15
|
+
hexLight: boolean;
|
|
16
|
+
sweep: boolean;
|
|
17
|
+
hidden: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { person, portrait, links, contactsLabel, faceLabel, hexLight, sweep, hidden } = Astro.props;
|
|
21
|
+
---
|
|
22
|
+
<div class="tmk-card-face tmk-card-front" role="group" aria-label={faceLabel} data-part="front" data-testid="card-front" inert={hidden}>
|
|
23
|
+
<CardIdentity person={person} />
|
|
24
|
+
<CardPortrait portrait={portrait} light={hexLight} />
|
|
25
|
+
<CardContacts links={links} label={contactsLabel} variant={CardContactsVariant.Rows} />
|
|
26
|
+
{sweep && <span class="tmk-card-sweep" aria-hidden="true" data-part="sweep"><span data-part="sweep-band"></span></span>}
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { CARD_ICONS } from './cardIcons';
|
|
3
|
+
import type { CardIconName } from './CardIconName';
|
|
4
|
+
import type { CardLinkKind } from './CardLinkKind';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
name: CardIconName | CardLinkKind;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { name } = Astro.props;
|
|
11
|
+
---
|
|
12
|
+
<svg class="tmk-card-icon" viewBox="0 0 24 24" aria-hidden="true" set:html={CARD_ICONS[name]} />
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ContactCardPerson } from './types';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
person: ContactCardPerson;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { person } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
<div class="tmk-card-identity">
|
|
11
|
+
<h1 class="tmk-card-name" data-part="name" data-testid="card-name"><span>{person.givenName}</span>{' '}<span>{person.familyName}</span></h1>
|
|
12
|
+
<slot />
|
|
13
|
+
<p class="tmk-card-role" data-part="role" data-testid="card-role">{person.role}</p>
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ContactCardPortrait } from './types';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
portrait: ContactCardPortrait;
|
|
6
|
+
light: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { portrait, light } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
<div class="tmk-card-portrait" data-part="portrait" data-testid="card-portrait">
|
|
12
|
+
<div><img src={portrait.src} width={portrait.width} height={portrait.height} alt={portrait.alt} /></div>
|
|
13
|
+
{light && <span class="tmk-card-hex-light" aria-hidden="true" data-part="hex-light"><span data-part="hex-band"></span></span>}
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { QrMotion } from './motion/QrMotion';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
qrSvg: string;
|
|
6
|
+
cardUrl: string;
|
|
7
|
+
title: string;
|
|
8
|
+
hideLabel: string;
|
|
9
|
+
qrMotion: QrMotion;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { qrSvg, cardUrl, title, hideLabel, qrMotion } = Astro.props;
|
|
13
|
+
const onBack = qrMotion === QrMotion.TurnOver || qrMotion === QrMotion.CubeTurn;
|
|
14
|
+
---
|
|
15
|
+
{onBack ? (
|
|
16
|
+
<div class="tmk-card-qr-side tmk-card-qr-back" role="group" aria-label={title} data-part="qr-back" data-side-hidden inert>
|
|
17
|
+
<div class="tmk-card-qr" data-qr-value={cardUrl} data-testid="card-qr" set:html={qrSvg} />
|
|
18
|
+
<button class="tmk-card-button" type="button" data-card-qr-close data-testid="card-qr-close">{hideLabel}</button>
|
|
19
|
+
</div>
|
|
20
|
+
) : (
|
|
21
|
+
<div class="tmk-card-qr-side" role="group" aria-label={title} data-part="qr-panel" data-side-hidden inert>
|
|
22
|
+
<div class="tmk-card-qr" data-qr-value={cardUrl} data-testid="card-qr" set:html={qrSvg} />
|
|
23
|
+
</div>
|
|
24
|
+
)}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
import CardIcon from './CardIcon.astro';
|
|
3
|
+
import { CardIconName } from './CardIconName';
|
|
4
|
+
import { SaveMotion } from './motion/SaveMotion';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
href: string;
|
|
8
|
+
label: string;
|
|
9
|
+
readyLabel: string;
|
|
10
|
+
saveMotion: SaveMotion;
|
|
11
|
+
gloss: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { href, label, readyLabel, saveMotion, gloss } = Astro.props;
|
|
15
|
+
const TICK = 'M5 12.5l4.5 4.5L19 7.5';
|
|
16
|
+
---
|
|
17
|
+
<a class="tmk-card-save" href={href} data-part="save" data-testid="card-save">
|
|
18
|
+
<span class="tmk-card-save-icon">
|
|
19
|
+
<span data-part="save-icon"><CardIcon name={CardIconName.Save} /></span>
|
|
20
|
+
{saveMotion === SaveMotion.Tick && (
|
|
21
|
+
<svg class="tmk-card-mini tmk-card-tick" viewBox="0 0 24 24" aria-hidden="true" data-part="tick"><path d={TICK} /></svg>
|
|
22
|
+
<span class="tmk-card-tick-cover" data-part="tick-cover"></span>
|
|
23
|
+
)}
|
|
24
|
+
{saveMotion === SaveMotion.CubeCloses && (
|
|
25
|
+
<svg class="tmk-card-mini tmk-card-cube" viewBox="0 0 24 24" aria-hidden="true">
|
|
26
|
+
<path data-part="cube-top" d="M12 3.5l7.5 4.2-7.5 4.2-7.5-4.2z" />
|
|
27
|
+
<path data-part="cube-left" d="M4.5 9.3l6.8 3.9v7.6l-6.8-3.9z" />
|
|
28
|
+
<path data-part="cube-right" d="M19.5 9.3l-6.8 3.9v7.6l6.8-3.9z" />
|
|
29
|
+
</svg>
|
|
30
|
+
)}
|
|
31
|
+
</span>
|
|
32
|
+
<span class="tmk-card-save-words">
|
|
33
|
+
<span data-part="save-text">{label}</span>
|
|
34
|
+
<span data-part="ready-text" aria-hidden="true">{readyLabel}</span>
|
|
35
|
+
</span>
|
|
36
|
+
{saveMotion === SaveMotion.LightCrosses && (
|
|
37
|
+
<span class="tmk-card-wipe" data-part="wipe" aria-hidden="true">
|
|
38
|
+
<span class="tmk-card-wipe-in" data-part="wipe-in">
|
|
39
|
+
<svg class="tmk-card-mini" viewBox="0 0 24 24"><path d={TICK} /></svg><span>{readyLabel}</span>
|
|
40
|
+
</span>
|
|
41
|
+
</span>
|
|
42
|
+
)}
|
|
43
|
+
{gloss && <span class="tmk-card-gloss" aria-hidden="true" data-part="save-gloss"></span>}
|
|
44
|
+
</a>
|
|
45
|
+
<span class="tmk-card-live" aria-live="polite" data-part="save-live"></span>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { ShareMode } from './motion/ShareMode';
|
|
3
|
+
import type { ContactCardBrand, ContactCardPerson, ContactCardPortrait } from './types';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
shareMode: ShareMode;
|
|
7
|
+
qrSvg: string;
|
|
8
|
+
cardUrl: string;
|
|
9
|
+
title: string;
|
|
10
|
+
closeLabel: string;
|
|
11
|
+
person: ContactCardPerson;
|
|
12
|
+
portrait: ContactCardPortrait;
|
|
13
|
+
brand: ContactCardBrand;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { shareMode, qrSvg, cardUrl, title, closeLabel, person, portrait, brand } = Astro.props;
|
|
17
|
+
const fullName = `${person.givenName} ${person.familyName}`;
|
|
18
|
+
---
|
|
19
|
+
<dialog class="tmk-card-share" aria-label={title} data-card-share data-share={shareMode} data-part="share" data-testid="card-share">
|
|
20
|
+
<div class="tmk-card-share-in">
|
|
21
|
+
{shareMode === ShareMode.FaceAbove && (
|
|
22
|
+
<div class="tmk-card-share-face" data-part="share-face"><img src={portrait.src} width={portrait.width} height={portrait.height} alt="" /></div>
|
|
23
|
+
)}
|
|
24
|
+
{shareMode === ShareMode.NightFrame && (
|
|
25
|
+
<img class="tmk-card-share-brand" src={brand.src} width={brand.width} height={brand.height} alt="" data-part="share-brand" />
|
|
26
|
+
)}
|
|
27
|
+
{shareMode !== ShareMode.WhiteSheet && <p class="tmk-card-share-name" data-part="share-name">{fullName}</p>}
|
|
28
|
+
{shareMode === ShareMode.FaceAbove && <p class="tmk-card-share-role" data-part="share-role">{person.role}</p>}
|
|
29
|
+
<div class="tmk-card-share-qr" data-qr-value={cardUrl} data-part="share-qr" data-testid="card-qr" set:html={qrSvg} />
|
|
30
|
+
<button class="tmk-card-button" type="button" autofocus data-card-share-close data-part="share-close" data-testid="card-share-close">{closeLabel}</button>
|
|
31
|
+
</div>
|
|
32
|
+
</dialog>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import CardIcon from './CardIcon.astro';
|
|
3
|
+
import { CardIconName } from './CardIconName';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
toBack: string;
|
|
7
|
+
toFront: string;
|
|
8
|
+
onBack: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { toBack, toFront, onBack } = Astro.props;
|
|
12
|
+
---
|
|
13
|
+
<button class="tmk-card-turn" type="button" aria-label={onBack ? toFront : toBack} data-label-back={toBack} data-label-front={toFront} data-card-turn data-part="turn" data-testid="card-turn">
|
|
14
|
+
<CardIcon name={CardIconName.Turn} />
|
|
15
|
+
</button>
|