Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1093/search redesign #1150

Merged
merged 66 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
8726a45
Created new react-aria-component based searchbar with tagbar
Ty-ci Dec 5, 2023
817c82b
Create new components for Search component, no style, no functionalit…
Ty-ci Dec 7, 2023
a220872
Add preliminary real data fetching to Search results
Ty-ci Dec 8, 2023
f98ab9e
Add a variant to search result card with image
Ty-ci Dec 11, 2023
7680fae
Refactor search components and add localization
Ty-ci Dec 11, 2023
1e79f94
Add localization and preliminary pagination
Ty-ci Dec 13, 2023
78314dd
Remove unused files
Ty-ci Dec 13, 2023
c775746
Undo unwanted change in PageCards component
Ty-ci Dec 13, 2023
c21793b
Refactor search result cards to be more composable
Ty-ci Dec 14, 2023
d6f8dd9
Refactor search page content and search results components to remove …
Ty-ci Dec 15, 2023
1adf937
add pictures, fix pagination and metadata
Ty-ci Dec 18, 2023
dc3f830
Remove unused files
Ty-ci Dec 18, 2023
4a6cec1
Add page header, fix style for small screens, fix translations, fix i…
Ty-ci Dec 18, 2023
73d85a8
Add connection for search query and URL
Ty-ci Dec 18, 2023
5e1145c
Merge branch 'master' into 1093/Search-redesign
Ty-ci Dec 18, 2023
7792ffb
Fix bug where cards with no data were shown when switching search opt…
Ty-ci Dec 18, 2023
bfa80f4
Refactor searchDataFetchers (remove redundant code), rename some vari…
Ty-ci Dec 19, 2023
6d45ade
Fix search data fetchers
Ty-ci Dec 19, 2023
c1f2f89
Refactor search page components and update translations based on some…
Ty-ci Dec 19, 2023
dbdc812
Fix small things with accordance to comments in review
Ty-ci Dec 19, 2023
3ee6678
Refactor types used in search components so there's no residual 'any'…
Ty-ci Dec 19, 2023
9d049b4
Refactor - remove usage of index value as React element key property
Ty-ci Dec 19, 2023
e35c4ff
Fix various thing according to review comments
Ty-ci Dec 20, 2023
6781e8a
Add default return from getDataBySearchOptionKey
Ty-ci Dec 20, 2023
a28883f
Isolate findIconByPageColor function to separate file
Ty-ci Dec 20, 2023
83f09fb
Remove unused imports
Ty-ci Dec 20, 2023
c9720cc
Add new search options for contacts and official board
Ty-ci Dec 20, 2023
bdf5c55
Small fixes according to review comments
Ty-ci Dec 20, 2023
0e805d4
Fix pagination and rename some variables to align with repo conventions
Ty-ci Dec 21, 2023
0eaa359
Implemented Typography component
Ty-ci Dec 21, 2023
5f305da
Change breakpoint for mobile screens from sm to lg
Ty-ci Dec 22, 2023
e9613e5
Wrap searchcard title by link and hide official board search option
Ty-ci Dec 22, 2023
d81eec8
address PR comments
radoslavzeman Dec 26, 2023
1c9d31f
fix hooks used outside of hook or component
radoslavzeman Dec 26, 2023
c9eb592
use custom clear button in SearchField
radoslavzeman Dec 26, 2023
1f03c91
better Selection handling in TagGroup
radoslavzeman Dec 26, 2023
c793ec6
fix styling
radoslavzeman Dec 26, 2023
5fd8a07
fix scroll-to-top on page change
radoslavzeman Dec 26, 2023
7d03ac0
improve focus styling
radoslavzeman Dec 26, 2023
1260787
adress some PR comments for SearchCard
Ty-ci Dec 27, 2023
0118b43
Fix key warning in SearchCardComposed and fix typos in some comments
Ty-ci Dec 29, 2023
c98ae95
Merge branch 'master' into 1093/Search-redesign
Ty-ci Jan 2, 2024
5ec2cc9
Add horizontal scrolling to tag list on mobile displays
Ty-ci Jan 2, 2024
064fb5e
Fix runtime errors: key in GeneralSearchResults and undefined otherMa…
Ty-ci Jan 2, 2024
63070a6
Add aria-label to TagGroup
Ty-ci Jan 2, 2024
de4a53b
Add custom icon support
Ty-ci Jan 3, 2024
abe053a
Fix SVG clip-path for kontakty-a-uradne-hodiny icon
Ty-ci Jan 3, 2024
d8bea61
Add icon to official board search result cards
Ty-ci Jan 3, 2024
5df7549
Fix React duplicate key error
Ty-ci Jan 3, 2024
4297b3a
Hide 'more results' button when no search results are found
Ty-ci Jan 3, 2024
91be2dd
Add black color option to Pagination and implement in main search page
Ty-ci Jan 3, 2024
5ea435f
Merge branch 'master' into 1093/Search-redesign
Ty-ci Jan 4, 2024
3d8b2b1
Add paragraph showing number of search results
Ty-ci Jan 4, 2024
5e5193f
Fix plural in translation of 'Showing XY results' message
Ty-ci Jan 5, 2024
6026188
Show number of results in search option chips
Ty-ci Jan 5, 2024
b9f8729
Fix style (contact result card background color)
Ty-ci Jan 8, 2024
5482748
fix minor issues from PR review comments
Ty-ci Jan 8, 2024
710461e
Remove clip path from top-services icons
Ty-ci Jan 8, 2024
22a684d
Fix disappearing ring around search option Tags
Ty-ci Jan 8, 2024
4081aed
Add new dokumenty icon and remove debug elements from search page
Ty-ci Jan 8, 2024
67d030f
Revert changes to pagination, keep default red background
Ty-ci Jan 8, 2024
e2c490c
Change type of resultsCount from Map to Object
Ty-ci Jan 8, 2024
65c8cc5
Change cross icon in search bar
Ty-ci Jan 8, 2024
82bb8fa
Fix resultsCount state
Ty-ci Jan 8, 2024
e058b3b
Use Typography
Ty-ci Jan 9, 2024
fd93624
Merge branch 'master' into 1093/Search-redesign
Ty-ci Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions next/assets/icons-top-services/kontakty-a-uradne-hodiny.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions next/components/atoms/icon/IconService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import Travel64pxFilledIcon from '@assets/images/menu-icons/64px/travel_64px_fil
import Travel64pxStrokeIcon from '@assets/images/menu-icons/64px/travel_64px_stroke.svg'
import Tree64pxIcon from '@assets/images/menu-icons/64px/tree_64px.svg'
import Trolleybus64pxIcon from '@assets/images/menu-icons/64px/trolleybus_64px.svg'
import Ostatne48pxIcon from '@assets/images/ostatne.svg'
import Phone48pxIcon from '@assets/images/phone-medium.svg'
import TouristSign48pxIcon from '@assets/images/Tourist-icon.svg'

Expand Down Expand Up @@ -181,6 +182,8 @@ export const ICON_URL_MAP: IconUrlMap = {
pracovne_prilezitosti: TopServices_PracovnePrilezitosti,
turistom_v_hlavnom_meste: TopServices_TuristomVHlavnomMeste,
prenajom_priestorov: TopServices_PrenajomPriestorov,
// Others
ostatne: Ostatne48pxIcon,
},
size_64: {
mesto_01: Castle64pxStrokeIcon,
Expand Down
2 changes: 1 addition & 1 deletion next/components/forms/simple-components/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Chip = ({ variant = 'large', ...props }: ChipProps) => {
<Tag
{...props}
className={cx(
'flex cursor-pointer items-center rounded-lg border-2 outline-none hover:bg-gray-200 focus-visible:ring focus-visible:ring-offset-2 selected:border-category-700 selected:bg-category-700 selected:text-gray-0 hover:selected:bg-category-700',
'flex shrink-0 cursor-pointer items-center rounded-lg border-2 outline-none hover:bg-gray-200 focus-visible:ring focus-visible:ring-offset-2 selected:border-category-700 selected:bg-category-700 selected:text-gray-0 hover:selected:bg-category-700',
{
'px-3 py-1.5 text-size-p-small lg:px-4 lg:py-2.5 lg:text-size-p-default':
variant === 'large',
Expand Down
20 changes: 17 additions & 3 deletions next/components/molecules/SearchPageNew/GeneralSearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
} from '@components/molecules/SearchPageNew/useQueryBySearchOption'
import { SearchOption } from '@components/pages/searchPageContentNew'
import { useTranslations } from 'next-intl'
import { Dispatch, SetStateAction } from 'react'
import { Dispatch, SetStateAction, useEffect } from 'react'

type GeneralSearchResultsProps = {
filters: SearchFilters
variant: 'allResults' | 'specificResults'
searchOption: SearchOption
handleSetResultsCount?: (searchOptionId: SearchOption['id'], count: number) => void
onShowMore?: Dispatch<SetStateAction<Set<SearchOption['id']>>>
onPageChange?: Dispatch<SetStateAction<number>>
}
Expand All @@ -22,6 +23,7 @@ const GeneralSearchResults = ({
filters,
onShowMore,
onPageChange,
handleSetResultsCount,
searchOption,
variant,
}: GeneralSearchResultsProps) => {
Expand All @@ -35,12 +37,17 @@ const GeneralSearchResults = ({

const GENERAL_RESULTS_COUNT = 5

useEffect(() => {
handleSetResultsCount(searchOption?.id, searchResultsCount)
}, [searchResultsCount])

return (
<div className="flex flex-col gap-y-8">
<div className="flex flex-col gap-y-4">
{variant === 'allResults' && (
<SearchResultsHeader
title={`${searchOption?.displayNamePlural}` ?? ''}
showButton={searchResultsCount > 0}
handleShowMore={() => {
onShowMore(new Set([searchOption.id]))
}}
Expand All @@ -55,7 +62,10 @@ const GeneralSearchResults = ({
data={{ ...item }}
tagText={searchOption.displayName}
variant="withPicture"
key={`item-${variant}-${searchOption.id}-${item.linkHref}`}
key={`item-${variant}-${searchOption.id}-${[
item.title,
...item.metadata,
].join('')}`}
/>
)
})
Expand All @@ -67,7 +77,10 @@ const GeneralSearchResults = ({
data={{ ...item }}
tagText={searchOption.displayName}
variant="withPicture"
key={`item-${variant}-${searchOption.id}-${item.linkHref}`}
key={`item-${variant}-${searchOption.id}-${[
item.title,
...item.metadata,
].join('')}`}
/>
)
})
Expand All @@ -85,6 +98,7 @@ const GeneralSearchResults = ({
<div>
<Pagination
currentPage={filters.page}
style="black"
totalCount={
searchResultsCount > 0 ? Math.ceil(searchResultsCount / filters.pageSize) : 1
}
Expand Down
44 changes: 33 additions & 11 deletions next/components/molecules/SearchPageNew/SearchCardComposed.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChevronRightIcon } from '@assets/ui-icons'
import { Enum_Page_Pagecolor, Enum_Pagecategory_Color } from '@backend/graphql'
import { Typography } from '@bratislava/component-library'
import { Icon } from '@components/atoms/icon/Icon'
import ImagePlaceholder from '@components/atoms/ImagePlaceholder'
import MLink from '@components/forms/simple-components/MLink'
import Tag from '@components/forms/simple-components/Tag'
Expand All @@ -11,7 +12,7 @@ import { isDefined } from '@utils/isDefined'
import { findIconByPageColor } from '@utils/pageIcons'
import cx from 'classnames'
import Image from 'next/image'
import React, { ReactNode } from 'react'
import React, { Fragment, ReactNode } from 'react'
import { twMerge } from 'tailwind-merge'

type SearchCardComposedProps = {
Expand All @@ -28,7 +29,7 @@ const SearchCardComposed = ({ data, variant = 'default', tagText }: SearchCardCo
<div className="flex w-full flex-row gap-6 px-6 py-4">
<SearchCardComposed.InfoContainer className="gap-1.5">
<div className="flex flex-row flex-wrap items-center gap-x-3 gap-y-1.5 lg:flex-nowrap">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is lg:flex-nowrap for? Does lg:flex-col do the same? Please use flex-col is possieble :)

<SearchCardComposed.TitleWithLink title={data.title} url={data.linkHref} />
<SearchCardComposed.TitleWithLink title={data.title} href={data.linkHref} />
<SearchCardComposed.Tag text={tagText} />
</div>
<SearchCardComposed.Metadata metadata={data.metadata} />
Expand All @@ -46,10 +47,12 @@ const SearchCardComposed = ({ data, variant = 'default', tagText }: SearchCardCo
>
{data.coverImageSrc ? (
<SearchCardComposed.ImageFromUrl imgUrl={data.coverImageSrc} />
) : data.customIconName ? (
<SearchCardComposed.ImageFromIcon iconName={data.customIconName} />
) : data.pageColor ? (
<SearchCardComposed.ImageFromPageColor pageColor={data.pageColor} />
) : (
<SearchCardComposed.ImageFromPageColor pageColor={Enum_Pagecategory_Color.Red} />
<SearchCardComposed.ImageFromIcon iconName={null} />
)}
<div className="flex w-full flex-row gap-6 py-4 lg:p-6">
<SearchCardComposed.InfoContainer className="flex flex-col gap-3">
Expand All @@ -58,7 +61,7 @@ const SearchCardComposed = ({ data, variant = 'default', tagText }: SearchCardCo
<SearchCardComposed.TitleWithLink
className=""
title={data.title}
url={data.linkHref}
href={data.linkHref}
/>
</div>
<SearchCardComposed.Metadata metadata={data.metadata} />
Expand All @@ -71,6 +74,25 @@ const SearchCardComposed = ({ data, variant = 'default', tagText }: SearchCardCo
)
}

SearchCardComposed.ImageFromIcon = function ({
iconName,
className,
}: {
iconName?: string
className?: string
}) {
return (
<div
className={twMerge(
'hidden w-[150px] shrink-0 items-center justify-center bg-gray-200 lg:flex',
className,
)}
>
{iconName ? <Icon iconName={iconName} /> : null}
</div>
)
}

SearchCardComposed.ImageFromPageColor = function ({
pageColor,
className,
Expand Down Expand Up @@ -113,7 +135,7 @@ SearchCardComposed.ImageFromUrl = function ({
alt=""
sizes={generateImageSizes({ default: '150px' })}
fill
className="h-full object-cover"
className="object-cover"
/>
<ImagePlaceholder />
</div>
Expand All @@ -132,17 +154,17 @@ SearchCardComposed.InfoContainer = function ({

SearchCardComposed.TitleWithLink = function ({
title,
url,
href,
className,
}: {
title: string
url?: string
href?: string
className?: string
}) {
return (
<>
{url ? (
<MLink stretched href={url ?? ''}>
{href ? (
<MLink stretched href={href}>
<Typography
type="h3"
size="h5"
Expand Down Expand Up @@ -186,7 +208,7 @@ SearchCardComposed.Metadata = function ({
const metaDataRow =
cleanedMetadata?.map((item: string, index: number) => {
return (
<>
<Fragment key={item}>
{index > 0 && (
<Typography type="p" className="max-lg:hidden">
Expand All @@ -195,7 +217,7 @@ SearchCardComposed.Metadata = function ({
<Typography type="p" className="max-lg:first-of-type:font-medium">
{item}
</Typography>
</>
</Fragment>
)
}) ?? null
return (
Expand Down
11 changes: 7 additions & 4 deletions next/components/molecules/SearchPageNew/SearchResultsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ import { useTranslations } from 'next-intl'

type SearchResultsHeaderProps = {
title: string
showButton?: boolean
handleShowMore: () => void
}

const SearchResultsHeader = ({ title, handleShowMore }: SearchResultsHeaderProps) => {
const SearchResultsHeader = ({ title, showButton, handleShowMore }: SearchResultsHeaderProps) => {
const t = useTranslations()

return (
<div className="flex flex-col flex-wrap items-baseline justify-between gap-y-2 lg:flex-row">
<Typography type="h2" size="h4" className="text-gray-800">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Color is handled by Typography

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default color for Typography is gray-700, however in Figma we have gray-800 for this text

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this kind of situations, we always want confront and change Figma to follow design system rules. --> Write a comment to Figma and tag Patrik.
DS Foundations can be found here https://www.figma.com/file/ctDKMhAPIjLUVNNmq430D4/DS-ESBS%3A-Foundations?node-id=59-21&t=M4lXbCEzOWWIiekd-0

{title}
</Typography>
<Button variant="black-link" endIcon={<ArrowRightIcon />} onPress={handleShowMore}>
{t('SearchPage.moreResults')}
</Button>
{showButton ? (
<Button variant="black-link" endIcon={<ArrowRightIcon />} onPress={handleShowMore}>
{t('SearchPage.moreResults')}
</Button>
) : null}
</div>
)
}
Expand Down
16 changes: 12 additions & 4 deletions next/components/molecules/SearchPageNew/useQueryBySearchOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import {
getGinisOfficialBoardQueryKey,
ginisOfficialBoardFetcher,
} from '@backend/ginis/fetchers/ginisOfficialBoard.fetcher'
import { Enum_Page_Pagecolor, LatestBlogPostEntityFragment } from '@backend/graphql'
import {
Enum_Componentblockstopservicesitem_Icon,
Enum_Page_Pagecolor,
Enum_Pagecategory_Color,
LatestBlogPostEntityFragment,
} from '@backend/graphql'
import {
blogPostsFetcher,
BlogPostsFilters,
Expand Down Expand Up @@ -35,7 +40,8 @@ export type SearchResult = {
linkHref?: string | null | undefined
metadata?: (string | null | undefined)[]
coverImageSrc?: string | null | undefined
pageColor?: Enum_Page_Pagecolor
pageColor?: Enum_Page_Pagecolor | Enum_Pagecategory_Color
customIconName?: string
}

export const useQueryBySearchOption = (optionKey: SearchOption['id'], filters: SearchFilters) => {
Expand All @@ -52,7 +58,7 @@ export const useQueryBySearchOption = (optionKey: SearchOption['id'], filters: S
title: page.title,
linkHref: `/${page.slug}`,
metadata: [page.pageCategory?.title, formatDate(page.publishedAt)],
pageColor: page.pageColor,
pageColor: page.pageColor ?? page.pageCategory?.color,
}
}) ?? []

Expand Down Expand Up @@ -115,11 +121,12 @@ export const useQueryBySearchOption = (optionKey: SearchOption['id'], filters: S
select: (axiosResponse) => {
const formattedData: SearchResult[] =
axiosResponse?.data.map((user) => {
const mail = user.otherMails.length > 0 ? user.otherMails[0] : user.mail
const mail = user.otherMails?.length > 0 ? user.otherMails[0] : user.mail

return {
title: user.displayName,
metadata: [user.jobTitle, mail, user.businessPhones?.join(', ')],
customIconName: Enum_Componentblockstopservicesitem_Icon.UradneHodiny,
}
}) ?? []

Expand All @@ -137,6 +144,7 @@ export const useQueryBySearchOption = (optionKey: SearchOption['id'], filters: S
return {
title: boardItem.title,
metadata: [boardItem.createdAt],
customIconName: 'ostatne',
}
}) ?? []

Expand Down
Loading
Loading