events 3.9.0, website 1.9.0, accounts 1.10.0: the church's details from Accounts everywhere
- Events: the Accounts profile's name, logo, icon, colours and contact details win over Events' own settings while Accounts is connected (pages, emails, WhatsApp, PDFs); Settings shows them read-only with a link to Accounts. The Accounts logo is copied for PDFs (PNG and JPEG). Fixes Events keeping its old church after a demo scenario load. - Website: a background per homepage section in the church's colours; "More info" instead of "Register" for events without registration; the shared colour field. - Accounts: the shared colour field in Church profile. - @crosscode/ui 0.4.0: ColourField and isHexColour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/ui",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"private": true,
|
||||
"description": "Shared UI for the church's sign-in pages, Website and App: the branded shell, forms and buttons, the church's fonts and footer (Tailwind; apps compile the source with transpilePackages)",
|
||||
"main": "src/index.tsx",
|
||||
|
||||
@@ -97,6 +97,62 @@ export function Field({ label, error, hint, id, className, ...rest }: FieldProps
|
||||
);
|
||||
}
|
||||
|
||||
export const isHexColour = (v: string) => /^#[0-9a-fA-F]{6}$/.test(v.trim());
|
||||
|
||||
type ColourFieldProps = {
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (hex: string) => void;
|
||||
hint?: React.ReactNode;
|
||||
error?: string | null;
|
||||
/** For a form read with FormData: the hex is sent under this name. */
|
||||
name?: string;
|
||||
id?: string;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* A colour: the swatch to pick it, the hex code to type or paste it, and a bar showing it, as Cross
|
||||
* Events' Branding settings. Controlled: `value` is what's typed, so it can be half-typed; it's a
|
||||
* colour once it reads `#rrggbb` (`isHexColour`), and says so when it doesn't.
|
||||
*/
|
||||
export function ColourField({ label, value, onChange, hint, error, name, id, disabled }: ColourFieldProps) {
|
||||
const fieldId = id ?? `f-${label.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
|
||||
const valid = isHexColour(value);
|
||||
const problem = error || (valid ? null : "Enter a colour code like #1f4e79.");
|
||||
return (
|
||||
<div className="mb-4">
|
||||
<label htmlFor={fieldId} className="mb-1 block text-sm font-medium text-gray-800">{label}</label>
|
||||
<div className="flex items-center gap-3">
|
||||
<input
|
||||
type="color"
|
||||
aria-label={`${label}: pick`}
|
||||
disabled={disabled}
|
||||
className="h-10 w-20 shrink-0 cursor-pointer rounded-[var(--cc-radius-sm,0.5rem)] border border-gray-300 bg-white p-1 disabled:cursor-not-allowed"
|
||||
value={valid ? value.trim().toLowerCase() : "#000000"}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
id={fieldId}
|
||||
name={name}
|
||||
disabled={disabled}
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
placeholder="#1f4e79"
|
||||
aria-invalid={!!problem}
|
||||
aria-describedby={problem ? `${fieldId}-error` : undefined}
|
||||
className={cx("w-full rounded-[var(--cc-radius-sm,0.5rem)] border px-3 py-2.5 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-brand/50", problem ? "border-red-500" : "border-gray-300")}
|
||||
value={value}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-2 h-6 rounded-[var(--cc-radius-sm,0.5rem)] border border-gray-200 transition-colors" style={{ background: valid ? value.trim() : "#f1f5f9" }} aria-hidden />
|
||||
{hint && !problem && <p className="mt-1 text-xs text-gray-500">{hint}</p>}
|
||||
{problem && <p id={`${fieldId}-error`} className="mt-1 text-sm text-red-700">{problem}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Checkbox({ label, hint, ...rest }: React.InputHTMLAttributes<HTMLInputElement> & { label: React.ReactNode; hint?: React.ReactNode }) {
|
||||
return (
|
||||
<label className="mb-3 flex items-start gap-3 text-sm">
|
||||
|
||||
Reference in New Issue
Block a user