Skip to content

Commit 6c3f5de

Browse files
committed
🎨 Extract component (#2020)
1 parent c80232d commit 6c3f5de

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script lang="ts">
2+
import { Heading, Button } from 'svelte-5-ui-lib';
3+
import HeadingOne from '$lib/components/HeadingOne.svelte';
4+
5+
interface Props {
6+
errorStatus: number | undefined;
7+
errorMessage: string | undefined;
8+
returnUrl: string;
9+
returnButtonLabel: string;
10+
}
11+
12+
let { errorStatus, errorMessage, returnUrl, returnButtonLabel }: Props = $props();
13+
</script>
14+
15+
<div
16+
class="container mx-auto md:w-4/5 lg:w-2/3 py-4 md:py-8 px-3 md:px-0 flex flex-col items-center"
17+
>
18+
<HeadingOne title="エラーが発生しました" />
19+
20+
<Heading tag="h2" class="text-3xl mb-3 text-gray-900 dark:text-gray-300">
21+
{errorStatus}
22+
</Heading>
23+
24+
<p class="dark:text-gray-300">{errorMessage}</p>
25+
26+
<div class="flex justify-center mt-6">
27+
<Button href={returnUrl} color="primary" class="px-6">
28+
{returnButtonLabel}
29+
</Button>
30+
</div>
31+
</div>

src/routes/workbooks/edit/[slug]/+page.svelte

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<script lang="ts">
22
import { superForm } from 'sveltekit-superforms/client';
3-
import { Heading, Button } from 'svelte-5-ui-lib';
43
5-
import HeadingOne from '$lib/components/HeadingOne.svelte';
64
import WorkBookForm from '$lib/components/WorkBook/WorkBookForm.svelte';
5+
import ErrorMessageAndReturnButton from '$lib/components/Messages/ErrorMessageAndReturnButton.svelte';
76
87
import type { WorkBookTasksBase } from '$lib/types/workbook';
98
import type { Task } from '$lib/types/task.js';
@@ -40,22 +39,10 @@
4039
submitButtonLabel="更新"
4140
/>
4241
{:else}
43-
<!-- TODO: コンポーネントとして抽出 -->
44-
<div
45-
class="container mx-auto md:w-4/5 lg:w-2/3 py-4 md:py-8 px-3 md:px-0 flex flex-col items-center"
46-
>
47-
<HeadingOne title="エラーが発生しました" />
48-
49-
<Heading tag="h2" class="text-3xl mb-3 text-gray-900 dark:text-gray-300">
50-
{data.status}
51-
</Heading>
52-
53-
<p class="dark:text-gray-300">{data.message}</p>
54-
55-
<div class="flex justify-center mt-6">
56-
<Button href={WORKBOOKS_PAGE} color="primary" class="px-6">
57-
{'問題集に戻る'}
58-
</Button>
59-
</div>
60-
</div>
42+
<ErrorMessageAndReturnButton
43+
errorStatus={data.status}
44+
errorMessage={data.message}
45+
returnUrl={WORKBOOKS_PAGE}
46+
returnButtonLabel="問題集に戻る"
47+
/>
6148
{/if}

0 commit comments

Comments
 (0)