diff --git a/src/components/PositionList/index.tsx b/src/components/PositionList/index.tsx index 4cd574ae32..697b5ba1d2 100644 --- a/src/components/PositionList/index.tsx +++ b/src/components/PositionList/index.tsx @@ -1,6 +1,6 @@ import { Trans } from '@lingui/macro' -import { ButtonText } from 'components/Button' import PositionListItem from 'components/PositionListItem' +import SimpleToggle from 'components/Toggle/SimpleToggle' import React from 'react' import styled from 'styled-components/macro' import { MEDIA_WIDTHS } from 'theme' @@ -28,9 +28,37 @@ const MobileHeader = styled.div` font-size: 16px; font-weight: 500; padding: 8px; + display: flex; + justify-content: space-between; + align-items: center; + @media screen and (min-width: ${MEDIA_WIDTHS.upToSmall}px) { display: none; } + + @media screen and (max-width: ${MEDIA_WIDTHS.upToExtraSmall}px) { + display: flex; + flex-direction: column; + align-items: start; + } +` + +const ToggleWrap = styled.div` + display: flex; + flex-direction: row; + align-items: center; +` + +const ToggleLabel = styled.div` + opacity: 0.6; + margin-right: 10px; +` + +const MobileTogglePosition = styled.div` + @media screen and (max-width: ${MEDIA_WIDTHS.upToExtraSmall}px) { + position: absolute; + right: 20px; + } ` type PositionListProps = React.PropsWithChildren<{ @@ -51,12 +79,35 @@ export default function PositionList({ Your positions {positions && ' (' + positions.length + ')'} - setUserHideClosedPositions(!userHideClosedPositions)}> - Hide closed positions - + + + Show closed positions + + { + setUserHideClosedPositions(!userHideClosedPositions) + }} + /> + Your positions + + + Show closed positions + + + { + setUserHideClosedPositions(!userHideClosedPositions) + }} + /> + + {positions.map((p) => { return diff --git a/src/components/Toggle/SimpleToggle.tsx b/src/components/Toggle/SimpleToggle.tsx new file mode 100644 index 0000000000..2a6fe12bd0 --- /dev/null +++ b/src/components/Toggle/SimpleToggle.tsx @@ -0,0 +1,45 @@ +import { darken } from 'polished' +import styled from 'styled-components/macro' + +const Wrapper = styled.button<{ isActive?: boolean; activeElement?: boolean }>` + border-radius: 20px; + border: none; + background: ${({ theme }) => theme.bg1}; + display: flex; + cursor: pointer; + outline: none; + padding: 0.4rem 0.4rem; + align-items: center; + height: 32px; + width: 56px; + position: relative; +` + +const ToggleElement = styled.span<{ isActive?: boolean; isOnSwitch?: boolean }>` + border-radius: 50%; + height: 24px; + width: 24px; + position: absolute; + background: ${({ theme, isActive, isOnSwitch }) => (isActive ? (isOnSwitch ? theme.primary1 : theme.text3) : 'none')}; + :hover { + user-select: ${({ isOnSwitch }) => (isOnSwitch ? 'none' : 'initial')}; + background: ${({ theme, isActive, isOnSwitch }) => + isActive ? (isOnSwitch ? darken(0.05, theme.primary1) : darken(0.05, theme.bg4)) : 'none'}; + color: ${({ theme, isActive, isOnSwitch }) => (isActive ? (isOnSwitch ? theme.white : theme.white) : theme.text3)}; + } +` + +interface ToggleProps { + id?: string + isActive: boolean + toggle: () => void +} + +export default function SimpleToggle({ id, isActive, toggle }: ToggleProps) { + return ( + + + + + ) +}