-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
171 additions
and
8 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
27 changes: 27 additions & 0 deletions
27
...es/toolkit/src/lib/use-instill-form/components/component-output/DownloadableFileField.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,27 @@ | ||
"use client"; | ||
|
||
import { Nullable } from "../../../type"; | ||
import { ComponentOutputFieldBaseProps } from "../../types"; | ||
import { FieldRoot } from "./FieldRoot"; | ||
|
||
export type DownloadableFileFieldProps = { | ||
file: Nullable<string>; | ||
} & ComponentOutputFieldBaseProps; | ||
|
||
export const DownloadableFileField = (props: DownloadableFileFieldProps) => { | ||
const { title, hideField, file } = props; | ||
|
||
return ( | ||
<FieldRoot title={title} fieldKey={`${title}-field`}> | ||
{!hideField && file ? ( | ||
<a | ||
className="text-semantic-accent-default hover:text-semantic-accent-hover cursor-pointer underline font-sans text-xs font-medium" | ||
download={`outout-${title}-download-file`} | ||
href={file} | ||
> | ||
Download file | ||
</a> | ||
) : null} | ||
</FieldRoot> | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
...s/toolkit/src/lib/use-instill-form/components/component-output/DownloadableFilesField.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,36 @@ | ||
"use client"; | ||
|
||
import { Nullable } from "../../../type"; | ||
import { ComponentOutputFieldBaseProps } from "../../types"; | ||
import { FieldRoot } from "./FieldRoot"; | ||
|
||
export type DownloadableFilesFieldProps = { | ||
files: Nullable<string>[]; | ||
} & ComponentOutputFieldBaseProps; | ||
|
||
export const DownloadableFilesField = (props: DownloadableFilesFieldProps) => { | ||
const { title, hideField, files } = props; | ||
|
||
return ( | ||
<FieldRoot title={title} fieldKey={`${title}-field`}> | ||
{!hideField ? ( | ||
<div className="flex flex-col gap-2 flex-wrap"> | ||
{files.map((file, index) => { | ||
if (!file) return null; | ||
|
||
return ( | ||
<a | ||
key={`${title}-download-file-${index}`} | ||
className="text-semantic-accent-default hover:text-semantic-accent-hover cursor-pointer underline font-sans text-xs font-medium" | ||
download={`outout-${title}-download-file-${index}`} | ||
href={file} | ||
> | ||
Download file | ||
</a> | ||
); | ||
})} | ||
</div> | ||
) : null} | ||
</FieldRoot> | ||
); | ||
}; |
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
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
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