From 190b50b69f915f92d91b06f8d935e3b12dc2a705 Mon Sep 17 00:00:00 2001 From: Sakura Knoll Date: Sat, 1 Jan 2022 17:40:11 +0900 Subject: [PATCH] Refactor components of battlesuit list page --- src/components/atoms/PageLink.tsx | 15 +++++ src/components/atoms/SquareImageBox.tsx | 2 +- src/components/molecules/BattlesuitCard.tsx | 49 ++++++++++++++++ src/pages/_app.tsx | 20 +++++++ .../honkai3rd/battlesuits/[battlesuitId].tsx | 10 +++- src/pages/honkai3rd/battlesuits/index.tsx | 57 +++---------------- 6 files changed, 102 insertions(+), 51 deletions(-) create mode 100644 src/components/atoms/PageLink.tsx create mode 100644 src/components/molecules/BattlesuitCard.tsx diff --git a/src/components/atoms/PageLink.tsx b/src/components/atoms/PageLink.tsx new file mode 100644 index 00000000..b3b98278 --- /dev/null +++ b/src/components/atoms/PageLink.tsx @@ -0,0 +1,15 @@ +/** @jsxImportSource theme-ui */ +import NextLink, { LinkProps as NextLinkProps } from 'next/link' +import { Link, LinkProps } from '@theme-ui/components' + +type PageLinkProps = LinkProps & NextLinkProps + +const PageLink = ({ href, ...otherProps }: PageLinkProps) => { + return ( + + + + ) +} + +export default PageLink diff --git a/src/components/atoms/SquareImageBox.tsx b/src/components/atoms/SquareImageBox.tsx index 61ba328c..419b2862 100644 --- a/src/components/atoms/SquareImageBox.tsx +++ b/src/components/atoms/SquareImageBox.tsx @@ -3,7 +3,7 @@ import { Box } from '@theme-ui/components' import Image from 'next/image' interface SquareImageBoxProps { - size: number | string + size: number | string | Array src: string alt?: string m?: number | string diff --git a/src/components/molecules/BattlesuitCard.tsx b/src/components/molecules/BattlesuitCard.tsx new file mode 100644 index 00000000..bcfe4459 --- /dev/null +++ b/src/components/molecules/BattlesuitCard.tsx @@ -0,0 +1,49 @@ +import { Box, Card, Text } from '@theme-ui/components' +import { BattlesuitData } from '../../server/data/honkai3rd/battlesuits' +import PageLink from '../atoms/PageLink' +import SquareImageBox from '../atoms/SquareImageBox' + +interface BattlesuitCardProps { + battlesuit: Pick + hidden?: boolean +} + +const BattlesuitCard = ({ battlesuit, hidden }: BattlesuitCardProps) => { + return ( + + + + + {battlesuit.name} + + + + ) +} + +export default BattlesuitCard diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 12bba9b1..c46a0808 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -54,6 +54,7 @@ export const theme: Theme = { }, borders: { default: `1px solid ${colors.gray[5]}`, + primary: `1px solid #007bff`, }, lineHeights: { body: 1.6, @@ -96,10 +97,19 @@ export const theme: Theme = { borderStyle: 'solid', borderWidth: 1, bg: 'background', + cursor: 'pointer', '&:hover, &.active': { color: 'background', bg: 'primary', }, + transition: + 'box-shadow 200ms ease-in-out, color 200ms ease-in-out, background-color 200ms ease-in-out', + '&:hover': { + boxShadow: 'rgba(0, 0, 0, 0.2) 0px 4px 8px;', + }, + '&.hidden': { + display: 'none', + }, }, secondary: { color: 'background', @@ -209,6 +219,16 @@ export const theme: Theme = { }, }, cards: { + primary: { + border: 'default', + borderRadius: 'default', + + transition: + 'box-shadow 200ms ease-in-out, color 200ms ease-in-out, background-color 200ms ease-in-out', + '&:hover': { + boxShadow: 'rgba(0, 0, 0, 0.2) 0px 4px 8px;', + }, + }, stigmata: { padding: 2, borderRadius: 4, diff --git a/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx b/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx index 739aaa2b..2a543211 100644 --- a/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx +++ b/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx @@ -41,8 +41,12 @@ const BattlesuitShowPage = ({ battlesuit }: BattlesuitShowPageProps) => { @@ -161,6 +165,10 @@ const BattlesuitSkillGroupCard = ({ sx={{ borderRadius: 4, border: 'default', + transition: 'box-shadow 200ms ease-in-out', + '&:hover': { + boxShadow: 'rgba(0, 0, 0, 0.2) 0px 4px 8px;', + }, }} > { return battlesuits.map((battlesuit) => { const hidden = isBattlesuitHidden(battlesuit, filter) return ( - - - - - - {battlesuit.name} - - - - + battlesuit={battlesuit} + hidden={hidden} + /> ) }) }, [battlesuits, filter]) @@ -120,6 +78,7 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => { /> Battlesuits + Filter by Features