fix upload

This commit is contained in:
rizky 2024-07-29 18:25:20 -07:00
parent c3bb624d25
commit 04dca7fa96
1 changed files with 47 additions and 30 deletions

View File

@ -119,21 +119,36 @@ export const FieldUpload: FC<{
input.ref.value = null; input.ref.value = null;
} }
}; };
if (isEditor) input.fase = "start";
return ( return (
<div className="c-flex-grow c-flex-row c-flex c-w-full c-h-full c-items-stretch"> <div className="c-flex-grow c-flex-row c-flex c-w-full c-h-full c-items-stretch">
{input.fase === "start" ? ( {input.fase === "start" ? (
<> <>
<div className="c-flex c-flex-row c-relative c-flex-grow c-items-center"> <div
<input className={cx(
ref={(ref) => (input.ref = ref)} "c-flex c-flex-row c-relative c-flex-grow c-items-center c-cursor-pointer hover:c-bg-blue-50",
type="file" css`
multiple={false} input[type="file"],
onChange={on_upload} input[type="file"]::-webkit-file-upload-button {
className={cx( cursor: pointer;
"c-absolute c-w-full c-h-full c-cursor-pointer c-top-0 c-left-0 c-opacity-0" }
)} `
/> )}
{styling === "inline" ? ( >
{!isEditor && (
<input
ref={(ref) => (input.ref = ref)}
type="file"
multiple={false}
onChange={on_upload}
className={cx(
"c-absolute c-w-full c-h-full c-cursor-pointer c-top-0 c-left-0 c-opacity-0"
)}
/>
)}
{styling !== "full" ? (
<> <>
<div <div
onClick={() => { onClick={() => {
@ -148,7 +163,7 @@ export const FieldUpload: FC<{
<Upload className="c-h-4 c-w-4" /> <Upload className="c-h-4 c-w-4" />
</div> </div>
<div className="c-flex c-flex-row c-items-center"> <div className="c-flex c-flex-row c-items-center">
Upload Your File Upload File
</div> </div>
</div> </div>
</> </>
@ -281,23 +296,25 @@ const Filename = ({ url }: { url: string }) => {
const color = darkenColor(generateRandomColor(file.extension)); const color = darkenColor(generateRandomColor(file.extension));
return ( return (
<> <>
<div {file.extension && (
className={cx( <div
css` className={cx(
border: 1px solid ${color}; css`
color: ${color}; border: 1px solid ${color};
border-radius: 3px; color: ${color};
text-transform: uppercase; border-radius: 3px;
padding: 0px 5px; text-transform: uppercase;
font-size: 9px; padding: 0px 5px;
height: 15px; font-size: 9px;
margin-right: 5px; height: 15px;
`, margin-right: 5px;
"c-flex c-items-center" `,
)} "c-flex c-items-center"
> )}
{file.extension} >
</div> {file.extension}
</div>
)}
<div <div
className={cx( className={cx(
css` css`
@ -305,7 +322,7 @@ const Filename = ({ url }: { url: string }) => {
` `
)} )}
> >
Open in New Tab View File in New Tab
</div> </div>
</> </>
); );