diff --git a/src/App.tsx b/src/App.tsx index 6a7373b..3d06ebe 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,6 @@ import { MiniContainer } from '@/components'; -import { Filter, Footer, Header, Issues } from '@/containers'; +import { Filter, Issues } from '@/containers'; +import { Footer, Header } from '@/containers/layout'; const App = () => { return ( diff --git a/src/__tests__/hooks/useUrlValues.test.jsx b/src/__tests__/hooks/useUrlValues.test.jsx index 207e761..35be84b 100644 --- a/src/__tests__/hooks/useUrlValues.test.jsx +++ b/src/__tests__/hooks/useUrlValues.test.jsx @@ -1,3 +1,4 @@ +import UrlProvider, { useUrlValues } from '@/lib/hooks/useUrlValues'; import { composeUrl } from '@/lib/utils'; import { DEFAULT_LANGUAGE, @@ -5,7 +6,6 @@ import { DEFAULT_PAGE, DEFAULT_SORTING_TAG, } from '@/lib/utils/config'; -import UrlProvider, { useUrlValues } from '@/providers/urlProvider/reducer'; import { act, render } from '@testing-library/react'; import { beforeEach, describe, expect, it } from 'vitest'; diff --git a/src/components/Logo.tsx b/src/components/Logo.tsx index ed12be2..79bfeb3 100644 --- a/src/components/Logo.tsx +++ b/src/components/Logo.tsx @@ -1,16 +1,15 @@ import React from 'react'; -interface Props { +interface Props extends React.ComponentPropsWithoutRef<'h1'> { title: string; - classNme: string; } -const Logo: React.FC = ({ title, classNme }) => { +const Logo: React.FC = ({ title, className }) => { const [first, ...rest] = title.split(' '); return (

{first}{' '} diff --git a/src/components/MultiLevelSwitch.jsx b/src/components/MultiLevelSwitch.jsx deleted file mode 100644 index 24b99e7..0000000 --- a/src/components/MultiLevelSwitch.jsx +++ /dev/null @@ -1,54 +0,0 @@ -import { useState } from 'react'; - -const MultiLevelSwitch = ({ options }) => { - // selected - const [selected, setSelected] = useState([]); - const [showOptions, setShowOptions] = useState(false); - - const addSelected = (option) => { - setSelected((prev) => [...prev, option]); - }; - - const removeSelected = (value) => { - setSelected((prev) => prev.filter((opt) => opt.value !== value)); - }; - - return ( -
- {selected.map(({ label, value }) => ( -
removeSelected(value)} - > - {label} -
- ))} - setShowOptions(true)} - // onBlur={() => setShowOptions(false)} - /> - {showOptions && ( -
- {options.map(({ label, value }) => ( - - ))} -
- )} -
- ); -}; - -export default MultiLevelSwitch; diff --git a/src/components/Switch.jsx b/src/components/Switch.jsx deleted file mode 100644 index 0ddda06..0000000 --- a/src/components/Switch.jsx +++ /dev/null @@ -1,16 +0,0 @@ -const Switch = ({ toggle, onChange }) => { - return ( - - ); -}; - -export default Switch; diff --git a/src/containers/Issues.tsx b/src/containers/Issues.tsx index 2b31d4d..18d2870 100644 --- a/src/containers/Issues.tsx +++ b/src/containers/Issues.tsx @@ -1,10 +1,10 @@ import { Error, Issue, Label, Loader, Pagination } from '@/components'; import useAsync from '@/lib/hooks/useAsync'; +import { useUrlValues } from '@/lib/hooks/useUrlValues'; import { getTotalPages, toId } from '@/lib/utils'; import httpGateway from '@/lib/utils/HttpGateway'; import { MAX_ISSUES_ALLOWED } from '@/lib/utils/config'; import { githubIssueSearchResponse } from '@/models/GithubIssueSearch'; -import { useUrlValues } from '@/providers/urlProvider/reducer'; import { useEffect } from 'react'; const Issues = () => { diff --git a/src/containers/Provider.tsx b/src/containers/Provider.tsx deleted file mode 100644 index 7764f40..0000000 --- a/src/containers/Provider.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function Provider({ children }: { children: React.ReactNode }) { - return; -} diff --git a/src/containers/index.tsx b/src/containers/index.ts similarity index 50% rename from src/containers/index.tsx rename to src/containers/index.ts index f6b2d04..cfa59a1 100644 --- a/src/containers/index.tsx +++ b/src/containers/index.ts @@ -1,4 +1,2 @@ export { default as Filter } from './Filter'; -export { default as Footer } from './Footer'; -export { default as Header } from './Header'; export { default as Issues } from './Issues'; diff --git a/src/containers/Footer.tsx b/src/containers/layout/Footer.tsx similarity index 100% rename from src/containers/Footer.tsx rename to src/containers/layout/Footer.tsx diff --git a/src/containers/Header.tsx b/src/containers/layout/Header.tsx similarity index 100% rename from src/containers/Header.tsx rename to src/containers/layout/Header.tsx diff --git a/src/containers/layout/Provider.tsx b/src/containers/layout/Provider.tsx new file mode 100644 index 0000000..dbecc1b --- /dev/null +++ b/src/containers/layout/Provider.tsx @@ -0,0 +1,15 @@ +import FilterProvider from '@/lib/hooks/use-filter'; +import ThemeProvider from '@/lib/hooks/use-theme'; +import UrlProvider from '@/lib/hooks/useUrlValues'; + +export default function Provider({ children }: { children: React.ReactNode }) { + return ( + <> + + + {children} + + + + ); +} diff --git a/src/containers/layout/index.ts b/src/containers/layout/index.ts new file mode 100644 index 0000000..3efb3c5 --- /dev/null +++ b/src/containers/layout/index.ts @@ -0,0 +1,3 @@ +export { default as Footer } from './Footer'; +export { default as Header } from './Header'; +export { default as Provider } from './Provider'; diff --git a/src/lib/hooks/use-filter.tsx b/src/lib/hooks/use-filter.tsx index daa21b1..6a866a7 100644 --- a/src/lib/hooks/use-filter.tsx +++ b/src/lib/hooks/use-filter.tsx @@ -1,8 +1,8 @@ +import { useUrlValues } from '@/lib/hooks/useUrlValues'; import { Label, sortedLabels } from '@/models/Label'; import { Language } from '@/models/Language'; import { Ordering } from '@/models/Ordering'; import { SortingTag } from '@/models/SortingTag'; -import { useUrlValues } from '@/providers/urlProvider/reducer'; import { FormEvent, createContext, useContext, useState } from 'react'; type FilterContextType = { diff --git a/src/providers/urlProvider/reducer.tsx b/src/lib/hooks/useUrlValues/index.tsx similarity index 100% rename from src/providers/urlProvider/reducer.tsx rename to src/lib/hooks/useUrlValues/index.tsx diff --git a/src/providers/urlProvider/types.ts b/src/lib/hooks/useUrlValues/types.ts similarity index 100% rename from src/providers/urlProvider/types.ts rename to src/lib/hooks/useUrlValues/types.ts diff --git a/src/main.tsx b/src/main.tsx index db78fd5..f7a7bb1 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,20 +1,13 @@ import App from '@/App'; +import { Provider } from '@/containers/layout'; import '@/index.css'; import React from 'react'; import ReactDOM from 'react-dom/client'; -import FilterProvider from './lib/hooks/use-filter'; -import ThemeProvider from './lib/hooks/use-theme'; -import UrlProvider from './providers/urlProvider/reducer'; - ReactDOM.createRoot(document.getElementById('root')!).render( - - - - - - - + + + );