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

User can see material description #73

Merged
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
efc1cb5
Add Storybook stories for CoverPicture component
Adamik10 Dec 10, 2024
63cafe5
Update CoverPicture stories to use iPhone 14 viewport and correct imp…
Adamik10 Dec 10, 2024
e0bdc3b
Remove unused tags from Button and Fonts story files (autodocs)
Adamik10 Dec 10, 2024
82604b1
Correct typo in BadgeButton comp - aria label + classname
Adamik10 Dec 10, 2024
cd4811f
Refactor SlideSelect component for improved layout & accessibility
Adamik10 Dec 10, 2024
3717abc
Add stories for SlideSelect component
Adamik10 Dec 10, 2024
5af577e
Add stories for Badge component
Adamik10 Dec 10, 2024
ca26fa1
Add work page header mock file
Adamik10 Dec 10, 2024
8e47176
Add drop shadow into blue badges for accessibility
Adamik10 Dec 10, 2024
d1a852d
Add test delays to ensure animations complete before accessibility ch…
Adamik10 Dec 10, 2024
0f5190e
Enhance color contrast for accessibility by updating blue title varia…
Adamik10 Dec 11, 2024
39adf8d
Update small typography to be 1px larger for improved readability
Adamik10 Dec 11, 2024
b8b8651
Refactor Badge stories for improved accessibility - color contrast
Adamik10 Dec 11, 2024
a426516
Remove drop shadow from workCard badge
Adamik10 Dec 11, 2024
5474e0d
Add aria-label to question mark icon and adjust opacity for better vi…
Adamik10 Dec 11, 2024
08c07d9
Update storybook/addon-a11y, @storybook/react & openid-client
Adamik10 Dec 11, 2024
3744c4c
Update yarn to match new package.json
Adamik10 Dec 11, 2024
4841962
Enhance accessibility testing configuration with global delay and pre…
Adamik10 Dec 11, 2024
b8353f0
Don't publish mobile stories through Chromatic but storybook
Adamik10 Dec 11, 2024
3a20178
Add custom variant for not-first child in Tailwind configuration
Adamik10 Dec 12, 2024
f77a87a
Reduce letter spacing for small button typography in global styles to…
Adamik10 Dec 12, 2024
b9102ed
Add WorkDescription and ManifestationDescription fragments to GraphQL…
Adamik10 Dec 12, 2024
22216d1
Scroll to top on page load when redirecting to the page
Adamik10 Dec 12, 2024
1d0d423
Make ariaLabel optional in ButtonProps and provide a default empty st…
Adamik10 Dec 12, 2024
1cb6365
Add InfoBoxItem component for displaying terms and descriptions with …
Adamik10 Dec 12, 2024
1b04ccb
Add InfoBox component for displaying work descriptions and related in…
Adamik10 Dec 12, 2024
0d738c2
Integrate InfoBox component into WorkPageLayout description display
Adamik10 Dec 12, 2024
847f121
Add InfoBox layout for mobile view
Adamik10 Dec 12, 2024
2eb703c
Merge branch 'main' into DDFBRA-169-bruger-skal-kunne-se-en-beskrivel…
Adamik10 Dec 12, 2024
2430a05
Refactor imports in SearchPageLayout, WorkPageButtons, WorkPageHeader…
Adamik10 Dec 12, 2024
470f175
Handle mobile stories through Chromatic, not Storybook
Adamik10 Dec 13, 2024
0015d64
Handle scrolling to the top inside router.push() function
Adamik10 Dec 13, 2024
8a7cbaf
Add SlideSelectSkeleton, CoverPictureSkeleton & ButtonSkeleton
Adamik10 Dec 13, 2024
d90db13
Rename ghost components to skeleton components for consistency
Adamik10 Dec 13, 2024
a4ada22
Enhance no search result message styling
Adamik10 Dec 13, 2024
b75c198
Add WorkPageSkeletons component for improved loading state representa…
Adamik10 Dec 13, 2024
67d5c27
Merge branch 'main' into DDFBRA-169-bruger-skal-kunne-se-en-beskrivel…
Adamik10 Dec 13, 2024
de5cfff
Add skeleton color variables to globals.css and update Tailwind config
Adamik10 Dec 13, 2024
68c3c18
Refactor skeleton components to use new skeleton background color var…
Adamik10 Dec 13, 2024
501adb4
Remove unused file-xyz classes from search input
Adamik10 Dec 13, 2024
d8567d2
Prettify classes
Adamik10 Dec 13, 2024
aad4e8b
Remove y-axis animation for InfoBox.tsx
Adamik10 Dec 13, 2024
4273693
Don't call search result actor outside search results
Adamik10 Dec 13, 2024
c25a3aa
Use more descriptive variable names in button mapping in InfoBox.tsx
Adamik10 Dec 13, 2024
5e2340e
Unify font spacing for button-sm between screen sizes
Adamik10 Dec 13, 2024
fb815fd
Update InfoBox.tsx to use grid gap for layout spacing
Adamik10 Dec 13, 2024
00f1462
Update InfoBox.tsx styling not to use absolute positioning
Adamik10 Dec 16, 2024
ba4f732
Rename WorkPageSkeletons to WorkPageSkeleton for consistency
Adamik10 Dec 16, 2024
99c41ab
Refactor InfoBoxItem component to use the existing border class
Adamik10 Dec 16, 2024
d76e39c
Prettify WorkPageLayout.tsx
Adamik10 Dec 16, 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
7 changes: 7 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ const preview: Preview = {
},
},
},
a11y: {
config: {
// Add a global 2-second delay for accessibility tests to make sure
// all animations are completed before the tests run
delay: 3000,
},
},
},
decorators: [
// 👇 Defining the decorator in the preview file applies it to all stories
Expand Down
7 changes: 6 additions & 1 deletion .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import { checkA11y, injectAxe } from "axe-playwright"
module.exports = {
async preVisit(page) {
await injectAxe(page)
// Add a delay to wait for all animations to finish
await page.waitForTimeout(2000)
},
async postVisit(page) {
// Ensure all animations are complete before running accessibility checks
await page.waitForTimeout(2000)

await checkA11y(page, "#storybook-root", {
axeOptions: {},
axeOptions: { preload: true },
detailedReport: true,
detailedReportOptions: {
html: true,
Expand Down
23 changes: 13 additions & 10 deletions components/pages/searchPageLayout/SearchPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import { motion, useInView } from "framer-motion"
import { useEffect, useRef } from "react"

import SearchResults, {
SearchResultsSkeleton,
} from "@/components/pages/searchPageLayout/SearchResults"
import { useSearchDataAndLoadingStates } from "@/components/pages/searchPageLayout/helper"
import SearchFiltersDesktop, {
SearchFiltersDesktopSkeleton,
} from "@/components/shared/searchFilters/SearchFiltersDesktop"
import SearchFiltersMobile from "@/components/shared/searchFilters/SearchFiltersMobile"
import useSearchMachineActor from "@/lib/machines/search/useSearchMachineActor"

import SearchFiltersDesktop, {
SearchFiltersDesktopGhost,
} from "../../shared/searchFilters/SearchFiltersDesktop"
import SearchResults, { SearchResultsGhost } from "./SearchResults"
import { useSearchDataAndLoadingStates } from "./helper"

const SearchPageLayout = () => {
const loadMoreRef = useRef(null)
const isInView = useInView(loadMoreRef)
Expand Down Expand Up @@ -62,15 +63,17 @@ const SearchPageLayout = () => {
</div>
) : (
<>
<div className="xl:hidden">{/* <SearchFiltersMobileGhost /> */}</div>
<div className="xl:hidden">{/* <SearchFiltersMobileSkeleton /> */}</div>
<div className="hidden xl:block">
<SearchFiltersDesktopGhost />
<SearchFiltersDesktopSkeleton />
</div>
</>
)}
<hr className="-mx-grid-edge w-screen border-foreground opacity-10 md:mx-auto md:w-full" />
<div className="mb-space-y flex flex-col gap-y-[calc(var(--grid-gap-x)*2)]">
{isNoSearchResult && <p>Ingen søgeresultat</p>}
{isNoSearchResult && (
<p className="text-typo-subtitle-lg opacity-35">Ingen søgeresultat</p>
)}
{data.search &&
data.search.pages.map(
(works, i) =>
Expand All @@ -85,7 +88,7 @@ const SearchPageLayout = () => {
</motion.div>
)
)}
{(isLoadingMoreResults || isLoadingResults) && <SearchResultsGhost />}
{(isLoadingMoreResults || isLoadingResults) && <SearchResultsSkeleton />}
</div>
</>
) : (
Expand Down
10 changes: 5 additions & 5 deletions components/pages/searchPageLayout/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React from "react"

import WorkCard, { WorkCardGhost } from "@/components/shared/workCard/WorkCard"
import WorkCard, { WorkCardSkeleton } from "@/components/shared/workCard/WorkCard"
import { WorkTeaserSearchPageFragment } from "@/lib/graphql/generated/fbi/graphql"

type SearchResultProps = {
Expand All @@ -21,14 +21,14 @@ const SearchResults = ({ works }: SearchResultProps) => {
)
}

export const SearchResultsGhost = () => {
const ghostItems = Array.from({ length: 6 })
export const SearchResultsSkeleton = () => {
const skeletonItems = Array.from({ length: 6 })

return (
<div className="grid-go gap-x-grid-gap-x gap-y-[calc(var(--grid-gap-x)*2)]">
{ghostItems.map((_, index) => (
{skeletonItems.map((_, index) => (
<div className="col-span-3 lg:col-span-4" key={index}>
<WorkCardGhost />
<WorkCardSkeleton />
</div>
))}
</div>
Expand Down
3 changes: 1 addition & 2 deletions components/pages/workPageLayout/WorkPageButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { useState } from "react"

import { isAudioBook, isEbook, isPodcast } from "@/components/pages/workPageLayout/helper"
import { Button } from "@/components/shared/button/Button"
import Player from "@/components/shared/publizonPlayer/PublizonPlayer"
import ResponsiveDialog from "@/components/shared/responsiveDialog/ResponsiveDialog"
import SmartLink from "@/components/shared/smartLink/SmartLink"
import { resolveUrl } from "@/lib/helpers/helper.routes"
import { useSelectedManifestationStore } from "@/store/selectedManifestation.store"

import { isAudioBook, isEbook, isPodcast } from "./helper"

export type WorkPageButtonsProps = {
workId: string
}
Expand Down
17 changes: 8 additions & 9 deletions components/pages/workPageLayout/WorkPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { motion } from "framer-motion"
import { useRouter, useSearchParams } from "next/navigation"
import React, { useEffect, useState } from "react"

import WorkPageButtons from "@/components/pages/workPageLayout/WorkPageButtons"
import {
addMaterialTypeIconToSelectOption,
findInitialSliderValue,
getManifestationByMaterialType,
getManifestationLanguageIsoCode,
getWorkMaterialTypes,
} from "@/components/pages/workPageLayout/helper"
import { Badge } from "@/components/shared/badge/Badge"
import { CoverPicture } from "@/components/shared/coverPicture/CoverPicture"
import SlideSelect, { SlideSelectOption } from "@/components/shared/slideSelect/SlideSelect"
Expand All @@ -16,15 +24,6 @@ import { GetCoverCollectionSizesItem } from "@/lib/rest/cover-service-api/genera
import { useGetV1ProductsIdentifier } from "@/lib/rest/publizon-api/generated/publizon"
import { useSelectedManifestationStore } from "@/store/selectedManifestation.store"

import WorkPageButtons from "./WorkPageButtons"
import {
addMaterialTypeIconToSelectOption,
findInitialSliderValue,
getManifestationByMaterialType,
getManifestationLanguageIsoCode,
getWorkMaterialTypes,
} from "./helper"

type WorkPageHeaderProps = {
work: WorkFullWorkPageFragment
}
Expand Down
47 changes: 39 additions & 8 deletions components/pages/workPageLayout/WorkPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import { notFound } from "next/navigation"
import { useSearchParams } from "next/navigation"
import React, { useEffect } from "react"

import WorkPageHeader from "@/components/pages/workPageLayout/WorkPageHeader"
import {
getBestRepresentation,
getManifestationByMaterialType,
} from "@/components/pages/workPageLayout/helper"
import { ButtonSkeleton } from "@/components/shared/button/Button"
import { CoverPictureSkeleton } from "@/components/shared/coverPicture/CoverPicture"
import InfoBox from "@/components/shared/infoBox/InfoBox"
import { SlideSelectSkeleton } from "@/components/shared/slideSelect/SlideSelect"
import { GetMaterialQuery, useGetMaterialQuery } from "@/lib/graphql/generated/fbi/graphql"
import { useSelectedManifestationStore } from "@/store/selectedManifestation.store"

import WorkPageHeader from "./WorkPageHeader"
import { getBestRepresentation, getManifestationByMaterialType } from "./helper"

type WorkPageLayoutProps = {
workId: string
dehydratedQueryData: GetMaterialQuery | undefined
Expand All @@ -23,8 +29,6 @@ function WorkPageLayout({ workId, dehydratedQueryData }: WorkPageLayoutProps) {
queryFn: useGetMaterialQuery.fetcher({ wid: workId }),
initialData: dehydratedQueryData,
})
const pageContainerClasses =
"content-container my-grid-gap-2 flex-row flex-wrap space-y-grid-gap-2 lg:space-y-grid-gap-1 lg:my-grid-gap-half"
const { selectedManifestation, setSelectedManifestation } = useSelectedManifestationStore()

// Cleanup at unmount
Expand Down Expand Up @@ -52,20 +56,47 @@ function WorkPageLayout({ workId, dehydratedQueryData }: WorkPageLayoutProps) {
}, [selectedManifestation])

if (isLoading && !data) {
return <div className={pageContainerClasses}>Loading...</div>
return (
<div className="content-container my-grid-gap-2 flex-row flex-wrap lg:my-grid-gap-half">
<WorkPageSkeletons />
</div>
)
}

if (!data || !data.work) {
notFound()
}

return (
<div className={pageContainerClasses}>
<div className="content-container my-grid-gap-2 flex-row flex-wrap lg:my-grid-gap-half">
<WorkPageHeader work={data.work} />
{/* <WorkPageDescription /> */}
<InfoBox work={data.work} />
{/* <WorkPageDetails /> */}
</div>
)
}

export const WorkPageSkeletons = () => {
return (
<div className="lg:grid-go mt-5">
<div className="col-span-4 h-auto lg:order-2">
<div className="h-auto w-full flex-col items-center justify-center lg:aspect-4/5">
<CoverPictureSkeleton />
</div>
<div className="flex w-full justify-center pt-12">
<SlideSelectSkeleton />
</div>
</div>
<div className="col-span-4 flex flex-col items-start justify-end pt-grid-gap-3 lg:pt-0">
<div className="h-[46px] w-full animate-pulse rounded-md bg-background-skeleton lg:mt-0" />
<div className="mt-grid-gap-2 h-[13px] w-[50%] animate-pulse rounded-md bg-background-skeleton lg:mt-7" />
</div>
<div className="col-span-4 mt-grid-gap-3 flex flex-col items-end justify-end lg:order-3 lg:mt-0">
<ButtonSkeleton />
<ButtonSkeleton />
</div>
</div>
)
}

export default WorkPageLayout
32 changes: 32 additions & 0 deletions components/shared/badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Meta, StoryObj } from "@storybook/react"

import { darkModeDecorator } from "@/.storybook/decorators"
import { Badge } from "@/components/shared/badge/Badge"

const meta = {
title: "components/Badge",
component: Badge,
parameters: {
layout: "centered",
},
argTypes: {
variant: {
control: { type: "select", options: ["default", "outline", "destructive", "blue-title"] },
},
},
args: {
variant: "blue-title",
},
} satisfies Meta<typeof Badge>

export default meta
type Story = StoryObj<typeof meta>

export const Default: Story = {
render: args => <Badge {...args}>Badge</Badge>,
}

export const DarkMode: Story = {
decorators: [darkModeDecorator],
render: args => <Badge {...args}>Badge</Badge>,
}
2 changes: 1 addition & 1 deletion components/shared/badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const badgeVariants = cva(
default: "bg-foreground text-background",
outline: "bg-secondary border-1 border border-foreground text-foreground",
destructive: "bg-destructive text-destructive-foreground",
"blue-title": "bg-blue-title",
"blue-title": "bg-blue-title text-blue-title-dark",
},
},
defaultVariants: {
Expand Down
10 changes: 5 additions & 5 deletions components/shared/badge/BadgeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const BadgeButton = ({
<button
onClick={onClick}
className={cn(
`focus-visible flex h-[28px] w-auto flex-row gap-2 self-start whitespace-nowrap rounded-full
bg-background-overlay px-4 py-2 text-typo-caption`,
`focus-visible flex h-[28px] w-auto flex-row justify-center gap-2 self-start whitespace-nowrap
rounded-full bg-background-overlay px-4 py-2 text-typo-caption`,
withAnimation ? "hover:animate-wiggle" : "",
variant === "transparent" ? "bg-transparent" : "",
isActive ? "bg-foreground text-background" : "",
classNames,
ariaLabel
)}>
classNames
)}
aria-label={ariaLabel}>
{children}
</button>
)
Expand Down
1 change: 0 additions & 1 deletion components/shared/button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const meta = {
parameters: {
layout: "centered",
},
tags: ["autodocs"],
} satisfies Meta<typeof Button>

export default meta
Expand Down
23 changes: 20 additions & 3 deletions components/shared/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
ariaLabel: string
ariaLabel?: string
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
Expand All @@ -70,12 +70,29 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
className={cn(buttonVariants({ variant, size }), className)}
ref={ref}
{...props}
aria-label={ariaLabel}
aria-label={ariaLabel || ""}
/>
)
}
)

Button.displayName = "Button"

export { Button, buttonVariants }
type ButtonSkeletonProps = {
size?: "sm" | "md" | "lg"
}

const ButtonSkeleton = ({ size }: ButtonSkeletonProps) => {
return (
<div
className={cn(
"mb-grid-gap-half w-full animate-pulse rounded-full bg-background-skeleton lg:min-w-72 lg:max-w-80",
size === "sm" ? "h-[32px]" : "",
size === "md" || !size ? "h-[40px]" : "",
size === "lg" ? "h-[48px]" : ""
)}
/>
)
}

export { Button, buttonVariants, ButtonSkeleton }
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading