-
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.
frontend: Implement MessageBox interactions
- Loading branch information
Showing
16 changed files
with
395 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { withReveal } from '../../hoc/withReveal' | ||
import { Input } from './index' | ||
|
||
export const RevealInput = withReveal(Input) |
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,67 @@ | ||
.input { | ||
width: 100%; | ||
position: relative; | ||
|
||
input { | ||
width: 100%; | ||
height: 2.8125rem; | ||
font-size: 16px; | ||
font-weight: 700; | ||
line-height: 24px; | ||
padding-inline-start: 24px; | ||
padding-inline-end: 15px; | ||
border-radius: 4px; | ||
min-width: 0; | ||
outline: 2px solid transparent; | ||
outline-offset: 2px; | ||
position: relative; | ||
appearance: none; | ||
transition-property: border; | ||
transition-duration: 100ms; | ||
border: 2px solid var(--brand-blue); | ||
color: var(--brand-extra-dark); | ||
} | ||
|
||
label { | ||
display: block; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
z-index: 2; | ||
background-color: var(--white); | ||
pointer-events: none; | ||
margin-inline-start: 1.5rem; | ||
margin-inline-end: 0.75rem; | ||
margin-top: 0.65625rem; | ||
margin-bottom: 0.65625rem; | ||
font-size: 16px; | ||
font-weight: 500; | ||
line-height: 24px; | ||
color: var(--brand-blue); | ||
transform-origin: left top; | ||
transition-property: transform, font-size, line-height; | ||
transition-duration: 200ms; | ||
} | ||
|
||
input + label, | ||
&:focus-within label { | ||
transform: translateY(-16px); | ||
font-size: 12px; | ||
font-weight: 700; | ||
line-height: 18px; | ||
padding-inline-start: 0.5rem; | ||
padding-inline-end: 0.5rem; | ||
margin-inline-start: 1rem; | ||
margin-top: 0.5rem; | ||
margin-bottom: 0.5rem; | ||
} | ||
} | ||
|
||
.inputDisabled { | ||
pointer-events: none; | ||
cursor: not-allowed; | ||
} | ||
|
||
.inputError { | ||
margin-top: 0.5rem; | ||
} |
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,40 @@ | ||
import { ChangeEventHandler, FC, useId } from 'react' | ||
import classes from './index.module.css' | ||
import { StringUtils } from '../../utils/string.utils' | ||
|
||
interface Props { | ||
required?: boolean | ||
label?: string | ||
error?: string | ||
className?: string | ||
value?: string | ||
disabled?: boolean | ||
onChange?: (value: string) => void | ||
} | ||
|
||
export const Input: FC<Props> = ({ required, label, error, className, disabled, value, onChange }) => { | ||
const id = useId() | ||
|
||
return ( | ||
<div className={className}> | ||
<div className={classes.input}> | ||
<input | ||
value={value} | ||
placeholder=" " | ||
id={id} | ||
required={required} | ||
onChange={ | ||
(({ target: { value } }) => { | ||
onChange?.(value) | ||
}) as ChangeEventHandler<HTMLInputElement> | ||
} | ||
autoComplete="off" | ||
disabled={disabled} | ||
className={StringUtils.clsx(disabled ? classes.inputDisabled : undefined)} | ||
/> | ||
<label htmlFor={id}>{label}</label> | ||
</div> | ||
{error && <p className={StringUtils.clsx('error', classes.inputError)}>{error}</p>} | ||
</div> | ||
) | ||
} |
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,20 @@ | ||
.mask { | ||
position: relative; | ||
|
||
&:after { | ||
content: attr(data-label); | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
width: 100%; | ||
height: 100%; | ||
background-color: var(--brand-blue); | ||
color: white; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
border-radius: 4px; | ||
} | ||
} |
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,38 @@ | ||
import { FC, useEffect, useState } from 'react' | ||
import classes from './index.module.css' | ||
import { StringUtils } from '../utils/string.utils' | ||
|
||
type RevealProps<T> = { | ||
reveal: boolean | ||
revealLabel?: string | ||
onRevealChange: (reveal: boolean) => void | ||
} & T | ||
|
||
export const withReveal = | ||
<P1 extends object>(Component: FC<P1>) => | ||
(props: RevealProps<P1>) => { | ||
const { reveal, revealLabel, onRevealChange, ...restProps } = props as RevealProps<P1> | ||
|
||
const [isRevealed, setIsRevealed] = useState(false) | ||
|
||
useEffect(() => { | ||
setIsRevealed(isRevealed) | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [reveal]) | ||
|
||
return ( | ||
<div | ||
data-label={revealLabel ?? 'Tap to reveal'} | ||
className={StringUtils.clsx(isRevealed && !revealLabel ? undefined : classes.mask)} | ||
onClick={() => { | ||
if (isRevealed) { | ||
return | ||
} | ||
setIsRevealed(true) | ||
onRevealChange(true) | ||
}} | ||
> | ||
<Component {...(restProps as P1)} /> | ||
</div> | ||
) | ||
} |
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,2 +1,20 @@ | ||
.homePage { | ||
} | ||
|
||
.connectWalletText { | ||
text-align: center; | ||
} | ||
|
||
.activeMessageText { | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.setMessageText { | ||
margin: 2rem 0 1rem; | ||
} | ||
|
||
.setMessageActions { | ||
display: flex; | ||
justify-content: center; | ||
padding-top: 1rem; | ||
} |
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
Oops, something went wrong.