aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/ScheduleTable.astro
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-07 13:07:55 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-07 13:07:55 +0900
commit0a0e4ee695b1d93084dc49d810297a3b50d8a5e0 (patch)
treec547c53f290691edf31c5f68818dcec96b4ea6a8 /src/components/ScheduleTable.astro
parentf14d27acf601f7d11fb76dcce430f2d2ba134d9d (diff)
events: 終了バッジを日付の次の行に置き、共有ボタンを共有メニューに
日付セルの「終了」を block にして改行して表示し、日付列が広がらない ようにした。共有ボタンのアイコンを指定の share-2 に変え、押すと 端末の共有メニュー(navigator.share)を開くようにした。非対応の ブラウザでは従来どおり文面をコピーする。
Diffstat (limited to 'src/components/ScheduleTable.astro')
-rw-r--r--src/components/ScheduleTable.astro18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/components/ScheduleTable.astro b/src/components/ScheduleTable.astro
index 2ce073b..1e23000 100644
--- a/src/components/ScheduleTable.astro
+++ b/src/components/ScheduleTable.astro
@@ -61,7 +61,7 @@ const dateHtml = (html: string) =>
const KINDS: { kind: string; label: string }[] = [
{ kind: 'x', label: 'Xでシェア' },
- { kind: 'copy', label: '共有用の文面をコピー' },
+ { kind: 'share', label: '共有する' },
];
function attachButtons() {
@@ -125,7 +125,19 @@ const dateHtml = (html: string) =>
return;
}
- // コピー:Instagram・Facebookなど、文面を直接渡せないSNSにも貼れる
+ // 共有:端末の共有メニュー(Instagram・メール・メモなど)を開く。
+ // 非対応のブラウザでは、文面をコピーして貼り付けられるようにする。
+ const share = (navigator as Navigator & { share?: (data: ShareData) => Promise<void> })
+ .share;
+ if (share) {
+ try {
+ await share.call(navigator, { text, url });
+ } catch {
+ // キャンセルされた場合は何もしない
+ }
+ return;
+ }
+
try {
await navigator.clipboard.writeText(`${text}\n${url}`);
const original = button.title;
@@ -138,7 +150,7 @@ const dateHtml = (html: string) =>
button.setAttribute('aria-label', original);
}, 1500);
} catch {
- window.alert('このブラウザではコピーできませんでした。文面を選択してコピーしてください。');
+ window.alert('このブラウザでは共有メニューもコピーも使えません。文面を選択してコピーしてください。');
}
});