From 81dfa091a04ea7a1fc3b4f31693238ff68c7c70d Mon Sep 17 00:00:00 2001 From: Futa IWATA Date: Mon, 4 Dec 2023 11:59:27 +0900 Subject: [PATCH 1/2] upgrade @astrojs/compiler --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index edbdd54dfb..d61e75f3bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,9 +53,9 @@ } }, "node_modules/@astrojs/compiler": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.1.0.tgz", - "integrity": "sha512-Mp+qrNhly+27bL/Zq8lGeUY+YrdoU0eDfIlAeGIPrzt0PnI/jGpvPUdCaugv4zbCrDkOUScFfcbeEiYumrdJnw==" + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@astrojs/compiler/-/compiler-2.3.2.tgz", + "integrity": "sha512-jkY7bCVxl27KeZsSxIZ+pqACe+g8VQUdTiSJRj/sXYdIaZlW3ZMq4qF2M17P/oDt3LBq0zLNwQr4Cb7fSpRGxQ==" }, "node_modules/@astrojs/internal-helpers": { "version": "0.2.0", From 9079b42ea4324fd6ad6c6ac10f48dafe20236b84 Mon Sep 17 00:00:00 2001 From: Futa IWATA Date: Mon, 4 Dec 2023 12:04:48 +0900 Subject: [PATCH 2/2] change attrbutes to better syntax --- .../pages/mfa/BaseTabSelectorButton.astro | 54 +++++++-------- .../pages/mfa/BaseTabSelectorGrid.astro | 42 +++++------- src/components/pages/mfa/BaseTabs.astro | 65 +++++++++---------- src/components/pages/mfa/tabs.ts | 2 +- 4 files changed, 70 insertions(+), 93 deletions(-) diff --git a/src/components/pages/mfa/BaseTabSelectorButton.astro b/src/components/pages/mfa/BaseTabSelectorButton.astro index 392253e7c6..c7a75ed997 100644 --- a/src/components/pages/mfa/BaseTabSelectorButton.astro +++ b/src/components/pages/mfa/BaseTabSelectorButton.astro @@ -1,5 +1,5 @@ --- -import type { Labels, Step } from "./tabs"; +import type { Labels, Selection, Step } from "./tabs"; interface Props { step: Step; @@ -8,50 +8,42 @@ interface Props { const { step, labels } = Astro.props; -const buttonProps = Object.fromEntries< - astroHTML.JSX.IntrinsicElements["button"] ->( - ["ms_auth", "auth_app", "phone", "fido"].map((selection) => [ - selection, - { - id: `button-${step}-${selection}`, - "aria-labelledby": `label-${step}-${selection}`, - value: selection, - }, - ]) -); +function buttonProps(selection: Selection) { + return { + id: `button-${step}-${selection}`, + "aria-labelledby": `label-${step}-${selection}`, + value: selection, + } satisfies astroHTML.JSX.ButtonHTMLAttributes; +} -const labelProps = Object.fromEntries( - ["ms_auth", "auth_app", "phone", "fido"].map((selection) => [ - selection, - { - id: `label-${step}-${selection}`, - for: `button-${step}-${selection}`, - }, - ]) -); +function labelProps(selection: Selection) { + return { + id: `label-${step}-${selection}`, + for: `button-${step}-${selection}`, + } satisfies astroHTML.JSX.LabelHTMLAttributes; +} ---
- - - { labels.fido && ( - ) @@ -69,7 +61,7 @@ const labelProps = Object.fromEntries( document.addEventListener("DOMContentLoaded", () => { document .querySelectorAll( - `button[id^="button"][aria-labelledby^="label"]` + `button[id^="button"][aria-labelledby^="label"]`, ) .forEach((button) => { button.addEventListener("click", onClick); diff --git a/src/components/pages/mfa/BaseTabSelectorGrid.astro b/src/components/pages/mfa/BaseTabSelectorGrid.astro index 2fbbbd965c..362b15d5b1 100644 --- a/src/components/pages/mfa/BaseTabSelectorGrid.astro +++ b/src/components/pages/mfa/BaseTabSelectorGrid.astro @@ -1,5 +1,5 @@ --- -import type { Labels } from "./tabs"; +import type { Labels, Selection, Step } from "./tabs"; import DemiRadioButton, { type Props as DemiRadioButtonProps, } from "./DemiRadioButton.astro"; @@ -10,22 +10,14 @@ interface Props { const { labels } = Astro.props; -const radioProps = Object.fromEntries( - ["first", "alt"].map((step) => [ - step, - Object.fromEntries( - ["ms_auth", "auth_app", "phone", "fido"].map((selection) => [ - selection, - { - id: `radio-${step}-${selection}`, - type: "radio", - name: `radio-${step}`, - value: selection, - }, - ]), - ), - ]), -); +function radioProps(step: Step, selection: Selection): DemiRadioButtonProps { + return { + id: `radio-${step}-${selection}`, + type: "radio", + name: `radio-${step}`, + value: selection, + }; +} ---
@@ -34,10 +26,10 @@ const radioProps = Object.fromEntries(

{labels.ms_auth}

- + - +
@@ -45,10 +37,10 @@ const radioProps = Object.fromEntries(

{labels.auth_app}

- + - +
@@ -56,10 +48,10 @@ const radioProps = Object.fromEntries(

{labels.phone}

- + - +
@@ -70,10 +62,10 @@ const radioProps = Object.fromEntries( <>

{labels.fido}

- + - +
diff --git a/src/components/pages/mfa/BaseTabs.astro b/src/components/pages/mfa/BaseTabs.astro index 57b5a74418..6303ce4282 100644 --- a/src/components/pages/mfa/BaseTabs.astro +++ b/src/components/pages/mfa/BaseTabs.astro @@ -1,6 +1,6 @@ --- import If from "@components/utils/If.astro"; -import type { Step, Labels } from "./tabs"; +import type { Step, Labels, Selection } from "./tabs"; interface Props { step: Step; @@ -9,49 +9,42 @@ interface Props { const { step, labels } = Astro.props; -// ` - - + + + - +
-
-
-
-
+
+
+
+
-
+
diff --git a/src/components/pages/mfa/tabs.ts b/src/components/pages/mfa/tabs.ts index fbd083154a..2e0f2cd495 100644 --- a/src/components/pages/mfa/tabs.ts +++ b/src/components/pages/mfa/tabs.ts @@ -1,6 +1,6 @@ export type Step = "first" | "alt"; export type Group = "intent" | Step; -export type Selection = "select" | "ms_auth" | "auth_app" | "phone" | "fido"; +export type Selection = "selector" | "ms_auth" | "auth_app" | "phone" | "fido"; export type Labels = Partial>; type Listener = (step: string, selection: string) => void;