Skip to content

Commit

Permalink
pin popup, error popup, error handling, tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterK0927 committed Aug 13, 2024
1 parent 686d7e8 commit e7be948
Show file tree
Hide file tree
Showing 10 changed files with 387 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
import * as React from 'react';
import {
StyledErrorPopup,
StyledErrorTitle,
StyledErrorMessage,
StyledErrorButtons,
StyledConfirmButton
} from './styles';
import { ErrorPopupProps } from '../../utils/types';

export const ErrorPopup: React.FC<ErrorPopupProps> = ({ message, onContinue }) => (
<StyledErrorPopup>
<StyledErrorTitle>
Action Incomplete!
</StyledErrorTitle>
<StyledErrorMessage>{message}</StyledErrorMessage>
<StyledErrorButtons>
<StyledConfirmButton onClick={onContinue} $continue>Continue</StyledConfirmButton>
</StyledErrorButtons>
</StyledErrorPopup>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
import styled from "styled-components";

export const StyledErrorPopup = styled('div')`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #323639;
border-radius: 24px;
padding: 20px 45px;
width: 595px;
display: flex;
flex-direction: column;
gap: 10px;
height: fit-content;
border: 1px solid #CACACA;
transition: height 0.3s ease;
overflow: hidden;
z-index: 1000;
`

export const StyledErrorTitle = styled('h2')<{ verification?: boolean }>`
color: Red;
font-family: Poppins;
font-size: ${p => p.verification ? '40px' : '45px'};
margin: 12px 0 0 0;
padding: 0;
font-style: normal;
font-weight: 400;
line-height: normal;
`

export const StyledErrorMessage = styled('p')`
color: #FFF;
font-family: Poppins;
font-size: 20px;
font-style: normal;
font-weight: 400;
line-height: normal;
margin-top: -5px;
`

export const StyledErrorName = styled('p')`
color: #FFF;
font-family: Poppins;
font-size: 25px;
font-style: normal;
margin: -10px 0 10px 0;
font-weight: 700;
line-height: normal;
`

export const StyledErrorButtons = styled('div')`
display: flex;
margin-top: 45px;
justify-content: center;
gap: 28px;
margin-left: 350px;
`

export const StyledConfirmButton = styled('button')<{ $continue?: boolean }>`
display: flex;
padding: 15px 35px;
align-items: baseline;
gap: 10px;
background-color: ${p => p.$continue ? '#2BB563' : 'white'};
color: ${p => p.$continue ? 'white' : 'black'};
border: none;
border-radius: 40px;
font-size: 16px;
cursor: pointer;
&:hover {
background-color: ${p => p.$continue ? '#2BB563' : '#2BB563'};
color: white;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import uploadLogo from '../../../assets/upload.svg';
import uploadHoverLogo from '../../../assets/uploadHover.svg';
import { AnimatedStatus } from '../AnimatedStatus/AnimatedStatus';
import { HeaderProps } from '../../utils/types';
import { Tooltip } from '../ToolTip/ToolTip';

export const Header: React.FC<HeaderProps> = ({
pdfFileName,
Expand All @@ -57,8 +58,13 @@ export const Header: React.FC<HeaderProps> = ({
statusType,
handleLogoClick,
fileInputRef,
isSigned,
}) => {
const [logoSrc, setLogoSrc] = useState(uploadLogo);
const [showPDFNameTooltip, setShowPDFNameTooltip] = useState(false);
const [showVerificationTooltip, setShowVerificationTooltip] = useState(false);
const [showHelpTooltip, setShowHelpTooltip] = useState(false);

const renderPageNumber = () => (
isEditingPageNumber ? (
<form onSubmit={handlePageNumberSubmit}>
Expand Down Expand Up @@ -92,13 +98,21 @@ export const Header: React.FC<HeaderProps> = ({
<StyledFadeAway fadeAnimation={isStatusVisible}>
<StyledHeaderButton pdfFile={pdfFile} onClick={handleSignButtonClick}>Add signature</StyledHeaderButton>
<StyledHeaderControlsBar />
<StyledHeaderButton
pdfFile={pdfFile}
onClick={handleVerifyButtonClick}
as={isVerified ? StyledVerified : isVerificationFailed ? StyledNotVerified : 'button'}
<Tooltip
text="Verification failed. Please check the document."
isVisible={showVerificationTooltip && isVerificationFailed}
isError={true}
>
Verify document
</StyledHeaderButton>
<StyledHeaderButton
pdfFile={pdfFile}
onClick={handleVerifyButtonClick}
as={isVerified ? StyledVerified : isVerificationFailed ? StyledNotVerified : 'button'}
onMouseEnter={() => setShowVerificationTooltip(true)}
onMouseLeave={() => setShowVerificationTooltip(false)}
>
Verify document
</StyledHeaderButton>
</Tooltip>
<StyledHeaderControlsBar />
</StyledFadeAway>
</>
Expand All @@ -111,39 +125,60 @@ export const Header: React.FC<HeaderProps> = ({
<StyledHeader>
<StyledNavBar>
<StyledPDFLogoContainer>
<StyledPDFLogo
src={logoSrc}
alt="PDF Logo"
onClick={handleLogoClick}
onMouseEnter={() => setLogoSrc(uploadHoverLogo)}
onMouseLeave={() => setLogoSrc(uploadLogo)}
/>
<input
type="file"
ref={fileInputRef}
style={{ display: 'none' }}
/>
<StyledPDFName>{pdfFileName}</StyledPDFName>
<StyledPDFLogo
src={logoSrc}
alt="PDF Logo"
onClick={handleLogoClick}
onMouseEnter={() => setLogoSrc(uploadHoverLogo)}
onMouseLeave={() => setLogoSrc(uploadLogo)}
/>
<input
type="file"
ref={fileInputRef}
style={{ display: 'none' }}
/>
<Tooltip
text={pdfFileName}
isVisible={showPDFNameTooltip}
>
<StyledPDFName
onMouseEnter={() => setShowPDFNameTooltip(true)}
onMouseLeave={() => setShowPDFNameTooltip(false)}
>
{pdfFileName}
</StyledPDFName>
</Tooltip>
</StyledPDFLogoContainer>
<StyledHeaderControlsContainer>
<StyledHeaderControls>
{renderHeaderControls()}
<StyledPageChangingControls>
<StyledPageControl as="div" direction="previous" pdfFile={pdfFile} onClick={handlePreviousPage}>&lt;</StyledPageControl>
<StyledPageNumber>
{renderPageNumber()}
</StyledPageNumber>
<StyledPageControl as="div" direction="next" pdfFile={pdfFile} onClick={handleNextPage}>&gt;</StyledPageControl>
</StyledPageChangingControls>
</StyledHeaderControls>
<StyledSaveButton onClick={handleDownloadButtonClick} disabled={!pdfFile} pdfFile={pdfFile}>Save</StyledSaveButton>
<StyledHeaderControls>
{renderHeaderControls()}
<StyledPageChangingControls>
<StyledPageControl as="div" direction="previous" pdfFile={pdfFile} onClick={handlePreviousPage}>&lt;</StyledPageControl>
<StyledPageNumber>
{renderPageNumber()}
</StyledPageNumber>
<StyledPageControl as="div" direction="next" pdfFile={pdfFile} onClick={handleNextPage}>&gt;</StyledPageControl>
</StyledPageChangingControls>
</StyledHeaderControls>
<StyledSaveButton isSigned={isSigned} onClick={handleDownloadButtonClick} disabled={!pdfFile} pdfFile={pdfFile}>Save</StyledSaveButton>
</StyledHeaderControlsContainer>
<StyledHelpButtonContainer>
<a href="https://ping-browser.com/help-1" target="_blank" rel="noopener noreferrer">
<StyledHelpButton>?</StyledHelpButton>
</a>
<Tooltip
text="Get help"
isVisible={showHelpTooltip}
>
<a
href="https://ping-browser.com/help-1"
target="_blank"
rel="noopener noreferrer"
onMouseEnter={() => setShowHelpTooltip(true)}
onMouseLeave={() => setShowHelpTooltip(false)}
>
<StyledHelpButton>?</StyledHelpButton>
</a>
</Tooltip>
</StyledHelpButtonContainer>
</StyledNavBar>
</StyledNavBar>
</StyledHeader>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

interface StyledDisabledProps {
pdfFile?: Blob | null;
isSigned?: boolean;
}

const breakpoints = {
Expand Down Expand Up @@ -205,6 +206,7 @@ export const StyledNavBar = styled('nav')`
margin-right: 12px;
cursor: pointer;
margin-left: 20px;
visibility: ${({ isSigned }) => (isSigned ? 'visible' : 'hidden')};
`;

export const StyledHelpButton = styled('button')`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at https://mozilla.org/MPL/2.0/. */
import { useState } from 'react';
import * as React from 'react';
import { PopupContainer, PopupContent, Title, InputField, ButtonContainer, BackButton, CompleteButton, InputWrapper, EyeButton } from './styles';

interface InputPopupProps {
userName: string;
onBack: () => void;
onComplete: (pin: string) => void;
}

const InputPopup: React.FC<InputPopupProps> = ({ userName, onBack, onComplete }) => {
const [pin, setPin] = useState('');
const [showPassword, setShowPassword] = useState(false);

const handlePinChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setPin(event.target.value);
};

const handleComplete = () => {
onComplete(pin);
};

const togglePasswordVisibility = () => {
setShowPassword(!showPassword);
};

return (
<PopupContainer>
<PopupContent>
<Title>{userName}</Title>
<InputWrapper>
<InputField
type={showPassword ? "text" : "password"}
placeholder="Please enter your signature pin"
value={pin}
onChange={handlePinChange}
/>
<EyeButton onClick={togglePasswordVisibility}>
{showPassword ? "👁️" : "👁️‍🗨️"}
</EyeButton>
</InputWrapper>
<ButtonContainer>
<BackButton onClick={onBack}>Back</BackButton>
<CompleteButton onClick={handleComplete}>Complete signature</CompleteButton>
</ButtonContainer>
</PopupContent>
</PopupContainer>
);
};

export default InputPopup;
Loading

0 comments on commit e7be948

Please sign in to comment.