yamori

有給休暇計算を主目的とした簡易勤怠管理システム

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
---
// 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>
import { YamoriButton } from "../../../components/button/button.ts";

YamoriButton.register();

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>