Skip to content

Commit

Permalink
Merge pull request #189 from mintlayer/dev
Browse files Browse the repository at this point in the history
* feat: add nested navigation and wallets menu

* feat: add Textarea basic component, replace textarea with new component on Restore wallet

* feat: add new array helpers

* feat: add Sign and Verify message components

* feat: add Message page

* feat: update MIntlayer lib with new messages functions update Textarea

* chore: remove console.log

* feat: add message verification

* feat: update wasm library (#187)

* feat: replace signing/verify function with verifyChallenge and signChallenge

* feat: remove steps from signin

* feat: remove steps from verify

---------

Co-authored-by: Sergey <[email protected]>
  • Loading branch information
owlsua and anyxem authored Oct 1, 2024
2 parents 8a77936 + 8f77279 commit 89e0e48
Show file tree
Hide file tree
Showing 28 changed files with 2,028 additions and 298 deletions.
8 changes: 8 additions & 0 deletions src/assets/images/icon-checkmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/assets/images/icon-cross.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/images/icon-triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/images/icon-wallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.seed-textarea {
.textarea {
width: 100%;
padding: 15px;
resize: none;
}

.seed-textarea.seed-invalid {
.textaria-invalid {
border-bottom: 2px solid rgb(var(--color-red));
}

.seed-textarea.seed-valid {
.textaria-valid {
border-bottom: 2px solid rgb(var(--color-green));
}
49 changes: 49 additions & 0 deletions src/components/basic/Textarea/Textarea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React, { useEffect, useState } from 'react'
import './Textarea.css'

const Textarea = ({
value,
onChange,
extraClasses,
id,
size,
validity = true,
disabled,
}) => {
const [textareaVakue, setTextareaValue] = useState(value ? value : '')

useEffect(() => {
setTextareaValue(value)
}, [value])

const getExtraClasses = () => {
if (value && validity) {
return 'textaria-valid'
} else if (value && !validity) {
return 'textaria-invalid'
} else {
return ''
}
}
const onChangeHandler = ({ target }) => {
onChange && onChange({ target })
setTextareaValue(target.value)
getExtraClasses()
}

return (
<textarea
data-testid={id}
value={textareaVakue}
onChange={onChangeHandler}
className={`textarea ${getExtraClasses()} ${extraClasses}`}
name={id}
id={id}
cols={size.cols}
rows={size.rows}
readOnly={disabled}
/>
)
}

export default Textarea
2 changes: 2 additions & 0 deletions src/components/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Logo from './Logo/Logo'
import LogoRound from './LogoRound/LogoRound'
import SkeletonLoader from './SkeletonLoader/SkeletonLoader'
import Tooltip from './Tooltip/Tooltip'
import Textarea from './Textarea/Textarea'

export {
Arc,
Expand All @@ -28,4 +29,5 @@ export {
LogoRound,
SkeletonLoader,
Tooltip,
Textarea,
}
58 changes: 51 additions & 7 deletions src/components/composed/Navigation/Navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,40 @@
padding: 10px 5px;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
}

.bottom-menu-item:last-child {
.navigation-item {
position: relative;
display: flex;
flex-direction: column;
justify-content: center;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
}

.bottom-menu-item:last-child,
.navigation-item:last-child {
border-bottom: none;
}

.bottom-menu-item:hover {
color: rgb(var(--color-green), var(--nearly-opaque-alpha));
background-color: rgb(var(--color-extra-light-gray));
.label-wrapper {
display: flex;
align-items: center;
padding: 10px 5px;
border-radius: 4px;
}

.bottom-menu-item svg {
width: 20px;
.bottom-menu-item:hover,
.navigation-item:hover {
color: rgb(var(--color-green), var(--nearly-opaque-alpha));
background-color: rgb(var(--color-extra-light-gray));
}

.bottom-menu-item svg,
.navigation-item svg {
width: 21px;
height: 20px;
margin-right: 10px;
}
Expand All @@ -25,5 +46,28 @@
display: flex;
margin-top: 5px;
padding-left: 5px;
font-size: 0.9rem
font-size: 0.9rem;
}

.navigation-item-open {
color: rgb(var(--color-green), var(--nearly-opaque-alpha));
background-color: rgb(var(--color-extra-light-gray));
padding: 5px;
transition: all 0.2s ease;
}

.navigation-item .navigation-triangle {
position: absolute;
top: 16px;
right: 10px;
width: 8px;
height: 8px;
margin: 0;
transform: rotate(180deg);
transition: all 0.2s ease;
}

.navigation-item .navigation-triangle-open {
transform: none;
top: 21px;
}
86 changes: 61 additions & 25 deletions src/components/composed/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ import { ReactComponent as SettingsImg } from '@Assets/images/settings.svg'
import { ReactComponent as LoginImg } from '@Assets/images/icon-login.svg'
import { ReactComponent as AddWalletImg } from '@Assets/images/icon-add-wallet.svg'
import { ReactComponent as HomeImg } from '@Assets/images/icon-home.svg'
import { ReactComponent as WalletIcon } from '@Assets/images/icon-wallet.svg'
import { ReactComponent as TriangleIcon } from '@Assets/images/icon-triangle.svg'

import { AccountContext } from '@Contexts'
import { AppInfo } from '@Constants'

import NestedNavigation from './NestedNavigation'

import './Navigation.css'

const Navigation = ({ customNavigation }) => {
const [unlocked, setUnlocked] = useState(false)
const [navigationItemID, setNavigationItemID] = useState(null)
const [nestedItemID, setNestedItemID] = useState(null)
const navigate = useNavigate()
const location = useLocation()
const {
Expand All @@ -35,24 +42,24 @@ const Navigation = ({ customNavigation }) => {
setSliderMenuOpen(!sliderMenuOpen)
}

const goSettings = () => {
navigate('/settings')
toggleSliderMenu()
}

const goDashboard = () => {
navigate('/dashboard')
toggleSliderMenu()
}

const goLogin = () => {
navigate('/')
toggleSliderMenu()
const onNavigationItemClick = (item) => {
if (item.type !== 'menu') {
navigate(item.link)
toggleSliderMenu()
} else {
setNavigationItemID(navigationItemID === item.id ? null : item.id)
}
return
}

const goCreateAccount = () => {
navigate('/create-restore')
toggleSliderMenu()
const onNestedItemClick = (item) => {
if (item.type !== 'menu') {
navigate(item.link)
toggleSliderMenu()
} else {
setNestedItemID(nestedItemID === item.id ? null : item.id)
}
return
}

const expandHandler = () => {
Expand All @@ -76,13 +83,20 @@ const Navigation = ({ customNavigation }) => {
id: 1,
label: 'Dashboard',
icon: <HomeImg />,
onClick: goDashboard,
link: '/dashboard',
},
{
id: 2,
label: 'Wallets',
icon: <WalletIcon />,
type: 'menu',
content: AppInfo.WALLETS_NAVIGATION,
},
{
id: 3,
label: 'Settings',
icon: <SettingsImg />,
onClick: goSettings,
link: '/settings',
},
]

Expand All @@ -91,19 +105,22 @@ const Navigation = ({ customNavigation }) => {
id: 1,
label: 'Login',
icon: <LoginImg />,
onClick: goLogin,
link: '/',
type: 'link',
},
{
id: 2,
label: 'Create/Restore Wallet',
icon: <AddWalletImg />,
onClick: goCreateAccount,
link: '/create-restore',
type: 'link',
},
{
id: 3,
label: 'Settings',
icon: <SettingsImg />,
onClick: goSettings,
link: '/settings',
type: 'link',
},
]

Expand All @@ -119,11 +136,30 @@ const Navigation = ({ customNavigation }) => {
{navList.map((item) => (
<li
key={item.id}
onClick={item.onClick}
className="bottom-menu-item"
className={`navigation-item ${navigationItemID === item.id && 'navigation-item-open'}`}
>
{item.icon && item.icon}
{item.label}
<div
className="label-wrapper"
onClick={() => {
onNavigationItemClick(item)
}}
>
{item.icon && item.icon}
{item.label}
</div>

{item.type === 'menu' && navigationItemID === item.id && (
<NestedNavigation
item={item}
onNestedItemClick={onNestedItemClick}
nestedItemID={nestedItemID}
/>
)}
{item.type === 'menu' && (
<TriangleIcon
className={`navigation-triangle ${navigationItemID === item.id && 'navigation-triangle-open'}`}
/>
)}
</li>
))}
</ul>
Expand Down
Loading

0 comments on commit 89e0e48

Please sign in to comment.