Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133<script lang="ts"> import type { Component } from "svelte"; import type { HTMLFormAttributes, SvelteHTMLElements } from "svelte/elements"; import Button from "#lib/components/ui/Button.svelte";
/** * An email field with its button inside the same rounded frame: the newsletter's and the * join forms'. On very narrow phones the button drops under the field, full width. `wide` * (the join forms) fills its parent and keeps the body copy's 16px at every size. */ interface Props extends Omit<HTMLFormAttributes, "children"> { value?: string; label: string; variant?: "primary" | "default"; icon?: Component<SvelteHTMLElements["svg"]>; disabled?: boolean; invalid?: boolean; describedby?: string; oninput?: () => void; wide?: boolean; }
let { value = $bindable(""), label, variant = "default", icon, disabled = false, invalid = false, describedby, oninput, wide = false, class: className, ...rest }: Props = $props();</script>
<form class={["email", wide && "wide", className]} novalidate {...rest}> <input type="email" name="email" placeholder="Enter your email..." aria-label="Email" autocomplete="email" required maxlength="320" aria-invalid={invalid} aria-describedby={describedby} bind:value {oninput} /> <!-- The field's type size: 13px unless wide, which keeps 16px on phones (iOS zooms into less). Flat text on the primary button. --> <Button type="submit" {variant} size="large" class={wide ? "text-shadow-none" : "typography-paragraph-regular text-shadow-none"} {icon} {disabled}>{label}</Button ></form>
<style> .email { display: flex; align-items: center; width: min(100%, 327px); box-sizing: border-box; padding: 4px 4px 4px 16px; border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); border-radius: 14px; /* Opaque, in the page's colour, so the thread and grid behind it don't show through. */ background: var(--bg); transition: border-color 0.15s ease; } .email:focus-within { border-color: var(--color-border-focus); } .email input { flex: 1; /* No intrinsic width (an input's default is ~20 characters), so it takes what's left. */ width: 0; min-width: 0; padding: 0; border: 0; background: transparent; outline: none; color: var(--text); /* 16px on phones: iOS zooms into anything smaller. */ font-size: 16px; font-weight: 450; letter-spacing: -0.01em; } .email input::placeholder { color: var(--text-3); }
/* Very narrow phones: the button drops under the input, full width, and the field's border moves from the form onto the input so the button sits outside it. */ @media (width < 340px) { .email { flex-direction: column; align-items: stretch; gap: 8px; padding: 0; border: 0; background: none; } .email input { width: auto; /* Sized to the button below it (36px). */ padding: 6px 16px; line-height: 1.4; border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); border-radius: 10px; background: var(--bg); transition: border-color 0.15s ease; } .email input:focus { border-color: var(--color-border-focus); } }
.email.wide { width: 100%; }
.email:not(.wide) input { font-size: var(--text-small); }</style>