Compare commits

...

3 Commits

Author SHA1 Message Date
c3f60b1e64 feat: extension icon label util component 2024-08-06 13:29:43 +02:00
6f05295cd0 docs: add comment for TooltipChild 2024-08-06 13:02:20 +02:00
21caaa7009 fix: sigit links and outline 2024-08-06 12:54:01 +02:00
6 changed files with 104 additions and 29 deletions

View File

@ -13,7 +13,7 @@ import {
faCalendar, faCalendar,
faCopy, faCopy,
faEye, faEye,
faFilePdf faFile
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { UserAvatar } from '../UserAvatar' import { UserAvatar } from '../UserAvatar'
@ -21,6 +21,7 @@ import { UserAvatarGroup } from '../UserAvatarGroup'
import styles from './style.module.scss' import styles from './style.module.scss'
import { TooltipChild } from '../TooltipChild' import { TooltipChild } from '../TooltipChild'
import { getExtensionIconLabel } from '../getExtensionIconLabel'
type SigitProps = { type SigitProps = {
meta: Meta meta: Meta
@ -28,30 +29,14 @@ type SigitProps = {
setProfiles: Dispatch<SetStateAction<{ [key: string]: ProfileMetadata }>> setProfiles: Dispatch<SetStateAction<{ [key: string]: ProfileMetadata }>>
} }
// function
// const ExtensionIconMapper = new Map<string, ReactNode>([
// [
// 'pdf',
// <>
// <FontAwesomeIcon icon={faFilePdf} /> PDF
// </>
// ],
// [
// 'csv',
// <>
// <FontAwesomeIcon icon={faFileCsv} /> CSV
// </>
// ]
// ])
export const DisplaySigit = ({ meta, profiles, setProfiles }: SigitProps) => { export const DisplaySigit = ({ meta, profiles, setProfiles }: SigitProps) => {
const { const {
title, title,
createdAt, createdAt,
submittedBy, submittedBy,
signers, signers,
signedStatus signedStatus,
// fileExtensions fileExtensions
} = useSigitMeta(meta) } = useSigitMeta(meta)
useEffect(() => { useEffect(() => {
@ -164,13 +149,17 @@ export const DisplaySigit = ({ meta, profiles, setProfiles }: SigitProps) => {
<span className={styles.iconLabel}> <span className={styles.iconLabel}>
<FontAwesomeIcon icon={faEye} /> {signedStatus} <FontAwesomeIcon icon={faEye} /> {signedStatus}
</span> </span>
<span className={styles.iconLabel}> {fileExtensions.length > 0 ? (
{/* {fileExtensions.map(ext => <span className={styles.iconLabel}>
{fileExtensions.length > 1 ? (
return <>
)} */} <FontAwesomeIcon icon={faFile} /> Multiple File Types
<FontAwesomeIcon icon={faFilePdf} /> {'PDF'} </>
</span> ) : (
getExtensionIconLabel(fileExtensions[0])
)}
</span>
) : null}
</div> </div>
<div className={styles.itemActions}> <div className={styles.itemActions}>
<Tooltip title="Duplicate" arrow placement="top" disableInteractive> <Tooltip title="Duplicate" arrow placement="top" disableInteractive>

View File

@ -6,6 +6,8 @@
background-color: $overlay-background-color; background-color: $overlay-background-color;
border-radius: 4px; border-radius: 4px;
outline: none !important;
display: flex; display: flex;
padding: 15px; padding: 15px;
gap: 15px; gap: 15px;
@ -79,6 +81,7 @@
.title { .title {
font-size: 20px; font-size: 20px;
color: $text-color;
} }
.users { .users {

View File

@ -1,5 +1,10 @@
import { forwardRef, PropsWithChildren } from 'react' import { forwardRef, PropsWithChildren } from 'react'
/**
* Helper wrapper for custom child components when using `@mui/material/tooltips`.
* Mui Tooltip works out-the-box with other `@mui` components but when using custom they require ref.
* @source https://mui.com/material-ui/react-tooltip/#custom-child-element
*/
export const TooltipChild = forwardRef<HTMLSpanElement, PropsWithChildren>( export const TooltipChild = forwardRef<HTMLSpanElement, PropsWithChildren>(
({ children, ...rest }, ref) => { ({ children, ...rest }, ref) => {
return ( return (

View File

@ -16,7 +16,11 @@ interface UserAvatarProps {
*/ */
export const UserAvatar = ({ pubkey, name, image }: UserAvatarProps) => { export const UserAvatar = ({ pubkey, name, image }: UserAvatarProps) => {
return ( return (
<Link to={getProfileRoute(pubkey)} className={styles.container}> <Link
to={getProfileRoute(pubkey)}
className={styles.container}
tabIndex={-1}
>
<AvatarIconButton <AvatarIconButton
src={image} src={image}
hexKey={pubkey} hexKey={pubkey}

View File

@ -0,0 +1,76 @@
import {
faFilePdf,
faFileExcel,
faFileWord,
faFilePowerpoint,
faFileZipper,
faFileCsv,
faFileLines,
faFileImage,
faFile,
IconDefinition
} from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
export const getExtensionIconLabel = (extension: string) => {
let icon: IconDefinition
switch (extension.toLowerCase()) {
case 'pdf':
icon = faFilePdf
break
case 'json':
icon = faFilePdf
break
case 'xslx':
case 'xsl':
icon = faFileExcel
break
case 'doc':
case 'docx':
icon = faFileWord
break
case 'ppt':
case 'pptx':
icon = faFilePowerpoint
break
case 'zip':
case '7z':
case 'rar':
case 'tar':
case 'gz':
icon = faFileZipper
break
case 'csv':
icon = faFileCsv
break
case 'txt':
icon = faFileLines
break
case 'png':
case 'jpg':
case 'jpeg':
case 'gif':
case 'svg':
case 'bmp':
case 'ico':
icon = faFileImage
break
default:
icon = faFile
return
}
return (
<>
<FontAwesomeIcon icon={icon} /> {extension.toUpperCase()}
</>
)
}

View File

@ -103,8 +103,6 @@ export const HomePage = () => {
const [isFilterVisible, setIsFilterVisible] = useState(true) const [isFilterVisible, setIsFilterVisible] = useState(true)
const [sort, setSort] = useState<Sort>('asc') const [sort, setSort] = useState<Sort>('asc')
console.log(filter, sort)
return ( return (
<Container className={styles.container}> <Container className={styles.container}>
<div className={styles.header}> <div className={styles.header}>