From 20660aed9e3d6792052cd714a5bec56acb9d08ee Mon Sep 17 00:00:00 2001 From: HHH-GH Date: Tue, 18 Apr 2023 11:23:55 +0800 Subject: [PATCH] Update Quest Tiles layout Change LinkOverlay to link Pass a size to SquareImage Style of heading matches new design Take out the read more button and related code Alignment of description, roles tags, and skills tags TODO(HHH-GH): the hydration error, look at why a description can be blank --- packages/web/components/Quest/QuestTile.tsx | 185 ++++++++++---------- 1 file changed, 90 insertions(+), 95 deletions(-) diff --git a/packages/web/components/Quest/QuestTile.tsx b/packages/web/components/Quest/QuestTile.tsx index cc9e17ff..7595c6e1 100644 --- a/packages/web/components/Quest/QuestTile.tsx +++ b/packages/web/components/Quest/QuestTile.tsx @@ -2,29 +2,26 @@ import { Box, Flex, Heading, - LinkBox, - LinkOverlay, - MetaButton, + Link, MetaTile, MetaTileBody, MetaTileHeader, Prose, Text, + VStack, } from '@metafam/ds'; -import { httpLink, isSGML, Maybe } from '@metafam/utils'; +import { httpLink, isSGML } from '@metafam/utils'; import BackgroundImage from 'assets/quests/quest.webp'; import { MarkdownViewer as Markdown } from 'components/MarkdownViewer'; import { RolesTags } from 'components/Quest/Roles'; import { SkillsTags } from 'components/Quest/Skills'; import { SquareImage } from 'components/SquareImage'; import { PlayerRole, QuestFragment, Skill } from 'graphql/autogen/types'; -import React, { PropsWithChildren, useEffect, useRef } from 'react'; +import React, { PropsWithChildren } from 'react'; import { safelyParseNChakrifyHtml } from 'utils/stringHelpers'; export const TileHeading: React.FC = ({ children }) => ( - - {children} - + {children} ); type Props = { @@ -37,101 +34,99 @@ export const QuestTile: React.FC = ({ quest }) => { const parsedDescription = descIsHtml ? safelyParseNChakrifyHtml(description) : null; - const descriptionRef = useRef>(null); - const [clamped, setClamped] = React.useState(false); - const descriptionContent = descriptionRef.current?.textContent; - - useEffect(() => { - const handleResize = () => { - const desc = descriptionRef.current; - if (desc) { - setClamped(desc.scrollHeight > desc.clientHeight); - } - }; - window.addEventListener('resize', handleResize); - handleResize(); - - return () => window.removeEventListener('resize', handleResize); - }, [descriptionContent]); return ( - - - - - - - - {quest.title} - - - - - - + + + + + + + {quest.title} + + + + + + {(description || parsedDescription) && ( + Description - + {descIsHtml ? ( {parsedDescription} ) : ( {description} )} - {clamped && ( - - - Read More… - - - )} - - - Skills - skill) as Skill[] - } - /> - - - Roles - {quest.quest_roles.length > 0 ? ( - r, - ) as PlayerRole[] - } - /> - ) : ( - None - )} - - - - - - + + )} + + + {quest.quest_skills.length > 0 && ( + <> + + Skills + + skill, + ) as Skill[] + } + /> + + + + )} + + {quest.quest_roles.length > 0 && ( + + Roles + + r, + ) as PlayerRole[] + } + /> + + + )} + + + + + ); };