diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..92f4cee --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,12 @@ +# https://taskfile.dev + +version: '3' + +vars: + GREETING: Hello, World! + +tasks: + templ: + cmds: + - templ generate + silent: true diff --git a/docs/pages/components/passkey.md b/docs/pages/components/passkey.md new file mode 100644 index 0000000..8f0499b --- /dev/null +++ b/docs/pages/components/passkey.md @@ -0,0 +1,22 @@ +--- +meta: + title: Passkey + description: +layout: component +--- + +```html:preview + +``` + +## Examples + +### First Example + +TODO + +### Second Example + +TODO + +[component-metadata:sl-passkey] diff --git a/src/components/passkey/passkey.component.ts b/src/components/passkey/passkey.component.ts new file mode 100644 index 0000000..05ab90e --- /dev/null +++ b/src/components/passkey/passkey.component.ts @@ -0,0 +1,43 @@ +import { property } from 'lit/decorators.js'; +import { html } from 'lit'; +import { LocalizeController } from '../../utilities/localize.js'; +import { watch } from '../../internal/watch.js'; +import componentStyles from '../../styles/component.styles.js'; +import ShoelaceElement from '../../internal/shoelace-element.js'; +import styles from './passkey.styles.js'; +import type { CSSResultGroup } from 'lit'; + +/** + * @summary Short summary of the component's intended use. + * @documentation https://shoelace.style/components/passkey + * @status experimental + * @since 2.0 + * + * @dependency sl-example + * + * @event sl-event-name - Emitted as an example. + * + * @slot - The default slot. + * @slot example - An example slot. + * + * @csspart base - The component's base wrapper. + * + * @cssproperty --example - An example CSS custom property. + */ +export default class SlPasskey extends ShoelaceElement { + static styles: CSSResultGroup = [componentStyles, styles]; + + private readonly localize = new LocalizeController(this); + + /** An example attribute. */ + @property() attr = 'example'; + + @watch('example') + handleExampleChange() { + // do something + } + + render() { + return html` `; + } +} diff --git a/src/components/passkey/passkey.styles.ts b/src/components/passkey/passkey.styles.ts new file mode 100644 index 0000000..940a155 --- /dev/null +++ b/src/components/passkey/passkey.styles.ts @@ -0,0 +1,7 @@ +import { css } from 'lit'; + +export default css` + :host { + display: block; + } +`; diff --git a/src/components/passkey/passkey.test.ts b/src/components/passkey/passkey.test.ts new file mode 100644 index 0000000..c16eabd --- /dev/null +++ b/src/components/passkey/passkey.test.ts @@ -0,0 +1,10 @@ +import '../../../dist/shoelace.js'; +import { expect, fixture, html } from '@open-wc/testing'; + +describe('', () => { + it('should render a component', async () => { + const el = await fixture(html` `); + + expect(el).to.exist; + }); +}); diff --git a/src/components/passkey/passkey.ts b/src/components/passkey/passkey.ts new file mode 100644 index 0000000..ce90269 --- /dev/null +++ b/src/components/passkey/passkey.ts @@ -0,0 +1,12 @@ +import SlPasskey from './passkey.component.js'; + +export * from './passkey.component.js'; +export default SlPasskey; + +SlPasskey.define('sl-passkey'); + +declare global { + interface HTMLElementTagNameMap { + 'sl-passkey': SlPasskey; + } +} diff --git a/src/shoelace.ts b/src/shoelace.ts index e6660e9..c2996d3 100644 --- a/src/shoelace.ts +++ b/src/shoelace.ts @@ -57,6 +57,7 @@ export { default as SlTooltip } from './components/tooltip/tooltip.js'; export { default as SlTree } from './components/tree/tree.js'; export { default as SlTreeItem } from './components/tree-item/tree-item.js'; export { default as SlVisuallyHidden } from './components/visually-hidden/visually-hidden.js'; +export { default as SlPasskey } from './components/passkey/passkey.js'; /* plop:component */ // Utilities diff --git a/ui/button/default.templ b/ui/button/default.templ deleted file mode 100644 index 04b164e..0000000 --- a/ui/button/default.templ +++ /dev/null @@ -1,15 +0,0 @@ -package button - -templ Primary(href string, text string) { -
-
- { text } -
-
-} - -templ Secondary(href string, text string) { -
-
{ text }
-
-} diff --git a/ui/button/default_templ.go b/ui/button/default_templ.go deleted file mode 100644 index 01d348e..0000000 --- a/ui/button/default_templ.go +++ /dev/null @@ -1,108 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package button - -//lint:file-ignore SA4006 This context is only used if a nested component is present. - -import "github.com/a-h/templ" -import templruntime "github.com/a-h/templ/runtime" - -func Primary(href string, text string) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var1 := templ.GetChildren(ctx) - if templ_7745c5c3_Var1 == nil { - templ_7745c5c3_Var1 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var3 string - templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(text) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/button/default.templ`, Line: 6, Col: 9} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func Secondary(href string, text string) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var4 := templ.GetChildren(ctx) - if templ_7745c5c3_Var4 == nil { - templ_7745c5c3_Var4 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var5 string - templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(text) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/button/default.templ`, Line: 13, Col: 175} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/ui/form/scripts.templ b/ui/form/scripts.templ deleted file mode 100644 index 40b9946..0000000 --- a/ui/form/scripts.templ +++ /dev/null @@ -1,175 +0,0 @@ -package form - -import "github.com/go-webauthn/webauthn/protocol" - -var credentialsHandle = templ.NewOnceHandle() - -// Base credentials script template -templ CredentialsScripts() { - @credentialsHandle.Once() { - - } -} - -script CreatePasskey(id string) { - function createPasskey(id) { - const passkey = document.getElementById(id); - passkey.value = window.crypto.getRandomValues(new Uint8Array(32)).join(''); - } -} - -// Template for creating credentials -templ CreateCredential(options *protocol.PublicKeyCredentialCreationOptions) { - @CredentialsScripts() - -} - -// Template for getting credentials -templ GetCredential(options *protocol.PublicKeyCredentialRequestOptions) { - @CredentialsScripts() - -} diff --git a/ui/layout/scripts.templ b/ui/layout/imports.templ similarity index 100% rename from ui/layout/scripts.templ rename to ui/layout/imports.templ diff --git a/ui/layout/scripts_templ.go b/ui/layout/imports_templ.go similarity index 97% rename from ui/layout/scripts_templ.go rename to ui/layout/imports_templ.go index 6f80d86..1d4cd52 100644 --- a/ui/layout/scripts_templ.go +++ b/ui/layout/imports_templ.go @@ -160,7 +160,7 @@ func Alpine() templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("alpinejs", "3.14.6", "dist/cdn.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 36, Col: 68} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 36, Col: 68} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -173,7 +173,7 @@ func Alpine() templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@alpinejs/focus", "3.14.6", "dist/cdn.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 37, Col: 75} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 37, Col: 75} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -234,7 +234,7 @@ func Dexie() templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie", "4.0.10", "dist/dexie.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 44, Col: 67} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 44, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -247,7 +247,7 @@ func Dexie() templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("dexie-export-import", "4.1.4", "dist/dexie-export-import.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 45, Col: 94} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 45, Col: 94} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -308,7 +308,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx.org", "1.9.12", "dist/htmx.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 52, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 52, Col: 69} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -321,7 +321,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-include-vals", "2.0.0", "include-vals.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 53, Col: 84} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 53, Col: 84} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -334,7 +334,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-path-params", "2.0.0", "path-params.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 54, Col: 82} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 54, Col: 82} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -347,7 +347,7 @@ func Htmx() templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("htmx-ext-alpine-morph", "2.0.0", "alpine-morph.min.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 55, Col: 84} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 55, Col: 84} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -396,7 +396,7 @@ func Nebula(version string) templ.Component { var templ_7745c5c3_Var20 string templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/light.css")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 64, Col: 71} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 64, Col: 71} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) if templ_7745c5c3_Err != nil { @@ -409,7 +409,7 @@ func Nebula(version string) templ.Component { var templ_7745c5c3_Var21 string templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/themes/dark.css")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 69, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 69, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { @@ -438,7 +438,7 @@ func Nebula(version string) templ.Component { var templ_7745c5c3_Var23 string templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(jsDelivrURL("@onsonr/nebula", version, "cdn/shoelace-autoloader.js")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/scripts.templ`, Line: 73, Col: 98} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/layout/imports.templ`, Line: 73, Col: 98} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil {