Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust mobile design #474

Merged
merged 29 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a02b34c
adjust content wrapper padding
torztomasz Aug 18, 2023
ce7e739
Merge remote-tracking branch 'origin/master' into adjust-mobile-design
torztomasz Aug 18, 2023
31c5cdd
remove horizontal margin from tables on mobiles
torztomasz Aug 19, 2023
6f24b74
adjust search bar on main page
torztomasz Aug 19, 2023
6c8bfa7
Merge remote-tracking branch 'origin/master' into adjust-mobile-design
torztomasz Aug 21, 2023
39ed29c
adjust empty table states
torztomasz Aug 21, 2023
50667cc
change way to display tables on home page
torztomasz Aug 21, 2023
6c8a76b
state update stats responsiveness
torztomasz Aug 21, 2023
1e82415
fix recover and register user pages
torztomasz Aug 21, 2023
6c37303
fix freeze banner on mobiles
torztomasz Aug 21, 2023
2ad59a2
fix freeze request page
torztomasz Aug 21, 2023
b181340
fix escape hatch page on smaller devices
torztomasz Aug 21, 2023
cf8ae99
make forced actions responsive
torztomasz Aug 21, 2023
1e05e6d
break balance on spot withdrawal
torztomasz Aug 21, 2023
8e04f49
tx overview improvements
torztomasz Aug 21, 2023
556f58e
fix overflowing hashes
torztomasz Aug 21, 2023
55a8e71
make asset trade card responsive
torztomasz Aug 21, 2023
40c2733
add preview debug env
torztomasz Aug 21, 2023
1b28a8d
small fixes
torztomasz Aug 21, 2023
e5f27de
fix label on register page
torztomasz Aug 21, 2023
cd7a655
fix overflowing raw l2 txs
torztomasz Aug 21, 2023
c121450
Merge remote-tracking branch 'origin/master' into adjust-mobile-design
torztomasz Aug 22, 2023
2bb7738
qa changes
torztomasz Aug 22, 2023
dba288f
adjust asset amount card responsiveness
torztomasz Aug 22, 2023
5e9d2e1
use Card component on user page
torztomasz Aug 22, 2023
b77efb8
adjust quick actions table on mobiles
torztomasz Aug 22, 2023
1c3a62d
change label
torztomasz Aug 22, 2023
e2d365f
adjust l2 transaction design on mobiles
torztomasz Aug 22, 2023
ecbf520
fix linter
torztomasz Aug 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class MerkleProofController {
const merkleProof = await this.stateUpdater.generateMerkleProof(
positionOrVaultId
)

const content = renderMerkleProofPage({
context,
positionOrVaultId,
Expand Down
17 changes: 13 additions & 4 deletions packages/frontend/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function cleanStatic() {

function buildScripts() {
return exec(
`esbuild --bundle src/scripts/index.ts --outfile=build/static/scripts/main.js --minify`
'esbuild --bundle src/scripts/index.ts --outfile=build/static/scripts/main.js --minify'
)
}

Expand All @@ -28,10 +28,19 @@ function watchScripts() {
}

function buildStyles() {
const isPreviewDebug =
process.env.DEPLOYMENT_ENV === 'preview' && process.env.DEBUG === 'true'
return Promise.all([
exec(
`tailwindcss -i ./src/styles/style.css -o ./build/static/styles/main.css`
'tailwindcss -i ./src/styles/style.css -o ./build/static/styles/main.css'
),
...(isPreviewDebug
? [
exec(
'tailwindcss -i ./src/styles/debug.css -o ./build/static/styles/debug.css'
),
]
: []),
])
}

Expand All @@ -48,7 +57,7 @@ function watchStatic() {
}

function buildTypescript() {
return exec(`tsc -p tsconfig.build.json`)
return exec('tsc -p tsconfig.build.json')
}

async function hashStaticFiles() {
Expand All @@ -61,7 +70,7 @@ async function hashStaticFiles() {

function startPreview() {
return exec(
`nodemon --watch src -e ts,tsx --exec "node -r esbuild-register" src/preview/index.ts`
'nodemon --watch src -e ts,tsx --exec "node -r esbuild-register" src/preview/index.ts'
)
}

Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"build": "NODE_ENV=production gulp build",
"clean": "rm -rf build",
"test": "mocha",
"dev": "DEPLOYMENT_ENV=preview gulp watch"
"dev": "DEPLOYMENT_ENV=preview gulp watch",
"dev:debug": "DEPLOYMENT_ENV=preview DEBUG=true gulp watch"
},
"dependencies": {
"@ethersproject/abi": "^5.6.3",
Expand Down
20 changes: 20 additions & 0 deletions packages/frontend/src/scripts/copyButtons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { makeQuery } from './utils/query'

export function initCopyButtons() {
const { $$ } = makeQuery(document.body)

const copyButtons = $$<HTMLButtonElement>('.CopyButton')
for (const copyButton of copyButtons) {
const copyContent = copyButton.dataset.content
if (!copyContent) {
return
}
//eslint-disable-next-line @typescript-eslint/no-misused-promises
copyButton.addEventListener('click', () => onClick(copyContent))
//eslint-enable-next-line @typescript-eslint/no-misused-promises
}

async function onClick(copyContent: string) {
await navigator.clipboard.writeText(copyContent)
}
}
2 changes: 2 additions & 0 deletions packages/frontend/src/scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { initCopyButtons } from './copyButtons'
import { initExpandableContainers } from './expandableContainers'
import { initForcedActionForms } from './forced-actions/forcedActionForm'
import { initForcedTradeOfferForms } from './forced-actions/perpetual/offer'
Expand All @@ -12,6 +13,7 @@ import { initTooltips } from './tooltips'

// #region UI elements
initTabs()
initCopyButtons()
initTooltips()
initPagination()
initExpandableContainers()
Expand Down
18 changes: 10 additions & 8 deletions packages/frontend/src/scripts/tooltips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,35 @@ export function initTooltips() {

window.addEventListener('resize', hide)
$$('.TableView').forEach((x) => x.addEventListener('scroll', hide))
document.body.addEventListener('scroll', hide)
document.addEventListener('scroll', hide)
document.body.addEventListener('click', (e) => {
if (e.currentTarget !== tooltip) {
hide()
}
})

for (const element of elements) {
const isOnHover = element.classList.contains('OnHover')
const title = element.getAttribute('title') ?? ''
element.removeAttribute('title')
element.setAttribute('tabindex', '0')

let mouseEnteredAt = Date.now()

element.addEventListener('mouseenter', () => {
mouseEnteredAt = Date.now()
show(element, title)
})
element.addEventListener('mouseleave', hide)
if (isOnHover) {
element.addEventListener('mouseenter', () => {
mouseEnteredAt = Date.now()
show(element, title)
})
element.addEventListener('mouseleave', hide)
}
element.addEventListener('focus', () => show(element, title))
element.addEventListener('blur', hide)

element.addEventListener('click', (e) => {
e.stopPropagation()
if (activeElement === element) {
// only hide if immediately preceded by mouse enter
if (Date.now() - mouseEnteredAt > 50) {
if (isOnHover && Date.now() - mouseEnteredAt > 50) {
hide()
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/styles/debug.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* {
box-sizing: border-box;
outline: 1px solid green;
}
30 changes: 30 additions & 0 deletions packages/frontend/src/view/assets/icons/CopyIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import classNames from 'classnames'
import React from 'react'

export function CopyIcon({
className,
...rest
}: React.SVGProps<SVGSVGElement>) {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
className={classNames('inline cursor-pointer fill-white', className)}
{...rest}
>
<g clipPath="url(#clip0_1041_8610)">
<path
d="M5.59996 0.199982C4.93696 0.199982 4.39996 0.736982 4.39996 1.39998V11C4.39996 11.663 4.93696 12.2 5.59996 12.2H13.4C14.063 12.2 14.6 11.663 14.6 11V4.09998C14.6 3.94098 14.537 3.78856 14.4242 3.67576L11.1242 0.375763C11.0114 0.262963 10.859 0.199982 10.7 0.199982H5.59996ZM10.4 1.34256L13.4574 4.39998H11C10.6688 4.39998 10.4 4.13118 10.4 3.79998V1.34256ZM2.59996 3.19998C1.93696 3.19998 1.39996 3.73698 1.39996 4.39998V14C1.39996 14.663 1.93696 15.2 2.59996 15.2H10.4C11.063 15.2 11.6 14.663 11.6 14V13.4H5.59996C4.27636 13.4 3.19996 12.3236 3.19996 11V3.19998H2.59996Z"
fillOpacity="0.8"
/>
</g>
<defs>
<clipPath id="clip0_1041_8610">
<rect width="16" height="16" />
</clipPath>
</defs>
</svg>
)
}
40 changes: 22 additions & 18 deletions packages/frontend/src/view/components/AssetAmountCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@ export function AssetAmountCard({
}: AssetAmountCardProps) {
const assetInfo = assetToInfo(asset)
return (
<div
className={cx(
'flex items-center justify-between rounded-lg bg-slate-800 p-4',
className
)}
>
<div>
<p className="mb-2 text-sm font-medium text-zinc-500">{amountLabel}</p>
<p className="text-xl font-semibold text-white">
{amount !== undefined ? formatAmount(asset, amount) : 'Unknown'}
</p>
</div>
<div>
<p className="mb-2 text-right text-sm font-medium text-zinc-500">
{assetLabel}
</p>
<div className="flex justify-end gap-2">
<AssetWithLogo assetInfo={assetInfo} type="symbol" />
<div className="@container">
<div
className={cx(
'flex flex-col justify-between gap-3 rounded-lg bg-slate-800 p-4 @[300px]:flex-row sm:flex-row',
className
)}
>
<div className="flex flex-col justify-between">
<p className="mb-2 text-sm font-medium text-zinc-500">
{amountLabel}
</p>
<p className="text-xl font-semibold text-white">
{amount !== undefined ? formatAmount(asset, amount) : 'Unknown'}
</p>
</div>
<div className="flex flex-col justify-between">
<p className="mb-2 text-sm font-medium text-zinc-500 @[300px]:text-right">
{assetLabel}
</p>
<div className="flex gap-2 @[300px]:justify-end">
<AssetWithLogo assetInfo={assetInfo} type="symbol" />
</div>
</div>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/src/view/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ type CardProps = React.HTMLAttributes<HTMLDivElement>
export function Card({ className, children, ...rest }: CardProps) {
return (
<div
className={cx('Card group/card rounded-lg bg-gray-800 p-6', className)}
className={cx(
'Card group/card -mx-4 rounded-lg bg-gray-800 p-6 sm:mx-0',
className
)}
{...rest}
>
{children}
Expand Down
15 changes: 15 additions & 0 deletions packages/frontend/src/view/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'

import { CopyIcon } from '../assets/icons/CopyIcon'
import { TooltipWrapper } from './Tooltip'

export function CopyButton({ content }: { content: string }) {
return (
<TooltipWrapper className="inline-flex" content="Copied!" onlyOnClick>
<CopyIcon
className="CopyButton transition-opacity hover:opacity-80"
data-content={content}
/>
</TooltipWrapper>
)
}
27 changes: 27 additions & 0 deletions packages/frontend/src/view/components/LongHash.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import classNames from 'classnames'
import React from 'react'

import { CopyButton } from './CopyButton'

interface LongHashProps {
className?: string
children: string | string[]
withCopy?: boolean
}

export function LongHash({
children,
className,
withCopy = false,
}: LongHashProps) {
return (
<span className={classNames('break-words', className)}>
{children}{' '}
{withCopy && <CopyButton content={getCopyButtonContent(children)} />}
</span>
)
}

function getCopyButtonContent(content: string | string[]) {
return Array.isArray(content) ? content.join('') : content
}
11 changes: 3 additions & 8 deletions packages/frontend/src/view/components/OrderedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function OrderedList({ items, className }: FancyListProps) {
<ol className={cx('ml-6', className)}>
{items.map((item, index) => {
return (
<li key={index} className="group relative pb-6 pl-4">
<div className="absolute -left-[13px] mt-2 h-full w-0.5 bg-zinc-500 group-last:hidden " />
<li key={index} className="group relative pb-6 pl-4 last:pb-0">
<div className="absolute -left-[13px] mt-2 h-full w-0.5 bg-zinc-500 group-last:hidden" />
<Index index={index} />
<span>{item}</span>
</li>
Expand All @@ -27,12 +27,7 @@ interface IndexProps {
}
function Index({ index }: IndexProps) {
return (
<span
className={cx(
'absolute -left-6 h-6 w-6 shrink-0 rounded-lg text-center',
index === 0 ? 'bg-brand' : 'bg-zinc-500'
)}
>
<span className="absolute -left-6 h-6 w-6 shrink-0 rounded-lg bg-brand text-center">
{index + 1}
</span>
)
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/view/components/SectionHeading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { default as classNames, default as cx } from 'classnames'
import classNames from 'classnames'
import React, { ReactNode } from 'react'

interface SectionHeadingProps {
Expand All @@ -17,7 +17,7 @@ export function SectionHeading(props: SectionHeadingProps) {
)}
>
<h2
className={cx(
className={classNames(
'text-xl font-semibold leading-tight',
props.children && 'flex-1'
)}
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/view/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ interface Tab {

export function Tabs({ items }: TabsProps) {
return (
<div className="Tabs">
<div className="Tabs -mx-4 sm:mx-0">
<div className="relative mb-4 border-b border-zinc-800">
<div className="TabsArrowLeft absolute inset-y-0 -left-1 z-10 hidden w-6 cursor-pointer bg-gradient-to-r from-neutral-900 via-neutral-900">
<div className="TabsArrowLeft absolute inset-y-0 left-0 z-10 hidden w-6 cursor-pointer bg-gradient-to-r from-neutral-900 via-neutral-900">
<div className="flex h-full items-center justify-center text-white">
<ChevronLeftIcon />
</div>
Expand All @@ -43,7 +43,7 @@ export function Tabs({ items }: TabsProps) {
))}
<span className="TabsUnderline absolute bottom-0 block h-1 rounded-t-sm bg-brand transition-all duration-300" />
</div>
<div className="TabsArrowRight absolute inset-y-0 -right-1 z-10 hidden w-6 cursor-pointer bg-gradient-to-l from-neutral-900 via-neutral-900">
<div className="TabsArrowRight absolute inset-y-0 right-0 z-10 hidden w-6 cursor-pointer bg-gradient-to-l from-neutral-900 via-neutral-900">
<div className="flex h-full items-center justify-center">
<ChevronRightIcon />
</div>
Expand Down
15 changes: 13 additions & 2 deletions packages/frontend/src/view/components/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from 'classnames'
import React from 'react'

export function Tooltip() {
Expand All @@ -19,11 +20,21 @@ export function Tooltip() {
interface TooltipWrapperProps {
children: React.ReactNode
content: string
onlyOnClick?: boolean
className?: string
}

export function TooltipWrapper({ children, content }: TooltipWrapperProps) {
export function TooltipWrapper({
children,
content,
className,
onlyOnClick,
}: TooltipWrapperProps) {
return (
<span className="Tooltip" title={content}>
<span
className={classNames('Tooltip', className, !onlyOnClick && 'OnHover')}
title={content}
>
{children}
</span>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function ContentWrapper(props: ContentWrapperProps) {
return (
<main
className={cx(
'mx-auto w-full max-w-5xl flex-1 px-4 py-16 sm:px-8',
'mx-auto w-full max-w-5xl flex-1 px-4 py-8 sm:py-16 md:px-8',
props.className
)}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/view/components/page/FreezeBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
export function FreezeBanner({ freezeStatus }: { freezeStatus: FreezeStatus }) {
if (freezeStatus === 'freezable') {
return (
<div className="sticky top-0 z-50 flex items-center justify-center gap-2 bg-brand px-6 py-0.5 text-white">
<div className="sticky top-0 z-50 flex items-center justify-center gap-4 bg-brand px-6 py-0.5 text-center text-white">
<span>
This exchange can be frozen due to inactivity of the operator.
</span>
Expand All @@ -16,7 +16,7 @@ export function FreezeBanner({ freezeStatus }: { freezeStatus: FreezeStatus }) {
}
if (freezeStatus === 'frozen') {
return (
<div className="sticky top-0 z-50 flex items-center justify-center gap-2 bg-red-500 px-6 py-0.5 text-white">
<div className="sticky top-0 z-50 flex items-center justify-center gap-4 bg-red-500 px-6 py-0.5 text-center text-white">
<span>This exchange is frozen and no longer operates normally. </span>
</div>
)
Expand Down
Loading