Use WebComponents for buttons

This simplifies the loading and cleanup logic, while providing ubiquitous support across JS frameworks. Buttons can now be added in any way imaginable and still work without requiring additional initialization. The upside of this aproach is that it doesn't require a mutation observer nor a global click listener, and is supported by all browsers that also support passkeys.
This commit is contained in:
Stanko K.R.
2026-03-25 10:40:40 +01:00
parent 70c08877b7
commit 4fb1cddb4c
5 changed files with 223 additions and 268 deletions
+3 -3
View File
@@ -32,12 +32,12 @@
opacity: 0;
}
[data-passkey-errors] [data-passkey-error] {
:is(rails-passkey-creation-button, rails-passkey-sign-in-button) [data-passkey-error] {
display: none;
}
[data-passkey-errors][data-passkey-error-state="error"] [data-passkey-error="error"],
[data-passkey-errors][data-passkey-error-state="cancelled"] [data-passkey-error="cancelled"] {
:is(rails-passkey-creation-button, rails-passkey-sign-in-button)[data-passkey-error-state="error"] [data-passkey-error="error"],
:is(rails-passkey-creation-button, rails-passkey-sign-in-button)[data-passkey-error-state="cancelled"] [data-passkey-error="cancelled"] {
display: block;
}
}