-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(login-page): add password action
- Loading branch information
Showing
4 changed files
with
219 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<script setup lang="ts"> | ||
import { useD } from '../composables/D' | ||
import { useV } from '../composables/V' | ||
import { email, maxLength, required } from '../validation/rules' | ||
import SCard from './SCard.vue' | ||
import SCardBlock from './SCardBlock.vue' | ||
import SContent from './SContent.vue' | ||
import SControl from './SControl.vue' | ||
import SControlButton from './SControlButton.vue' | ||
import SControlRight from './SControlRight.vue' | ||
import SDoc from './SDoc.vue' | ||
import SInputText from './SInputText.vue' | ||
defineProps<{ | ||
loading: boolean | ||
}>() | ||
const emit = defineEmits<{ | ||
cancel: [] | ||
submit: [email: string, password: string] | ||
}>() | ||
const { data } = useD({ | ||
email: null as string | null, | ||
password: null as string | null | ||
}) | ||
const { validation, validateAndNotify } = useV(data, { | ||
email: { | ||
required: required(), | ||
maxLength: maxLength(255), | ||
email: email() | ||
}, | ||
password: { | ||
required: required(), | ||
maxLength: maxLength(255) | ||
} | ||
}) | ||
async function onSubmit() { | ||
if (await validateAndNotify()) { | ||
emit('submit', data.value.email!, data.value.password!) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<SCard size="small"> | ||
<SCardBlock class="s-p-24"> | ||
<SDoc> | ||
<SContent> | ||
<h2>Sign in to account</h2> | ||
</SContent> | ||
<SInputText | ||
name="email" | ||
type="email" | ||
label="Email" | ||
placeholder="[email protected]" | ||
v-model="data.email" | ||
:validation="validation.email" | ||
/> | ||
<SInputText | ||
name="password" | ||
type="password" | ||
label="Password" | ||
placeholder="Password" | ||
v-model="data.password" | ||
:validation="validation.password" | ||
/> | ||
</SDoc> | ||
</SCardBlock> | ||
<SCardBlock size="xlarge" class="s-px-24"> | ||
<SControl> | ||
<SControlRight> | ||
<SControlButton | ||
label="Cancel" | ||
:disabled="loading" | ||
@click="$emit('cancel')" | ||
/> | ||
<SControlButton | ||
mode="info" | ||
label="Sign in" | ||
:loading="loading" | ||
@click="onSubmit" | ||
/> | ||
</SControlRight> | ||
</SControl> | ||
</SCardBlock> | ||
</SCard> | ||
</template> |
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,59 +1,37 @@ | ||
<script setup lang="ts"> | ||
import SLoginPage from 'sefirot/components/SLoginPage.vue' | ||
import SLoginPage, { type Action } from 'sefirot/components/SLoginPage.vue' | ||
import { sleep } from 'sefirot/support/Time' | ||
const title = 'Components / SLoginPage / 01. Playground' | ||
const docs = '/components/login-page' | ||
function state() { | ||
const state: InstanceType<typeof SLoginPage>['$props'] = { | ||
cover: 'https://images.unsplash.com/photo-1526783166374-1239abde1c20?q=80&w=3008&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D', | ||
coverTitle: { | ||
text: 'Golden Gate Bridge', | ||
link: 'https://unsplash.com/photos/bottom-view-of-orange-building-LjE32XEW01g' | ||
}, | ||
coverPhotographer: { | ||
text: 'Keegan Houser', | ||
link: 'https://unsplash.com/@khouser01' | ||
}, | ||
actions: [ | ||
{ type: 'google', onClick: async () => {} } | ||
] | ||
} | ||
const cover = 'https://images.unsplash.com/photo-1526783166374-1239abde1c20?q=80&w=3008&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D' | ||
return state | ||
const coverTitle = { | ||
text: 'Golden Gate Bridge', | ||
link: 'https://unsplash.com/photos/bottom-view-of-orange-building-LjE32XEW01g' | ||
} | ||
const coverPhotographer = { | ||
text: 'Keegan Houser', | ||
link: 'https://unsplash.com/@khouser01' | ||
} | ||
const actions: Action[] = [ | ||
{ type: 'password', onSubmit: async () => { await sleep(1000) } }, | ||
{ type: 'google', onClick: async () => {} } | ||
] | ||
</script> | ||
|
||
<template> | ||
<Story :title="title" :init-state="state" source="Not available" auto-props-disabled> | ||
<template #controls="{ state }"> | ||
<HstText | ||
title="cover" | ||
v-model="state.cover" | ||
/> | ||
<HstJson | ||
title="coverTitle" | ||
v-model="state.coverTitle" | ||
<Story :title="title" source="Not available" auto-props-disabled> | ||
<Board :title="title" :docs="docs"> | ||
<SLoginPage | ||
:cover="cover" | ||
:cover-title="coverTitle" | ||
:cover-photographer="coverPhotographer" | ||
:actions="actions" | ||
/> | ||
<HstJson | ||
title="coverPhotographer" | ||
v-model="state.coverPhotographer" | ||
/> | ||
<HstJson | ||
title="actions" | ||
v-model="state.actions" | ||
/> | ||
</template> | ||
|
||
<template #default="{ state }"> | ||
<Board :title="title" :docs="docs"> | ||
<SLoginPage | ||
:cover="state.cover" | ||
:cover-title="state.coverTitle" | ||
:cover-photographer="state.coverPhotographer" | ||
:actions="state.actions" | ||
/> | ||
</Board> | ||
</template> | ||
</Board> | ||
</Story> | ||
</template> |