Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
the-kwisatz-haderach committed Jan 8, 2024
1 parent 687d878 commit 69619de
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 64 deletions.
7 changes: 4 additions & 3 deletions components/Contained/Contained.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Container, ContainerProps } from '@chakra-ui/react'
import { Container, ContainerProps, forwardRef } from '@chakra-ui/react'
import React, { ReactNode } from 'react'

type Props = {
children: ReactNode
} & Omit<ContainerProps, 'px' | 'maxW' | 'maxWidth' | 'p'>

export function Contained({ children, ...props }: Props) {
export const Contained = forwardRef(({ children, ...props }: Props, ref) => {
return (
<Container
ref={ref}
py={2}
{...props}
maxW="container.xl"
Expand All @@ -17,4 +18,4 @@ export function Contained({ children, ...props }: Props) {
{children}
</Container>
)
}
})
20 changes: 9 additions & 11 deletions components/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ const getIcon = (icon: Props['icon']) => {
)
case 'no-results':
return (
<div
style={{
opacity: 0.2,
}}
>
<Image alt="" src="/images/no-results.png" width={200} height={200} />
</div>
<Box opacity={0.15} width={[150, 180, 200]} height={[150, 180, 200]}>
<Image alt="" src="/images/no-results.png" fill />
</Box>
)
default:
return undefined
Expand All @@ -42,14 +38,16 @@ export default function EmptyState({
...stackProps
}: Props): ReactElement {
return (
<VStack {...stackProps} spacing={0} color="blackAlpha.900">
<VStack {...stackProps} spacing={0} py={8} color="blackAlpha.500">
{icon && (
<Box mb={4} position="relative">
<Box mb={5} position="relative">
{getIcon(icon)}
</Box>
)}
<Text fontSize="4xl">{title}</Text>
<Text fontSize="lg">{description}</Text>
<Text fontWeight="500" fontSize={['lg', 'xl', '4xl']}>
{title}
</Text>
<Text fontSize={['md', 'md', 'lg']}>{description}</Text>
</VStack>
)
}
3 changes: 3 additions & 0 deletions components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ import { TranslatedLink } from '../TranslatedLink'

type Props = LinkProps & {
onClick?: () => void
bold?: boolean
}

export default function Link({
children,
href,
onClick,
bold,
...props
}: PropsWithChildren<Props>): ReactElement {
return (
<TranslatedLink {...props} href={href} passHref>
<ChakraLink
color="brand.500"
fontWeight={bold ? 600 : 400}
onClick={
onClick
? (e) => {
Expand Down
1 change: 1 addition & 0 deletions components/Obituary/components/Obituary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export const Obituary: ObituaryRenderer = (props) => {
onClick={openModal}
href={`/${formattedType}/${_id}`}
prefetch={false}
bold
>
{t('search-results-view_full')}
</Link>
Expand Down
10 changes: 5 additions & 5 deletions components/ObituaryGrid/ObituaryGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { ReactElement } from 'react'
import { Button, Container, Flex, GridItem, SimpleGrid } from '@chakra-ui/react'
import { Button, Flex, GridItem, SimpleGrid } from '@chakra-ui/react'
import { IObituary } from '../../lib/domain/types'
import { Obituary, ObituarySkeleton, ObituaryContainer } from '../Obituary'
import { EmptyState } from '../EmptyState'
import { useTranslation } from 'next-i18next'
import { ResultsDescription } from './ResultsDescription'
import { isMultiObituary } from 'lib/domain/isMultiObituary'
import { Contained } from 'components/Contained/Contained'

interface Props {
obituaries: IObituary[]
Expand All @@ -24,7 +25,7 @@ export default function ObituaryGrid({
}: Props): ReactElement {
const { t } = useTranslation()
return (
<Container maxW="container.xl" my={8}>
<Contained my={{ base: 0, lg: 8 }}>
<ResultsDescription resultsCount={obituaries.length} hasMore={hasMore} />
{isLoading || obituaries.length > 0 ? (
<SimpleGrid spacing={4} columns={[1, 2, 3, 4]}>
Expand All @@ -48,14 +49,13 @@ export default function ObituaryGrid({
</SimpleGrid>
) : (
<EmptyState
mt={24}
title={t('search-results-empty-title')}
description={t('search-results-empty-description')}
icon="no-results"
/>
)}
{hasMore && (
<Flex justifyContent="center" mt={10}>
<Flex justifyContent="center" mt={[4, 6, 8, 10]}>
<Button
isLoading={isLoadingNext}
colorScheme="brand"
Expand All @@ -67,6 +67,6 @@ export default function ObituaryGrid({
</Button>
</Flex>
)}
</Container>
</Contained>
)
}
3 changes: 1 addition & 2 deletions components/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export default function SearchInput({
<Flex
as="form"
width="100%"
maxW={500}
px={[4, 0]}
maxW={{ base: 'unset', md: 500 }}
flexDir={['column', 'row']}
>
<Input
Expand Down
14 changes: 14 additions & 0 deletions components/TopScroll/TopScroll.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.wrapper {
opacity: 0;
animation: fade-in 1s ease-in-out forwards;
}

@keyframes fade-in {
from {
opacity: 0;
}

to {
opacity: 1;
}
}
40 changes: 15 additions & 25 deletions components/TopScroll/TopScroll.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { ReactElement } from 'react'
import { Box, BoxProps, IconButton, Fade } from '@chakra-ui/react'
import { Box, BoxProps, IconButton } from '@chakra-ui/react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faArrowUp as scrollTopIcon } from '@fortawesome/free-solid-svg-icons'
import styles from './TopScroll.module.css'

interface Props extends BoxProps {
onClick: () => void
Expand All @@ -13,36 +14,25 @@ export default function TopScroll({
show,
...boxProps
}: Props): ReactElement {
return (
return show ? (
<Box
{...boxProps}
textAlign="right"
position="sticky"
bottom={0}
pointerEvents="none"
className={styles.wrapper}
px={3}
py={[3, 3, 5]}
>
<Fade
in={show}
transition={{
enter: {
delay: 1,
duration: 1,
},
exit: {
delay: 1,
duration: 1,
},
}}
>
<IconButton
pointerEvents="all"
colorScheme="brand"
onClick={onClick}
aria-label="Scroll to top"
isRound
icon={<FontAwesomeIcon icon={scrollTopIcon} />}
/>
</Fade>
<IconButton
pointerEvents="all"
colorScheme="brand"
onClick={onClick}
aria-label="Scroll to top"
isRound
icon={<FontAwesomeIcon icon={scrollTopIcon} />}
/>
</Box>
)
) : null
}
33 changes: 17 additions & 16 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
StoryblokComponent,
useStoryblokState,
} from '@storyblok/react'
import { Contained } from 'components/Contained/Contained'

interface Props {
story: PageStory
Expand All @@ -48,22 +49,24 @@ export default function Home({ story: initialStory }: Props): ReactElement {
return (
<div>
<StoryblokComponent blok={story.content} />
<Flex
ref={ref}
backgroundColor="gray.300"
justifyContent="center"
height={32}
alignItems="center"
>
<SearchInput
title={t('search')}
value={query}
onChange={setQuery}
placeholder={t('search-placeholder')}
/>
<Flex ref={ref} backgroundColor="gray.300">
<Contained
display="flex"
justifyContent="center"
height={32}
py={[2, 4, 6]}
alignItems="center"
>
<SearchInput
title={t('search')}
value={query}
onChange={setQuery}
placeholder={t('search-placeholder')}
/>
</Contained>
</Flex>
<ProgressBar show={isLoading || isFetching} />
<Box my={14}>
<Box>
<ObituaryGrid
isLoading={isLoading}
isLoadingNext={isFetchingNextPage}
Expand All @@ -76,8 +79,6 @@ export default function Home({ story: initialStory }: Props): ReactElement {
margin="auto"
maxW="container.xl"
width="100%"
px={3}
py={[3, 3, 5]}
onClick={scrollToTop}
/>
</Box>
Expand Down
4 changes: 2 additions & 2 deletions public/static/locales/hr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"search-results-result": "rezultata",
"search-results-more": "Prikaži više",
"search-results-view_full": "Pročitaj više",
"search-results-empty-title": "Nema rezultata.",
"search-results-empty-description": "Izmijenite pretragu.",
"search-results-empty-title": "Nema rezultata",
"search-results-empty-description": "Izmijenite pretragu",
"address": "Adresa",
"phone": "Broj telefona",
"mail": "E-mail",
Expand Down

0 comments on commit 69619de

Please sign in to comment.