-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: styling improvements, removed thiccness
- Loading branch information
Showing
7 changed files
with
167 additions
and
98 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,67 @@ | ||
<script> | ||
import {getContext, onDestroy} from "svelte" | ||
import FancyPassword from "./components/FancyPassword.svelte"; | ||
import { getContext, onDestroy } from 'svelte'; | ||
import FancyPassword from './components/FancyPassword.svelte'; | ||
let secret; | ||
export let field; | ||
export let label; | ||
export let greenThreshold = 15; | ||
export let max = 30; | ||
export let poorMessage = '💩'; | ||
export let goodMessage = '✅'; | ||
export let field; | ||
const { styleable } = getContext('sdk'); | ||
const component = getContext('component'); | ||
const formContext = getContext('form'); | ||
const formStepContext = getContext('form-step'); | ||
export let thiccness; | ||
export let greenThreshold; | ||
export let max; | ||
export let poorMessage = '💩'; | ||
export let goodMessage = '✅'; | ||
let secret; | ||
const {styleable} = getContext("sdk") | ||
const component = getContext("component") | ||
const formContext = getContext("form"); | ||
const formStepContext = getContext("form-step"); | ||
const formApi = formContext?.formApi; | ||
$: formStep = $formStepContext ?? 1; | ||
$: formField = formApi?.registerField( | ||
field, | ||
'text', | ||
'', | ||
false, | ||
null, | ||
formStep | ||
); | ||
const formApi = formContext?.formApi; | ||
$: formStep = formStepContext ? $formStepContext ?? 1 : 1; | ||
$: formField = formApi?.registerField(field, "text", "", false, null, formStep); | ||
let fieldApi; | ||
let fieldApi; | ||
let fieldState; | ||
$: unsubscribe = formField?.subscribe(value => { | ||
fieldApi = value?.fieldApi; | ||
}); | ||
$: unsubscribe = formField?.subscribe((value) => { | ||
fieldState = value?.fieldState; | ||
fieldApi = value?.fieldApi; | ||
}); | ||
$: fieldApi?.setValue(secret); | ||
onDestroy(() => { | ||
fieldApi?.deregister(); | ||
unsubscribe?.(); | ||
}); | ||
$: { | ||
fieldApi?.setValue(secret); | ||
} | ||
onDestroy(() => { | ||
fieldApi?.deregister(); | ||
unsubscribe?.(); | ||
}); | ||
</script> | ||
<div use:styleable={$component.styles}> | ||
<FancyPassword | ||
bind:secret={secret} | ||
{thiccness} | ||
{greenThreshold} | ||
{max} | ||
{poorMessage} | ||
{goodMessage} | ||
/> | ||
bind:secret | ||
{label} | ||
{greenThreshold} | ||
{max} | ||
{poorMessage} | ||
{goodMessage} /> | ||
</div> | ||
<style> | ||
:root { | ||
--grey-3: #eeeeee; | ||
--grey-4: #e0e0e0; | ||
--grey-7: #757575; | ||
--red: #e26d69; | ||
--green: #84c991; | ||
--border-grey: 1px var(--grey-4) solid; | ||
--border-blue: 2px var(--blue) solid; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -1,27 +1,30 @@ | ||
<script> | ||
import clamp from "./utils/clamp"; | ||
import clamp from './utils/clamp'; | ||
export let secret = ''; | ||
export let greenThreshold = 15; | ||
export let max = 30; | ||
export let thiccness = 5; | ||
let color; | ||
let width; | ||
let styles; | ||
export let secret = ''; | ||
export let greenThreshold = 15; | ||
export let max = 30; | ||
export let thiccness = 5; | ||
let color; | ||
let width; | ||
$: { | ||
color = 'red'; | ||
if (secret.length > greenThreshold) { | ||
color = 'green'; | ||
} | ||
width = `${clamp(secret.length, 0, max) / max * 100}%`; | ||
$: { | ||
color = 'var(--red)'; | ||
if (secret.length > greenThreshold) { | ||
color = 'var(--green)'; | ||
} | ||
width = `${(clamp(secret.length, 0, max) / max) * 100}%`; | ||
} | ||
</script> | ||
|
||
<div class="container" style="background-color: {color}; height: {thiccness}px; width: {width};"></div> | ||
<div | ||
class="container" | ||
style="background-color: {color}; height: {thiccness}px; width: {width};" /> | ||
|
||
<style> | ||
.container { | ||
transition: 100ms; | ||
} | ||
.container { | ||
transition: 100ms; | ||
border-bottom-left-radius: 0.5em; | ||
border-bottom-right-radius: 0.5em; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -1,50 +1,81 @@ | ||
<script> | ||
import ComplexityBar from "./ComplexityBar.svelte"; | ||
import ComplexityBar from './ComplexityBar.svelte'; | ||
export let secret = ''; | ||
export let secret = ''; | ||
export let label = ''; | ||
export let greenThreshold = 15; | ||
export let max = 30; | ||
export let poorMessage = '💩'; | ||
export let goodMessage = '✅'; | ||
export let greenThreshold = 15; | ||
export let max = 30; | ||
export let thiccness = 5; | ||
export let poorMessage = '💩'; | ||
export let goodMessage = '✅'; | ||
$: notEmpty = secret.length > 0; | ||
</script> | ||
|
||
<div class="container"> | ||
<input type="password" class="password-input" bind:value={secret}> | ||
<ComplexityBar {secret} {greenThreshold} {max} {thiccness}/> | ||
<div class="input-container"> | ||
{#if label} | ||
<div class="label">{label}</div> | ||
{/if} | ||
<input | ||
type="password" | ||
class="password-input {notEmpty && 'password-input-not-empty'}" | ||
bind:value={secret} /> | ||
</div> | ||
|
||
<ComplexityBar {secret} {greenThreshold} {max} thiccness={5} /> | ||
|
||
<div class="error-message"> | ||
{#if secret === ''} | ||
<div /> | ||
{:else if secret.length > greenThreshold} | ||
<span style="color: green;">{goodMessage}</span> | ||
<span style="color: var(--green);">{goodMessage}</span> | ||
{:else} | ||
<span style="color: red;">{poorMessage}</span> | ||
<span style="color: var(--red);">{poorMessage}</span> | ||
{/if} | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 0.5rem; | ||
border-radius: 0.5rem; | ||
} | ||
.password-input { | ||
padding: 0.5rem; | ||
font-size: x-large; | ||
border-style: none; | ||
outline: none; | ||
transition: 100ms; | ||
} | ||
.password-input:focus { | ||
box-shadow: 0.2em 0.2em 0 rgba(0, 0, 0, 0.1); | ||
} | ||
.error-message { | ||
text-align: center; | ||
} | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.input-container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.2rem; | ||
} | ||
.label { | ||
font-size: small; | ||
color: var(--grey-7); | ||
} | ||
.password-input { | ||
padding: 0.5rem; | ||
font-size: x-large; | ||
color: var(--grey-9); | ||
border-style: none; | ||
outline: none; | ||
border-radius: 0.5em; | ||
transition: 100ms; | ||
border: var(--border-grey); | ||
} | ||
.password-input-not-empty { | ||
border-radius: 0; | ||
border-top-left-radius: 0.5em; | ||
border-top-right-radius: 0.5em; | ||
} | ||
.password-input:focus { | ||
border-bottom: var(--border-blue); | ||
} | ||
.error-message { | ||
text-align: center; | ||
font-size: x-small; | ||
padding-top: 0.5rem; | ||
} | ||
</style> |
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