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

fix: mobile selects #222

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gravity-ui/blog-constructor",
"version": "6.4.3",
"version": "6.4.4-alpha.0",
"description": "Gravity UI Blog Constructor",
"license": "MIT",
"repository": {
Expand Down
128 changes: 67 additions & 61 deletions src/components/FeedHeader/components/Controls/Controls.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {ReactNode, useContext, useMemo, useState} from 'react';

import {useAnalytics} from '@gravity-ui/page-constructor';
import {Button, Icon, Select} from '@gravity-ui/uikit';
import {Button, Icon, MobileProvider, Select} from '@gravity-ui/uikit';

import {DefaultGoalIds} from '../../../../constants';
import {LikesContext} from '../../../../contexts/LikesContext';
Expand Down Expand Up @@ -140,77 +140,83 @@ export const Controls = ({
);

return (
<div className={b('header')}>
<h1 className={b('header-item', {title: true})}>{i18n(Keyset.Title)}</h1>
<div className={b('header-item', {filters: true})}>
<div className={b('filter-item')}>
<Search
className={b('search')}
placeholder={i18n(Keyset.Search)}
initialValue={search && typeof search === 'string' ? search : ''}
onSubmit={handleSearch}
/>
</div>
<div className={b('filter-item')}>
<Select
className={b('select')}
size="xl"
options={tagsItems}
defaultValue={[tagInitial] as string[]}
onUpdate={handleTagSelect}
placeholder={i18n(Keyset.AllTags)}
popupClassName={b('popup', {isMobile})}
renderControl={renderSwitcher({
initial: [tagInitial],
list: tagsItems,
defaultLabel: i18n(Keyset.AllTags),
})}
disablePortal
virtualizationThreshold={VIRTUALIZATION_THRESHOLD}
renderOption={renderOption}
/>
</div>

{services.length > 0 ? (
<MobileProvider mobile={false}>
<div className={b('header')}>
<h1 className={b('header-item', {title: true})}>{i18n(Keyset.Title)}</h1>
<div className={b('header-item', {filters: true})}>
<div className={b('filter-item')}>
<Search
className={b('search')}
placeholder={i18n(Keyset.Search)}
initialValue={search && typeof search === 'string' ? search : ''}
onSubmit={handleSearch}
/>
</div>
<div className={b('filter-item')}>
<Select
className={b('select')}
size="xl"
multiple
filterable
hasClear
disablePortal
options={services}
defaultValue={servicesItems}
options={tagsItems}
defaultValue={[tagInitial] as string[]}
onUpdate={handleTagSelect}
placeholder={i18n(Keyset.AllTags)}
popupClassName={b('popup', {isMobile})}
onUpdate={handleServicesSelect}
placeholder={i18n(Keyset.AllServices)}
renderControl={renderSwitcher({
initial: servicesItems,
list: services,
defaultLabel: i18n(Keyset.AllServices),
initial: [tagInitial],
list: tagsItems,
defaultLabel: i18n(Keyset.AllTags),
})}
disablePortal
virtualizationThreshold={VIRTUALIZATION_THRESHOLD}
renderOption={renderOption}
renderFilter={renderFilter}
/>
</div>
) : null}
{hasLikes ? (
<div className={b('filter-item', {'width-auto': true})}>
<Button
view={'outlined'}
className={b('saved-only-button', {savedOnly})}
size="xl"
onClick={handleSavedOnly}
selected={savedOnly}
>
<Icon data={Save} size={ICON_SIZE} className={b('icon', {savedOnly})} />
{i18n(Keyset.ActionSavedOnly)}
</Button>
</div>
) : null}

{services.length > 0 ? (
<div className={b('filter-item')}>
<Select
className={b('select')}
size="xl"
multiple
filterable
hasClear
disablePortal
options={services}
defaultValue={servicesItems}
popupClassName={b('popup', {isMobile})}
onUpdate={handleServicesSelect}
placeholder={i18n(Keyset.AllServices)}
renderControl={renderSwitcher({
initial: servicesItems,
list: services,
defaultLabel: i18n(Keyset.AllServices),
})}
virtualizationThreshold={VIRTUALIZATION_THRESHOLD}
renderOption={renderOption}
renderFilter={renderFilter}
/>
</div>
) : null}
{hasLikes ? (
<div className={b('filter-item', {'width-auto': true})}>
<Button
view={'outlined'}
className={b('saved-only-button', {savedOnly})}
size="xl"
onClick={handleSavedOnly}
selected={savedOnly}
>
<Icon
data={Save}
size={ICON_SIZE}
className={b('icon', {savedOnly})}
/>
{i18n(Keyset.ActionSavedOnly)}
</Button>
</div>
) : null}
</div>
</div>
</div>
</MobileProvider>
);
};