Skip to content

Commit

Permalink
v7.9.6
Browse files Browse the repository at this point in the history
v7.9.6
  • Loading branch information
platschi authored Oct 4, 2023
2 parents 43f4221 + 737f7c5 commit cff0664
Show file tree
Hide file tree
Showing 35 changed files with 739 additions and 116 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kwenta",
"version": "7.9.5",
"version": "7.9.6",
"description": "Kwenta",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kwenta/app",
"version": "7.9.5",
"version": "7.9.6",
"scripts": {
"dev": "next",
"build": "next build",
Expand Down
11 changes: 6 additions & 5 deletions packages/app/src/components/Table/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type PaginationProps = {
pageCount: number
canNextPage: boolean
canPreviousPage: boolean
compact: boolean
size: 'xs' | 'sm' | 'md'
setPage: (page: number) => void
previousPage: () => void
nextPage: () => void
Expand All @@ -28,7 +28,7 @@ const Pagination: FC<PaginationProps> = React.memo(
pageCount,
canNextPage = true,
canPreviousPage = true,
compact = false,
size = 'md',
setPage,
nextPage,
previousPage,
Expand All @@ -41,7 +41,7 @@ const Pagination: FC<PaginationProps> = React.memo(

return (
<>
<PaginationContainer $compact={compact} $bottomBorder={!!extra}>
<PaginationContainer $size={size} $bottomBorder={!!extra}>
<FlexDivRow columnGap="5px">
<ArrowButton onClick={firstPage} disabled={!canPreviousPage}>
<LeftEndArrowIcon />
Expand Down Expand Up @@ -77,11 +77,12 @@ const PageInfo = styled.span`
`

const PaginationContainer = styled(GridDivCenteredCol)<{
$compact: boolean
$size: 'xs' | 'sm' | 'md'
$bottomBorder: boolean
}>`
grid-template-columns: auto 1fr auto;
padding: ${(props) => (props.$compact ? '10px' : '15px')} 12px;
padding: ${(props) => (props.$size === 'xs' ? '5px' : props.$size === 'sm' ? '10px' : '15px')}
12px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
justify-items: center;
Expand Down
18 changes: 11 additions & 7 deletions packages/app/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ type TableProps<T> = {
sortBy?: SortingState
showShortList?: boolean
lastRef?: any
compactPagination?: boolean
paginationSize?: 'xs' | 'sm' | 'md'
noResultsContainerPadding?: string
rounded?: boolean
noBottom?: boolean
columnVisibility?: VisibilityState
Expand All @@ -98,7 +99,8 @@ const Table = <T,>({
showShortList,
sortBy = [],
lastRef = null,
compactPagination = false,
paginationSize = 'md',
noResultsContainerPadding = '',
rounded = true,
noBottom = false,
columnVisibility,
Expand Down Expand Up @@ -196,7 +198,9 @@ const Table = <T,>({
<Loader />
</LoadingContainer>
) : !!noResultsMessage && data.length === 0 ? (
<NoResultsContainer>{noResultsMessage}</NoResultsContainer>
<NoResultsContainer $padding={noResultsContainerPadding}>
{noResultsMessage}
</NoResultsContainer>
) : (
<TableBody className="table-body">
{table.getRowModel().rows.map((row, i) => {
Expand All @@ -217,7 +221,7 @@ const Table = <T,>({
)}
{(shouldShowPagination || paginationExtra) && !CustomPagination ? (
<Pagination
compact={compactPagination}
size={paginationSize}
pageIndex={table.getState().pagination.pageIndex}
pageCount={table.getPageCount() === 0 ? 1 : table.getPageCount()}
canNextPage={table.getCanNextPage()}
Expand All @@ -232,7 +236,7 @@ const Table = <T,>({
</TableContainer>
{CustomPagination && (
<CustomPagination
compact={compactPagination}
size={paginationSize}
pageIndex={table.getState().pagination.pageIndex}
pageCount={table.getPageCount()}
canNextPage={table.getCanNextPage()}
Expand Down Expand Up @@ -278,8 +282,8 @@ export const TableCellHead = styled(TableCell)<{ hideHeaders: boolean; $canSort:
`}
`

const NoResultsContainer = styled(Body)`
padding: 50px 0;
const NoResultsContainer = styled(Body)<{ $padding?: string }>`
padding: ${(props) => (props.$padding ? props.$padding : '50px')} 0;
`

const LoadingContainer = styled.div`
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/pages/dashboard/staking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { FlexDivCol } from 'components/layout/flex'
import { NO_VALUE } from 'constants/placeholder'
import DashboardLayout from 'sections/dashboard/DashboardLayout'
import EscrowTable from 'sections/dashboard/Stake/EscrowTable'
import StakingPortfolio, { StakeTab } from 'sections/dashboard/Stake/StakingPortfolio'
import StakingPortfolio from 'sections/dashboard/Stake/StakingPortfolio'
import StakingTab from 'sections/dashboard/Stake/StakingTab'
import StakingTabs from 'sections/dashboard/Stake/StakingTabs'
import { StakingCards } from 'sections/dashboard/Stake/types'
import { StakeTab, StakingCards } from 'sections/dashboard/Stake/types'
import { useFetchStakeMigrateData } from 'state/futures/hooks'
import { useAppSelector } from 'state/hooks'
import {
Expand Down
110 changes: 110 additions & 0 deletions packages/app/src/sections/dashboard/Stake/DelegationInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { memo, useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

import Button from 'components/Button'
import Input from 'components/Input/Input'
import { FlexDivCol } from 'components/layout/flex'
import { Body, Heading } from 'components/Text'
import { useAppDispatch, useAppSelector } from 'state/hooks'
import { approveOperator } from 'state/staking/actions'
import { selectIsApprovingOperator } from 'state/staking/selectors'
import { media } from 'styles/media'

import { StakingCard } from './card'

const DelegationInput = memo(() => {
const { t } = useTranslation()
const dispatch = useAppDispatch()
const isApprovingOperator = useAppSelector(selectIsApprovingOperator)
const [delegatedAddress, setDelegatedAddress] = useState('')

const onInputChange = useCallback((text: string) => {
setDelegatedAddress(text.toLowerCase().trim())
}, [])

const handleApproveOperator = useCallback(
(delegatedAddress: string) => {
dispatch(approveOperator({ delegatedAddress, isApproval: true }))
setDelegatedAddress('')
},
[dispatch]
)

return (
<CardGridContainer>
<FlexDivCol rowGap="5px">
<StyledHeading variant="h4">{t('dashboard.stake.tabs.delegate.title')}</StyledHeading>
<Body color="secondary">{t('dashboard.stake.tabs.delegate.copy')}</Body>
</FlexDivCol>
<FlexDivCol rowGap="10px" style={{ marginBottom: '10px' }}>
<Body color="secondary">{t('dashboard.stake.tabs.delegate.address')}</Body>
<InputBarContainer>
<InputBar>
<AddressInput
autoFocus={true}
value={delegatedAddress}
onChange={(e) => onInputChange(e.target.value)}
placeholder=""
/>
</InputBar>
</InputBarContainer>
</FlexDivCol>
<Button
fullWidth
variant="flat"
size="small"
loading={isApprovingOperator}
disabled={delegatedAddress.length !== 42}
onClick={() => handleApproveOperator(delegatedAddress)}
>
{t('dashboard.stake.tabs.delegate.title')}
</Button>
</CardGridContainer>
)
})

const AddressInput = styled(Input)`
position: relative;
height: 38px;
border-radius: 8px;
padding: 10px 0px;
font-size: 14px;
background: ${(props) => props.theme.colors.selectedTheme.input.background};
font-family: ${(props) => props.theme.fonts.mono};
border: none;
${media.lessThan('sm')`
font-size: 12px;
`}
`

const InputBar = styled.div`
width: 100%;
overflow-x: auto;
position: relative;
display: flex;
align-items: center;
padding-left: 8px;
background: ${(props) => props.theme.colors.selectedTheme.input.background};
border-radius: 8px;
border: ${(props) => props.theme.colors.selectedTheme.input.border};
`

const InputBarContainer = styled.div`
display: flex;
height: 100%;
width: 100%;
`

const StyledHeading = styled(Heading)`
font-weight: 400;
`

const CardGridContainer = styled(StakingCard)`
display: flex;
flex-direction: column;
justify-content: space-between;
row-gap: 25px;
`

export default DelegationInput
30 changes: 30 additions & 0 deletions packages/app/src/sections/dashboard/Stake/DelegationTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import styled from 'styled-components'

import media from 'styles/media'

import DelegationInput from './DelegationInput'
import DelegationTable from './DelegationTable'

const DelegationTab = () => {
return (
<GridContainer>
<DelegationInput />
<DelegationTable />
</GridContainer>
)
}

const GridContainer = styled.div`
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 15px;

${media.lessThan('lg')`
display: grid;
grid-template-columns: 1fr;
row-gap: 25px;
margin-bottom: 25px;
`}
`

export default DelegationTab
Loading

1 comment on commit cff0664

@vercel
Copy link

@vercel vercel bot commented on cff0664 Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kwenta – ./packages/app

kwenta-git-main-kwenta.vercel.app
kwenta.io
kwenta-kwenta.vercel.app
www.kwenta.io

Please sign in to comment.