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

#1299 Update FileList component according to DS #1311

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
9 changes: 7 additions & 2 deletions next/components/cards/FileCardWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ import { useLocale } from '@/utils/useLocale'
export type FileCardWrapperProps = {
fileItem: FileItemBlockFragment
variant?: 'grid' | 'rows'
hideBottomDivider?: boolean
}

/**
* Figma: https://www.figma.com/file/17wbd0MDQcMW9NbXl6UPs8/DS-ESBS%2BBK%3A-Component-library?type=design&node-id=7367-17767&t=Km8W7qXXiWIDWSYw-0
*/
const FileCardWrapper = ({ fileItem, variant = 'grid' }: FileCardWrapperProps) => {
const FileCardWrapper = ({
fileItem,
variant = 'grid',
hideBottomDivider,
}: FileCardWrapperProps) => {
const locale = useLocale()
const { getDownloadAriaLabel } = useGetDownloadAriaLabel()

Expand All @@ -41,7 +46,7 @@ const FileCardWrapper = ({ fileItem, variant = 'grid' }: FileCardWrapperProps) =
const transformedProps = transformFileProps(fileItem)

return variant === 'rows' ? (
<FileRowCard {...transformedProps} />
<FileRowCard {...transformedProps} hideBottomDivider={hideBottomDivider} />
) : (
<FileCard {...transformedProps} />
)
Expand Down
14 changes: 9 additions & 5 deletions next/components/common/FileList/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ const FileList = ({ className, fileSections, hideCategory, variantFileList }: Fi
<Typography type="h2">{fileSection.category}</Typography>
)}
{variantFileList === 'rows' && (
<div className="mt-4 flex flex-col lg:mt-6">
<ul className="mt-4 flex flex-col rounded-lg border-2 py-2 lg:mt-6">
{fileSection?.files.map((file, fileIndex) => (
// eslint-disable-next-line react/no-array-index-key
<div key={fileIndex} className="w-full">
<FileCardWrapper fileItem={file} variant={variantFileList} />
</div>
<li key={fileIndex} className="w-full">
<FileCardWrapper
fileItem={file}
variant={variantFileList}
hideBottomDivider={fileIndex === (fileSection?.files?.length ?? false) - 1}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
hideBottomDivider={fileIndex === (fileSection?.files?.length ?? false) - 1}
hideBottomDivider={fileIndex === fileSection.files.length - 1}

Operators ?. and ?? are not needed, because the files array is defined. We use these only when necessary :)

/>
</li>
))}
</div>
</ul>
)}
{variantFileList === 'grid' && (
<div>
Expand Down
Loading