Skip to content

Commit

Permalink
fix: add field functionality, FOR REAL final final final
Browse files Browse the repository at this point in the history
  • Loading branch information
doggodoge committed Oct 1, 2022
1 parent c1aaea1 commit 966c44a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
5 changes: 5 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"description": "A kinda cool fancy password input",
"icon": "Text",
"settings": [
{
"type": "field/string",
"key": "field",
"label": "Field"
},
{
"type": "number",
"key": "greenThreshold",
Expand Down
40 changes: 37 additions & 3 deletions src/Component.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
<script>
import {getContext} from "svelte"
import {getContext, onDestroy} from "svelte"
import FancyPassword from "./components/FancyPassword.svelte";
let secret;
export let field;
export let thiccness;
export let greenThreshold;
export let max;
export let poorMessage = '💩';
export let goodMessage = '';
const {styleable} = getContext("sdk")
const component = getContext("component")
const formContext = getContext("form");
const formStepContext = getContext("form-step");
const formApi = formContext?.formApi;
$: formStep = formStepContext ? $formStepContext ?? 1 : 1;
$: formField = formApi?.registerField(field, "text", "", false, null, formStep);
let fieldApi;
let fieldState;
$: unsubscribe = formField?.subscribe((value) => {
fieldState = value?.fieldState;
fieldApi = value?.fieldApi;
});
onDestroy(() => {
fieldApi?.deregister();
unsubscribe?.();
});
$: {
fieldApi?.setValue(secret);
}
</script>
<div use:styleable={$component.styles}>
<FancyPassword {thiccness} {greenThreshold} {max} {poorMessage} {goodMessage} />
<FancyPassword
bind:secret={secret}
{thiccness}
{greenThreshold}
{max}
{poorMessage}
{goodMessage}
/>
</div>
2 changes: 1 addition & 1 deletion src/components/FancyPassword.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import ComplexityBar from "./ComplexityBar.svelte";
let secret = '';
export let secret = '';
export let greenThreshold = 15;
export let max = 30;
Expand Down

0 comments on commit 966c44a

Please sign in to comment.