-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FileCard): Add Link and Image to FileCard (#957)
- Loading branch information
Showing
12 changed files
with
212 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/components/src/components/FileCard/components/Avatar/Avatar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { FC } from "react"; | ||
import React from "react"; | ||
import IconImage from "../../../Icon/components/icons/IconImage"; | ||
import { IconFile } from "@/components/Icon/components/icons"; | ||
import { Avatar as AvatarComponent } from "@/components/Avatar"; | ||
import { Image } from "@/components/Image"; | ||
|
||
interface Props { | ||
type?: string; | ||
imageSrc?: string; | ||
} | ||
|
||
export const Avatar: FC<Props> = (props) => { | ||
const { type, imageSrc } = props; | ||
|
||
if (imageSrc) { | ||
return ( | ||
<AvatarComponent> | ||
<Image src={imageSrc} /> | ||
</AvatarComponent> | ||
); | ||
} | ||
|
||
return ( | ||
<AvatarComponent color="blue"> | ||
{type?.startsWith("image") ? <IconImage /> : <IconFile />} | ||
</AvatarComponent> | ||
); | ||
}; | ||
export default Avatar; |
1 change: 1 addition & 0 deletions
1
packages/components/src/components/FileCard/components/Avatar/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Avatar"; |
31 changes: 31 additions & 0 deletions
31
packages/components/src/components/FileCard/components/DeleteButton/DeleteButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { FC } from "react"; | ||
import React from "react"; | ||
import { Button } from "@/components/Button"; | ||
import styles from "@/components/FileCard/FileCard.module.scss"; | ||
import { IconClose } from "@/components/Icon/components/icons"; | ||
import locales from "../../locales/*.locale.json"; | ||
import { useLocalizedStringFormatter } from "react-aria"; | ||
|
||
interface Props { | ||
onDelete: () => void; | ||
} | ||
|
||
export const DeleteButton: FC<Props> = (props) => { | ||
const { onDelete } = props; | ||
const stringFormatter = useLocalizedStringFormatter(locales); | ||
|
||
return ( | ||
<Button | ||
className={styles.deleteButton} | ||
aria-label={stringFormatter.format(`fileCard.delete`)} | ||
size="s" | ||
variant="plain" | ||
color="secondary" | ||
onPress={onDelete} | ||
> | ||
<IconClose /> | ||
</Button> | ||
); | ||
}; | ||
|
||
export default DeleteButton; |
1 change: 1 addition & 0 deletions
1
packages/components/src/components/FileCard/components/DeleteButton/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./DeleteButton"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/docs/src/content/03-components/upload/file-card/examples/image.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FileCard from "@mittwald/flow-react-components/FileCard"; | ||
|
||
<FileCard | ||
type="image/jpg" | ||
name="image.jpg" | ||
sizeInBytes={47500} | ||
imageSrc="https://mittwald.github.io/flow/assets/mittwald_logo_rgb.jpg" | ||
/>; |
8 changes: 8 additions & 0 deletions
8
packages/docs/src/content/03-components/upload/file-card/examples/link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FileCard from "@mittwald/flow-react-components/FileCard"; | ||
|
||
<FileCard | ||
type="image/jpg" | ||
name="image.jpg" | ||
sizeInBytes={47500} | ||
href="#" | ||
/>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters