Skip to content

Commit

Permalink
fix: feed select (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeksandla authored Feb 16, 2024
1 parent 2b1af84 commit b0db083
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 21 deletions.
9 changes: 8 additions & 1 deletion src/blocks/Feed/__stories__/Feed.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {Feed} from '../Feed';
import mockedPosts from '../../../../.mocks/posts.json';
import mockedServices from '../../../../.mocks/services.json';
import mockedTags from '../../../../.mocks/tags.json';
import {RouterContext} from '../../../contexts/RouterContext';
import {routerData} from '../../../demo/mocks';

export default {
title: 'Blocks/Feed',
Expand Down Expand Up @@ -76,7 +78,12 @@ const contextData = {

const DefaultTemplate: StoryFn<FeedModel> = (args) => (
<FeedContext.Provider value={contextData as unknown as FeedContextProps}>
<PageConstructor content={{blocks: [args] as unknown as Block[]}} custom={customBlocks} />
<RouterContext.Provider value={routerData}>
<PageConstructor
content={{blocks: [args] as unknown as Block[]}}
custom={customBlocks}
/>
</RouterContext.Provider>
</FeedContext.Provider>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ export const renderSwitcher: RenderSwitcherType =
/>
);

export const renderFilter: SelectProps['renderFilter'] = ({value, ref, onChange, onKeyDown}) => (
export const renderFilter: SelectProps['renderFilter'] = ({value, onChange, onKeyDown}) => (
<TextInput
controlRef={ref}
controlProps={{size: 1}}
value={value}
view="clear"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ $clearIconSize: 11px;
}

&__custom-switcher-element {
color: var(--g-color-text-primary);

&_content {
display: inline-block;
flex-grow: 1;
Expand Down Expand Up @@ -77,6 +79,15 @@ $clearIconSize: 11px;
min-width: 30px;
height: 100%;
}

&_overlay {
position: absolute;
inset: 0;
border-radius: var(--g-border-radius-xl);
background: transparent;
border: none;
cursor: pointer;
}
}

&__switcher-arrow {
Expand All @@ -87,5 +98,6 @@ $clearIconSize: 11px;
&__clear {
width: $clearIconSize;
height: $clearIconSize;
color: var(--g-color-text-primary);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export const CustomSwitcher = ({
const hasCounter = itemsNames.length > 1;

return (
<button
className={b('custom-switcher')}
onClick={onClick}
ref={controlRef as LegacyRef<HTMLButtonElement>}
onKeyDown={onKeyDown}
aria-expanded={open}
>
<div className={b('custom-switcher')} ref={controlRef as LegacyRef<HTMLDivElement>}>
<button
onClick={onClick}
className={b('custom-switcher-element', {overlay: true})}
onKeyDown={onKeyDown}
aria-expanded={open}
/>
<div className={b('custom-switcher-element', {content: true})}>
{itemsNames?.join(', ')}
</div>
Expand All @@ -67,6 +67,6 @@ export const CustomSwitcher = ({
<div className={b('custom-switcher-element', {arrow: true})}>
<Icon data={DropdownArrow} size={ICON_SIZE} className={b('switcher-arrow')} />
</div>
</button>
</div>
);
};
12 changes: 2 additions & 10 deletions src/containers/BlogPage/__stories__/BlogPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import type {Meta, StoryContext, StoryFn} from '@storybook/react';

import {BlogConstructorProvider} from '../../../constructor/BlogConstructorProvider';
import {GetPostsRequest, Query} from '../../../models/common';
import {GetPostsRequest} from '../../../models/common';
import {BlogPage, BlogPageProps} from '../BlogPage';

import page from '../../../../.mocks/blogPage.json';
Expand All @@ -12,17 +12,9 @@ import posts from '../../../../.mocks/posts.json';
import services from '../../../../.mocks/services.json';
import tags from '../../../../.mocks/tags.json';
import {Lang} from '../../../models/locale';
import {routerData} from '../../../demo/mocks';

const mockMetaComponent = <title>Blog page</title>;
const routerData = {
as: '/',
pathname: '/',
hostname: 'host',
query: {},
updateQueryCallback: (params: Query) => {
console.log('params', params);
},
};

export default {
title: 'Containers/BlogPage',
Expand Down
12 changes: 12 additions & 0 deletions src/demo/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Query} from '../models/common';

export const routerData = {
as: '/',
pathname: '/',
hostname: 'host',
query: {},
updateQueryCallback: (params: Query) => {
// eslint-disable-next-line no-console
console.log('params', params);
},
};

0 comments on commit b0db083

Please sign in to comment.