Skip to content

Commit

Permalink
list box
Browse files Browse the repository at this point in the history
  • Loading branch information
nothing9537 committed Oct 16, 2023
1 parent 2b3f70b commit 79e72bd
Show file tree
Hide file tree
Showing 17 changed files with 243 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"consts",
"@reduxjs",
"testid",
"inited"
"inited",
"headlessui"
],
"cSpell.words": [
"Nothingg"
Expand Down
1 change: 1 addition & 0 deletions extractedTranslations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"search-filter": "search-filter",
"seartch": "seartch",
"select-currency": "",
"select-value": "",
"send-new-comment": "send-new-comment",
"sort-by": "sort-by",
"sort-direction": "sort-direction",
Expand Down
34 changes: 34 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"webpack-dev-server": "^4.7.4"
},
"dependencies": {
"@headlessui/react": "^1.7.17",
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.4.0",
"babel-plugin-i18next-extract": "^0.9.0",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"desc-sort": "descending",
"sort-field-creation-time": "creation time",
"sort-filed-title": "title",
"sort-field-views": "views"
"sort-field-views": "views",
"select-value": "Choose a value"
}
3 changes: 2 additions & 1 deletion public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"desc-sort": "убыванию",
"sort-field-creation-time": "дате создания",
"sort-filed-title": "заголовку",
"sort-field-views": "просмотрам"
"sort-field-views": "просмотрам",
"select-value": "Выберите значение"
}
5 changes: 2 additions & 3 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FC, Suspense, useEffect } from 'react';
import { classNames } from 'shared/lib/classNames/classNames';
import { HStack } from 'shared/ui/Stack';
import { useAppDispatch } from 'shared/lib/hooks/useAppDispatch';
import { Navbar } from 'widgets/Navbar';
import { Aside } from 'widgets/Aside';
Expand All @@ -20,10 +19,10 @@ const App: FC = () => {
<div className={classNames('App', {}, ['scroll'])}>
<Suspense fallback="">
<Navbar />
<HStack align="center" justify="flex-start">
<div className="content-page">
<Aside />
{_mounted && <AppRouter />}
</HStack>
</div>
</Suspense>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions src/app/styles/themes/blue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@

// * Card bg
--card-bg: #101557;

// * ListBox bg
--list-box-bg: #101557;
}
3 changes: 3 additions & 0 deletions src/app/styles/themes/dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@

// * Card bg
--card-bg: #202074;

// * ListBox bg
--list-box-bg: #202074;
}
3 changes: 3 additions & 0 deletions src/app/styles/themes/light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@

// * Card bg
--card-bg: #d3d3d3;

// * ListBox bg
--list-box-bg: #d3d3d3;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.ArticlesListFilters {
display: flex;
flex-direction: column;
gap: 16px;
// padding: 12px;
}

.sort-filters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getArticlesListView,
} from '../../model/selectors/articlesList';
import cls from './ArticlesListFilters.module.scss';
import { VStack } from 'shared/ui/Stack';

interface ArticlesListFiltersProps {
className?: string;
Expand Down Expand Up @@ -77,7 +78,7 @@ export const ArticlesListFilters: FC<ArticlesListFiltersProps> = memo(({ classNa
], []);

return (
<div className={classNames(cls.ArticlesListFilters, {}, [className])}>
<VStack gap={16} className={classNames('', {}, [className])}>
<div className={cls['sort-filters']}>
<ArticlesSortSelector
order={order}
Expand All @@ -101,6 +102,6 @@ export const ArticlesListFilters: FC<ArticlesListFiltersProps> = memo(({ classNa
onTabClick={onChangeTag}
value={tag}
/>
</div>
</VStack>
);
});
38 changes: 30 additions & 8 deletions src/pages/ArticlesPage/ui/ArticlesPage/ArticlesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
getArticlesListView,
initArticlesList,
ArticlesList,
ArticlesListFilters,
} from 'features/ArticlesList';
import { VStack } from 'shared/ui/Stack';
import { PageWrapper } from 'widgets/PageWrapper';

interface ArticlesPageProps {
className?: string;
Expand All @@ -23,6 +26,7 @@ const reducers: ReducersList = {

const ArticlesPage: FC<ArticlesPageProps> = ({ className }) => {
const dispatch = useAppDispatch();
const isVirtualized = false;

const articles = useAppSelector(getArticlesList.selectAll);
const isLoading = useAppSelector(getArticlesListIsLoading);
Expand All @@ -39,14 +43,32 @@ const ArticlesPage: FC<ArticlesPageProps> = ({ className }) => {

return (
<DynamicModuleWrapper reducers={reducers} removeAfterUnmount={false}>
<ArticlesList
className={className}
articles={articles}
isLoading={isLoading}
onNextArticlesPageLoad={onNextArticlesPageLoad}
isVirtualized
view={view}
/>
{isVirtualized ? (
<ArticlesList
className={className}
articles={articles}
isLoading={isLoading}
onNextArticlesPageLoad={onNextArticlesPageLoad}
isVirtualized
view={view}
/>
) : (
<PageWrapper
onScrollEnd={onNextArticlesPageLoad}
>
<VStack>
<ArticlesListFilters />
<ArticlesList
className={className}
articles={articles}
isLoading={isLoading}
onNextArticlesPageLoad={onNextArticlesPageLoad}
isVirtualized={false}
view={view}
/>
</VStack>
</PageWrapper>
)}
</DynamicModuleWrapper>
);
};
Expand Down
37 changes: 37 additions & 0 deletions src/shared/ui/ListBox/ListBox.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.ListBox {
position: relative;
}

.trigger {
background: none;
margin: 0;
padding: 0;
outline: none;
border: none;
}

.options {
position: absolute;
background: var(--list-box-bg);
border-radius: 0 0 12px 12px;
z-index: 20;
width: 100%;
max-width: fit-content;

&:active {
outline: none;
}
}

.option {
padding: 10px 20px;
cursor: pointer;
}

.active {
background: var(--inverted-primary-color);
}

.disabled {
opacity: .5;
}
50 changes: 50 additions & 0 deletions src/shared/ui/ListBox/ListBox.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { Meta, StoryObj } from '@storybook/react';
import { ListBox } from './ListBox';

const meta: Meta<typeof ListBox> = {
title: 'shared/ListBox',
component: ListBox,
tags: ['autodocs'],
};

export default meta;
type Story = StoryObj<typeof ListBox>;

export const Root: Story = {
args: {
options: [
{
content: 'First option label',
value: 'First option value',
},
{
content: 'Second option label',
value: 'Second option value',
},
{
content: 'Third option label',
value: 'Third option value',
},
],
},
};

export const WithDisabledOption: Story = {
args: {
options: [
{
content: 'First label',
value: 'First value',
},
{
content: 'Second label',
value: 'Second value',
disabled: true,
},
{
content: 'Third label',
value: 'Third value',
},
],
},
};
Loading

0 comments on commit 79e72bd

Please sign in to comment.