Skip to content

Commit 3b73bf3

Browse files
authored
Merge pull request #1994 from oasisprotocol/csillag/adjust-votes
Votes page: adjust filter positions on layout
2 parents f55f821 + 05ab445 commit 3b73bf3

5 files changed

Lines changed: 50 additions & 9 deletions

File tree

.changelog/1994.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Votes page: adjust filter positions

src/app/components/CardHeaderWithResponsiveActions/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import CardHeader, { cardHeaderClasses } from '@mui/material/CardHeader'
22
import { styled } from '@mui/material/styles'
33

44
export const CardHeaderWithResponsiveActions = styled(CardHeader)(({ theme }) => ({
5+
[`.${cardHeaderClasses.content}`]: {
6+
flex: 0,
7+
textWrap: 'nowrap',
8+
},
9+
[`.${cardHeaderClasses.action}`]: {
10+
marginLeft: theme.spacing(4),
11+
flex: 1,
12+
alignSelf: 'auto',
13+
textAlign: 'end',
14+
},
515
[theme.breakpoints.down('md')]: {
616
display: 'inline',
717
alignItems: 'flex-start',

src/app/components/Proposals/VoteTypeFilter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FilterButtons } from '../FilterButtons'
66
type VoteTypeFilterProps = {
77
onSelect: (voteType: VoteType) => void
88
value?: VoteType
9+
fullWidth?: boolean
910
}
1011

1112
export const VoteTypeFilter: FC<VoteTypeFilterProps> = props => {

src/app/components/Search/TableSearchBar.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,29 @@ export interface TableSearchBarProps {
1818
placeholder: string
1919
warning?: string
2020
value: string
21+
/**
22+
* Should we go 100% width?
23+
*/
24+
fullWidth?: boolean
25+
26+
/**
27+
* Width of the whole component
28+
*
29+
* Note: fullWidth overrides this.
30+
*/
31+
width?: string | number
32+
2133
onChange: (value: string) => void
2234
}
2335

24-
export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, placeholder, warning }) => {
36+
export const TableSearchBar: FC<TableSearchBarProps> = ({
37+
value,
38+
onChange,
39+
placeholder,
40+
warning,
41+
fullWidth,
42+
width = 250,
43+
}) => {
2544
const { isTablet } = useScreenSize()
2645

2746
const [isWarningFresh, setIsWarningFresh] = useState(false)
@@ -72,7 +91,7 @@ export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, place
7291
verticalAlign: 'middle',
7392
mt: 3,
7493
mb: 4,
75-
width: isTablet ? '160px' : undefined,
94+
width: fullWidth ? '100%' : isTablet ? '160px' : undefined,
7695
}}
7796
>
7897
<WarningIcon sx={{ mr: 3 }} />
@@ -84,10 +103,8 @@ export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, place
84103
<TextField
85104
sx={{
86105
backgroundColor: COLORS.white,
87-
marginLeft: 4,
88-
marginRight: helperText ? '25px' : '25px',
89106
'&:focus-within': {
90-
boxShadow: '3px 3px 3px 3px rgb(0, 0, 98, 0.25) !important',
107+
boxShadow: '3px 3px 3px 3px rgb(0, 0, 98, 0.125) !important',
91108
},
92109
[`.${inputBaseClasses.root}`]: {
93110
border: '1px solid',
@@ -101,6 +118,7 @@ export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, place
101118
}
102119
: {}),
103120
zIndex: 10,
121+
...(fullWidth ? { width: '100%' } : {}),
104122
}}
105123
variant={'outlined'}
106124
value={value}
@@ -109,7 +127,7 @@ export const TableSearchBar: FC<TableSearchBarProps> = ({ value, onChange, place
109127
inputProps: {
110128
sx: {
111129
p: 0,
112-
width: isTablet ? 110 : 300,
130+
width: fullWidth ? '100%' : width,
113131
margin: 2,
114132
},
115133
},

src/app/pages/ProposalDetailsPage/ProposalVotesCard.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ErrorBoundary } from '../../components/ErrorBoundary'
1616
import Box from '@mui/material/Box'
1717
import { NoMatchingDataMaybeClearFilters, TableSearchBar } from '../../components/Search/TableSearchBar'
1818
import { CardEmptyState } from '../../components/CardEmptyState'
19+
import { useScreenSize } from '../../hooks/useScreensize'
1920

2021
type ProposalVotesProps = {
2122
isLoading: boolean
@@ -115,22 +116,32 @@ export const ProposalVotesView: FC = () => {
115116

116117
export const ProposalVotesCard: FC = () => {
117118
const { t } = useTranslation()
119+
const { isMobile, isTablet } = useScreenSize()
118120

119121
const { wantedType, setWantedType, wantedNameInput, setWantedNameInput, nameError } = useVoteFiltering()
120122

121123
return (
122124
<SubPageCard>
123125
<CardHeaderWithResponsiveActions
124126
action={
125-
<>
127+
<Box
128+
sx={{
129+
display: 'flex',
130+
justifyContent: 'space-between',
131+
flexWrap: isTablet ? 'wrap' : 'nowrap',
132+
gap: 4,
133+
paddingRight: isMobile ? 4 : 0,
134+
}}
135+
>
136+
<VoteTypeFilter onSelect={setWantedType} value={wantedType} />
126137
<TableSearchBar
127138
value={wantedNameInput}
128139
onChange={setWantedNameInput}
129140
placeholder={t('networkProposal.searchForVoter')}
130141
warning={nameError}
142+
fullWidth={isTablet}
131143
/>
132-
<VoteTypeFilter onSelect={setWantedType} value={wantedType} />
133-
</>
144+
</Box>
134145
}
135146
disableTypography
136147
component="h2"

0 commit comments

Comments
 (0)