From 128deaa9d301fa1baf4aefd1217976b77df3d0dc Mon Sep 17 00:00:00 2001 From: Sakura Knoll Date: Sun, 2 Jan 2022 16:58:20 +0900 Subject: [PATCH] Extract page compoentns from stigmata show page --- src/components/pages/SingleStigmataPage.tsx | 121 ++++++++++ src/components/pages/StigmataSetPage.tsx | 107 +++++++++ src/pages/honkai3rd/stigmata/[stigmataId].tsx | 219 +----------------- 3 files changed, 237 insertions(+), 210 deletions(-) create mode 100644 src/components/pages/SingleStigmataPage.tsx create mode 100644 src/components/pages/StigmataSetPage.tsx diff --git a/src/components/pages/SingleStigmataPage.tsx b/src/components/pages/SingleStigmataPage.tsx new file mode 100644 index 00000000..39588c3c --- /dev/null +++ b/src/components/pages/SingleStigmataPage.tsx @@ -0,0 +1,121 @@ +/** @jsxImportSource theme-ui */ +import { StigmataData, StigmataSet } from '../../lib/honkai3rd/stigmata' +import Image from 'next/image' +import { Box, Heading, Text, Paragraph, Card, Flex } from '@theme-ui/components' +import PageLink from '../../components/atoms/PageLink' +import StigmataCard from '../../components/molecules/StigmataCard' +import Breadcrumb from '../../components/organisms/Breadcrumb' +import Honkai3rdNavigator from '../../components/organisms/Honkai3rdNavigator' +import { capitalize } from '../../lib/string' + +export interface SingleStigmataPageProps { + type: 'single' + stigmataData: StigmataData + stigmataSetList: StigmataData[] + stigmataSet?: StigmataSet +} + +const SingleStigmataPage = ({ + stigmataData, + stigmataSet, + stigmataSetList, +}: SingleStigmataPageProps) => { + return ( + + + + + + {stigmataData.name} + + + {stigmataData.name} + + + + + {capitalize(stigmataData.type)} + + + {'⭐'.repeat(stigmataData.rarity)} + + + HP : {stigmataData.hp} / ATK : {stigmataData.atk} / DEF :{' '} + {stigmataData.def} / CRT : {stigmataData.crt} + + {stigmataData.skill.description} + + + {stigmataSet != null && ( + + + + {stigmataSet.name} + +
+ + Set + +
+ + {stigmataSetList.map((stigmataSetItem) => { + return ( + + ) + })} + + + + {stigmataSet.twoSetSkill.name} + + + {stigmataSet.twoSetSkill.description} + + + {stigmataSet.threeSetSkill.name} + + + {stigmataSet.threeSetSkill.description} + +
+ )} +
+
+ ) +} + +export default SingleStigmataPage diff --git a/src/components/pages/StigmataSetPage.tsx b/src/components/pages/StigmataSetPage.tsx new file mode 100644 index 00000000..c848b18c --- /dev/null +++ b/src/components/pages/StigmataSetPage.tsx @@ -0,0 +1,107 @@ +/** @jsxImportSource theme-ui */ +import { Box, Heading, Text, Paragraph, Card, Flex } from '@theme-ui/components' +import React from 'react' +import PageLink from '../../components/atoms/PageLink' +import StigmataCard from '../../components/molecules/StigmataCard' +import Breadcrumb from '../../components/organisms/Breadcrumb' +import Honkai3rdNavigator from '../../components/organisms/Honkai3rdNavigator' +import { StigmataData, StigmataSet } from '../../lib/honkai3rd/stigmata' +import { capitalize } from '../../lib/string' + +export interface StigmataSetProps { + type: 'set' + stigmataSet: StigmataSet + stigmataSetList: StigmataData[] +} + +const StigmataSetPage = ({ + stigmataSet, + stigmataSetList, +}: StigmataSetProps) => { + return ( + + + + + + + {stigmataSet.name} Set + + + + {stigmataSetList.map((stigmataSetItem) => { + return ( + + ) + })} + + {stigmataSetList.map((stigmataSetItem) => { + return ( + + + + {stigmataSetItem.name} + + +
+ + {capitalize(stigmataSetItem.type)} + +
+ + HP : {stigmataSetItem.hp} / ATK : {stigmataSetItem.atk} / DEF + : {stigmataSetItem.def} / CRT : {stigmataSetItem.crt} + + + {stigmataSetItem.skill.description} + +
+ ) + })} +
+ + + + {stigmataSet.twoSetSkill.name} + + + {stigmataSet.twoSetSkill.description} + + + {stigmataSet.threeSetSkill.name} + + + {stigmataSet.threeSetSkill.description} + + +
+
+ ) +} + +export default StigmataSetPage diff --git a/src/pages/honkai3rd/stigmata/[stigmataId].tsx b/src/pages/honkai3rd/stigmata/[stigmataId].tsx index d8ca2572..658ffc41 100644 --- a/src/pages/honkai3rd/stigmata/[stigmataId].tsx +++ b/src/pages/honkai3rd/stigmata/[stigmataId].tsx @@ -1,13 +1,11 @@ -import { Box, Heading, Text, Paragraph, Card, Flex } from '@theme-ui/components' +/** @jsxImportSource theme-ui */ import { NextPageContext } from 'next' -import Image from 'next/image' -import React from 'react' -import PageLink from '../../../components/atoms/PageLink' -import StigmataCard from '../../../components/molecules/StigmataCard' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator' -import { StigmataData, StigmataSet } from '../../../lib/honkai3rd/stigmata' -import { capitalize } from '../../../lib/string' +import SingleStigmataPage, { + SingleStigmataPageProps, +} from '../../../components/pages/SingleStigmataPage' +import StigmataSetPage, { + StigmataSetProps, +} from '../../../components/pages/StigmataSetPage' import { listStigmata, getStigmataById, @@ -16,213 +14,14 @@ import { listStigmataSet, } from '../../../server/data/honkai3rd/stigmata' -interface SingleStigmataPageProps { - type: 'single' - stigmataData: StigmataData - stigmataSetList: StigmataData[] - stigmataSet?: StigmataSet -} - -interface StigmataSetProps { - type: 'set' - stigmataSet: StigmataSet - stigmataSetList: StigmataData[] -} - type StigmataShowPageProps = SingleStigmataPageProps | StigmataSetProps const StigmataListPage = (props: StigmataShowPageProps) => { if (props.type === 'single') { - const { stigmataData, stigmataSet, stigmataSetList } = props - - return ( - - - - - - {stigmataData.name} - - - {stigmataData.name} - - - - - {capitalize(stigmataData.type)} - - - {'⭐'.repeat(stigmataData.rarity)} - - - HP : {stigmataData.hp} / ATK : {stigmataData.atk} / DEF :{' '} - {stigmataData.def} / CRT : {stigmataData.crt} - - - - - - Skill - {stigmataData.skill.name} - - {stigmataData.skill.description} - - - {stigmataSet != null && ( - - - - {stigmataSet.name} - -
- - Set - -
- - {stigmataSetList.map((stigmataSetItem) => { - return ( - - ) - })} - - - - {stigmataSet.twoSetSkill.name} - - - {stigmataSet.twoSetSkill.description} - - - {stigmataSet.threeSetSkill.name} - - - {stigmataSet.threeSetSkill.description} - -
- )} -
-
- ) + return } - const { stigmataSet, stigmataSetList } = props - return ( - - - - - - - {stigmataSet.name} Set - - - - {stigmataSetList.map((stigmataSetItem) => { - return ( - - ) - })} - - {stigmataSetList.map((stigmataSetItem) => { - return ( - - - - {stigmataSetItem.name} - - -
- - {capitalize(stigmataSetItem.type)} - -
- - HP : {stigmataSetItem.hp} / ATK : {stigmataSetItem.atk} / DEF - : {stigmataSetItem.def} / CRT : {stigmataSetItem.crt} - - - {stigmataSetItem.skill.description} - -
- ) - })} -
- - - {stigmataSet.twoSetSkill.name} - - - {stigmataSet.twoSetSkill.description} - - - {stigmataSet.threeSetSkill.name} - - - {stigmataSet.threeSetSkill.description} - - -
-
- ) + return } export default StigmataListPage