-
Notifications
You must be signed in to change notification settings - Fork 6
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 #20 from xyzith/feature/emailVerifyPage
feat email verify page & refine css
- Loading branch information
Showing
8 changed files
with
166 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
div.main-container{ | ||
background: rgb(225, 244, 255); | ||
display: flex; | ||
flex-direction: column; | ||
min-height: 100vh; | ||
} | ||
|
||
main { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
position: relative; | ||
padding: 100rem 0 50rem; | ||
box-sizing: border-box; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.email-verify-page { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
flex: 1; | ||
|
||
h1 { | ||
font-size: 50rem; | ||
} | ||
|
||
input { | ||
position: absolute; | ||
opacity: 0; | ||
pointer-events: none; | ||
} | ||
.verify-code { | ||
display: inline-block; | ||
height: 50rem; | ||
line-height: 50rem; | ||
font-size: 44rem; | ||
width: 44rem; | ||
margin: 8rem; | ||
border-bottom: 4rem solid; | ||
text-align: center; | ||
vertical-align: bottom; | ||
} | ||
|
||
.verify-message-container { | ||
margin-top: 10rem; | ||
height: 30rem; | ||
min-width: 10rem; | ||
} | ||
|
||
.verify-message { | ||
font-size: 24rem; | ||
animation: 0.5s ease-in 0s fadein; | ||
&.success { | ||
color: ForestGreen; | ||
svg path{ | ||
fill: ForestGreen; | ||
} | ||
} | ||
|
||
&.failed { | ||
color: FireBrick; | ||
svg path{ | ||
fill: FireBrick; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@media (orientation: portrait) { | ||
.email-verify-page { | ||
h1 { | ||
font-size: 36rem; | ||
} | ||
} | ||
} | ||
|
||
@keyframes fadein { | ||
from { | ||
opacity: 0; | ||
} | ||
|
||
to { | ||
opactity: 1; | ||
} | ||
} |
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,65 @@ | ||
import { useState } from 'react'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faExclamationTriangle, faCheck } from '@fortawesome/free-solid-svg-icons'; | ||
import './EmailVerifyPage.scss'; | ||
|
||
const CODE_LENGTH = 6; | ||
|
||
const VERIFY_RESULT = { | ||
PENDING: 0, | ||
PASSED: 1, | ||
FAILED: 2, | ||
}; | ||
|
||
const EmailVerifyPage = () => { | ||
const [verifyCode, setVerifyCode] = useState(''); | ||
const [verifyResult, setVerifyResult] = useState(VERIFY_RESULT.PENDING); | ||
|
||
const updateVerifyCode = (ev) => { | ||
const { value } = ev?.target || {}; | ||
if (value.length <= CODE_LENGTH) { | ||
setVerifyCode(value); | ||
} | ||
|
||
if (value.length === CODE_LENGTH) { | ||
// TODO: send verify codes | ||
setVerifyResult(VERIFY_RESULT.PASSED); | ||
} else if (value.length < CODE_LENGTH) { | ||
setVerifyResult(VERIFY_RESULT.PENDING); | ||
} | ||
}; | ||
|
||
const defaultCodes = new Array(CODE_LENGTH).fill(''); | ||
|
||
const codes = [...verifyCode.split(''), ...defaultCodes].slice(0, CODE_LENGTH); | ||
|
||
const renderCode = (code, idx) => (<span key={idx} className="verify-code">{code}</span>); | ||
|
||
const faileMessage = ( | ||
<div className="failed verify-message"> | ||
<FontAwesomeIcon icon={faExclamationTriangle} /> | ||
<span>驗證失敗</span> | ||
</div> | ||
); | ||
|
||
const successMessage = ( | ||
<div className="success verify-message"> | ||
<FontAwesomeIcon icon={faCheck} /> | ||
<span>驗證通過</span> | ||
</div> | ||
); | ||
|
||
return ( | ||
<label className="email-verify-page"> | ||
<input type="number" value={verifyCode} onChange={updateVerifyCode} /> | ||
<h1>請輸入Email驗證碼</h1> | ||
<div>{codes.map(renderCode)}</div> | ||
<div className="verify-message-container"> | ||
{(verifyResult === VERIFY_RESULT.FAILED) && faileMessage} | ||
{(verifyResult === VERIFY_RESULT.PASSED) && successMessage} | ||
</div> | ||
</label> | ||
); | ||
}; | ||
|
||
export default EmailVerifyPage; |
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