Skip to content

Commit

Permalink
feat(oracle): cool fixes
Browse files Browse the repository at this point in the history
some updates in root
toggle off menu opening on mobile
commander query to hash conversion
'ask' button on commander focus
  • Loading branch information
mastercyb authored Oct 4, 2023
2 parents 4a1240b + b5e179f commit 265d1d9
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 43 deletions.
55 changes: 53 additions & 2 deletions src/components/actionBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { $TsFixMeFunc } from 'src/types/tsfix';
import { useSelector } from 'react-redux';
import { RootState } from 'src/redux/store';
import { routes } from 'src/routes';
import { CYBER } from 'src/utils/config';
import { useLocation } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { Networks } from 'src/types/networks';
import ButtonIcon from '../buttons/ButtonIcon';
import styles from './styles.scss';
import Button from '../btnGrd';
import usePassportByAddress from 'src/features/passport/hooks/usePassportByAddress';
import { id } from 'src/containers/application/Header/Commander/Commander';

const back = require('../../image/arrow-left-img.svg');

Expand Down Expand Up @@ -43,6 +44,9 @@ type Props = {

function ActionBar({ children, text, onClickBack, button }: Props) {
const location = useLocation();
const navigate = useNavigate();

const [commanderFocused, setCommanderFocused] = useState(false);

const { defaultAccount } = useSelector((store: RootState) => {
return {
Expand All @@ -57,8 +61,55 @@ function ActionBar({ children, text, onClickBack, button }: Props) {
const noAccount = !defaultAccount.account;
const noPassport = CYBER.CHAIN_ID === Networks.BOSTROM && !passport;

useEffect(() => {
const commander = document.getElementById(id);

function onFocus() {
setCommanderFocused(true);
}

function onBlur(e) {
if (e.relatedTarget?.tagName.toLowerCase() === 'button') {
e.relatedTarget.click();
}
setCommanderFocused(false);
}

if (commander) {
commander.addEventListener('focus', onFocus);
commander.addEventListener('blur', onBlur);
}

return () => {
if (commander) {
commander.removeEventListener('focus', onFocus);
commander.removeEventListener('blur', onBlur);
}
};
}, [id]);

// TODO: not show while loading passport

// refactor
if (commanderFocused) {
return (
<ActionBarContainer>
<Button
onClick={() => {
navigate(
routes.search.getLink(
document.getElementById(id)?.value?.replace('~', '')
)
);
}}
// link={routes.search.getLink(val)}
>
Ask
</Button>
</ActionBarContainer>
);
}

if (
(noAccount || noPassport) &&
// maybe change to props
Expand Down
14 changes: 12 additions & 2 deletions src/containers/application/Header/Commander/Commander.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { useEffect, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { replaceSlash } from '../../../../utils/utils';
import { encodeSlash, replaceSlash } from '../../../../utils/utils';
import { Input } from '../../../../components';
import styles from './Commander.module.scss';
import { Color } from 'src/components/LinearGradientContainer/LinearGradientContainer';
import { routes } from 'src/routes';
import { getIpfsHash } from 'src/utils/search/utils';
import { PATTERN_IPFS_HASH } from 'src/utils/config';

const fixedValue = '~';

Expand Down Expand Up @@ -41,7 +43,15 @@ function Commander() {
}, []);

useEffect(() => {
setSearch(fixedValue + (query || ''));
(async () => {
let search = query || '';

if (!search.match(PATTERN_IPFS_HASH) && search) {
search = await getIpfsHash(encodeSlash(query));
}

setSearch(fixedValue + (search || ''));
})();
}, [query]);

function onChange(event: React.ChangeEvent<HTMLInputElement>) {
Expand Down
9 changes: 7 additions & 2 deletions src/layouts/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import Header from 'src/containers/application/Header/Header';
import useSetActiveAddress from 'src/hooks/useSetActiveAddress';
import { RootState } from 'src/redux/store';
import styles from './Main.module.scss';
import { useDevice } from 'src/contexts/device';

function MainLayout({ children }: { children: JSX.Element }) {
const { pocket } = useSelector((state: RootState) => state);
const { defaultAccount } = pocket;
const { isMobile } = useDevice();

const { addressActive } = useSetActiveAddress(defaultAccount);
const [openMenu, setOpenMenu] = useState(false);
Expand All @@ -26,10 +28,13 @@ function MainLayout({ children }: { children: JSX.Element }) {

useEffect(() => {
// for animation
if (localStorage.getItem(localStorageKeys.MENU_SHOW) !== 'false') {
if (
localStorage.getItem(localStorageKeys.MENU_SHOW) !== 'false' &&
!isMobile
) {
toggleMenu(true);
}
}, []);
}, [isMobile]);

function closeMenu() {
toggleMenu(false);
Expand Down
101 changes: 71 additions & 30 deletions src/pages/Search/Search.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

padding: 0 50px;
gap: 15px;
// margin-top: -3px;
z-index: 1;

grid-template-columns: repeat(2, 1fr);

Expand Down Expand Up @@ -93,20 +95,38 @@

gap: 0 40px;

.imgWrapper {
position: relative;
border-radius: 50%;

&::after {
// content: '';
position: absolute;
border-radius: 50%;

left: 0;
right: 0;
height: 100%;
}
}

img {
max-width: 100%;
box-shadow: 0px 0px 15px -2px #76ff03;
border-radius: 50%;
border: 1px solid #fff;

@keyframes identifier2 {
from {
rotate: 0;
}
// @keyframes anim {
// from {
// box-shadow: 0px 0px 15px 2px #76ff03;
// }

to {
rotate: 360deg;
}
}
// to {
// box-shadow: 0px 0px 0px 2px #76ff03;
// }
// }

animation: identifier2 140s infinite;
// animation: anim 8s infinite alternate;
}

> * {
Expand Down Expand Up @@ -140,33 +160,48 @@
}
}

@media (max-width: 500px) {
@media (max-width: 580px) {
.info {
display: unset;

margin-top: -20px;
h2 {
position: relative;
text-shadow: 0px 0px 15px #ffd900;

// &::before {
// content: '';
// position: absolute;
// left: -30%;
// right: -30%;

// margin-top: auto;
// height: 100%;
// z-index: -1;
// filter: blur(20px);
// background: linear-gradient(
// 90deg,
// rgba(0, 0, 0, 0) 3.92%,
// rgba(118, 255, 3, 0.2) 43.95%,
// rgba(118, 255, 3, 0.2) 55.96%,
// rgba(0, 0, 0, 0) 100%
// );
// }
// left: -20px;
}
&::before {
content: unset;
}

.image {
.imgWrapper {
position: absolute;
right: -65%;
top: 85px;
right: -105%;

@keyframes anim {
from {
box-shadow: 0px 0px 25px 2px #76ff03;
}
img {
// box-shadow: 0px 0px 30px -1px #76ff03;

to {
box-shadow: 0px 0px 0px 2px #76ff03;
}
box-shadow: 0px 0px 25px -10px #76ff03, 0px 0px 200px -20px #76ff03;
}

animation: anim 8s infinite alternate;

border: 1px solid #fff;
border-radius: 50%;
top: 45px;
}

.particles {
Expand All @@ -176,9 +211,9 @@

.advantages {
// text-align: left;
margin-top: 40px;
margin-top: 20px;
position: relative;
left: -40px;
left: -25px;
display: flex;
flex-direction: column;
}
Expand Down Expand Up @@ -247,8 +282,14 @@
}

p {
// margin-top: 15px;
line-height: 30px;
margin-top: 7px;
line-height: 23px;
color: rgba(255, 255, 255, 0.5);
}

a {
&:hover {
opacity: 0.7;
}
}
}
17 changes: 10 additions & 7 deletions src/pages/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ function Search() {
decentralized <span>search</span> <br />
is here
</h2>

<img
className={styles.image}
src={require('./img.png')}
alt="cyber"
/>
<div className={styles.imgWrapper}>
<img
className={styles.image}
src={require('./img.png')}
alt="cyber"
/>
</div>

<div className={styles.particles}>
<h4>111 000 particles</h4>
Expand Down Expand Up @@ -88,7 +89,9 @@ function Search() {
].map(({ title, text }) => {
return (
<li key={title}>
<h6>{title}</h6>
<Link to={routes.search.getLink(title)}>
<h6>{title}</h6>
</Link>
<p>{text}</p>
</li>
);
Expand Down

0 comments on commit 265d1d9

Please sign in to comment.