-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: fix small bugs and reformat
- Loading branch information
1 parent
41811dd
commit 8fbea8f
Showing
26 changed files
with
296 additions
and
338 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'; | ||
import type { RootState, AppDispatch } from './store'; | ||
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux"; | ||
import type { RootState, AppDispatch } from "./store"; | ||
|
||
// Use throughout your app instead of plain `useDispatch` and `useSelector` | ||
export const useAppDispatch = () => useDispatch<AppDispatch>(); | ||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { RootState } from "./store"; | ||
|
||
export const darkModeSelector = (state: RootState) => state.darkMode.dark; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import React, { FC } from "react"; | ||
import { FC, HTMLAttributes } from "react"; | ||
import styles from "./Button.module.scss"; | ||
import classNames from "classnames"; | ||
import { useAppSelector } from "../../app/hooks"; | ||
import { RootState } from "../../app/store"; | ||
|
||
interface IButton { | ||
onClick: () => void; | ||
} | ||
|
||
export const Button: FC<IButton> = ({ children, onClick }) => { | ||
const dark = useAppSelector((state: RootState) => state.darkMode.dark) | ||
export const Button: FC<HTMLAttributes<HTMLButtonElement>> = ({ | ||
children, | ||
className, | ||
...rest | ||
}) => { | ||
return ( | ||
<div onClick={onClick} className={classNames([styles.Button, {secondary: !dark, "secondary-dark": dark}])}> | ||
<button | ||
className={classNames([styles.Button, "secondary", className])} | ||
{...rest} | ||
> | ||
{children} | ||
</div> | ||
</button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import classNames from "classnames"; | ||
import React, { FC } from "react"; | ||
import { useAppSelector } from "../../app/hooks"; | ||
import { RootState } from "../../app/store"; | ||
import { FC } from "react"; | ||
import styles from "./Counter.module.scss"; | ||
|
||
interface ICounter { | ||
pokemons: number | ||
} | ||
|
||
type CounterProps = { | ||
pokemons: number; | ||
}; | ||
|
||
export const Counter:FC<ICounter> = ({pokemons}) => { | ||
const dark = useAppSelector((state: RootState) => state.darkMode.dark) | ||
return <div className={styles.Counter}><h3>Your Pokemons:</h3><div className={classNames([styles.Counter__number, {primary: !dark, "primary-dark": dark}])}>{pokemons}</div></div>; | ||
export const Counter: FC<CounterProps> = ({ pokemons }) => { | ||
return ( | ||
<div className={styles.Counter}> | ||
<h3>Your Pokemons:</h3> | ||
<div className={classNames([styles.Counter__number, "primary"])}> | ||
{pokemons} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactNode } from "react"; | ||
import { useAppSelector } from "../../app/hooks"; | ||
import { darkModeSelector } from "../../app/selectors"; | ||
|
||
export const DarkThemeHandler = ({ children }: { children: ReactNode }) => { | ||
const dark = useAppSelector(darkModeSelector); | ||
return <div className={dark ? "dark" : "light"}>{children}</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import React, { FC } from "react"; | ||
import { FC } from "react"; | ||
import { toggle } from "../../features/darkModeSlice"; | ||
import { useAppDispatch, useAppSelector } from "../../app/hooks"; | ||
import { RootState } from "../../app/store"; | ||
import { Icon } from "../Icon"; | ||
import { useAppDispatch } from "../../app/hooks"; | ||
import { Icon } from "./Icon"; | ||
import styles from "./DarkThemeToggle.module.scss"; | ||
import classNames from "classnames"; | ||
|
||
export const DarkThemeToggle: FC = () => { | ||
const dispatch = useAppDispatch(); | ||
const dark = useAppSelector((state: RootState) => state.darkMode.dark); | ||
return ( | ||
<div className={classNames([styles.DarkThemeToggle, {primary: !dark, "primary-dark": dark}])} onClick={() => dispatch(toggle())}> | ||
<Icon dark={dark} /> | ||
<div | ||
className={classNames([styles.DarkThemeToggle, "primary"])} | ||
onClick={() => dispatch(toggle())} | ||
> | ||
<Icon /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.