-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Sphereon-Opensource/feat/CWALL-250
feat/CWALL-250
- Loading branch information
Showing
10 changed files
with
365 additions
and
52 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
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
71 changes: 71 additions & 0 deletions
71
packages/web-wallet/src/components/modals/ImportFileModal/index.module.css
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,71 @@ | ||
.overlay { | ||
position: absolute; | ||
z-index: 1; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(217,217,217, 0.6); | ||
align-items: center; | ||
justify-content: center; | ||
display: flex; | ||
} | ||
|
||
.container { | ||
border-radius: 24px; | ||
background-color: #FBFBFB; | ||
overflow: hidden; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.headerContainer { | ||
display: flex; | ||
flex-direction: row; | ||
padding-left: 49px; | ||
padding-right: 15px; | ||
} | ||
|
||
.headerCaptionContainer { | ||
flex-grow: 1; | ||
padding-top: 50px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
} | ||
|
||
.headerCloseContainer { | ||
margin-left: auto; | ||
padding-top: 16px; | ||
} | ||
|
||
.closeButton { | ||
display: flex; | ||
aspect-ratio: 1; | ||
cursor: pointer; | ||
align-items: center; | ||
justify-content: center; | ||
width: 52px; | ||
} | ||
|
||
.titleCaption { | ||
font-size: 24px; | ||
font-style: normal; | ||
font-weight: 500; | ||
line-height: normal; | ||
} | ||
|
||
.subTitleCaption { | ||
font-size: 14px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: normal; | ||
letter-spacing: 0.14px; | ||
} | ||
|
||
.contentContainer { | ||
padding: 24px 49px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 24px; | ||
} |
94 changes: 94 additions & 0 deletions
94
packages/web-wallet/src/components/modals/ImportFileModal/index.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,94 @@ | ||
import React, {FC, ReactElement, useState} from 'react'; | ||
import {useTranslate} from '@refinedev/core'; | ||
import {PrimaryButton} from '@sphereon/ui-components.ssi-react'; | ||
import CrossIcon from '@components/assets/icons/CrossIcon'; | ||
import DragAndDropBox from '@components/fields/DragAndDropBox'; | ||
import FileSelectionField from '@components/fields/FileSelectionField'; | ||
import style from './index.module.css' | ||
|
||
type Props = { | ||
headerTitle?: string | ||
headerSubTitle?: string | ||
dragBoxCaption: string | ||
dragBoxDescription?: string | ||
onImportFile: (file: File) => Promise<void> | ||
onValidateFile?: (file: File) => Promise<boolean> | ||
onClose: () => Promise<void> | ||
fileMask?: RegExp | ||
} | ||
|
||
const ImportFileModal: FC<Props> = (props: Props): ReactElement => { | ||
const { | ||
headerTitle, | ||
headerSubTitle, | ||
dragBoxCaption, | ||
dragBoxDescription, | ||
onImportFile, | ||
onValidateFile, | ||
onClose | ||
} = props | ||
const translate = useTranslate() | ||
const [file, setFile] = useState<File | undefined>() | ||
|
||
const onChangeFile = async (file: File): Promise<void> => { | ||
if (onValidateFile) { | ||
const validationResult = await onValidateFile(file).then( | ||
(result) => result, | ||
() => false | ||
); | ||
|
||
if (!validationResult) { | ||
return | ||
} | ||
} | ||
|
||
setFile(file) | ||
} | ||
|
||
const onImport = async (): Promise<void> => { | ||
if (!file) { | ||
return | ||
} | ||
|
||
void onImportFile(file) | ||
} | ||
|
||
return ( | ||
<div | ||
className={style.overlay} | ||
onClick={onClose} | ||
> | ||
<div className={style.container} onClick={(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => event.stopPropagation()}> | ||
<div className={style.headerContainer}> | ||
{(headerTitle || headerSubTitle) && | ||
<div className={style.headerCaptionContainer}> | ||
{headerTitle && <div className={style.titleCaption}>{headerTitle}</div>} | ||
{headerSubTitle && <div className={style.subTitleCaption}>{headerSubTitle}</div>} | ||
</div> | ||
} | ||
<div className={style.headerCloseContainer}> | ||
<div className={style.closeButton} onClick={onClose}> | ||
<CrossIcon /> | ||
</div> | ||
</div> | ||
</div> | ||
<div className={style.contentContainer}> | ||
<DragAndDropBox | ||
caption={dragBoxCaption} | ||
description={dragBoxDescription} | ||
onChangeFile={onChangeFile} | ||
/> | ||
{file && <FileSelectionField file={file} />} | ||
<PrimaryButton | ||
style={{width: 180, marginLeft: 'auto'}} | ||
caption={translate('action_import_label')} | ||
disabled={!file} | ||
onClick={onImport} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ImportFileModal |
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
Oops, something went wrong.