-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into nm-vc-merge
- Loading branch information
Showing
23 changed files
with
14,423 additions
and
9,152 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<choose-pin></choose-pin> | ||
|
||
<script> | ||
import { LitComponent } from "./lit"; | ||
|
||
import { pinInput } from "$src/components/pinInput"; | ||
import { Chan } from "$src/utils/utils"; | ||
import { html } from "lit-html"; | ||
import { asyncReplace } from "lit-html/directives/async-replace.js"; | ||
|
||
class ChoosePin extends LitComponent { | ||
render() { | ||
const submittedPin = new Chan("N/A"); | ||
const pinInputHidden_ = pinInput({ | ||
verify: (pin: string) => ({ ok: true, value: pin }), | ||
onSubmit: (pin) => submittedPin.send(pin), | ||
secret: true, | ||
}); | ||
const pinInput_ = pinInput({ | ||
verify: (pin: string) => ({ ok: true, value: pin }), | ||
onSubmit: (pin) => submittedPin.send(pin), | ||
}); | ||
|
||
return html` <div | ||
class="c-card" | ||
style="max-width: 30em; margin: 40px auto;" | ||
> | ||
<h2 class="t-title t-title--sub">Regular & Secret PIN inputs</h2> | ||
<div class="c-input--stack">${pinInput_.template}</div> | ||
<div class="c-input--stack">${pinInputHidden_.template}</div> | ||
|
||
<output | ||
class="c-input c-input--readonly c-input--stack c-input--fullwidth" | ||
> | ||
Submitted: | ||
<strong class="t-strong">${asyncReplace(submittedPin)}</strong> | ||
</output> | ||
<div class="c-button-group"> | ||
<button | ||
@click=${() => pinInput_.submit()} | ||
class="c-button c-input--stack" | ||
> | ||
submit regular | ||
</button> | ||
<button | ||
@click=${() => pinInputHidden_.submit()} | ||
class="c-button c-input--stack" | ||
> | ||
submit hidden | ||
</button> | ||
</div> | ||
</div>`; | ||
} | ||
} | ||
|
||
customElements.define("choose-pin", ChoosePin); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<pick-anchor></pick-anchor> | ||
|
||
<script> | ||
import { asyncReplace } from "lit-html/directives/async-replace.js"; | ||
import { Ref, createRef, ref } from "lit-html/directives/ref.js"; | ||
import { Chan, NonEmptyArray, asNonEmptyArray } from "$src/utils/utils"; | ||
import { LitComponent } from "./lit"; | ||
import { withRef } from "$src/utils/lit-html"; | ||
import { TemplateResult, html } from "lit-html"; | ||
import { mkAnchorPicker } from "$src/components/anchorPicker"; | ||
|
||
class PickAnchor extends LitComponent { | ||
render() { | ||
const showSelected: Chan<string> = new Chan("Please pick anchor"); | ||
const savedAnchors: Ref<HTMLInputElement> = createRef(); | ||
const updateSavedAnchors: Ref<HTMLButtonElement> = createRef(); | ||
|
||
const mk = (anchors: NonEmptyArray<bigint>): TemplateResult => | ||
mkAnchorPicker({ | ||
savedAnchors: anchors, | ||
pick: (anchor: bigint) => showSelected.send(anchor.toString()), | ||
moreOptions: () => console.log("More options requested"), | ||
focus: false, | ||
}).template; | ||
|
||
const chan = new Chan<TemplateResult>( | ||
mk([BigInt(10055), BigInt(1669234)]) | ||
); | ||
const update = () => | ||
withRef(savedAnchors, (savedAnchors) => { | ||
const value = savedAnchors.value; | ||
if (value !== "") { | ||
const values = value.split(",").map((x) => BigInt(x)); | ||
const anchors = asNonEmptyArray(values); | ||
if (anchors !== undefined) { | ||
chan.send(mk(anchors)); | ||
} | ||
} | ||
}); | ||
|
||
return html` | ||
<div class="c-card" style="margin: 40px;"> | ||
<input class="c-input c-input--fullwidth" ${ref( | ||
savedAnchors | ||
)} placeholder="stored anchors: anchor1, anchor2, ..." ></input> | ||
<button class="c-button c-input--stack" ${ref( | ||
updateSavedAnchors | ||
)} @click="${update}">update</button> | ||
<div>${asyncReplace(chan)}</div> | ||
<div class="c-input c-input--stack c-input--readonly">${asyncReplace( | ||
showSelected | ||
)} </div> | ||
</div>`; | ||
} | ||
} | ||
customElements.define("pick-anchor", PickAnchor); | ||
</script> |
Oops, something went wrong.