Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
garywang committed Dec 9, 2020
1 parent fae3fa2 commit f705703
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 36 deletions.
48 changes: 31 additions & 17 deletions src/components/AppSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import React, {useRef, useState} from 'react';
import React, { useRef, useState } from 'react';
import { Select, Typography } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
import {TOKEN_MINTS} from "@project-serum/serum";
import apps from "@project-serum/awesome-serum";
import { TOKEN_MINTS } from '@project-serum/serum';
import apps from '@project-serum/awesome-serum';

const { Option } = Select;

const appsAndTokens = apps.concat(TOKEN_MINTS.map(mint => {
return {
"name": `${mint.name} SPL`,
"url": `https://explorer.solana.com/address/${mint.address.toBase58()}`,
"description": `${mint.name} SPL token`,
"icon": "",
"tags": ["token", "blockchain", "solana", "spl", "solana", mint.address.toBase58()]
}
}))
const appsAndTokens = apps.concat(
TOKEN_MINTS.map((mint) => {
return {
name: `${mint.name} SPL`,
url: `https://explorer.solana.com/address/${mint.address.toBase58()}`,
description: `${mint.name} SPL token`,
icon: '',
tags: [
'token',
'blockchain',
'solana',
'spl',
'solana',
mint.address.toBase58(),
],
};
}),
);

interface App {
name: string;
Expand All @@ -27,7 +36,6 @@ export default function AppSearch(props) {
const [searchMatches, setSearchMatches] = useState<App[]>([]);
const [searchValue, setSearchValue] = useState<string | undefined>(undefined);


const matchApp = (searchString: string, app: App) => {
const lowerSearchStr = searchString.toLowerCase();
return (
Expand Down Expand Up @@ -72,7 +80,11 @@ export default function AppSearch(props) {
showSearch
allowClear
value={searchValue}
placeholder={props.focussed || props.focussed === undefined ? 'Search for dex, swap, wallet, token...' : ''}
placeholder={
props.focussed || props.focussed === undefined
? 'Search for dex, swap, wallet, token...'
: ''
}
onSearch={handleSearch}
onClear={handleClear}
onSelect={handleSelect}
Expand All @@ -84,13 +96,15 @@ export default function AppSearch(props) {
notFoundContent={null} // todo: make this search history
style={{
width: props.width || '300px',
transition: props.focussed ? "width 0.1s ease 0.1s" : ""
transition: props.focussed ? 'width 0.1s ease 0.1s' : '',
}}
dropdownStyle={{
width: props.width || "300px"
width: props.width || '300px',
}}
dropdownMatchSelectWidth={false}
suffixIcon={<SearchOutlined onClick={() => ref.current && ref.current.focus()}/>}
suffixIcon={
<SearchOutlined onClick={() => ref.current && ref.current.focus()} />
}
filterOption={false}
>
{options}
Expand Down
50 changes: 31 additions & 19 deletions src/components/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export default function TopBar() {
onClose={() => setAddEndpointVisible(false)}
/>
<Wrapper>
<LogoWrapper onClick={() => history.push('/')} >
<img src={logo} alt=""/>
<LogoWrapper onClick={() => history.push('/')}>
<img src={logo} alt="" />
{'SERUM'}
</LogoWrapper>
<Menu
Expand All @@ -151,9 +151,11 @@ export default function TopBar() {
flex: 1,
}}
>
<Menu.Item key="/" style={{margin: "0 10px 0 20px"}}>TRADE</Menu.Item>
<Menu.Item key="/" style={{ margin: '0 10px 0 20px' }}>
TRADE
</Menu.Item>
{!searchFocussed && (
<Menu.Item key="/swap" style={{margin: "0 10px"}}>
<Menu.Item key="/swap" style={{ margin: '0 10px' }}>
<a
href={EXTERNAL_LINKS['/swap']}
target="_blank"
Expand All @@ -163,23 +165,33 @@ export default function TopBar() {
</a>
</Menu.Item>
)}
{connected && (!searchFocussed || location.pathname === '/balances') &&
<Menu.Item key="/balances" style={{margin: "0 10px"}}>BALANCES</Menu.Item>
}
{connected && (!searchFocussed || location.pathname === '/orders') &&
<Menu.Item key="/orders" style={{margin: "0 10px"}}>ORDERS</Menu.Item>
}
{connected && (!searchFocussed || location.pathname === '/convert') &&
<Menu.Item key="/convert" style={{margin: "0 10px"}}>CONVERT</Menu.Item>
}
{(!searchFocussed || location.pathname === '/list-new-market') &&
<Menu.Item key="/list-new-market" style={{margin: "0 10px"}}>ADD MARKET</Menu.Item>
}
{connected && (!searchFocussed || location.pathname === '/balances') && (
<Menu.Item key="/balances" style={{ margin: '0 10px' }}>
BALANCES
</Menu.Item>
)}
{connected && (!searchFocussed || location.pathname === '/orders') && (
<Menu.Item key="/orders" style={{ margin: '0 10px' }}>
ORDERS
</Menu.Item>
)}
{connected && (!searchFocussed || location.pathname === '/convert') && (
<Menu.Item key="/convert" style={{ margin: '0 10px' }}>
CONVERT
</Menu.Item>
)}
{(!searchFocussed || location.pathname === '/list-new-market') && (
<Menu.Item key="/list-new-market" style={{ margin: '0 10px' }}>
ADD MARKET
</Menu.Item>
)}
{!searchFocussed && (
<Menu.SubMenu
title="LEARN"
onTitleClick={() => window.open(EXTERNAL_LINKS['/learn'], '_blank')}
style={{margin: "0 0px 0 10px"}}
onTitleClick={() =>
window.open(EXTERNAL_LINKS['/learn'], '_blank')
}
style={{ margin: '0 0px 0 10px' }}
>
<Menu.Item key="/add-market">
<a
Expand Down Expand Up @@ -249,7 +261,7 @@ export default function TopBar() {
onFocus={() => setSearchFocussed(true)}
onBlur={() => setSearchFocussed(false)}
focussed={searchFocussed}
width={searchFocussed ? "350px" : "35px"}
width={searchFocussed ? '350px' : '35px'}
/>
</div>
<div>
Expand Down

0 comments on commit f705703

Please sign in to comment.