Skip to content

Commit

Permalink
style(wallet): Segmented Control Sizing and Padding
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglashdaniel committed Sep 4, 2024
1 parent 7a3a37e commit c595e2b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) 2023 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
import styled from 'styled-components'

// Shared Styles
import { Row } from '../../shared/style'
import {
layoutSmallWidth //
} from '../wallet-page-wrapper/wallet-page-wrapper.style'

export const HeaderWrapper = styled(Row)`
padding: 24px 24px 0px 24px;
@media screen and (max-width: ${layoutSmallWidth}px) {
padding: 16px 16px 0px 16px;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@

import * as React from 'react'

// utils
import { ExploreNavOptions } from '../../../../options/nav-options'
// Options
import { ExploreNavOptions } from '../../../options/nav-options'

// Components
import {
SegmentedControl //
} from '../../../shared/segmented_control/segmented_control'
} from '../../shared/segmented_control/segmented_control'

// components
// Styled Components
import { HeaderWrapper } from './explorer_web3_header.style'

export const ExploreWeb3Header = () => {
// render
return <SegmentedControl navOptions={ExploreNavOptions} />
return (
<HeaderWrapper>
<SegmentedControl
maxWidth='384px'
navOptions={ExploreNavOptions}
/>
</HeaderWrapper>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { Column } from '../../../shared/style'
// components
import getWalletPageApiProxy from '../../../../page/wallet_page_api_proxy'
import { WalletBanner } from '../../wallet-banner/index'
import { ExploreWeb3Header } from '../explore_web3/explore_web3_header'
import { ExploreWeb3Header } from '../../card-headers/explorer_web3_header'
import {
EditVisibleAssetsModal //
} from '../../popup-modals/edit-visible-assets-modal/index'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const AccountsAndTransactionsList = ({
<Row padding='24px 0px'>
<SegmentedControl
navOptions={PortfolioAssetOptions}
width={'384px'}
maxWidth='384px'
/>
</Row>
)}
Expand Down Expand Up @@ -300,7 +300,7 @@ export const AccountsAndTransactionsList = ({
<Row padding='24px 0px'>
<SegmentedControl
navOptions={PortfolioAssetOptions}
width={'384px'}
maxWidth='384px'
/>
</Row>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ export const PortfolioOverview = () => {
{!hidePortfolioNFTsTab && (
<SegmentedControl
navOptions={PortfolioNavOptions}
width={'384px'}
maxWidth='384px'
/>
)}
</ControlsRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,29 @@ import LeoSegmentedControl, {
SegmentedControlProps
} from '@brave/leo/react/segmentedControl'

export const StyledWrapper = styled.div<{ width?: string }>`
flex: 1;
// Shared Styles
import {
layoutPanelWidth,
layoutSmallWidth //
} from '../../desktop/wallet-page-wrapper/wallet-page-wrapper.style'

export const StyledWrapper = styled.div<{ maxWidth?: string }>`
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
z-index: 0px;
width: 100%;
max-width: ${(p) => p.maxWidth ?? 'unset'};
--leo-segmented-control-width: 100%;
@media screen and (max-width: ${layoutSmallWidth}px) {
max-width: unset;
}
`

export const SegmentedControl = styled(
LeoSegmentedControl
)<SegmentedControlProps>`
margin: 24px 0 10px 0;
`
export const SegmentedControl = styled(LeoSegmentedControl).attrs({
size: window.innerWidth <= layoutPanelWidth ? 'small' : 'default'
})<SegmentedControlProps>``

export const ControlItemWrapper = styled.div`
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {

interface Props {
navOptions: NavOption[]
width?: string
maxWidth?: string
}

export const SegmentedControl = ({ navOptions, width }: Props) => {
export const SegmentedControl = ({ navOptions, maxWidth }: Props) => {
// Routing
const history = useHistory()
const { pathname: walletLocation, hash } = useLocation()
Expand All @@ -40,7 +40,7 @@ export const SegmentedControl = ({ navOptions, width }: Props) => {

// Render
return (
<StyledWrapper width={width}>
<StyledWrapper maxWidth={maxWidth}>
<StyledSegmentedControl
value={selectedRoute}
onChange={({ value }) => {
Expand Down

0 comments on commit c595e2b

Please sign in to comment.