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

refact: file structure and reusablity add #88

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/hooks/useUrlValues.test.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import UrlProvider, { useUrlValues } from '@/lib/hooks/useUrlValues';
import { composeUrl } from '@/lib/utils';
import {
DEFAULT_LANGUAGE,
DEFAULT_ORDERING,
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';

Expand Down
7 changes: 3 additions & 4 deletions src/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';

interface Props {
interface Props extends React.ComponentPropsWithoutRef<'h1'> {
title: string;
classNme: string;
}

const Logo: React.FC<Props> = ({ title, classNme }) => {
const Logo: React.FC<Props> = ({ title, className }) => {
const [first, ...rest] = title.split(' ');

return (
<h1
className={`text-3xl font-light leading-relaxed sm:text-4xl ${classNme}`}
className={`text-3xl font-light leading-relaxed sm:text-4xl ${className}`}
>
<a href='/'>
<span className='font-sans font-medium text-dark-1'>{first}</span>{' '}
Expand Down
54 changes: 0 additions & 54 deletions src/components/MultiLevelSwitch.jsx

This file was deleted.

16 changes: 0 additions & 16 deletions src/components/Switch.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/containers/Issues.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down
3 changes: 0 additions & 3 deletions src/containers/Provider.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/containers/index.tsx → src/containers/index.ts
Original file line number Diff line number Diff line change
@@ -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';
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions src/containers/layout/Provider.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<UrlProvider>
<ThemeProvider>
<FilterProvider>{children}</FilterProvider>
</ThemeProvider>
</UrlProvider>
</>
);
}
3 changes: 3 additions & 0 deletions src/containers/layout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as Footer } from './Footer';
export { default as Header } from './Header';
export { default as Provider } from './Provider';
2 changes: 1 addition & 1 deletion src/lib/hooks/use-filter.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
File renamed without changes.
15 changes: 4 additions & 11 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -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(
<React.StrictMode>
<UrlProvider>
<ThemeProvider>
<FilterProvider>
<App />
</FilterProvider>
</ThemeProvider>
</UrlProvider>
<Provider>
<App />
</Provider>
</React.StrictMode>
);
Loading