-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: 819 upload component improvements #820
Conversation
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
=======================================
Coverage 90.26% 90.26%
=======================================
Files 163 163
Lines 6061 6061
Branches 927 927
=======================================
Hits 5471 5471
Misses 590 590
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
${({ $v2 }) => | ||
$v2 && | ||
css` | ||
aspect-ratio: 1/1; | ||
padding-inline: 1.5rem; | ||
background: ${colors.white}; | ||
min-width: 9.375rem; | ||
width: auto; | ||
height: auto; | ||
border-radius: 12px; | ||
border: 2px solid ${theme.colors.light.border}; | ||
color: ${theme.colors.light.greyText}; | ||
`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${({ $v2 }) => | |
$v2 && | |
css` | |
aspect-ratio: 1/1; | |
padding-inline: 1.5rem; | |
background: ${colors.white}; | |
min-width: 9.375rem; | |
width: auto; | |
height: auto; | |
border-radius: 12px; | |
border: 2px solid ${theme.colors.light.border}; | |
color: ${theme.colors.light.greyText}; | |
`} | |
${({ theme : {overrides}) => overrides} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theme.overrides should be what css`` returns which isRuleSet<object>
and these styles should be passed in the Upload component in fermion react-kit
@@ -137,6 +137,8 @@ export type UploadProps = BaseProps & { | |||
borderRadiusUnit?: "px" | "%"; | |||
width?: number; | |||
height?: number; | |||
errorComponent?: (errorMessage: string) => React.ReactNode; | |||
v2?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2?: boolean; |
@@ -39,7 +40,7 @@ export function WithUploadToIpfs<P extends WithUploadToIpfsProps>( | |||
const { saveFile, loadMedia, removeFile } = useSaveImageToIpfs(); | |||
|
|||
const saveToIpfs: WithUploadToIpfsProps["saveToIpfs"] = useCallback( | |||
async (filesArray: File[] | null) => { | |||
async (filesArray: File[] | null, throwOnError?: boolean) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async (filesArray: File[] | null, throwOnError?: boolean) => { | |
async (filesArray: File[] | null, options:{throwOnError?:boolean}={}) => { |
`There has been an error because 'files' ${files} is falsy in handleSave` | ||
); | ||
try { | ||
const files = await saveToIpfs(efiles, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const files = await saveToIpfs(efiles, true); | |
const files = await saveToIpfs(efiles, {throwOnError:true}); |
@@ -52,6 +52,8 @@ function BaseUpload({ | |||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |||
removeFile, | |||
saveButtonTheme, | |||
errorComponent, | |||
v2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2, |
@@ -128,6 +128,7 @@ export type FileUploadWrapperTheme = Partial<{ | |||
}>; | |||
export const FileUploadWrapper = styled.div<{ | |||
$error: unknown; | |||
$v2?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$v2?: boolean; |
} catch (err) { | ||
if (err instanceof Error) { | ||
setErrorMessage(err.message); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
}else{ | |
setErrorMessage("Something went wrong"); | |
} |
@@ -306,6 +319,7 @@ function BaseUpload({ | |||
data-disabled={disabled} | |||
onClick={handleChooseFile} | |||
$error={errorMessage} | |||
$v2={v2} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$v2={v2} |
…upload_component_fix
No description provided.