|
2 | 2 | import { Card, Button, Label, Input } from 'flowbite-svelte'; |
3 | 3 |
|
4 | 4 | // 必要なコンポーネントだけを読み込んで、コンパイルを時間を短縮 |
5 | | - // モジュールは読み込めているのに以下のエラーが発生するため、やむなく@ts-ignoreを使用 |
6 | | - // Cannot find module 'flowbite-svelte-icons/xxx.svelte' or its corresponding type declarations.ts(2307) |
7 | | - // @ts-ignore |
| 5 | + import Checkbox from 'flowbite-svelte/Checkbox.svelte'; |
8 | 6 | import UserOutlineSolid from 'flowbite-svelte-icons/UserCircleSolid.svelte'; |
9 | | - // @ts-ignore |
10 | 7 | import EyeOutline from 'flowbite-svelte-icons/EyeOutline.svelte'; |
11 | | - // @ts-ignore |
12 | 8 | import EyeSlashOutline from 'flowbite-svelte-icons/EyeSlashOutline.svelte'; |
13 | 9 |
|
14 | 10 | import MessageHelperWrapper from '$lib/components/MessageHelperWrapper.svelte'; |
15 | 11 |
|
| 12 | + import { |
| 13 | + GUEST_USER_NAME, |
| 14 | + GUEST_USER_PASSWORD, |
| 15 | + // GUEST_USER_PASSWORD_FOR_LOCAL, |
| 16 | + LOGIN_LABEL, |
| 17 | + } from '$lib/constants/forms'; |
| 18 | +
|
16 | 19 | // FIXME: 構造体に相当するものを利用した方が拡張・修正がしやすくなるかもしれせまん |
17 | 20 | export let formProperties; |
18 | 21 | export let title: string; |
|
23 | 26 |
|
24 | 27 | const { form, message, errors, submitting, enhance } = formProperties; |
25 | 28 |
|
| 29 | + let isGuest: boolean = false; |
| 30 | +
|
| 31 | + $: if (isGuest) { |
| 32 | + $form.username = GUEST_USER_NAME; |
| 33 | +
|
| 34 | + // HACK: ローカル環境のパスワードは一時的に書き換えて対応している |
| 35 | + // |
| 36 | + // See: |
| 37 | + // src/lib/constants/forms.ts |
| 38 | + // $form.password = GUEST_USER_PASSWORD_FOR_LOCAL; |
| 39 | + $form.password = GUEST_USER_PASSWORD; |
| 40 | + } else { |
| 41 | + $form.username = ''; |
| 42 | + $form.password = ''; |
| 43 | + } |
| 44 | +
|
26 | 45 | const UNFOCUSABLE = -1; |
27 | 46 | let showPassword = false; |
28 | 47 | </script> |
29 | 48 |
|
30 | | -<!-- TODO: ゲストユーザ(お試し用)としてログインできるようにする --> |
31 | 49 | <!-- FIXME: コンポーネントが巨大になってきたと思われるので、分割しましょう --> |
32 | 50 | <!-- TODO: containerのデフォルト値を設定できないか? --> |
33 | 51 | <!-- See: --> |
|
40 | 58 |
|
41 | 59 | <MessageHelperWrapper message={$message} /> |
42 | 60 |
|
| 61 | + {#if title === LOGIN_LABEL} |
| 62 | + <Checkbox bind:checked={isGuest}>お試し用のアカウントを使う</Checkbox> |
| 63 | + {/if} |
| 64 | + |
43 | 65 | <!-- User name --> |
44 | 66 | <div class="space-y-2"> |
45 | 67 | <Label for="username-in-auth-form"> |
|
0 commit comments