-
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.
feat(ui): implement paste connection peer id modal
- Loading branch information
Vu Van Duc
authored and
Vu Van Duc
committed
May 9, 2024
1 parent
7a673d6
commit 1de029d
Showing
9 changed files
with
142 additions
and
5 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
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
42 changes: 42 additions & 0 deletions
42
src/ui/pages/Menu/components/PasteConnectionPeerIdModal/PasteConnectionPeerIdModal.scss
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,42 @@ | ||
.input-pid-modal { | ||
& ion-buttons.buttons-last-slot { | ||
min-width: auto !important; | ||
|
||
.action-button-label { | ||
& > p { | ||
color: var(--ion-color-action-blue) !important; | ||
} | ||
} | ||
} | ||
|
||
ion-input { | ||
border-radius: 0.5rem; | ||
border: 1px solid var(--ion-color-dark-grey); | ||
margin-top: 0.5rem; | ||
min-height: 1.25rem; | ||
|
||
input { | ||
overflow: hidden; | ||
padding: 0.875rem 1.25rem !important; | ||
font-size: 1rem; | ||
font-weight: 400 !important; | ||
color: var(--ion-color-secondary) !important; | ||
} | ||
|
||
&.has-focus { | ||
border-color: var(--ion-color-secondary); | ||
} | ||
} | ||
|
||
.secondary-button { | ||
width: 100%; | ||
} | ||
|
||
@media screen and (min-width: 250px) and (max-width: 370px) { | ||
ion-input { | ||
input { | ||
padding: 0.5rem 1rem !important; | ||
} | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/ui/pages/Menu/components/PasteConnectionPeerIdModal/PasteConnectionPeerIdModal.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,63 @@ | ||
import { IonButton, IonInput } from "@ionic/react"; | ||
import { useState } from "react"; | ||
import { i18n } from "../../../../../i18n"; | ||
import { OptionModal } from "../../../../components/OptionsModal"; | ||
import { PasteConnectionPeerIdModalProps } from "./PasteConnectionPeerIdModal.types"; | ||
import "./PasteConnectionPeerIdModal.scss"; | ||
|
||
const PasteConnectionPeerIdModal = ({ | ||
openModal, | ||
onCloseModal, | ||
onConfirm, | ||
onScanQR, | ||
}: PasteConnectionPeerIdModalProps) => { | ||
const [pid, setPid] = useState(""); | ||
|
||
const handleClose = () => { | ||
setPid(""); | ||
onCloseModal(); | ||
}; | ||
|
||
const confirm = () => { | ||
onConfirm(pid); | ||
handleClose(); | ||
}; | ||
|
||
const handleScanQR = () => { | ||
onScanQR(); | ||
handleClose(); | ||
}; | ||
|
||
return ( | ||
<OptionModal | ||
modalIsOpen={openModal} | ||
componentId="input-pid-modal" | ||
onDismiss={handleClose} | ||
customClasses="input-pid-modal" | ||
header={{ | ||
closeButton: true, | ||
closeButtonAction: handleClose, | ||
closeButtonLabel: `${i18n.t("connectwallet.inputpidmodal.cancel")}`, | ||
actionButton: true, | ||
actionButtonLabel: `${i18n.t("connectwallet.inputpidmodal.confirm")}`, | ||
actionButtonAction: confirm, | ||
title: `${i18n.t("connectwallet.inputpidmodal.header")}`, | ||
}} | ||
> | ||
<IonInput | ||
data-testid="input-pid" | ||
value={pid} | ||
onIonInput={(event) => setPid(event.target.value as string)} | ||
/> | ||
<IonButton | ||
className="secondary-button" | ||
data-testid="scanqr-btn" | ||
onClick={handleScanQR} | ||
> | ||
{i18n.t("connectwallet.inputpidmodal.scanQR")} | ||
</IonButton> | ||
</OptionModal> | ||
); | ||
}; | ||
|
||
export { PasteConnectionPeerIdModal }; |
8 changes: 8 additions & 0 deletions
8
src/ui/pages/Menu/components/PasteConnectionPeerIdModal/PasteConnectionPeerIdModal.types.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,8 @@ | ||
interface PasteConnectionPeerIdModalProps { | ||
onConfirm: (pid: string) => void; | ||
openModal: boolean; | ||
onCloseModal: () => void; | ||
onScanQR: () => void; | ||
} | ||
|
||
export type { PasteConnectionPeerIdModalProps }; |
1 change: 1 addition & 0 deletions
1
src/ui/pages/Menu/components/PasteConnectionPeerIdModal/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 "./PasteConnectionPeerIdModal"; |