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

refactor(orders-table): move styled elements from OrdersTablePagination #3896

Merged
merged 1 commit into from
Feb 22, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { CancellableOrder } from 'common/utils/isOrderCancellable'
import { isOrderOffChainCancellable } from 'common/utils/isOrderOffChainCancellable'

import { OrderRow } from './OrderRow'
import { OrdersTablePagination } from './OrdersTablePagination'
import { TableGroup } from './TableGroup'
import { getOrderParams } from './utils/getOrderParams'

Expand All @@ -44,6 +43,7 @@ import {
OrderTableItem,
tableItemsToOrders,
} from '../../utils/orderTableGroupUtils'
import { OrdersTablePagination } from '../OrdersTablePagination'

// TODO: move elements to styled.jsx

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { BalancesAndAllowances } from 'modules/tokens'

import { OrderRow } from './OrderRow'
import * as styledEl from './OrderRow/styled'
import { OrdersTablePagination } from './OrdersTablePagination'
import { OrderActions } from './types'
import { getOrderParams } from './utils/getOrderParams'

import { ORDERS_TABLE_PAGE_SIZE } from '../../const/tabs'
import { OrderTableGroup } from '../../utils/orderTableGroupUtils'
import { OrdersTablePagination } from '../OrdersTablePagination'

const GroupBox = styled.div``

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useCallback, useMemo } from 'react'

import { UI } from '@cowprotocol/ui'

import { transparentize } from 'color2k'
import { ChevronLeft, ChevronRight } from 'react-feather'
import { Link } from 'react-router-dom'
import styled, { css } from 'styled-components/macro'

import { ArrowButton, BlankButton, PageButton, PageButtonLink, PaginationBox } from './styled'

const PAGES_LIMIT = 14

export interface OrdersTablePaginationProps {
getPageUrl?(index: number): Partial<{ pathname: string; search: string }>
Expand All @@ -16,70 +15,6 @@ export interface OrdersTablePaginationProps {
className?: string
}

const PaginationBox = styled.div`
width: 100%;
display: flex;
overflow-x: auto;
text-align: center;
margin: 20px auto 0;
justify-content: center;
font-size: 14px;
font-weight: 500;

${({ theme }) => theme.mediaWidth.upToSmall`
justify-content: flex-start;
`};
`

const pageButtonStyles = css<{ $active?: boolean }>`
background: ${({ theme, $active }) => ($active ? transparentize(theme.text3, 0.9) : 'transparent')};
color: ${({ $active }) => ($active ? `var(${UI.COLOR_TEXT})` : `var(${UI.COLOR_TEXT_OPACITY_25})`)};
border: 0;
outline: 0;
padding: 5px 6px;
border-radius: 4px;
width: 34px;
margin: 0 5px;
cursor: pointer;
transition: background var(${UI.ANIMATION_DURATION}) ease-in-out, color var(${UI.ANIMATION_DURATION}) ease-in-out;
text-decoration: none;

&:hover {
background: var(${UI.COLOR_PAPER});
color: inherit;
}
`

const PageButtonLink = styled(Link)`
${pageButtonStyles}
`

const PageButton = styled.div`
${pageButtonStyles}
`

const BlankButton = styled(PageButton)`
cursor: default;

&:hover {
background: transparent !important;
color: var(${UI.COLOR_TEXT_OPACITY_25}) !important;
}
`

const ArrowButton = styled.button`
${pageButtonStyles};
width: 30px;
height: 30px;
text-align: center;
margin: 0 5px;
padding: 0;
line-height: 0;
border: 1px solid var(${UI.COLOR_TEXT_OPACITY_25});
`

const PAGES_LIMIT = 14

export function OrdersTablePagination({
pageSize,
totalCount,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { UI } from '@cowprotocol/ui'

import { transparentize } from 'color2k'
import { Link } from 'react-router-dom'
import styled, { css } from 'styled-components/macro'

export const PaginationBox = styled.div`
width: 100%;
display: flex;
overflow-x: auto;
text-align: center;
margin: 20px auto 0;
justify-content: center;
font-size: 14px;
font-weight: 500;

${({ theme }) => theme.mediaWidth.upToSmall`
justify-content: flex-start;
`};
`
const pageButtonStyles = css<{ $active?: boolean }>`
background: ${({ theme, $active }) => ($active ? transparentize(theme.text3, 0.9) : 'transparent')};
color: ${({ $active }) => ($active ? `var(${UI.COLOR_TEXT})` : `var(${UI.COLOR_TEXT_OPACITY_25})`)};
border: 0;
outline: 0;
padding: 5px 6px;
border-radius: 4px;
width: 34px;
margin: 0 5px;
cursor: pointer;
transition: background var(${UI.ANIMATION_DURATION}) ease-in-out, color var(${UI.ANIMATION_DURATION}) ease-in-out;
text-decoration: none;

&:hover {
background: var(${UI.COLOR_PAPER});
color: inherit;
}
`
export const PageButtonLink = styled(Link)`
${pageButtonStyles}
`
export const PageButton = styled.div`
${pageButtonStyles}
`
export const BlankButton = styled(PageButton)`
cursor: default;

&:hover {
background: transparent !important;
color: var(${UI.COLOR_TEXT_OPACITY_25}) !important;
}
`
export const ArrowButton = styled.button`
${pageButtonStyles};
width: 30px;
height: 30px;
text-align: center;
margin: 0 5px;
padding: 0;
line-height: 0;
border: 1px solid var(${UI.COLOR_TEXT_OPACITY_25});
`
Loading