@atelic-action/ui 8.5.0 → 8.6.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/README.md +15 -0
- package/package.json +1 -1
- package/src/chrome/StickyCTABar.tsx +3 -2
- package/src/primitives/AddressSearch.tsx +109 -10
- package/src/primitives/ExpandableText.tsx +28 -4
- package/src/primitives/PhoneLink.tsx +20 -8
- package/src/sections/ContactForm.tsx +3 -1
- package/src/sections/ContactSection.tsx +72 -0
- package/src/sections/LocationSection.tsx +4 -2
- package/src/sections/index.ts +1 -0
- package/src/styles/defaults.css +11 -0
- package/src/styles/primitives.css +11 -4
- package/src/styles/sections.css +44 -0
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ Every export, grouped by the entry it is imported from. The Storybook column lin
|
|
|
79
79
|
| `ContactForm` | `@atelic-action/ui/sections` | Validated form with a honeypot that posts to `endpoint` (or hands off to mail); `onLead` replaces the default GA4 `generate_lead` event; opt in props add a split name, a phone, the address with its search, a services picker, a consent line, a count of fields to fix, and a thanks that replaces the form (8.5.0) | [Sections/ContactForm](https://ui.atelic.me/?path=/docs/sections-contactform--docs) |
|
|
80
80
|
| `ContactFormAddress`, `ContactFormConsent`, `ContactFormLabels`, `ContactFormPlaceholders`, `ContactFormThanks`, `ContactFormValues`, `ContactFormField`, `isPhoneNumber`, `isZIP` | `@atelic-action/ui/sections` | The shapes the form's opt in props take, what a visitor wrote, and the form's default phone and ZIP checks (8.5.0) | none |
|
|
81
81
|
| `ContactInfoCard` | `@atelic-action/ui/sections` | A dark card of direct contact rows: call, email, visit, portal; `layout="stacked"` sets each label over its number (8.5.0) | [Sections/ContactInfoCard](https://ui.atelic.me/?path=/docs/sections-contactinfocard--docs) |
|
|
82
|
+
| `ContactSection`, `ContactSectionProps` | `@atelic-action/ui/sections` | A contact page's body: the form in a card with an optional heading and lead, beside a side column of what the site stacks there; one column, the card first, when the two no longer fit; the ratio, bases, gaps, and card padding by token (8.6.0) | [Sections/ContactSection](https://ui.atelic.me/?path=/docs/sections-contactsection--docs) |
|
|
82
83
|
| `InfoRows`, `InfoRow`, `InfoRowAction`, `InfoRowIcon`, `InfoRowsProps` | `@atelic-action/ui/sections` | Rows of a title over a few lines with one icon action on the right, the way a map pack lists a place with its directions (8.5.0) | [Sections/InfoRows](https://ui.atelic.me/?path=/docs/sections-inforows--docs) |
|
|
83
84
|
| `CredentialList` | `@atelic-action/ui/sections` | Credential cards with a mono code before each | [Sections/CredentialList](https://ui.atelic.me/?path=/docs/sections-credentiallist--docs) |
|
|
84
85
|
| `ExpandList` | `@atelic-action/ui/sections` | A light accordion of numbered rows whose bodies stay in the HTML while closed | [Sections/ExpandList](https://ui.atelic.me/?path=/docs/sections-expandlist--docs) |
|
|
@@ -748,6 +749,16 @@ The space a section leaves above and below itself is one token, `--section-space
|
|
|
748
749
|
|
|
749
750
|
`.section` pads with it, and the steps derived from it keep their old proportion to it: `.section-md` 0.7, `.section-sm` 0.6, `tight-top` and `tight-bottom` a third, the `PricingBand` 0.84, `PageHero` and the not found opener 0.72 on top and 0.5 below, and the `FeatureDetail` rows 0.6, whose first and last rows now sit flush with the section around them. `--block-gap` is the space between a section's heading and the grid under it (`FeatureGrid`, `ProfileCards`, `LinkColumns`, `CalloutPanel`, and `Gallery` at 0.77 of it), and `--card-min` the least a `FeatureGrid` card stands. A site that wants its own value sets the property on `.atelic-ui` in its own sheet, outside the layer. `ArtifactShell` pins `comfortable`, so a document reads as it did; the app shell reads none of these.
|
|
750
751
|
|
|
752
|
+
### Moving to 8.6.0
|
|
753
|
+
|
|
754
|
+
No API breaks. Two additions: `ContactSection`, and `AddressSearch`'s `onPick` may return `false` to decline a pick, the field then going back to what was typed without searching again until the visitor types (`ContactForm` does so when the visitor has edited an address field by hand while a pick was on its way); a handler that returns nothing (`onPick={setAddress}`) fits as before. The rest fixes 8.5.0's new pieces.
|
|
755
|
+
|
|
756
|
+
- **`ContactSection`** draws a contact page's body: the form in a card, with an optional heading (`headingLevel`, 2 by default) and lead, beside a side column of whatever the site stacks there (`side`, an `aside` landmark when given `sideLabel`). The two stand side by side while both columns' bases and the gap fit, and stack, the card first, below that, about 900px on a site's default gutter. The ratio, the bases, the gaps, and the card's padding are tokens (below), and the card sets `--expandable-ground` to its own ground, so an inline consent's Show more fades over it. A site that built this layout by hand deletes its rules.
|
|
757
|
+
|
|
758
|
+
- **An inline `ExpandableText` never moves the page.** Its control is out of the flow from the first paint, over the end of the last line: unseen and unreachable until the text is measured (before paint, in a layout effect), shown with its ellipsis once the text is measured as cut, and not drawn when the text fits, where what `more` holds shows at once since nothing is hidden. In 8.5.0 it sat over a line that ended whole when the text fit.
|
|
759
|
+
- **A pick that moves focus first** (a touch screen, a screen reader) lands: a press on a suggestion holds from its `pointerdown` to its click, through the `pointerup`, `pointerleave`, and blur a touch sends first, so the blur keeps the suggestions and the provider's session. A press the browser cancels, one no click follows, or one whose suggestions are replaced ends, and leaving the field then cleans up as usual.
|
|
760
|
+
- **A configured phone with no digit** (`e164: ""`) draws no call: no `tel:` link, no call button in `LocationSection`, and none on `StickyCTABar`.
|
|
761
|
+
|
|
751
762
|
### Moving to 8.5.0
|
|
752
763
|
|
|
753
764
|
No API breaks, and nothing moves on a site that changes nothing: every addition is an optional prop, an export, or a token whose default is the look it had. `@radix-ui/react-popover` and `@radix-ui/react-checkbox` move from optional peers to dependencies, as `@radix-ui/react-tabs` is, so a marketing site installs nothing for `MultiSelect`; an app that already had them keeps one copy where the ranges meet.
|
|
@@ -913,6 +924,7 @@ Nothing breaks: every addition is an optional prop, config key, token, or entry.
|
|
|
913
924
|
| `HoursTable` | Day rows with dashed rules and mono times |
|
|
914
925
|
| `ContactForm` | Validated form with a honeypot that posts to `endpoint` (or hands off to mail); `onLead` replaces the default GA4 `generate_lead` event; the service business's opt in fields (8.5.0), below |
|
|
915
926
|
| `ContactInfoCard` | A dark card of direct contact rows: call, email, visit, portal; the single phone row reads `phoneLabel`, default "Call" (8.3.0); `layout="stacked"` puts each label over its number, the numbers large (8.5.0) |
|
|
927
|
+
| `ContactSection` | A contact page's body: the form in a card (heading, lead) beside a side column, one column when they no longer fit (8.6.0) |
|
|
916
928
|
| `InfoRows` | Rows of a title over lines (an address) and an optional `detail` (an office's hours), with one action on the right as an icon over its words; the action is described by its row's title, and a directions link opens a new tab with `newTab` (8.5.0) |
|
|
917
929
|
| `FAQBrowser` | The help page: live search, a sticky `JumpRail` of categories with scroll spy, expand all, deep links; `contactHref` sets where the no match line points |
|
|
918
930
|
| `JumpRail` | Sticky in page pill tabs with scroll spy, used by `FAQBrowser` and on its own |
|
|
@@ -1166,6 +1178,9 @@ The sheets read a set of tokens beyond the theme's palette, type, radii, and lay
|
|
|
1166
1178
|
| `--form-footnote-size` | `0.82rem` | The contact form's footnote size (8.5.0) |
|
|
1167
1179
|
| `--field-padding-block`, `--field-padding-inline` | `14px`, `16px` | Every form field's padding, the services button and the address search with them, so a form stays even (the search keeps its 44px for the pin) (8.5.0) |
|
|
1168
1180
|
| `--page-hero-kicker-font`, `--page-hero-kicker-size`, `--page-hero-kicker-weight`, `--page-hero-kicker-tracking` | `--font-mono`, and the eyebrow's own size, weight, and tracking, read in place | `PageHero`'s kicker, as `--hero-kicker-*` set the hero's (8.5.0) |
|
|
1181
|
+
| `--contact-section-main`, `--contact-section-side` | `5`, `3` | `ContactSection`'s columns' grow ratio, the 1.25 to 0.75 the contact design draws; each at least 1, or a column alone on its line stops short of the width (8.6.0) |
|
|
1182
|
+
| `--contact-section-main-basis`, `--contact-section-side-basis` | `30.25rem`, `18.25rem` | The widths the columns grow from: they stand side by side while both and the gap fit, about 900px on a site's default gutter (8.6.0) |
|
|
1183
|
+
| `--contact-section-gap`, `--contact-section-side-gap`, `--contact-section-card-pad` | `clamp(24px, 4vw, 56px)`, `24px`, `clamp(20px, 3vw, 34px)` | The gap between the columns (and between the card and the column under it), between the side column's items, and the card's padding (8.6.0) |
|
|
1169
1184
|
| `--page-hero-title-size`, `--page-hero-pad-block` | `clamp(2.4rem, 7vw, 4.2rem)`; none, each side keeping its own padding, read in place | `PageHero`'s headline size, and its band's top and bottom padding alike (8.5.0) |
|
|
1170
1185
|
| `--form-footnote-align`, `--form-footnote-link-weight`, `--form-footnote-link-color` | each the inherited value, read in place | The contact form's line under its button (`footnote`, now `.form-footnote` in the sheet rather than an inline style): its alignment, and its links' weight and color (8.5.0) |
|
|
1171
1186
|
| `--hours-rule`, `--hours-time-font`, `--hours-time-size` | `1px dashed --neutral-200` and `--font-mono`, read in place; `0.85rem` | `HoursTable`'s line under each row (a whole border value: `1px solid var(--hairline)` for a solid hairline), and its times' face and size (8.5.0) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atelic-action/ui",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"description": "Shared UI for the Atelic templates: site chrome, base styles, the component library, the access gate, and the app shell they install",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Phone as PhoneIcon } from "lucide-react";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { newTabProps } from "../lib/newTabProps";
|
|
4
|
-
import { PhoneLink } from "../primitives/PhoneLink";
|
|
4
|
+
import { PhoneLink, phoneHref } from "../primitives/PhoneLink";
|
|
5
5
|
import type { CallToAction, Phone } from "../types";
|
|
6
6
|
|
|
7
7
|
export interface StickyCTABarProps {
|
|
@@ -157,7 +157,8 @@ export function StickyCTABar({
|
|
|
157
157
|
>
|
|
158
158
|
{primaryCTA.label}
|
|
159
159
|
</a>
|
|
160
|
-
{
|
|
160
|
+
{/* No number to dial, no call button: never a nameless empty one (8.6.0). */}
|
|
161
|
+
{phone && phoneHref(phone) && (
|
|
161
162
|
<PhoneLink className="btn btn-ghost btn-call" phone={phone} aria-label={callLabel}>
|
|
162
163
|
<PhoneIcon size={18} aria-hidden="true" />
|
|
163
164
|
</PhoneLink>
|
|
@@ -57,8 +57,14 @@ export interface AddressSearchProps {
|
|
|
57
57
|
/** A quiet note beside the label, such as "(optional)". */
|
|
58
58
|
hint?: ReactNode;
|
|
59
59
|
placeholder?: string;
|
|
60
|
-
/**
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Called with the parts of the address picked. Return false when the
|
|
62
|
+
* pick is not taken after all (a form that has moved on): the field then
|
|
63
|
+
* goes back to what the visitor typed (8.6.0). Any handler that returns
|
|
64
|
+
* nothing, a state setter included, still fits.
|
|
65
|
+
*/
|
|
66
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: void keeps every handler that returns nothing (onPick={setAddress}) assignable, as it was before 8.6.0
|
|
67
|
+
onPick: (address: AddressParts) => boolean | void;
|
|
62
68
|
/**
|
|
63
69
|
* Called the moment a suggestion is chosen, before its parts arrive, so a
|
|
64
70
|
* form can tell a pick that lands after the visitor moved on.
|
|
@@ -82,6 +88,12 @@ export interface AddressSearchProps {
|
|
|
82
88
|
const defaultCount = (count: number) =>
|
|
83
89
|
count === 0 ? "No suggestions" : count === 1 ? "1 suggestion" : `${count} suggestions`;
|
|
84
90
|
|
|
91
|
+
/**
|
|
92
|
+
* How long a press may still bring its click after it is released, or
|
|
93
|
+
* after it leaves its suggestion: past a touch's click delay.
|
|
94
|
+
*/
|
|
95
|
+
const PRESS_WAIT_MS = 600;
|
|
96
|
+
|
|
85
97
|
/** The line an address reads as once picked: the main line and the rest. */
|
|
86
98
|
const pickedText = (suggestion: AddressSuggestion) =>
|
|
87
99
|
[suggestion.text, suggestion.secondary].filter(Boolean).join(", ");
|
|
@@ -143,10 +155,68 @@ export function AddressSearch({
|
|
|
143
155
|
// The provider whose answer the offered suggestions are, which a pick
|
|
144
156
|
// resolves through even if the site has passed a new one since.
|
|
145
157
|
const offeredBy = useRef<AddressProvider | null>(null);
|
|
158
|
+
// A press on a suggestion, from its pointerdown until its click. A touch
|
|
159
|
+
// fires pointerdown, pointerup, pointerout, pointerleave, and only then
|
|
160
|
+
// the compatibility mousedown (where focus moves, so the blur) and the
|
|
161
|
+
// click (Pointer Events 3, 4.2.6): the blur in between is the pick's, and
|
|
162
|
+
// leaves the list, the suggestions, and the provider's session alone
|
|
163
|
+
// (8.6.0). The press ends at its click, at a pointercancel, when its
|
|
164
|
+
// suggestions are replaced, or a while after its pointerup with no click.
|
|
165
|
+
const picking = useRef(false);
|
|
166
|
+
// The end of a press whose click never came, started at its pointerup.
|
|
167
|
+
const pressEnd = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
168
|
+
// The blur's cleanup, held past the click so a pick can call it off.
|
|
169
|
+
const leaving = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
146
170
|
// The pause before a lookup, held so a blur can stop it.
|
|
147
171
|
const pending = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
148
172
|
const hasProvider = Boolean(provider);
|
|
149
173
|
|
|
174
|
+
/** What leaving the field does once no pick is under way. */
|
|
175
|
+
const leave = () => {
|
|
176
|
+
clearTimeout(pending.current);
|
|
177
|
+
lookups.cancel();
|
|
178
|
+
setOpen(false);
|
|
179
|
+
setActive(-1);
|
|
180
|
+
// The session and the suggestions go only after any click has landed,
|
|
181
|
+
// and once however many blurs ask.
|
|
182
|
+
clearTimeout(leaving.current);
|
|
183
|
+
leaving.current = setTimeout(() => {
|
|
184
|
+
leaving.current = undefined;
|
|
185
|
+
latestProvider.current?.abandon?.();
|
|
186
|
+
// Nothing stale is offered after the visitor leaves; typing again asks anew.
|
|
187
|
+
setSuggestions([]);
|
|
188
|
+
}, 0);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/** Ends a press that brought no pick; a field the press left is then left properly. */
|
|
192
|
+
const endPress = () => {
|
|
193
|
+
clearTimeout(pressEnd.current);
|
|
194
|
+
if (!picking.current) return;
|
|
195
|
+
picking.current = false;
|
|
196
|
+
if (document.activeElement !== inputRef.current) leave();
|
|
197
|
+
};
|
|
198
|
+
const latestEndPress = useRef(endPress);
|
|
199
|
+
latestEndPress.current = endPress;
|
|
200
|
+
|
|
201
|
+
// A press on an option the list no longer holds (its suggestions replaced,
|
|
202
|
+
// or the list gone) is no pick, so the guard never outlives its option.
|
|
203
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: the suggestions are what a press belongs to; the press ends when they change
|
|
204
|
+
useEffect(() => () => latestEndPress.current(), [suggestions]);
|
|
205
|
+
|
|
206
|
+
// Nothing waits on a field that is gone, but a leave it had begun (a blur
|
|
207
|
+
// just before the field went) still ends the provider's session.
|
|
208
|
+
useEffect(
|
|
209
|
+
() => () => {
|
|
210
|
+
clearTimeout(pressEnd.current);
|
|
211
|
+
if (leaving.current !== undefined) {
|
|
212
|
+
clearTimeout(leaving.current);
|
|
213
|
+
leaving.current = undefined;
|
|
214
|
+
latestProvider.current?.abandon?.();
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[],
|
|
218
|
+
);
|
|
219
|
+
|
|
150
220
|
useEffect(() => {
|
|
151
221
|
if (!hasProvider) return;
|
|
152
222
|
if (picked.current === query) return;
|
|
@@ -207,6 +277,10 @@ export function AddressSearch({
|
|
|
207
277
|
if (!provider) return null;
|
|
208
278
|
|
|
209
279
|
const pick = (suggestion: AddressSuggestion) => {
|
|
280
|
+
picking.current = false;
|
|
281
|
+
clearTimeout(pressEnd.current);
|
|
282
|
+
clearTimeout(leaving.current);
|
|
283
|
+
leaving.current = undefined;
|
|
210
284
|
const text = pickedText(suggestion);
|
|
211
285
|
// What the visitor typed, to go back to if the pick cannot be resolved.
|
|
212
286
|
const typed = query;
|
|
@@ -223,7 +297,15 @@ export function AddressSearch({
|
|
|
223
297
|
.run((signal) => source.resolve(suggestion, { signal }))
|
|
224
298
|
.then(
|
|
225
299
|
(answer) => {
|
|
226
|
-
if (
|
|
300
|
+
if (answer.stale) return;
|
|
301
|
+
// A form that has moved on declines the pick: the field goes back
|
|
302
|
+
// to what was typed, as it does when the address cannot be read.
|
|
303
|
+
// The restored words count as answered, so no new lookup (and no
|
|
304
|
+
// new billable request) runs until the visitor types again.
|
|
305
|
+
if (latestPick.current(answer.value) === false) {
|
|
306
|
+
picked.current = typed;
|
|
307
|
+
setQuery(typed);
|
|
308
|
+
}
|
|
227
309
|
},
|
|
228
310
|
() => {
|
|
229
311
|
// The address could not be read: the field goes back to what was
|
|
@@ -293,15 +375,12 @@ export function AddressSearch({
|
|
|
293
375
|
onKeyDown={onKeyDown}
|
|
294
376
|
onFocus={() => latestProvider.current?.prepare?.()}
|
|
295
377
|
onBlur={() => {
|
|
378
|
+
// A press on a suggestion moved focus first (a touch browser, a
|
|
379
|
+
// screen reader): the pick is coming, and keeps what it needs.
|
|
380
|
+
if (picking.current) return;
|
|
296
381
|
// Leaving the field stops the pause and the lookup in flight,
|
|
297
382
|
// so no answer reopens the list behind the visitor.
|
|
298
|
-
|
|
299
|
-
lookups.cancel();
|
|
300
|
-
latestProvider.current?.abandon?.();
|
|
301
|
-
// Nothing stale is offered after the visitor leaves; typing again asks anew.
|
|
302
|
-
setSuggestions([]);
|
|
303
|
-
setOpen(false);
|
|
304
|
-
setActive(-1);
|
|
383
|
+
leave();
|
|
305
384
|
}}
|
|
306
385
|
/>
|
|
307
386
|
</div>
|
|
@@ -318,6 +397,26 @@ export function AddressSearch({
|
|
|
318
397
|
className="address-search-option"
|
|
319
398
|
// Keeps focus in the field, so the press is a pick and not a blur.
|
|
320
399
|
onMouseDown={(event) => event.preventDefault()}
|
|
400
|
+
onPointerDown={() => {
|
|
401
|
+
clearTimeout(pressEnd.current);
|
|
402
|
+
picking.current = true;
|
|
403
|
+
}}
|
|
404
|
+
// No click follows a cancelled press (a scroll that took the touch).
|
|
405
|
+
onPointerCancel={endPress}
|
|
406
|
+
// A mouse press dragged off its suggestion is released elsewhere,
|
|
407
|
+
// where this option hears no pointerup: the wait starts here, and
|
|
408
|
+
// a press that comes back and clicks still picks.
|
|
409
|
+
onPointerLeave={() => {
|
|
410
|
+
if (!picking.current) return;
|
|
411
|
+
clearTimeout(pressEnd.current);
|
|
412
|
+
pressEnd.current = setTimeout(endPress, PRESS_WAIT_MS);
|
|
413
|
+
}}
|
|
414
|
+
// A click follows a pointerup at once, or after a touch's short
|
|
415
|
+
// delay; a press that brings none ends after this.
|
|
416
|
+
onPointerUp={() => {
|
|
417
|
+
clearTimeout(pressEnd.current);
|
|
418
|
+
pressEnd.current = setTimeout(endPress, PRESS_WAIT_MS);
|
|
419
|
+
}}
|
|
321
420
|
onClick={() => pick(suggestion)}
|
|
322
421
|
>
|
|
323
422
|
<span className="address-search-option-text">{suggestion.text}</span>
|
|
@@ -4,10 +4,14 @@ import {
|
|
|
4
4
|
type RefObject,
|
|
5
5
|
useEffect,
|
|
6
6
|
useId,
|
|
7
|
+
useLayoutEffect,
|
|
7
8
|
useRef,
|
|
8
9
|
useState,
|
|
9
10
|
} from "react";
|
|
10
11
|
|
|
12
|
+
/** A layout effect in a browser, so a measure lands before paint; an effect where nothing paints (prerender). */
|
|
13
|
+
const useMeasureEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
14
|
+
|
|
11
15
|
export interface ExpandableTextProps {
|
|
12
16
|
/** The text: prose only, since all of it stays in the page while clamped. */
|
|
13
17
|
children: ReactNode;
|
|
@@ -73,7 +77,7 @@ export function ExpandableText({
|
|
|
73
77
|
// Whether the text runs past its lines; unknown until measured.
|
|
74
78
|
const [overflows, setOverflows] = useState<boolean | null>(null);
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
useMeasureEffect(() => {
|
|
77
81
|
const body = bodyRef.current;
|
|
78
82
|
if (!body || open) return;
|
|
79
83
|
const measure = () => setOverflows(body.scrollHeight > body.clientHeight + 1);
|
|
@@ -85,9 +89,26 @@ export function ExpandableText({
|
|
|
85
89
|
}, [open]);
|
|
86
90
|
|
|
87
91
|
const hasMore = more != null && more !== false;
|
|
88
|
-
|
|
92
|
+
// Inline text that fits has nothing hidden, so what `more` holds shows
|
|
93
|
+
// and no control is drawn; inline text not yet measured has its control
|
|
94
|
+
// placed but unseen, so measuring never moves the page (8.6.0).
|
|
95
|
+
const fitsInline = inline && !open && overflows === false;
|
|
96
|
+
const unmeasuredInline = inline && !open && overflows === null;
|
|
97
|
+
const moreShown = open || (fitsInline && hasMore);
|
|
98
|
+
const showControl = inline ? !fitsInline : hasMore || open || overflows !== false;
|
|
89
99
|
const style = { "--expandable-lines": lines } as CSSProperties;
|
|
90
|
-
|
|
100
|
+
// is-clamped is the clamp the measuring needs, which cuts nothing when the
|
|
101
|
+
// text fits; is-cut says it was measured cutting, and only then is an
|
|
102
|
+
// inline control seen over the line's end (8.6.0). Before measuring (a
|
|
103
|
+
// prerendered page) the inline control already sits there, out of the
|
|
104
|
+
// flow and unseen, so nothing moves when it shows.
|
|
105
|
+
const bodyClass = [
|
|
106
|
+
"expandable-text-body",
|
|
107
|
+
!open && "is-clamped",
|
|
108
|
+
!open && overflows === true && "is-cut",
|
|
109
|
+
]
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.join(" ");
|
|
91
112
|
|
|
92
113
|
const control = showControl && (
|
|
93
114
|
<button
|
|
@@ -95,6 +116,9 @@ export function ExpandableText({
|
|
|
95
116
|
className="expandable-text-toggle"
|
|
96
117
|
aria-expanded={open}
|
|
97
118
|
aria-controls={hasMore ? `${bodyId} ${moreId}` : bodyId}
|
|
119
|
+
// Unseen until measured: out of the accessibility tree and the tab order.
|
|
120
|
+
aria-hidden={unmeasuredInline || undefined}
|
|
121
|
+
tabIndex={unmeasuredInline ? -1 : undefined}
|
|
98
122
|
onClick={() => setOpen((was) => !was)}
|
|
99
123
|
>
|
|
100
124
|
<span className="expandable-text-toggle-label">{open ? lessLabel : moreLabel}</span>
|
|
@@ -127,7 +151,7 @@ export function ExpandableText({
|
|
|
127
151
|
)}
|
|
128
152
|
{inline && control}
|
|
129
153
|
{hasMore && (
|
|
130
|
-
<div id={moreId} className="expandable-text-more" hidden={!
|
|
154
|
+
<div id={moreId} className="expandable-text-more" hidden={!moreShown} inert={!moreShown}>
|
|
131
155
|
{more}
|
|
132
156
|
</div>
|
|
133
157
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnchorHTMLAttributes, isValidElement, type ReactNode } from "react";
|
|
2
2
|
import { dialable, toE164 } from "../lib/contactLinks";
|
|
3
3
|
import type { Phone } from "../types";
|
|
4
4
|
|
|
@@ -31,27 +31,39 @@ const hasDigits = (value: string) => /\d/.test(value);
|
|
|
31
31
|
* 8.5.0: the browser is never stricter than it was, and a loose `e164` is
|
|
32
32
|
* the build guard's to catch (`contactProblems`). A typed number is read
|
|
33
33
|
* into E.164 (`toE164`), or failing that dials what a dialer can take
|
|
34
|
-
* (`dialable`: the digits, a typed + kept, an extension dropped)
|
|
35
|
-
* no digit at all has no href.
|
|
34
|
+
* (`dialable`: the digits, a typed + kept, an extension dropped). Either
|
|
35
|
+
* with no digit at all has no href (8.6.0), so nothing draws a call that
|
|
36
|
+
* dials nothing.
|
|
36
37
|
*/
|
|
37
38
|
export function phoneHref(phone: Pick<Phone, "e164"> | string): string | undefined {
|
|
38
|
-
if (typeof phone !== "string")
|
|
39
|
+
if (typeof phone !== "string") {
|
|
40
|
+
return hasDigits(phone.e164 ?? "") ? `tel:${phone.e164}` : undefined;
|
|
41
|
+
}
|
|
39
42
|
const number = toE164(phone) ?? dialable(phone);
|
|
40
43
|
return number ? `tel:${number}` : undefined;
|
|
41
44
|
}
|
|
42
45
|
|
|
46
|
+
/** The words a node shows, gathered through its elements; an icon alone shows none. */
|
|
47
|
+
function textOf(node: ReactNode): string {
|
|
48
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
49
|
+
if (Array.isArray(node)) return node.map(textOf).join("");
|
|
50
|
+
if (isValidElement<{ children?: ReactNode }>(node)) return textOf(node.props.children);
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
/**
|
|
44
55
|
* A phone number as a link that dials it (Component Rules 17), the one way
|
|
45
56
|
* the package draws one. It never opens a new tab (Component Rules 12). Its
|
|
46
|
-
* href is `phoneHref`'s.
|
|
47
|
-
*
|
|
57
|
+
* href is `phoneHref`'s. A number with no digit to dial is shown as plain
|
|
58
|
+
* words rather than a dead link, with a warning in development, and as
|
|
59
|
+
* nothing at all when it has no words to show (an icon alone).
|
|
48
60
|
*/
|
|
49
61
|
export function PhoneLink({ phone, children, className, ...anchor }: PhoneLinkProps) {
|
|
50
62
|
const href = phoneHref(phone);
|
|
51
63
|
const words = children ?? (typeof phone === "string" ? phone : phone.display);
|
|
52
|
-
if (!href
|
|
64
|
+
if (!href) {
|
|
53
65
|
warnOnce(typeof phone === "string" ? phone : phone.e164);
|
|
54
|
-
return <span className={className}>{words}</span
|
|
66
|
+
return textOf(words).trim() ? <span className={className}>{words}</span> : null;
|
|
55
67
|
}
|
|
56
68
|
return (
|
|
57
69
|
<a className={className} href={href} {...anchor}>
|
|
@@ -539,7 +539,9 @@ export function ContactForm({
|
|
|
539
539
|
choosing.current = true;
|
|
540
540
|
}}
|
|
541
541
|
onPick={(picked) => {
|
|
542
|
-
|
|
542
|
+
// A hand edit came first: the form keeps it, and the search
|
|
543
|
+
// goes back to what was typed (8.6.0).
|
|
544
|
+
if (!choosing.current) return false;
|
|
543
545
|
choosing.current = false;
|
|
544
546
|
// A pick with no state keeps the one the field shows, so a state
|
|
545
547
|
// select and what it submits never part ways.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Surface } from "./siteConfig";
|
|
3
|
+
|
|
4
|
+
export interface ContactSectionProps {
|
|
5
|
+
/** The card's body: the contact form. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** The card's heading, above its lead; a real heading element a site's heading rules reach. */
|
|
8
|
+
title?: ReactNode;
|
|
9
|
+
/** The line under the card's heading. */
|
|
10
|
+
lead?: ReactNode;
|
|
11
|
+
/** The level the card's heading is drawn at. Defaults to 2. */
|
|
12
|
+
headingLevel?: 2 | 3 | 4;
|
|
13
|
+
/** The card's id, for a link straight to the form (`#message`). */
|
|
14
|
+
cardId?: string;
|
|
15
|
+
/** The column beside the card: whatever the site stacks there (a contact card, info rows, the hours). */
|
|
16
|
+
side?: ReactNode;
|
|
17
|
+
/** The side column's accessible name, which makes it an `aside` landmark; without it, a plain column. */
|
|
18
|
+
sideLabel?: string;
|
|
19
|
+
/** The band's background. Defaults to the page surface. */
|
|
20
|
+
surface?: Surface;
|
|
21
|
+
id?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A contact page's body: the form in a card, with an optional heading and
|
|
27
|
+
* lead, beside a column of the other ways to reach the business. The two
|
|
28
|
+
* stand side by side while both columns' bases and the gap fit the width,
|
|
29
|
+
* and stack, the card first, below that, so the section takes the site's
|
|
30
|
+
* width and sets none of its own (Component Rules 19). The ratio, the
|
|
31
|
+
* bases, the gap, and the card's padding are tokens. The card sets
|
|
32
|
+
* `--expandable-ground` to its own ground, so an inline Show more inside
|
|
33
|
+
* the form fades over the card.
|
|
34
|
+
*/
|
|
35
|
+
export function ContactSection({
|
|
36
|
+
children,
|
|
37
|
+
title,
|
|
38
|
+
lead,
|
|
39
|
+
headingLevel = 2,
|
|
40
|
+
cardId,
|
|
41
|
+
side,
|
|
42
|
+
sideLabel,
|
|
43
|
+
surface = "default",
|
|
44
|
+
id,
|
|
45
|
+
className,
|
|
46
|
+
}: ContactSectionProps) {
|
|
47
|
+
const Title = `h${headingLevel}` as const;
|
|
48
|
+
const Side = sideLabel ? "aside" : "div";
|
|
49
|
+
return (
|
|
50
|
+
<section
|
|
51
|
+
className={["section", "contact-section", surface === "alt" && "surface-alt", className]
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.join(" ")}
|
|
54
|
+
id={id}
|
|
55
|
+
>
|
|
56
|
+
<div className="wrap contact-section-layout">
|
|
57
|
+
<div className="contact-section-main">
|
|
58
|
+
<div className="contact-section-card" id={cardId}>
|
|
59
|
+
{title && <Title className="contact-section-title">{title}</Title>}
|
|
60
|
+
{lead && <p className="contact-section-lead">{lead}</p>}
|
|
61
|
+
{children}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
{side && (
|
|
65
|
+
<Side className="contact-section-side" aria-label={sideLabel}>
|
|
66
|
+
{side}
|
|
67
|
+
</Side>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
</section>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -44,6 +44,7 @@ export function LocationSection({
|
|
|
44
44
|
headingLevel = 2,
|
|
45
45
|
}: LocationSectionProps) {
|
|
46
46
|
const Title = `h${headingLevel}` as const;
|
|
47
|
+
const callHref = site.phone ? phoneHref(site.phone) : undefined;
|
|
47
48
|
return (
|
|
48
49
|
<section
|
|
49
50
|
className={["section location", surface === "alt" && "surface-alt"].filter(Boolean).join(" ")}
|
|
@@ -74,8 +75,9 @@ export function LocationSection({
|
|
|
74
75
|
Get Directions
|
|
75
76
|
</Button>
|
|
76
77
|
)}
|
|
77
|
-
{
|
|
78
|
-
|
|
78
|
+
{/* No number to dial, no call button (8.6.0). */}
|
|
79
|
+
{site.phone && callHref && (
|
|
80
|
+
<Button variant="ghost" href={callHref}>
|
|
79
81
|
{site.phone.display}
|
|
80
82
|
</Button>
|
|
81
83
|
)}
|
package/src/sections/index.ts
CHANGED
|
@@ -43,6 +43,7 @@ export {
|
|
|
43
43
|
type ContactInfoCardSite,
|
|
44
44
|
type ContactPhone,
|
|
45
45
|
} from "./ContactInfoCard";
|
|
46
|
+
export { ContactSection, type ContactSectionProps } from "./ContactSection";
|
|
46
47
|
export { type Credential, CredentialList, type CredentialListProps } from "./CredentialList";
|
|
47
48
|
export { CTASection, type CTASectionProps } from "./CTASection";
|
|
48
49
|
export { ExpandList, type ExpandListItem, type ExpandListProps } from "./ExpandList";
|
package/src/styles/defaults.css
CHANGED
|
@@ -191,6 +191,17 @@
|
|
|
191
191
|
--field-padding-block: 14px;
|
|
192
192
|
--field-padding-inline: 16px;
|
|
193
193
|
--form-footnote-size: 0.82rem;
|
|
194
|
+
/* ContactSection (8.6.0): the columns' grow ratio (5 to 3, the 1.25 to
|
|
195
|
+
0.75 the contact design draws; each at least 1, or a column alone on
|
|
196
|
+
its line stops short of the width) and bases (side by side while both
|
|
197
|
+
and the gap fit), the gaps, and the card's padding. */
|
|
198
|
+
--contact-section-main: 5;
|
|
199
|
+
--contact-section-side: 3;
|
|
200
|
+
--contact-section-main-basis: 30.25rem;
|
|
201
|
+
--contact-section-side-basis: 18.25rem;
|
|
202
|
+
--contact-section-gap: clamp(24px, 4vw, 56px);
|
|
203
|
+
--contact-section-side-gap: 24px;
|
|
204
|
+
--contact-section-card-pad: clamp(20px, 3vw, 34px);
|
|
194
205
|
/* The page hero's headline size (8.5.0). */
|
|
195
206
|
--page-hero-title-size: clamp(2.4rem, 7vw, 4.2rem);
|
|
196
207
|
/* A form field's label: its size, its case, and its tracking (8.5.0). */
|
|
@@ -750,9 +750,12 @@
|
|
|
750
750
|
color: var(--primary-ink, var(--primary));
|
|
751
751
|
text-decoration: underline;
|
|
752
752
|
}
|
|
753
|
-
/* inline (8.5.0). Closed
|
|
754
|
-
|
|
755
|
-
|
|
753
|
+
/* inline (8.5.0). Closed, the control is out of the flow from the first
|
|
754
|
+
paint, over the end of the last line, so measuring the text never moves
|
|
755
|
+
the page (8.6.0): unseen until the text is measured as cut (.is-cut),
|
|
756
|
+
then shown on a fade of the ground, after an ellipsis whose empty
|
|
757
|
+
alternative text keeps it out of the control's name. Text that fits
|
|
758
|
+
draws no control. */
|
|
756
759
|
.atelic-ui .expandable-text.is-inline {
|
|
757
760
|
position: relative;
|
|
758
761
|
}
|
|
@@ -762,15 +765,19 @@
|
|
|
762
765
|
bottom: 0;
|
|
763
766
|
margin: 0;
|
|
764
767
|
padding-left: 1.25em;
|
|
768
|
+
visibility: hidden;
|
|
765
769
|
background: linear-gradient(
|
|
766
770
|
to right,
|
|
767
771
|
transparent,
|
|
768
772
|
var(--expandable-ground, var(--surface)) 1em
|
|
769
773
|
);
|
|
770
774
|
}
|
|
775
|
+
.atelic-ui .expandable-text.is-inline .expandable-text-body.is-cut + .expandable-text-toggle {
|
|
776
|
+
visibility: visible;
|
|
777
|
+
}
|
|
771
778
|
.atelic-ui
|
|
772
779
|
.expandable-text.is-inline
|
|
773
|
-
.expandable-text-body.is-
|
|
780
|
+
.expandable-text-body.is-cut
|
|
774
781
|
+ .expandable-text-toggle::before {
|
|
775
782
|
content: "\2026\00a0" / "";
|
|
776
783
|
display: inline-block;
|
package/src/styles/sections.css
CHANGED
|
@@ -597,6 +597,50 @@
|
|
|
597
597
|
text-decoration: underline;
|
|
598
598
|
}
|
|
599
599
|
|
|
600
|
+
/* ---- ContactSection (8.6.0) ----
|
|
601
|
+
The form's card beside the side column. The columns are flex items that
|
|
602
|
+
grow in the ratio of --contact-section-main and --contact-section-side
|
|
603
|
+
from their bases; they stand side by side while both bases and the gap
|
|
604
|
+
fit, and wrap, the card first, below that, so the stacking follows the
|
|
605
|
+
width the section is given rather than a viewport breakpoint (the
|
|
606
|
+
defaults stack it below about 900px on a site's default gutter). */
|
|
607
|
+
.atelic-ui .contact-section-layout {
|
|
608
|
+
display: flex;
|
|
609
|
+
flex-wrap: wrap;
|
|
610
|
+
align-items: flex-start;
|
|
611
|
+
gap: var(--contact-section-gap);
|
|
612
|
+
}
|
|
613
|
+
.atelic-ui .contact-section-main {
|
|
614
|
+
flex: var(--contact-section-main) 1 var(--contact-section-main-basis);
|
|
615
|
+
min-width: 0;
|
|
616
|
+
}
|
|
617
|
+
.atelic-ui .contact-section-side {
|
|
618
|
+
flex: var(--contact-section-side) 1 var(--contact-section-side-basis);
|
|
619
|
+
min-width: 0;
|
|
620
|
+
display: flex;
|
|
621
|
+
flex-direction: column;
|
|
622
|
+
gap: var(--contact-section-side-gap);
|
|
623
|
+
}
|
|
624
|
+
.atelic-ui .contact-section-card {
|
|
625
|
+
padding: var(--contact-section-card-pad);
|
|
626
|
+
background: var(--ui-card, var(--card));
|
|
627
|
+
border: 1px solid var(--hairline-strong);
|
|
628
|
+
border-radius: var(--radius-lg);
|
|
629
|
+
/* An inline Show more in the form fades over the card's own ground. */
|
|
630
|
+
--expandable-ground: var(--ui-card, var(--card));
|
|
631
|
+
}
|
|
632
|
+
.atelic-ui .contact-section-title {
|
|
633
|
+
margin: 0 0 4px;
|
|
634
|
+
font-size: clamp(1.4rem, 2.4vw, 1.8rem);
|
|
635
|
+
line-height: 1.15;
|
|
636
|
+
}
|
|
637
|
+
.atelic-ui .contact-section-lead {
|
|
638
|
+
margin: 0 0 22px;
|
|
639
|
+
font-size: 1.03rem;
|
|
640
|
+
line-height: 1.5;
|
|
641
|
+
color: var(--ink-soft);
|
|
642
|
+
}
|
|
643
|
+
|
|
600
644
|
/* ---- InfoRows ---- */
|
|
601
645
|
/* A title over a few lines, with one action on the right, the way a map
|
|
602
646
|
pack lists a place: an office and its directions. */
|