@feitio/astro 0.2.1 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feitio/astro",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Feitio's components for Astro: the single source of each component's HTML.",
5
5
  "keywords": [
6
6
  "feitio",
@@ -34,8 +34,8 @@
34
34
  "astro": ">=7"
35
35
  },
36
36
  "dependencies": {
37
- "@feitio/core": "0.2.1",
38
- "@feitio/vanilla": "0.2.1"
37
+ "@feitio/core": "0.3.0",
38
+ "@feitio/vanilla": "0.3.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "astro": "7.4.11"
@@ -0,0 +1,51 @@
1
+ ---
2
+ /**
3
+ * Kanban: work in columns, one per stage, and cards that go from one to the next. Wide, a file of
4
+ * folders, each with its tab; on a phone, a row of stage tabs and one stage at a time. The cards of a
5
+ * column go in the slot named after it (KanbanCard). A column may offer a new-card button (create);
6
+ * the board then sends feitio-kanban-create with what was written, and the page adds the card. Every
7
+ * move, by dragging or by the card's button, sends feitio-kanban-move (cancelable) first.
8
+ */
9
+ import Icon from './Icon.astro';
10
+
11
+ type Column = {
12
+ id: string;
13
+ title: string;
14
+ /** What an empty column says, inviting to act. */
15
+ empty?: string;
16
+ /** The new-card button: its words, the field's label, and the words of Save and Cancel. */
17
+ create?: { label: string; field: string; save?: string; cancel?: string };
18
+ };
19
+ interface Props {
20
+ id: string;
21
+ /** The board's name, for screen readers. */
22
+ label: string;
23
+ columns: Column[];
24
+ /** The stage a phone shows first; the first column when left out. */
25
+ current?: string;
26
+ /** The title of the move list. */
27
+ moveLabel?: string;
28
+ sprite?: string;
29
+ }
30
+ const { id, label, columns, current, moveLabel = 'Mover para', sprite } = Astro.props;
31
+ const shown = current ?? columns[0]?.id;
32
+ const rendered = await Promise.all(
33
+ columns.map(async (c) => {
34
+ const html = Astro.slots.has(c.id) ? await Astro.slots.render(c.id) : '';
35
+ return { ...c, html, n: (html.match(/class="feitio-kanban-card"/g) ?? []).length };
36
+ }),
37
+ );
38
+ ---
39
+ <div class="feitio-kanban" id={id} data-move-label={moveLabel}>
40
+ <div class="feitio-kanban-scroll tabs-scroll"><span class="edge start" aria-hidden="true"></span><div class="tabs" role="group" aria-label={label}>{rendered.map((c) => <button type="button" data-col={c.id} aria-pressed={c.id === shown ? 'true' : 'false'} data-has={c.n ? '' : undefined}>{c.title} <span class="n">{c.n}</span></button>)}</div><span class="edge end" aria-hidden="true"></span></div>
41
+ <div class="feitio-kanban-scroll"><span class="edge start" aria-hidden="true"></span><div class="cols">{rendered.map((c) => <div class="col" role="group" data-col={c.id} aria-labelledby={`${id}-${c.id}`} data-current={c.id === shown ? '' : undefined} data-empty={c.n ? undefined : ''}><div class="col-head"><h3 id={`${id}-${c.id}`}>{c.title}</h3><span class="n">{c.n}</span></div>{c.empty && <p class="empty" hidden={c.n > 0}>{c.empty}</p>}<Fragment set:html={c.html} />{c.create && <button type="button" class="add" data-field={c.create.field} data-save={c.create.save ?? 'Salvar'} data-cancel={c.create.cancel ?? 'Cancelar'}><Icon name="plus" sprite={sprite} />{c.create.label}</button>}</div>)}</div><span class="edge end" aria-hidden="true"></span></div>
42
+ <div class="minimap" aria-hidden="true" hidden></div>
43
+ </div>
44
+ <script>
45
+ import { kanbans } from '@feitio/vanilla/kanban/source';
46
+ const page = window as Window & { feitioKanban?: boolean };
47
+ if (!page.feitioKanban) {
48
+ page.feitioKanban = true;
49
+ kanbans(window);
50
+ }
51
+ </script>
@@ -0,0 +1,23 @@
1
+ ---
2
+ /**
3
+ * KanbanCard: one card of a Kanban column, lifted paper held by a strip of tape. Its content is free
4
+ * (a title, a picture, a Tag, a list). to lists the columns it may go to; with none, it stays put and
5
+ * says so. The move button opens the list of those columns, for the phone and the keyboard.
6
+ */
7
+ import Icon from './Icon.astro';
8
+
9
+ interface Props {
10
+ id: string;
11
+ /** The card's name, for screen readers (and the move button's label). */
12
+ name: string;
13
+ /** The columns it may go to, by id. */
14
+ to?: string[];
15
+ /** The move button's word; screen readers hear it with the card's name. */
16
+ moveLabel?: string;
17
+ /** What a card that cannot move says. */
18
+ fixedLabel?: string;
19
+ sprite?: string;
20
+ }
21
+ const { id, name, to = [], moveLabel = 'Mover', fixedLabel = 'fixo', sprite } = Astro.props;
22
+ ---
23
+ <article class="feitio-kanban-card" data-id={id} data-to={to.length ? to.join(' ') : undefined} aria-label={name}><slot />{to.length ? <button type="button" class="feitio-button move" data-size="small" aria-label={`${moveLabel}: ${name}`} aria-haspopup="true" aria-expanded="false">{moveLabel}<Icon name="chevron-down" sprite={sprite} /></button> : <span class="fixed">{fixedLabel}</span>}</article>