@feitio/astro 0.0.0-stage → 0.1.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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -2
  3. package/package.json +44 -4
  4. package/src/Anchor.astro +18 -0
  5. package/src/AppShell.astro +44 -0
  6. package/src/BackToTop.astro +12 -0
  7. package/src/Block.astro +8 -0
  8. package/src/Breadcrumbs.astro +13 -0
  9. package/src/Button.astro +29 -0
  10. package/src/Checkbox.astro +12 -0
  11. package/src/CodeBlock.astro +18 -0
  12. package/src/Details.astro +12 -0
  13. package/src/Dialog.astro +25 -0
  14. package/src/Divider.astro +12 -0
  15. package/src/DoDont.astro +14 -0
  16. package/src/Drawer.astro +23 -0
  17. package/src/EmptyState.astro +16 -0
  18. package/src/ErrorMessage.astro +11 -0
  19. package/src/ErrorSummary.astro +15 -0
  20. package/src/Example.astro +27 -0
  21. package/src/Field.astro +22 -0
  22. package/src/Fieldset.astro +9 -0
  23. package/src/FilterField.astro +29 -0
  24. package/src/Footer.astro +12 -0
  25. package/src/Grid.astro +11 -0
  26. package/src/Header.astro +21 -0
  27. package/src/Heading.astro +10 -0
  28. package/src/Hint.astro +8 -0
  29. package/src/Icon.astro +14 -0
  30. package/src/Inline.astro +10 -0
  31. package/src/Kbd.astro +4 -0
  32. package/src/Label.astro +8 -0
  33. package/src/Link.astro +17 -0
  34. package/src/LinkCard.astro +12 -0
  35. package/src/Menu.astro +47 -0
  36. package/src/Nav.astro +15 -0
  37. package/src/Notice.astro +61 -0
  38. package/src/Pagination.astro +52 -0
  39. package/src/Radios.astro +17 -0
  40. package/src/ScrollFade.astro +4 -0
  41. package/src/Search.astro +25 -0
  42. package/src/SegmentedControl.astro +11 -0
  43. package/src/Select.astro +18 -0
  44. package/src/SkipLink.astro +8 -0
  45. package/src/Stack.astro +10 -0
  46. package/src/StatusOverlay.astro +17 -0
  47. package/src/SummaryList.astro +8 -0
  48. package/src/Swatch.astro +9 -0
  49. package/src/Switch.astro +12 -0
  50. package/src/Table.astro +26 -0
  51. package/src/Tag.astro +16 -0
  52. package/src/TaskList.astro +17 -0
  53. package/src/Text.astro +4 -0
  54. package/src/TextInput.astro +17 -0
  55. package/src/Textarea.astro +12 -0
  56. package/src/TimeInput.astro +26 -0
  57. package/src/VisuallyHidden.astro +4 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Henrique Artur
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,36 @@
1
- # Temporary Holding Version
1
+ # @feitio/astro
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Feitio's components for Astro, and the single source of each component's HTML: the React port
4
+ ([`@feitio/react`](https://www.npmjs.com/package/@feitio/react)) is tested to render the very same
5
+ markup.
6
+
7
+ ```sh
8
+ npm install @feitio/core @feitio/astro
9
+ ```
10
+
11
+ ```astro
12
+ ---
13
+ import '@feitio/core/css/fonts.css';
14
+ import '@feitio/core/css/feitio.css';
15
+ import Button from '@feitio/astro/Button.astro';
16
+ import Field from '@feitio/astro/Field.astro';
17
+ import Stack from '@feitio/astro/Stack.astro';
18
+ import TextInput from '@feitio/astro/TextInput.astro';
19
+ ---
20
+ <Stack gap={5}>
21
+ <Field label="Name" for="name" hint="Shown in the notification">
22
+ <TextInput id="name" describedBy="name-hint" />
23
+ </Field>
24
+ <Button variant="primary" type="submit">Save</Button>
25
+ </Stack>
26
+ ```
27
+
28
+ - Components with a behavior (Menu, Notice) bring their script; for Dialog, the form controls and
29
+ the scroll helpers, call [`@feitio/vanilla`](https://www.npmjs.com/package/@feitio/vanilla) once
30
+ on the page.
31
+ - Icons read the sprite at `/feitio/icons/sprite.svg` (copy `@feitio/core/icons/sprite.svg` there),
32
+ or wherever each component's `sprite` prop says.
33
+
34
+ Every component, when to use it and when not to: https://made-by-maid.github.io/feitio/
35
+
36
+ MIT.
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@feitio/astro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Feitio's components for Astro: the single source of each component's HTML.",
5
+ "keywords": [
6
+ "feitio",
7
+ "design-system",
8
+ "accessibility",
9
+ "a11y",
10
+ "handmade",
11
+ "astro",
12
+ "astro-component",
13
+ "components",
14
+ "ui"
15
+ ],
16
+ "homepage": "https://made-by-maid.github.io/feitio/",
17
+ "bugs": {
18
+ "url": "https://github.com/Made-by-MAID/feitio/issues"
19
+ },
20
+ "license": "MIT",
21
+ "type": "module",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/Made-by-MAID/feitio.git",
25
+ "directory": "packages/astro"
26
+ },
27
+ "files": [
28
+ "src"
29
+ ],
30
+ "exports": {
31
+ "./*": "./src/*"
32
+ },
33
+ "peerDependencies": {
34
+ "astro": ">=7"
35
+ },
36
+ "dependencies": {
37
+ "@feitio/core": "0.1.0",
38
+ "@feitio/vanilla": "0.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "astro": "7.4.11"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ }
46
+ }
@@ -0,0 +1,18 @@
1
+ ---
2
+ /** Anchor: the page index, following the scroll; the current part in ink, with the hand-drawn arrow. */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ title?: string;
7
+ items: {
8
+ id: string;
9
+ text: string;
10
+ current?: boolean;
11
+ children?: { id: string; text: string; current?: boolean }[];
12
+ }[];
13
+ label?: string;
14
+ sprite?: string;
15
+ }
16
+ const { title, items, label, sprite } = Astro.props;
17
+ ---
18
+ <nav class="feitio-anchor" aria-label={label ?? title}>{title && <p class="title">{title}</p>}<ul>{items.map((t) => <li><a href={`#${t.id}`} aria-current={t.current ? 'location' : undefined}><Icon name="chevron-right" sprite={sprite} />{t.text}</a>{t.children && <ul>{t.children.map((c) => <li><a href={`#${c.id}`} aria-current={c.current ? 'location' : undefined}><Icon name="chevron-right" sprite={sprite} />{c.text}</a></li>)}</ul>}</li>)}</ul></nav>
@@ -0,0 +1,44 @@
1
+ ---
2
+ /**
3
+ * AppShell: a product's layout of regions: the header (it leaves when scrolling down on mobile and
4
+ * comes back up), the navigation in a Drawer from the right, the main area with its ScrollFade and
5
+ * BackToTop. The slot is the main area's content.
6
+ */
7
+ import Icon from './Icon.astro';
8
+ import Nav from './Nav.astro';
9
+
10
+ interface Props {
11
+ id: string;
12
+ brand: string;
13
+ nav: {
14
+ title?: string;
15
+ items: { text: string; href: string; current?: boolean; icon?: string }[];
16
+ }[];
17
+ user?: string;
18
+ signOut?: { text: string; href: string };
19
+ menuLabel?: string;
20
+ closeLabel?: string;
21
+ topLabel?: string;
22
+ sprite?: string;
23
+ }
24
+ const {
25
+ id,
26
+ brand,
27
+ nav,
28
+ user,
29
+ signOut,
30
+ menuLabel = 'Menu',
31
+ closeLabel = 'Fechar',
32
+ topLabel = 'Topo',
33
+ sprite,
34
+ } = Astro.props;
35
+ ---
36
+ <div class="feitio-app">
37
+ <header class="feitio-app-header" data-hide-on-scroll><a class="brand" href={`#${id}-content`}>{brand}</a><button type="button" class="feitio-button menu" data-size="small" popovertarget={id} aria-controls={id}>{menuLabel}<Icon name="menu" sprite={sprite} /></button></header>
38
+ <nav class="feitio-drawer feitio-app-nav" id={id} popover aria-label={menuLabel}>
39
+ <div class="drawer-header"><h2>{menuLabel}</h2><button type="button" class="feitio-button close" data-size="small" popovertarget={id} popovertargetaction="hide"><Icon name="close" sprite={sprite} />{closeLabel}</button></div>
40
+ <div class="drawer-body"><Nav groups={nav} sprite={sprite} /></div>
41
+ {(user || signOut) && <div class="drawer-footer nav-footer">{user && <span class="who">{user}</span>}{signOut && <a class="feitio-link" href={signOut.href}>{signOut.text}</a>}</div>}
42
+ </nav>
43
+ <div class="feitio-app-main" id={`${id}-content`} tabindex="-1"><slot /><span class="feitio-scroll-fade" aria-hidden="true"></span><a class="feitio-button feitio-back-to-top" data-size="small" href={`#${id}-content`}><Icon name="chevron-down" sprite={sprite} />{topLabel}</a></div>
44
+ </div>
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** BackToTop: back to the start, shown after half a screen of scrolling, in the window's bottom-right corner (or its box's). */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ href?: string;
7
+ label?: string;
8
+ sprite?: string;
9
+ }
10
+ const { href = '#content', label = 'Topo', sprite } = Astro.props;
11
+ ---
12
+ <a class="feitio-button feitio-back-to-top" data-size="small" href={href}><Icon name="chevron-down" sprite={sprite} />{label}</a>
@@ -0,0 +1,8 @@
1
+ ---
2
+ /** Block: a block of content on the page, on its own paper. */
3
+ interface Props {
4
+ as?: 'div' | 'section' | 'article';
5
+ }
6
+ const { as: Tag = 'div' } = Astro.props;
7
+ ---
8
+ <Tag class="feitio-block"><slot /></Tag>
@@ -0,0 +1,13 @@
1
+ ---
2
+ /** Breadcrumbs: the path from the start to here; the last step is this page, not a link. */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ items: { text: string; href: string }[];
7
+ current: string;
8
+ label?: string;
9
+ sprite?: string;
10
+ }
11
+ const { items, current, label = 'Você está em', sprite } = Astro.props;
12
+ ---
13
+ <nav class="feitio-breadcrumbs" aria-label={label}><ol>{items.map((i, n) => <li>{n > 0 && <span class="sep" aria-hidden="true"><Icon name="chevron-right" sprite={sprite} /></span>}<a href={i.href}>{i.text}</a></li>)}<li><span class="sep" aria-hidden="true"><Icon name="chevron-right" sprite={sprite} /></span><span aria-current="page">{current}</span></li></ol></nav>
@@ -0,0 +1,29 @@
1
+ ---
2
+ /**
3
+ * Button: an action on the screen it is on. With href it is a link styled as a button, for
4
+ * "Get started" kinds of doors; an action is always a <button>.
5
+ */
6
+ import type { HTMLAttributes } from 'astro/types';
7
+
8
+ interface Props extends Omit<HTMLAttributes<'button'>, 'type'> {
9
+ /** primary is the screen's main action (orange, at most one); danger destroys something. */
10
+ variant?: 'primary' | 'danger';
11
+ size?: 'small' | 'large';
12
+ type?: 'button' | 'submit' | 'reset';
13
+ /** Makes it a link that looks like a button. */
14
+ href?: string;
15
+ }
16
+ const { variant, size, type = 'button', href, class: extra, ...rest } = Astro.props;
17
+ const classes = ['feitio-button', extra].filter(Boolean).join(' ');
18
+ ---
19
+ {
20
+ href ? (
21
+ <a class={classes} href={href} data-variant={variant} data-size={size} {...(rest as HTMLAttributes<'a'>)}>
22
+ <slot />
23
+ </a>
24
+ ) : (
25
+ <button class={classes} type={type} data-variant={variant} data-size={size} {...rest}>
26
+ <slot />
27
+ </button>
28
+ )
29
+ }
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** Checkbox: yes or no, or one of several choices; the whole label is the click target. */
3
+ interface Props {
4
+ label: string;
5
+ name?: string;
6
+ value?: string;
7
+ checked?: boolean;
8
+ disabled?: boolean;
9
+ }
10
+ const { label, name, value, checked, disabled } = Astro.props;
11
+ ---
12
+ <label class="feitio-choice"><input type="checkbox" name={name} value={value} checked={checked} disabled={disabled} />{label}</label>
@@ -0,0 +1,18 @@
1
+ ---
2
+ /** CodeBlock: code with colors and the Copy button, which says "Copied" in place. */
3
+ interface Props {
4
+ code: string;
5
+ label?: string;
6
+ syntax?: 'html' | 'jsx' | 'shell';
7
+ copyLabel?: string;
8
+ copiedLabel?: string;
9
+ }
10
+ const {
11
+ code,
12
+ label = 'HTML',
13
+ syntax = 'html',
14
+ copyLabel = 'Copiar',
15
+ copiedLabel = 'Copiado',
16
+ } = Astro.props;
17
+ ---
18
+ <div class="feitio-code" data-lang={syntax}><div class="bar"><span>{label}</span><button type="button" class="feitio-button copy" data-size="small" data-done-label={copiedLabel}>{copyLabel}</button></div><pre tabindex="0"><code>{code}</code></pre></div>
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** Details: a closed passage the person opens if they want; opening and closing animate the height. */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ summary: string;
7
+ open?: boolean;
8
+ sprite?: string;
9
+ }
10
+ const { summary, open, sprite } = Astro.props;
11
+ ---
12
+ <details class="feitio-details" open={open}><summary><Icon name="chevron-right" sprite={sprite} />{summary}</summary><div class="content"><slot /></div></details>
@@ -0,0 +1,25 @@
1
+ ---
2
+ /**
3
+ * Dialog: a question before a big action, in the middle of the screen, closing only with an answer.
4
+ * The slot is the explanation. confirmWord asks for a typed word before the danger action turns on.
5
+ * Open it with a button carrying data-open-dialog="id" (the behavior comes from @feitio/vanilla).
6
+ */
7
+ interface Props {
8
+ id: string;
9
+ title: string;
10
+ action: string;
11
+ cancel?: string;
12
+ danger?: boolean;
13
+ /** For what deletes a lot at once: the word to type, and the field's label. */
14
+ confirmWord?: { word: string; label: string };
15
+ }
16
+ const { id, title, action, cancel = 'Cancelar', danger = false, confirmWord } = Astro.props;
17
+ ---
18
+ <dialog class="feitio-dialog" id={id} aria-labelledby={`${id}-t`} aria-describedby={`${id}-d`}>
19
+ <form method="dialog" data-type-to-confirm={confirmWord?.word}>
20
+ <h2 id={`${id}-t`}>{title}</h2>
21
+ <div id={`${id}-d`}><slot /></div>
22
+ {confirmWord && <div class="feitio-field"><label class="feitio-label" for={`${id}-word`}>{confirmWord.label}</label><input class="feitio-input" id={`${id}-word`} autocomplete="off" /></div>}
23
+ <div class="actions"><button type="submit" class="feitio-button" data-variant={danger ? 'danger' : 'primary'} value="yes" disabled={Boolean(confirmWord)}>{action}</button><button type="submit" class="feitio-button" value="cancel" autofocus={!confirmWord}>{cancel}</button></div>
24
+ </form>
25
+ </dialog>
@@ -0,0 +1,12 @@
1
+ ---
2
+ /**
3
+ * Divider: the hairline between two parts that touch, when space alone is not enough. vertical sits
4
+ * between pieces side by side, as tall as their row.
5
+ */
6
+ interface Props {
7
+ tone?: 'ink';
8
+ orientation?: 'horizontal' | 'vertical';
9
+ }
10
+ const { tone, orientation = 'horizontal' } = Astro.props;
11
+ ---
12
+ <hr class="feitio-divider" data-tone={tone} aria-orientation={orientation === 'vertical' ? 'vertical' : undefined} />
@@ -0,0 +1,14 @@
1
+ ---
2
+ /** DoDont: the right way and the wrong way, side by side, each with its why in one sentence. Slots: do and dont. */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ doWhy: string;
7
+ dontWhy: string;
8
+ doLabel?: string;
9
+ dontLabel?: string;
10
+ sprite?: string;
11
+ }
12
+ const { doWhy, dontWhy, doLabel = 'Faça assim', dontLabel = 'Não faça', sprite } = Astro.props;
13
+ ---
14
+ <div class="pair feitio-dodont"><div class="do"><p class="verdict"><Icon name="check" sprite={sprite} />{doLabel}</p><div class="demo"><slot name="do" /></div><p class="why">{doWhy}</p></div><div class="dont"><p class="verdict"><Icon name="close" sprite={sprite} />{dontLabel}</p><div class="demo"><slot name="dont" /></div><p class="why">{dontWhy}</p></div></div>
@@ -0,0 +1,23 @@
1
+ ---
2
+ /**
3
+ * Drawer: a panel that slides in from an edge (end, start, top or bottom), with an optional title and
4
+ * footer. It opens with the popover API from any button with popovertarget="id"; Esc and a click
5
+ * outside close it. The slot is its body; slot="footer" goes at its foot.
6
+ */
7
+ import Icon from './Icon.astro';
8
+
9
+ interface Props {
10
+ id: string;
11
+ title?: string;
12
+ side?: 'end' | 'start' | 'top' | 'bottom';
13
+ label?: string;
14
+ closeLabel?: string;
15
+ sprite?: string;
16
+ }
17
+ const { id, title, side = 'end', label, closeLabel = 'Fechar', sprite } = Astro.props;
18
+ ---
19
+ <div class="feitio-drawer" id={id} popover data-side={side === 'end' ? undefined : side} role="dialog" aria-label={label ?? title}>
20
+ <div class="drawer-header">{title && <h2>{title}</h2>}<button type="button" class="feitio-button close" data-size="small" popovertarget={id} popovertargetaction="hide"><Icon name="close" sprite={sprite} />{closeLabel}</button></div>
21
+ <div class="drawer-body"><slot /></div>
22
+ {Astro.slots.has('footer') && <div class="drawer-footer"><slot name="footer" /></div>}
23
+ </div>
@@ -0,0 +1,16 @@
1
+ ---
2
+ /** EmptyState: what shows instead of an empty list: the drawing, why it is empty, and the next step (the slot). */
3
+ import basket from '@feitio/core/illustrations/empty-basket.svg?raw';
4
+ import torn from '@feitio/core/illustrations/torn-paper.svg?raw';
5
+
6
+ interface Props {
7
+ title: string;
8
+ text?: string;
9
+ /** "basket" for nothing yet, "torn" for an error. */
10
+ illustration?: 'basket' | 'torn' | 'none';
11
+ size?: 'compact';
12
+ }
13
+ const { title, text, illustration = 'basket', size } = Astro.props;
14
+ const art = illustration === 'basket' ? basket : illustration === 'torn' ? torn : '';
15
+ ---
16
+ <div class="feitio-empty" data-size={size}>{art && <Fragment set:html={art} />}<h3>{title}</h3>{text && <p>{text}</p>}<slot /></div>
@@ -0,0 +1,11 @@
1
+ ---
2
+ /** ErrorMessage: a field's error, under it: what happened and how to fix it, with the X. The id ties it to the control (aria-describedby). */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ id?: string;
7
+ sprite?: string;
8
+ }
9
+ const { id, sprite } = Astro.props;
10
+ ---
11
+ <span class="feitio-error-message" id={id}><Icon name="close" sprite={sprite} /><slot /></span>
@@ -0,0 +1,15 @@
1
+ ---
2
+ /**
3
+ * ErrorSummary: every error of the form, at the top, each a link to its field. It takes the focus
4
+ * when the form is sent (role="alert", tabindex="-1").
5
+ */
6
+ import Icon from './Icon.astro';
7
+
8
+ interface Props {
9
+ title: string;
10
+ errors: { text: string; href: string }[];
11
+ sprite?: string;
12
+ }
13
+ const { title, errors, sprite } = Astro.props;
14
+ ---
15
+ <div class="feitio-error-summary" role="alert" tabindex="-1"><h3><Icon name="close" sprite={sprite} />{title}</h3><ul>{errors.map((e) => <li><a href={e.href}>{e.text}</a></li>)}</ul></div>
@@ -0,0 +1,27 @@
1
+ ---
2
+ /** Example: the live example, with its code underneath, closed until asked. The slot is the live part. */
3
+ import CodeBlock from './CodeBlock.astro';
4
+ import Icon from './Icon.astro';
5
+
6
+ interface Props {
7
+ id: string;
8
+ title: string;
9
+ description: string;
10
+ code: string;
11
+ showLabel?: string;
12
+ copyLabel?: string;
13
+ copiedLabel?: string;
14
+ sprite?: string;
15
+ }
16
+ const {
17
+ id,
18
+ title,
19
+ description,
20
+ code,
21
+ showLabel = 'Mostrar código',
22
+ copyLabel,
23
+ copiedLabel,
24
+ sprite,
25
+ } = Astro.props;
26
+ ---
27
+ <div class="feitio-example"><div class="live"><slot /></div><div class="about"><h3 id={id}>{title}</h3><p>{description}</p><details><summary><Icon name="chevron-right" sprite={sprite} />{showLabel}</summary><CodeBlock code={code} copyLabel={copyLabel} copiedLabel={copiedLabel} /></details></div></div>
@@ -0,0 +1,22 @@
1
+ ---
2
+ /**
3
+ * Field: a field's label, hint, control and error, in that order. The control goes in the slot with
4
+ * the id given in `for`; the hint and the error are tied to it through aria-describedby by the control.
5
+ */
6
+ import Icon from './Icon.astro';
7
+
8
+ interface Props {
9
+ label: string;
10
+ for: string;
11
+ hint?: string;
12
+ error?: string;
13
+ sprite?: string;
14
+ }
15
+ const { label, for: target, hint, error, sprite } = Astro.props;
16
+ ---
17
+ <div class="feitio-field">
18
+ <label class="feitio-label" for={target}>{label}</label>
19
+ {hint && <span class="feitio-hint" id={`${target}-hint`}>{hint}</span>}
20
+ <slot />
21
+ {error && <span class="feitio-error-message" id={`${target}-error`}><Icon name="close" sprite={sprite} />{error}</span>}
22
+ </div>
@@ -0,0 +1,9 @@
1
+ ---
2
+ /** Fieldset: groups the fields that answer one question; the legend is that question. */
3
+ interface Props {
4
+ legend: string;
5
+ hint?: string;
6
+ }
7
+ const { legend, hint } = Astro.props;
8
+ ---
9
+ <fieldset class="feitio-fieldset"><legend class="feitio-label">{legend}</legend>{hint && <span class="feitio-hint">{hint}</span>}<slot /></fieldset>
@@ -0,0 +1,29 @@
1
+ ---
2
+ /**
3
+ * FilterField: filters the list below as the person types, and says how many are left. Off by
4
+ * default: debounce (ms) waits for the typing to stop, with a line filling under the field; async
5
+ * hands the search to the page (a feitio-filter event with the query and done()), turning a stroke
6
+ * inside the field until the results are in.
7
+ */
8
+ interface Props {
9
+ id: string;
10
+ /** The id of the list it filters; each item carries data-search. */
11
+ list: string;
12
+ label: string;
13
+ placeholder?: string;
14
+ debounce?: number;
15
+ async?: boolean;
16
+ /** What the count says while an asynchronous search runs. */
17
+ busyLabel?: string;
18
+ }
19
+ const {
20
+ id,
21
+ list,
22
+ label,
23
+ placeholder,
24
+ debounce,
25
+ async: isAsync,
26
+ busyLabel = 'Buscando…',
27
+ } = Astro.props;
28
+ ---
29
+ <div class="feitio-filter"><label class="feitio-visually-hidden" for={id}>{label}</label><span class="box"><input class="feitio-input" id={id} type="search" autocomplete="off" placeholder={placeholder} data-filter={list} data-debounce={debounce} data-async={isAsync ? '' : undefined} data-busy-label={isAsync ? busyLabel : undefined} /><span class="wait" aria-hidden="true"></span><svg class="busy" viewBox="0 0 24 24" aria-hidden="true"><path pathLength="1" d="M12 3.4C16.9 3.2 20.7 7.1 20.6 12C20.5 16.7 16.7 20.6 12 20.6C7.2 20.6 3.4 16.8 3.4 12.1C3.4 7.6 6.9 3.9 11.4 3.5" /></svg></span><span class="count" data-count={list} aria-live="polite"></span></div>
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** Footer: the brand with the years (since → this year, by itself), who made it, and the site-wide links. */
3
+ interface Props {
4
+ name: string;
5
+ since: number;
6
+ links: { text: string; href: string }[];
7
+ note?: string;
8
+ }
9
+ const { name, since, links, note } = Astro.props;
10
+ const year = new Date().getFullYear();
11
+ ---
12
+ <footer class="feitio-footer"><div class="inner"><span class="who"><slot name="logo" /><strong>{name}</strong><span>© <span data-since={since}>{since === year ? since : `${since}–${year}`}</span></span></span>{note && <span set:html={note} />}<ul>{links.map((l) => <li><a href={l.href}>{l.text}</a></li>)}</ul></div></footer>
package/src/Grid.astro ADDED
@@ -0,0 +1,11 @@
1
+ ---
2
+ /** Grid: columns that fit the width, each at least `min` wide, never past the screen. A missing item leaves its cell empty. */
3
+ interface Props {
4
+ gap?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
5
+ /** The narrowest a column may get, like "9rem". */
6
+ min?: string;
7
+ as?: 'div' | 'ul';
8
+ }
9
+ const { gap = 4, min, as: Tag = 'div' } = Astro.props;
10
+ ---
11
+ <Tag class="feitio-grid" data-gap={gap} style={min ? `--feitio-grid-min: ${min}` : undefined}><slot /></Tag>
@@ -0,0 +1,21 @@
1
+ ---
2
+ /**
3
+ * Header: a site's header: the brand, the big areas (the current one in placed paper) and the tools.
4
+ * It answers to the width it has, not the window's: narrow, the brand, the tools without wide-only
5
+ * and the Menu; wide, the areas and every tool. Tools go in the slot; mark with class="wide-only"
6
+ * the ones that move into the Menu when narrow.
7
+ */
8
+ import Icon from './Icon.astro';
9
+
10
+ interface Props {
11
+ brand: string;
12
+ brandHref: string;
13
+ areas: { text: string; href: string; current?: boolean }[];
14
+ label?: string;
15
+ /** The Menu button's words and the id of the Drawer it opens; without it, no Menu. */
16
+ menu?: { label: string; target: string };
17
+ sprite?: string;
18
+ }
19
+ const { brand, brandHref, areas, label, menu, sprite } = Astro.props;
20
+ ---
21
+ <div class="feitio-header-wrap"><header class="feitio-header"><a class="brand" href={brandHref}><slot name="logo" />{brand}</a><nav class="areas" aria-label={label}>{areas.map((a) => <a href={a.href} aria-current={a.current ? 'true' : undefined}>{a.text}</a>)}</nav><div class="tools"><slot />{menu && <button type="button" class="feitio-button menu" data-size="small" popovertarget={menu.target} aria-controls={menu.target}>{menu.label}<Icon name="menu" sprite={sprite} /></button>}</div></header></div>
@@ -0,0 +1,10 @@
1
+ ---
2
+ /** Heading: the title of a page or a section. The level is the outline (h1 to h4); the look comes from the base CSS. */
3
+ interface Props {
4
+ level?: 1 | 2 | 3 | 4;
5
+ id?: string;
6
+ }
7
+ const { level = 2, id } = Astro.props;
8
+ const Tag = `h${level}` as 'h1' | 'h2' | 'h3' | 'h4';
9
+ ---
10
+ <Tag id={id}><slot /></Tag>
package/src/Hint.astro ADDED
@@ -0,0 +1,8 @@
1
+ ---
2
+ /** Hint: a short help under a label; the control points to it with aria-describedby. */
3
+ interface Props {
4
+ id?: string;
5
+ }
6
+ const { id } = Astro.props;
7
+ ---
8
+ <span class="feitio-hint" id={id}><slot /></span>
package/src/Icon.astro ADDED
@@ -0,0 +1,14 @@
1
+ ---
2
+ /**
3
+ * Icon: a drawing from the sprite, next to a word. It is decoration (aria-hidden): the word, or the
4
+ * aria-label of an icon-only button, names it.
5
+ */
6
+ interface Props {
7
+ /** The icon's name in the sprite, like "check" or "search". */
8
+ name: string;
9
+ /** Where the sprite is served. */
10
+ sprite?: string;
11
+ }
12
+ const { name, sprite = '/feitio/icons/sprite.svg' } = Astro.props;
13
+ ---
14
+ <svg class="feitio-icon" aria-hidden="true"><use href={`${sprite}#feitio-${name}`} /></svg>
@@ -0,0 +1,10 @@
1
+ ---
2
+ /** Inline: puts the pieces side by side, wrapping to the next line when they do not fit; the gap holds between lines too. */
3
+ interface Props {
4
+ gap?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
5
+ justify?: 'between' | 'end';
6
+ as?: 'div' | 'ul';
7
+ }
8
+ const { gap = 3, justify, as: Tag = 'div' } = Astro.props;
9
+ ---
10
+ <Tag class="feitio-inline" data-gap={gap} data-justify={justify}><slot /></Tag>
package/src/Kbd.astro ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ /** Kbd: a key, written as on the keyboard. One key per Kbd; a combination puts a plus between them. */
3
+ ---
4
+ <kbd class="feitio-kbd"><slot /></kbd>
@@ -0,0 +1,8 @@
1
+ ---
2
+ /** Label: a control's name, tied to it by for (the control's id). */
3
+ interface Props {
4
+ for: string;
5
+ }
6
+ const { for: target } = Astro.props;
7
+ ---
8
+ <label class="feitio-label" for={target}><slot /></label>
package/src/Link.astro ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ /**
3
+ * Link: takes you to another page. newTab opens another tab, only when leaving would lose
4
+ * something, and always says so: the icon, and the words for screen readers.
5
+ */
6
+ import Icon from './Icon.astro';
7
+
8
+ interface Props {
9
+ href: string;
10
+ newTab?: boolean;
11
+ /** What screen readers hear after the text when it opens in a new tab. */
12
+ newTabLabel?: string;
13
+ sprite?: string;
14
+ }
15
+ const { href, newTab = false, newTabLabel = '(abre em nova aba)', sprite } = Astro.props;
16
+ ---
17
+ <a class="feitio-link" href={href} target={newTab ? '_blank' : undefined} rel={newTab ? 'noopener' : undefined}><slot />{newTab && <Icon name="new-tab" sprite={sprite} />}{newTab && <span class="feitio-visually-hidden"> {newTabLabel}</span>}</a>
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** LinkCard: a door to another area. The whole card is the link: a title with the arrow, and one sentence. */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ href: string;
7
+ title: string;
8
+ sprite?: string;
9
+ }
10
+ const { href, title, sprite } = Astro.props;
11
+ ---
12
+ <a class="feitio-link-card" href={href}><strong>{title}<Icon name="chevron-right" sprite={sprite} /></strong><span><slot /></span></a>
package/src/Menu.astro ADDED
@@ -0,0 +1,47 @@
1
+ ---
2
+ /**
3
+ * Menu: a button that opens a short list of links or actions under it, for when there are too many
4
+ * options to show side by side (the language, the extra actions of a row). The list is lifted paper
5
+ * and opens with the popover API: Esc and a click outside close it, the arrows move through it.
6
+ * Each item: { text, href?, current?, lang? }; with href it is a link, without it a button.
7
+ */
8
+ import Icon from './Icon.astro';
9
+
10
+ type Item = { text: string; href?: string; current?: boolean; lang?: string; hreflang?: string };
11
+ interface Props {
12
+ /** What the button says: the current choice, or what the menu is for. */
13
+ label: string;
14
+ /**
15
+ * Words screen readers hear after the label, when it is short ("PT" + ", idioma: Português"). They
16
+ * come after the visible text, never instead of it, so a voice command can still say "PT".
17
+ */
18
+ hint?: string;
19
+ items: Item[];
20
+ id: string;
21
+ size?: 'small';
22
+ sprite?: string;
23
+ }
24
+ const { label, hint, items, id, size, sprite } = Astro.props;
25
+ ---
26
+ <span class="feitio-menu">
27
+ <button type="button" class="feitio-button" data-size={size} popovertarget={`${id}-list`} aria-haspopup="true" aria-expanded="false">{label}{hint && <span class="feitio-visually-hidden">{hint}</span>}<Icon name="chevron-down" sprite={sprite} /></button>
28
+ <ul class="feitio-menu-list" id={`${id}-list`} popover>
29
+ {
30
+ items.map((item) =>
31
+ item.href ? (
32
+ <li><a href={item.href} lang={item.lang} hreflang={item.hreflang} aria-current={item.current ? 'true' : undefined}>{item.current && <Icon name="check" sprite={sprite} />}<span>{item.text}</span></a></li>
33
+ ) : (
34
+ <li><button type="button">{item.text}</button></li>
35
+ ),
36
+ )
37
+ }
38
+ </ul>
39
+ </span>
40
+ <script>
41
+ import { menus } from '@feitio/vanilla/menu/source';
42
+ const page = window as Window & { feitioMenus?: boolean };
43
+ if (!page.feitioMenus) {
44
+ page.feitioMenus = true;
45
+ menus(window);
46
+ }
47
+ </script>
package/src/Nav.astro ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ /** Nav: the product's places, in groups, with the current one marked (aria-current="page"). */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ groups: {
7
+ title?: string;
8
+ items: { text: string; href: string; current?: boolean; icon?: string }[];
9
+ }[];
10
+ label?: string;
11
+ sprite?: string;
12
+ }
13
+ const { groups, label, sprite } = Astro.props;
14
+ ---
15
+ <nav class="feitio-nav" aria-label={label}>{groups.map((g) => <div class="group">{g.title && <p class="group-title">{g.title}</p>}<ul>{g.items.map((i) => <li><a href={i.href} aria-current={i.current ? 'page' : undefined}>{i.icon && <Icon name={i.icon} sprite={sprite} />}{i.text}</a></li>)}</ul></div>)}</nav>
@@ -0,0 +1,61 @@
1
+ ---
2
+ /**
3
+ * Notice: what the person needs to know now. close adds the X; timeout (ms) makes it go away on its
4
+ * own, only for success and information, with the thread around the X coming undone. The behavior
5
+ * comes from @feitio/vanilla; window.feitioNotice.show(element) shows it after an action.
6
+ */
7
+ import Icon from './Icon.astro';
8
+
9
+ interface Props {
10
+ status?: 'ok' | 'warn' | 'error';
11
+ title: string;
12
+ close?: boolean;
13
+ timeout?: number;
14
+ id?: string;
15
+ hidden?: boolean;
16
+ /** "status" after an action, "alert" for an error after an action. */
17
+ role?: 'status' | 'alert';
18
+ closeLabel?: string;
19
+ sprite?: string;
20
+ }
21
+ const icons = { ok: 'check', warn: 'warn', error: 'close', info: 'info' } as const;
22
+ const {
23
+ status,
24
+ title,
25
+ close = false,
26
+ timeout,
27
+ id,
28
+ hidden,
29
+ role,
30
+ closeLabel = 'Fechar o aviso',
31
+ sprite,
32
+ } = Astro.props;
33
+ const ring =
34
+ 'M12 3.2C17.2 3 21 7 20.8 12.2C20.6 17.2 16.8 20.9 11.8 20.8C6.9 20.7 3.1 16.8 3.2 11.8C3.3 7 6.9 3.4 12.6 3.5';
35
+ const hasTools = close || Boolean(timeout);
36
+ const text = Astro.slots.has('default');
37
+ ---
38
+ <div class="feitio-notice" data-status={status} id={id} role={role} data-timeout={timeout} hidden={hidden}>
39
+ <Icon name={icons[status ?? 'info']} sprite={sprite} />
40
+ <strong>{title}</strong>
41
+ {text && <p><slot /></p>}
42
+ {
43
+ hasTools && (
44
+ <span class="tools">
45
+ <button type="button" class="close" aria-label={closeLabel}>
46
+ {timeout && (
47
+ <svg class="ring" viewBox="0 0 24 24" aria-hidden="true">
48
+ <path pathLength="100" d={ring} />
49
+ </svg>
50
+ )}
51
+ <Icon name="close" sprite={sprite} />
52
+ </button>
53
+ </span>
54
+ )
55
+ }
56
+ </div>
57
+ <script>
58
+ import { notices } from '@feitio/vanilla/notice/source';
59
+ const page = window as Window & { feitioNotice?: ReturnType<typeof notices> };
60
+ page.feitioNotice ??= notices(window);
61
+ </script>
@@ -0,0 +1,52 @@
1
+ ---
2
+ /**
3
+ * Pagination: splits a long list into pages. Previous and Next, the pages around the current one, a
4
+ * gap to the last, the count of what is shown and, optionally, how many per page.
5
+ */
6
+ import Icon from './Icon.astro';
7
+
8
+ interface Props {
9
+ label: string;
10
+ current: number;
11
+ total: number;
12
+ href: (page: number) => string;
13
+ count?: string;
14
+ perPage?: { label: string; options: number[]; current: number; href: (n: number) => string };
15
+ previousLabel?: string;
16
+ nextLabel?: string;
17
+ pageLabel?: (page: number) => string;
18
+ sprite?: string;
19
+ }
20
+ const {
21
+ label,
22
+ current,
23
+ total,
24
+ href,
25
+ count,
26
+ perPage,
27
+ previousLabel = 'Anterior',
28
+ nextLabel = 'Próxima',
29
+ pageLabel = (p: number) => `Página ${p}`,
30
+ sprite,
31
+ } = Astro.props;
32
+ const around = [current - 1, current, current + 1].filter((p) => p >= 1 && p <= total);
33
+ const pages = [...new Set([1, ...around, total])].sort((a, b) => a - b);
34
+ ---
35
+ <nav class="feitio-pagination" aria-label={label}>
36
+ <ul>
37
+ {current > 1 && <li><a class="step prev" href={href(current - 1)} rel="prev"><Icon name="chevron-right" sprite={sprite} />{previousLabel}</a></li>}
38
+ {pages.map((p, i) => (
39
+ <>
40
+ {i > 0 && p - (pages[i - 1] ?? p) > 1 && <li><span class="gap" aria-hidden="true">…</span></li>}
41
+ <li>{p === current ? <span aria-current="page">{p}</span> : <a href={href(p)} aria-label={pageLabel(p)}>{p}</a>}</li>
42
+ </>
43
+ ))}
44
+ {current < total && <li><a class="step" href={href(current + 1)} rel="next">{nextLabel}<Icon name="chevron-right" sprite={sprite} /></a></li>}
45
+ </ul>
46
+ {(count || perPage) && (
47
+ <div class="meta">
48
+ {count && <p class="count">{count}</p>}
49
+ {perPage && <div class="per-page" role="group" aria-label={perPage.label}><span>{perPage.label}</span>{perPage.options.map((n) => n === perPage.current ? <span aria-current="true">{n}</span> : <a href={perPage.href(n)}>{n}</a>)}</div>}
50
+ </div>
51
+ )}
52
+ </nav>
@@ -0,0 +1,17 @@
1
+ ---
2
+ /** Radios: one choice among a few, all in view, in a Fieldset whose legend is the question. */
3
+ interface Props {
4
+ legend: string;
5
+ name: string;
6
+ options: string[];
7
+ value?: string;
8
+ disabled?: boolean;
9
+ /** "inline" puts short options side by side. */
10
+ layout?: 'stack' | 'inline';
11
+ }
12
+ const { legend, name, options, value, disabled, layout = 'stack' } = Astro.props;
13
+ ---
14
+ <fieldset class="feitio-fieldset" disabled={disabled}>
15
+ <legend class="feitio-label">{legend}</legend>
16
+ <div class="feitio-choices" data-layout={layout === 'inline' ? 'inline' : undefined}>{options.map((o) => <label class="feitio-choice"><input type="radio" name={name} value={o} checked={o === value} />{o}</label>)}</div>
17
+ </fieldset>
@@ -0,0 +1,4 @@
1
+ ---
2
+ /** ScrollFade: the soft fade at the foot of a box that scrolls, saying there is more below. Put it last inside the scrolling box. */
3
+ ---
4
+ <span class="feitio-scroll-fade" aria-hidden="true"></span>
@@ -0,0 +1,25 @@
1
+ ---
2
+ /**
3
+ * Search: the product search, a field in the middle of the screen with the results one per line, and
4
+ * the keys at the foot. The page fills the results (with Pagefind or its own index).
5
+ */
6
+ import Icon from './Icon.astro';
7
+
8
+ interface Props {
9
+ id: string;
10
+ title: string;
11
+ placeholder?: string;
12
+ closeLabel?: string;
13
+ keys?: { open: string; choose: string; close: string };
14
+ sprite?: string;
15
+ }
16
+ const { id, title, placeholder, closeLabel = 'Fechar', keys, sprite } = Astro.props;
17
+ ---
18
+ <dialog class="feitio-dialog search-dialog" id={id} aria-labelledby={`${id}-t`}>
19
+ <form method="dialog">
20
+ <h2 id={`${id}-t`} class="feitio-visually-hidden">{title}</h2>
21
+ <div class="search-head"><Icon name="search" sprite={sprite} /><label class="feitio-visually-hidden" for={`${id}-field`}>{title}</label><input class="search-field" id={`${id}-field`} type="search" autocomplete="off" placeholder={placeholder} /><button type="submit" class="feitio-button close" data-size="small" value="close"><Icon name="close" sprite={sprite} />{closeLabel}</button></div>
22
+ <ul class="results"><slot /></ul>
23
+ {keys && <p class="foot"><span><kbd class="feitio-kbd">↵</kbd> {keys.open}</span><span><kbd class="feitio-kbd">↑</kbd><kbd class="feitio-kbd">↓</kbd> {keys.choose}</span><span><kbd class="feitio-kbd">Esc</kbd> {keys.close}</span></p>}
24
+ </form>
25
+ </dialog>
@@ -0,0 +1,11 @@
1
+ ---
2
+ /** SegmentedControl: one choice among a few neighboring options, always in view; the chosen one is in ink. */
3
+ interface Props {
4
+ label: string;
5
+ options: string[];
6
+ value?: string;
7
+ }
8
+ const { label, options, value } = Astro.props;
9
+ const current = value ?? options[0];
10
+ ---
11
+ <div class="feitio-segmented" role="group" aria-label={label}>{options.map((o) => <button type="button" aria-pressed={o === current ? 'true' : 'false'}>{o}</button>)}</div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ /** Select: one choice from a long list, with the hand-drawn arrow. */
3
+ import Icon from './Icon.astro';
4
+
5
+ interface Props {
6
+ id: string;
7
+ options: string[];
8
+ value?: string;
9
+ /** A first, empty option, like "Choose…". */
10
+ empty?: string;
11
+ disabled?: boolean;
12
+ invalid?: boolean;
13
+ describedBy?: string;
14
+ sprite?: string;
15
+ }
16
+ const { id, options, value, empty, disabled, invalid, describedBy, sprite } = Astro.props;
17
+ ---
18
+ <span class="feitio-select"><select id={id} disabled={disabled} aria-invalid={invalid ? 'true' : undefined} aria-describedby={describedBy}>{empty && <option value="">{empty}</option>}{options.map((o) => <option selected={o === value}>{o}</option>)}</select><Icon name="chevron-down" sprite={sprite} /></span>
@@ -0,0 +1,8 @@
1
+ ---
2
+ /** SkipLink: the first link of the page, to jump straight to the content. It only shows with the keyboard's focus. */
3
+ interface Props {
4
+ href?: string;
5
+ }
6
+ const { href = '#content' } = Astro.props;
7
+ ---
8
+ <a class="feitio-skip-link" href={href}><slot /></a>
@@ -0,0 +1,10 @@
1
+ ---
2
+ /** Stack: stacks the pieces, with the scale's space between them (gap 1 to 7). The children never bring their own margin. */
3
+ interface Props {
4
+ gap?: 1 | 2 | 3 | 4 | 5 | 6 | 7;
5
+ align?: 'start' | 'center';
6
+ as?: 'div' | 'section' | 'ul' | 'ol';
7
+ }
8
+ const { gap = 4, align, as: Tag = 'div' } = Astro.props;
9
+ ---
10
+ <Tag class="feitio-stack" data-gap={gap} data-align={align}><slot /></Tag>
@@ -0,0 +1,17 @@
1
+ ---
2
+ /**
3
+ * StatusOverlay: the feedback on the container itself. The slot is the container's content; state
4
+ * shows over it: loading (faded, a stroke turning), ok (a check drawn), error (an X drawn). Set it
5
+ * from the page with the status() of @feitio/vanilla.
6
+ */
7
+ interface Props {
8
+ state?: 'loading' | 'ok' | 'error';
9
+ label?: string;
10
+ as?: 'div' | 'form' | 'section';
11
+ }
12
+ const { state, label = '', as: Tag = 'div' } = Astro.props;
13
+ ---
14
+ <Tag class="feitio-status-host" data-state={state}>
15
+ <slot />
16
+ <div class="feitio-status" role="status"><svg viewBox="0 0 48 48" aria-hidden="true"><g class="loading"><path pathLength="1" d="M24 7 C34 6.5 41.5 14 41 24 C40.6 33 33 41 24 41.2" /><path pathLength="1" d="M25.5 41 C14.5 41.6 6.8 33.5 7.2 23.6 C7.6 14 14.6 7.4 23 6.4" /></g><g class="ok"><path pathLength="1" d="M13 25 L21 33.5" /><path pathLength="1" d="M19.5 34 L36 14.5" /></g><g class="error"><path pathLength="1" d="M15 15 L33.5 33" /><path pathLength="1" d="M33 14.5 L15.5 33.5" /></g></svg><span class="label">{label}</span></div>
17
+ </Tag>
@@ -0,0 +1,8 @@
1
+ ---
2
+ /** SummaryList: the details of a single thing, key and value, each row with an optional "Change" that edits only it. */
3
+ interface Props {
4
+ rows: { key: string; value: string; change?: { href: string; label: string } }[];
5
+ }
6
+ const { rows } = Astro.props;
7
+ ---
8
+ <dl class="feitio-summary-list">{rows.map((r) => <div><dt>{r.key}</dt><dd>{r.value}</dd>{r.change && <dd class="change"><a class="feitio-link" href={r.change.href}>{r.change.label}<span class="feitio-visually-hidden"> {r.key}</span></a></dd>}</div>)}</dl>
@@ -0,0 +1,9 @@
1
+ ---
2
+ /** Swatch: a sample of a Feitio color, with the ink line around it; it follows the theme by itself. */
3
+ interface Props {
4
+ /** A color role, like "accent" or "ok". */
5
+ role: string;
6
+ }
7
+ const { role } = Astro.props;
8
+ ---
9
+ <span class="feitio-swatch" style={`--swatch: var(--feitio-color-${role})`}></span>
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** Switch: turns a setting on and off, applied when the form is saved; the state is said in words too. */
3
+ interface Props {
4
+ label: string;
5
+ on?: boolean;
6
+ disabled?: boolean;
7
+ onLabel?: string;
8
+ offLabel?: string;
9
+ }
10
+ const { label, on = false, disabled, onLabel = 'Ligado', offLabel = 'Desligado' } = Astro.props;
11
+ ---
12
+ <label class="feitio-switch" data-on={onLabel} data-off={offLabel}><input type="checkbox" role="switch" checked={on} disabled={disabled} />{label}<span class="state">{on ? onLabel : offLabel}</span></label>
@@ -0,0 +1,26 @@
1
+ ---
2
+ /**
3
+ * Table: many things of the same kind, to compare. On a phone each row becomes a card, the column
4
+ * names beside each value. The caption names the scrolling region; actions go in the last column.
5
+ */
6
+ interface Props {
7
+ id: string;
8
+ caption?: string;
9
+ columns: { label: string; align?: 'end'; hidden?: boolean }[];
10
+ /** Each row: one cell per column, as HTML (a Tag, a link, a button). */
11
+ rows: string[][];
12
+ /** The first column is the row's title on a phone card. */
13
+ compact?: boolean;
14
+ }
15
+ const { id, caption, columns, rows, compact } = Astro.props;
16
+ const cap = `${id}-cap`;
17
+ ---
18
+ <div data-density={compact ? 'compact' : undefined} style="inline-size: 100%">
19
+ <div class="feitio-table-scroll" tabindex="0" role="region" aria-labelledby={caption ? cap : undefined} aria-label={caption ? undefined : columns[0]?.label}>
20
+ <table class="feitio-table">
21
+ {caption && <caption id={cap}>{caption}</caption>}
22
+ <thead><tr>{columns.map((c) => <th scope="col" data-align={c.align}>{c.hidden ? <span class="feitio-visually-hidden">{c.label}</span> : c.label}</th>)}</tr></thead>
23
+ <tbody>{rows.map((r) => <tr>{r.map((cell, i) => i === 0 ? <td class="title" set:html={cell} /> : columns[i]?.hidden ? <td class="actions" set:html={cell} /> : <td data-align={columns[i]?.align} data-label={columns[i]?.label} set:html={cell} />)}</tr>)}</tbody>
24
+ </table>
25
+ </div>
26
+ </div>
package/src/Tag.astro ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ /**
3
+ * Tag: an item's status, always with icon and word, never orange. small is for next to a name in a
4
+ * list or a menu ("soon").
5
+ */
6
+ import Icon from './Icon.astro';
7
+
8
+ interface Props {
9
+ status?: 'ok' | 'warn' | 'error';
10
+ size?: 'small';
11
+ sprite?: string;
12
+ }
13
+ const icons = { ok: 'check', warn: 'warn', error: 'close', info: 'info' } as const;
14
+ const { status, size, sprite } = Astro.props;
15
+ ---
16
+ <span class="feitio-tag" data-status={status} data-size={size}>{size !== 'small' && <Icon name={icons[status ?? 'info']} sprite={sprite} />}<slot /></span>
@@ -0,0 +1,17 @@
1
+ ---
2
+ /** TaskList: things to do or follow, each with its status (a Tag) and a link to it. */
3
+ import Tag from './Tag.astro';
4
+
5
+ interface Props {
6
+ items: {
7
+ name: string;
8
+ href: string;
9
+ detail?: string;
10
+ status?: 'ok' | 'warn' | 'error';
11
+ word: string;
12
+ }[];
13
+ sprite?: string;
14
+ }
15
+ const { items, sprite } = Astro.props;
16
+ ---
17
+ <ul class="feitio-task-list">{items.map((i) => <li><span class="name"><a class="feitio-link" href={i.href}>{i.name}</a>{i.detail && <small>{i.detail}</small>}</span><Tag status={i.status} sprite={sprite}>{i.word}</Tag></li>)}</ul>
package/src/Text.astro ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ /** Text: text for reading, at its measure, in the reading face. */
3
+ ---
4
+ <p class="feitio-text"><slot /></p>
@@ -0,0 +1,17 @@
1
+ ---
2
+ /**
3
+ * TextInput: one line of text. invalid marks it with the error (aria-invalid); with a hint or an error
4
+ * in the Field, describedBy names them.
5
+ */
6
+ import type { HTMLAttributes } from 'astro/types';
7
+
8
+ interface Props extends HTMLAttributes<'input'> {
9
+ id: string;
10
+ invalid?: boolean;
11
+ describedBy?: string;
12
+ /** The width it is meant for, in characters: 2, 4, 10, 20 or 40. Without it, the whole line. */
13
+ width?: 2 | 4 | 10 | 20 | 40;
14
+ }
15
+ const { invalid, describedBy, width, class: extra, ...rest } = Astro.props;
16
+ ---
17
+ <input class:list={['feitio-input', extra]} aria-invalid={invalid ? 'true' : undefined} aria-describedby={describedBy} data-width={width} {...rest} />
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** Textarea: several lines of text. It grows downward; the person can make it taller. */
3
+ import type { HTMLAttributes } from 'astro/types';
4
+
5
+ interface Props extends HTMLAttributes<'textarea'> {
6
+ id: string;
7
+ invalid?: boolean;
8
+ describedBy?: string;
9
+ }
10
+ const { invalid, describedBy, class: extra, ...rest } = Astro.props;
11
+ ---
12
+ <textarea class:list={['feitio-textarea', extra]} aria-invalid={invalid ? 'true' : undefined} aria-describedby={describedBy} {...rest}><slot /></textarea>
@@ -0,0 +1,26 @@
1
+ ---
2
+ /** TimeInput: hour and minute in a single box, in 24 hours or 12 with AM/PM. */
3
+ interface Props {
4
+ hour?: string;
5
+ minute?: string;
6
+ cycle?: '12' | '24';
7
+ period?: 'AM' | 'PM';
8
+ hourLabel?: string;
9
+ minuteLabel?: string;
10
+ periodLabel?: string;
11
+ invalid?: boolean;
12
+ disabled?: boolean;
13
+ }
14
+ const {
15
+ hour = '09',
16
+ minute = '00',
17
+ cycle = '24',
18
+ period = 'AM',
19
+ hourLabel = 'Hora',
20
+ minuteLabel = 'Minuto',
21
+ periodLabel = 'AM ou PM',
22
+ invalid,
23
+ disabled,
24
+ } = Astro.props;
25
+ ---
26
+ <div class="feitio-time-field" data-hour-cycle={cycle}><input class="seg" inputmode="numeric" maxlength="2" value={hour} aria-label={hourLabel} aria-invalid={invalid ? 'true' : undefined} disabled={disabled} /><span class="sep" aria-hidden="true">:</span><input class="seg" inputmode="numeric" maxlength="2" value={minute} aria-label={minuteLabel} disabled={disabled} />{cycle === '12' && <button type="button" class="period" aria-label={periodLabel} disabled={disabled}>{period}</button>}</div>
@@ -0,0 +1,4 @@
1
+ ---
2
+ /** VisuallyHidden: text for screen readers only, never for hiding something from everyone. */
3
+ ---
4
+ <span class="feitio-visually-hidden"><slot /></span>