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

fix: mobile styles for positions block #298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/pages/trade/ui/history-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const HistoryTabs = () => {
const [showInactive, setshowInactive] = useState(false);

return (
<div ref={parent} className='flex flex-col'>
<div ref={parent} className='flex flex-col w-screen desktop:w-auto'>
<div className='flex justify-between gap-2 px-4 border-b border-b-other-solidStroke'>
<Density compact>
<Tabs
Expand Down
325 changes: 161 additions & 164 deletions src/pages/trade/ui/positions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Text } from '@penumbra-zone/ui/Text';
import { Table } from '@penumbra-zone/ui/Table';
import { ValueViewComponent } from '@penumbra-zone/ui/ValueView';
import { Density } from '@penumbra-zone/ui/Density';
import { Tooltip, TooltipProvider } from '@penumbra-zone/ui/Tooltip';
import { Tooltip } from '@penumbra-zone/ui/Tooltip';
import { stateToString, usePositions } from '@/pages/trade/api/positions.ts';
import { positionsStore } from '@/pages/trade/model/positions';
import { pnum } from '@penumbra-zone/types/pnum';
Expand Down Expand Up @@ -59,172 +59,169 @@ const Positions = observer(({ showInactive }: { showInactive: boolean }) => {
}

return (
<TooltipProvider>
<Density variant='slim'>
<div className='flex justify-center px-4 overflow-x-auto'>
<Table bgColor='base.blackAlt'>
<Table.Thead>
<Table.Tr>
<Table.Th density='slim'>
<Text tableHeadingSmall>Type</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Trade Amount</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Effective Price</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall whitespace='nowrap'>
Fee Tier
</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Base Price</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Current Value</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Position ID</Text>
</Table.Th>
<Table.Th hAlign='right' density='slim'>
<HeaderActionButton displayPositions={displayPositions} />
</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>
{isLoading &&
Array.from({ length: 15 }).map((_, i) => (
<Table.Tr key={i}>
{Array.from({ length: 8 }).map((_, index) => (
<Table.Td key={index}>
<LoadingCell key={index} />
</Table.Td>
))}
</Table.Tr>
))}
{displayPositions
.filter(position => (showInactive ? true : !position.isWithdrawn))
.map(position => {
return (
<Table.Tr key={position.idString}>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) =>
position.isOpened ? (
<Text
as='div'
detail
color={
order.direction === 'Buy' ? 'success.light' : 'destructive.light'
}
key={i}
>
{order.direction}
</Text>
) : (
<Text as='div' detail color='neutral.light' key={i}>
{stateToString(position.state)}
</Text>
),
)}
</div>
</Table.Td>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) => (
<ValueViewComponent
key={i}
valueView={order.amount}
trailingZeros={false}
density='slim'
/>
))}
</div>
</Table.Td>
<Table.Td density='slim'>
{/* Fight display inline 4 px spacing */}
<div className='flex flex-col gap-2 -mb-1 items-start'>
{position.orders.map((order, i) => (
<Tooltip
key={i}
message={
<>
<Text as='div' detail color='text.primary'>
Base price: {pnum(order.basePrice).toFormattedString()}
</Text>
<Text as='div' detail color='text.primary'>
Fee:{' '}
{pnum(order.basePrice)
.toBigNumber()
.minus(pnum(order.effectivePrice).toBigNumber())
.toString()}{' '}
({position.fee})
</Text>
<Text as='div' detail color='text.primary'>
Effective price:{' '}
{pnum(order.effectivePrice).toFormattedString()}
</Text>
</>
<Density variant='slim'>
<div className='flex justify-center px-4 overflow-x-auto'>
<Table bgColor='base.blackAlt'>
<Table.Thead>
<Table.Tr>
<Table.Th density='slim'>
<Text tableHeadingSmall>Type</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Trade Amount</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Effective Price</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall whitespace='nowrap'>
Fee Tier
</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Base Price</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Current Value</Text>
</Table.Th>
<Table.Th density='slim'>
<Text tableHeadingSmall>Position ID</Text>
</Table.Th>
<Table.Th hAlign='right' density='slim'>
<HeaderActionButton displayPositions={displayPositions} />
</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>
{isLoading &&
Array.from({ length: 15 }).map((_, i) => (
<Table.Tr key={i}>
{Array.from({ length: 8 }).map((_, index) => (
<Table.Td key={index}>
<LoadingCell key={index} />
</Table.Td>
))}
</Table.Tr>
))}
{displayPositions
.filter(position => (showInactive ? true : !position.isWithdrawn))
.map(position => {
return (
<Table.Tr key={position.idString}>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) =>
position.isOpened ? (
<Text
as='div'
detail
color={
order.direction === 'Buy' ? 'success.light' : 'destructive.light'
}
key={i}
>
<div>
<ValueViewComponent
valueView={order.effectivePrice}
trailingZeros={false}
density='slim'
/>
</div>
</Tooltip>
))}
</div>
</Table.Td>
<Table.Td density='slim'>
<Text as='div' detailTechnical color='text.primary'>
{position.fee}
{order.direction}
</Text>
) : (
<Text as='div' detail color='neutral.light' key={i}>
{stateToString(position.state)}
</Text>
),
)}
</div>
</Table.Td>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) => (
<ValueViewComponent
key={i}
valueView={order.amount}
trailingZeros={false}
density='slim'
/>
))}
</div>
</Table.Td>
<Table.Td density='slim'>
{/* Fight display inline 4 px spacing */}
<div className='flex flex-col gap-2 -mb-1 items-start'>
{position.orders.map((order, i) => (
<Tooltip
key={i}
message={
<>
<Text as='div' detail color='text.primary'>
Base price: {pnum(order.basePrice).toFormattedString()}
</Text>
<Text as='div' detail color='text.primary'>
Fee:{' '}
{pnum(order.basePrice)
.toBigNumber()
.minus(pnum(order.effectivePrice).toBigNumber())
.toString()}{' '}
({position.fee})
</Text>
<Text as='div' detail color='text.primary'>
Effective price: {pnum(order.effectivePrice).toFormattedString()}
</Text>
</>
}
>
<div>
<ValueViewComponent
valueView={order.effectivePrice}
trailingZeros={false}
density='slim'
/>
</div>
</Tooltip>
))}
</div>
</Table.Td>
<Table.Td density='slim'>
<Text as='div' detailTechnical color='text.primary'>
{position.fee}
</Text>
</Table.Td>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) => (
<ValueViewComponent
key={i}
valueView={order.basePrice}
trailingZeros={false}
density='slim'
/>
))}
</div>
</Table.Td>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) => (
<PositionsCurrentValue key={i} order={order} />
))}
</div>
</Table.Td>
<Table.Td density='slim'>
<div className='flex max-w-[104px]'>
<Text as='div' detailTechnical color='text.primary' truncate>
{position.idString}
</Text>
</Table.Td>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) => (
<ValueViewComponent
key={i}
valueView={order.basePrice}
trailingZeros={false}
density='slim'
/>
))}
</div>
</Table.Td>
<Table.Td density='slim'>
<div className='flex flex-col gap-4'>
{position.orders.map((order, i) => (
<PositionsCurrentValue key={i} order={order} />
))}
</div>
</Table.Td>
<Table.Td density='slim'>
<div className='flex max-w-[104px]'>
<Text as='div' detailTechnical color='text.primary' truncate>
{position.idString}
</Text>
<Link href={`/inspect/lp/${position.idString}`}>
<SquareArrowOutUpRight className='w-4 h-4 text-text-secondary' />
</Link>
</div>
</Table.Td>
<Table.Td hAlign='right' density='slim'>
<ActionButton id={position.id} position={position.position} />
</Table.Td>
</Table.Tr>
);
})}
</Table.Tbody>
</Table>
</div>
</Density>
</TooltipProvider>
<Link href={`/inspect/lp/${position.idString}`}>
<SquareArrowOutUpRight className='w-4 h-4 text-text-secondary' />
</Link>
</div>
</Table.Td>
<Table.Td hAlign='right' density='slim'>
<ActionButton id={position.id} position={position.position} />
</Table.Td>
</Table.Tr>
);
})}
</Table.Tbody>
</Table>
</div>
</Density>
);
});

Expand Down