-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
---
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com>
// SPDX-License-Identifier: AGPL-3.0-only
import DocsLayout from "../../layouts/DocsLayout.astro";
import Document from "../../components/Document.astro";
import Preview from "../../components/Preview.astro";
import ThemeMatrixPreview from "../../components/ThemeMatrixPreview.astro";
---
<script>
const buttons = document.querySelectorAll("yamori-button");
buttons.forEach((button) => {
button.addEventListener("click", (event) => {
console.log(event);
});
});
</script>
<DocsLayout title="Button">
<Document>
<p>
ユーザがクリックやタップをすることでアクションを実行する UI です。
以下の操作を「押す」という操作とみなします。
</p>
<ul>
<li>クリック (マウス)</li>
<li>タップ (タッチインターフェイス)</li>
<li>フォーカスが当たっている状態で <kbd>Space</kbd> キー (キーボード)</li>
</ul>
<ThemeMatrixPreview>
<yamori-button>ボタン</yamori-button>
</ThemeMatrixPreview>
<h2>Inline / Block</h2>
<p>
ボタンはデフォルトでブロックレベル要素となっています。
<code>inline</code> 属性を指定することでインラインになります。
</p>
<Preview title="inline">
<yamori-button inline="">ボタン</yamori-button>
</Preview>
<Preview title="block (デフォルト)">
<yamori-button>Button</yamori-button>
</Preview>
<h2>Disabled</h2>
<p>
<code>yamori-button</code> は form-associated custom element であるため、
<code>disabled</code> 属性がそのまま使えます。
</p>
<ThemeMatrixPreview>
<yamori-button disabled>ボタン</yamori-button>
</ThemeMatrixPreview>
<p>
ただ、<code>disabled</code>
属性はフォーカスができないというアクセシビリティにおける大きな欠陥仕様があります。
<code>aria-disabled</code> 属性を可能な限り使いましょう。
</p>
<Preview title="aria-disabled">
<yamori-button aria-disabled="true">ボタン</yamori-button>
</Preview>
<h2>Pending</h2>
<p>
ボタンの押下に伴うアクションの実行中やアクションに必要な準備中でボタンが押せない場合は、
<code>pending</code> 属性を指定することで読込中表示にすることができます。
</p>
<ThemeMatrixPreview>
<yamori-button pending="">ボタン</yamori-button>
</ThemeMatrixPreview>
<p>
ユーザインタラクションに起因する読込中表示の場合は明確ですが、そうでない場合は「どうして読込中表示なのか」「何を読み込んでいるのか」が分かりづらくなりがちです。可能な限り
<code>title</code> 属性や補助テキストを使って状況を説明しましょう。
</p>
</Document>
</DocsLayout>