1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-16 17:33:26 +02:00

update ui components for mobile (#1495)

* fix mobile layout for filter buttons

* fix tabs component mobile view

* fix zoom in on input focus on mobile devices

* reduce searchbar font-size
This commit is contained in:
Sebastian Abromeit 2022-06-28 14:55:29 +02:00 committed by GitHub
parent 8396b705d3
commit 8249ff1397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 119 additions and 93 deletions

View File

@ -1,14 +1,20 @@
.tabListContainer {
margin-left: auto;
margin-right: auto;
border-bottom: 1px solid var(--border-color);
max-width: 100%;
}
.tabList {
text-align: center;
border-bottom: 1px solid var(--border-color);
padding: calc(var(--spacer) / 2);
display: flex;
justify-content: center;
overflow-x: auto;
}
.tab {
display: inline-block;
padding: calc(var(--spacer) / 8) var(--spacer);
padding: calc(var(--spacer) / 8) calc(var(--spacer) / 2);
font-weight: var(--font-weight-bold);
font-size: var(--font-size-small);
text-transform: uppercase;
@ -16,7 +22,6 @@
background-color: var(--background-body);
border: 1px solid var(--border-color);
margin-right: -1px;
min-width: 90px;
}
.tab,
@ -27,11 +32,13 @@
.tab:first-child {
border-top-left-radius: var(--border-radius);
border-bottom-left-radius: var(--border-radius);
margin-left: auto;
}
.tab:last-child {
border-top-right-radius: var(--border-radius);
border-bottom-right-radius: var(--border-radius);
margin-right: auto;
}
.tab[aria-selected='true'] {
@ -58,6 +65,12 @@
}
}
@media (min-width: 60rem) {
.tab {
padding: calc(var(--spacer) / 8) var(--spacer);
}
}
.radio {
composes: radio from '../../FormInput/InputRadio.module.css';
}

View File

@ -26,28 +26,32 @@ export default function Tabs({
}: TabsProps): ReactElement {
return (
<ReactTabs className={`${className || ''}`} defaultIndex={defaultIndex}>
<TabList className={styles.tabList}>
{items.map((item, index) => (
<Tab
className={styles.tab}
key={index}
onClick={handleTabChange ? () => handleTabChange(item.title) : null}
disabled={item.disabled}
>
{showRadio ? (
<InputRadio
name={item.title}
type="radio"
checked={index === defaultIndex}
options={[item.title]}
readOnly
/>
) : (
item.title
)}
</Tab>
))}
</TabList>
<div className={styles.tabListContainer}>
<TabList className={styles.tabList}>
{items.map((item, index) => (
<Tab
className={styles.tab}
key={index}
onClick={
handleTabChange ? () => handleTabChange(item.title) : null
}
disabled={item.disabled}
>
{showRadio ? (
<InputRadio
name={item.title}
type="radio"
checked={index === defaultIndex}
options={[item.title]}
readOnly
/>
) : (
item.title
)}
</Tab>
))}
</TabList>
</div>
<div className={styles.tabContent}>
{items.map((item, index) => (
<TabPanel key={index}>{item.content}</TabPanel>

View File

@ -26,6 +26,7 @@
}
.input {
font-size: 16px; /* prevent zoom in on input focus on mobile devices */
background-color: transparent;
height: 36px;
margin: 0;

View File

@ -1,16 +1,14 @@
.filterList,
div.filterList {
white-space: normal;
margin-top: 0;
margin-bottom: 0;
display: flex;
flex-direction: row;
gap: calc(var(--spacer) / 4) calc(var(--spacer) / 2);
flex-direction: column;
align-items: baseline;
}
.separator {
width: calc(var(--spacer) / 2);
}
.filter {
display: inline-block;
}
@ -65,3 +63,10 @@ button.filter,
.hideClear {
display: none !important;
}
@media screen and (min-width: 35rem) {
.filterList,
div.filterList {
flex-direction: row;
}
}

View File

@ -137,66 +137,69 @@ export default function FilterPrice({
return (
<div className={styleClasses}>
{serviceFilterItems.map((e, index) => {
const isServiceSelected =
e.value === serviceType || serviceSelections.includes(e.value)
const selectFilter = cx({
[styles.selected]: isServiceSelected,
[styles.filter]: true
})
return (
<Button
size="small"
style="text"
key={index}
className={selectFilter}
onClick={async () => {
handleSelectedFilter(isServiceSelected, e.value)
}}
>
{e.display}
</Button>
)
})}
<div className={styles.separator} />
{accessFilterItems.map((e, index) => {
const isAccessSelected =
e.value === accessType || accessSelections.includes(e.value)
const selectFilter = cx({
[styles.selected]: isAccessSelected,
[styles.filter]: true
})
return (
<Button
size="small"
style="text"
key={index}
className={selectFilter}
onClick={async () => {
handleSelectedFilter(isAccessSelected, e.value)
}}
>
{e.display}
</Button>
)
})}
{clearFilters.map((e, index) => {
const showClear =
accessSelections.length > 0 || serviceSelections.length > 0
return (
<Button
size="small"
style="text"
key={index}
className={showClear ? styles.showClear : styles.hideClear}
onClick={async () => {
applyClearFilter(addFiltersToUrl)
}}
>
{e.display}
</Button>
)
})}
<div>
{serviceFilterItems.map((e, index) => {
const isServiceSelected =
e.value === serviceType || serviceSelections.includes(e.value)
const selectFilter = cx({
[styles.selected]: isServiceSelected,
[styles.filter]: true
})
return (
<Button
size="small"
style="text"
key={index}
className={selectFilter}
onClick={async () => {
handleSelectedFilter(isServiceSelected, e.value)
}}
>
{e.display}
</Button>
)
})}
</div>
<div>
{accessFilterItems.map((e, index) => {
const isAccessSelected =
e.value === accessType || accessSelections.includes(e.value)
const selectFilter = cx({
[styles.selected]: isAccessSelected,
[styles.filter]: true
})
return (
<Button
size="small"
style="text"
key={index}
className={selectFilter}
onClick={async () => {
handleSelectedFilter(isAccessSelected, e.value)
}}
>
{e.display}
</Button>
)
})}
{clearFilters.map((e, index) => {
const showClear =
accessSelections.length > 0 || serviceSelections.length > 0
return (
<Button
size="small"
style="text"
key={index}
className={showClear ? styles.showClear : styles.hideClear}
onClick={async () => {
applyClearFilter(addFiltersToUrl)
}}
>
{e.display}
</Button>
)
})}
</div>
</div>
)
}

View File

@ -12,7 +12,7 @@
margin-bottom: calc(var(--spacer) / 2);
}
@media (min-width: 40rem) {
@media (min-width: 55rem) {
.row {
flex-direction: row;
}

View File

@ -8,7 +8,7 @@
overflow-y: auto;
}
@media (min-width: 40rem) {
@media (min-width: 55rem) {
.sortList {
align-self: flex-end;
overflow-y: unset;