-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed commit of the following: commit eb9a396ee29d2bf2ab9cc55228ad8c716e10e3c9 Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Mon Jan 30 17:38:04 2023 +0800 添加全部禁用和启用的快捷方式 commit e0866c30d69d9142c06415031d68b1fad657465f Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Mon Jan 30 15:12:29 2023 +0800 配置题单页开关 commit b8c01e5dbf3a56b8c6ef61df47c209bd64c43ec7 Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Mon Jan 30 14:48:39 2023 +0800 配置题库页开关 commit 3c1025f6583f1a287e7d9fbd89d8a812ee2012e2 Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Mon Jan 30 05:19:38 2023 +0800 修复答题页 commit ddc090d856ca9ad26f16f17c0fa498f7f589b624 Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Mon Jan 30 04:11:27 2023 +0800 统一处理所有页面 commit cdd50a6b21b2f07b4afd538074f4c8586171ce21 Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Mon Jan 30 03:47:06 2023 +0800 配置竞赛排名页开关 commit b7d4526ab38fb11e39e269fca211946e23edd380 Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Sun Jan 29 15:43:23 2023 +0800 配置答题页开关 commit 93a8eba806a12cae7636b5db354912a05fb15b25 Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Sun Jan 29 15:01:46 2023 +0800 配置首页黑名单开关 commit a5f5c76422345c66e5f458a0a1711d14e4c9807e Author: XYShaoKang <38753204+XYShaoKang@users.noreply.github.com> Date: Sun Jan 29 07:33:21 2023 +0800 添加 options
- Loading branch information
1 parent
f2d8551
commit 7e4029f
Showing
54 changed files
with
1,594 additions
and
1,184 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
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
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Refined LeetCode</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { FC } from 'react' | ||
import { withRoot } from './hoc' | ||
|
||
import Ranking from './pages/ranking/App' | ||
import Home from './pages/home/App' | ||
import Timer from './pages/problems/App' | ||
import ShortcutKeyOption from './pages/problems/ShortcutKeyOption' | ||
import Problemset from './pages/problemset/App' | ||
import ProblemList from './pages/problem-list/App' | ||
|
||
const App: FC = () => { | ||
return ( | ||
<> | ||
<Ranking /> | ||
<Home /> | ||
<Timer /> | ||
<ShortcutKeyOption /> | ||
<Problemset /> | ||
<ProblemList /> | ||
</> | ||
) | ||
} | ||
|
||
export default withRoot(App) |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ChangeEventHandler, FC } from 'react' | ||
import { css } from 'styled-components/macro' | ||
import { | ||
CheckBoxCheckedIcon, | ||
CheckBoxIndeterminateIcon, | ||
CheckBoxUncheckedIcon, | ||
} from './icons' | ||
|
||
interface CheckboxProps { | ||
checked?: boolean | ||
indeterminate?: boolean | ||
onChange?: ChangeEventHandler<HTMLInputElement> | ||
size?: number | ||
color?: string | ||
} | ||
|
||
const Checkbox: FC<CheckboxProps> = ({ | ||
checked, | ||
indeterminate, | ||
onChange, | ||
size, | ||
color, | ||
}) => { | ||
const Icon = indeterminate | ||
? CheckBoxIndeterminateIcon | ||
: checked | ||
? CheckBoxCheckedIcon | ||
: CheckBoxUncheckedIcon | ||
const chandleChange: ChangeEventHandler<HTMLInputElement> = e => { | ||
onChange?.(e) | ||
} | ||
return ( | ||
<span | ||
css={css` | ||
cursor: pointer; | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
`} | ||
> | ||
<input | ||
type="checkbox" | ||
checked={checked} | ||
onChange={chandleChange} | ||
css={css` | ||
opacity: 0; | ||
position: absolute; | ||
margin: 0; | ||
padding: 0; | ||
left: 0; | ||
top: 0; | ||
height: 100%; | ||
width: 100%; | ||
cursor: pointer; | ||
`} | ||
/> | ||
<Icon width={size} height={size} color={color} /> | ||
</span> | ||
) | ||
} | ||
|
||
export default Checkbox |
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,46 @@ | ||
import { useRef, useState } from 'react' | ||
|
||
interface SwitchProps { | ||
enable?: boolean | ||
height?: number | ||
width?: number | ||
onToggle?: () => void | ||
} | ||
|
||
const Switch: React.FC<SwitchProps> = ({ | ||
enable: enableProp, | ||
height, | ||
width, | ||
onToggle, | ||
}) => { | ||
const { current: isControlled } = useRef(enableProp !== undefined) | ||
const [state, setState] = useState<boolean>() | ||
const handleToggle = () => { | ||
setState(!state) | ||
if (onToggle) onToggle() | ||
} | ||
if (height === undefined && width === undefined) height = 24 | ||
const enable = isControlled ? enableProp : state | ||
return ( | ||
<svg | ||
viewBox="0 0 24 24" | ||
style={{ width, height, cursor: 'pointer' }} | ||
onClick={handleToggle} | ||
> | ||
{enable ? ( | ||
<path | ||
d="M17 7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h10c2.76 0 5-2.24 5-5s-2.24-5-5-5zm0 8c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z" | ||
fill="currentColor" | ||
color="rgb(144, 202, 249)" | ||
/> | ||
) : ( | ||
<path | ||
d="M17 7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h10c2.76 0 5-2.24 5-5s-2.24-5-5-5zM7 15c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z" | ||
fill="currentColor" | ||
/> | ||
)} | ||
</svg> | ||
) | ||
} | ||
|
||
export default Switch |
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,25 @@ | ||
import SvgIcon, { SvgIconProps } from '../SvgIcon' | ||
|
||
export const CheckBoxCheckedIcon: React.FC<SvgIconProps> = props => { | ||
return ( | ||
<SvgIcon {...props}> | ||
<path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" /> | ||
</SvgIcon> | ||
) | ||
} | ||
|
||
export const CheckBoxUncheckedIcon: React.FC<SvgIconProps> = props => { | ||
return ( | ||
<SvgIcon {...props}> | ||
<path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z" /> | ||
</SvgIcon> | ||
) | ||
} | ||
|
||
export const CheckBoxIndeterminateIcon: React.FC<SvgIconProps> = props => { | ||
return ( | ||
<SvgIcon {...props}> | ||
<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z" /> | ||
</SvgIcon> | ||
) | ||
} |
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 +1,2 @@ | ||
export * from './withRoot' | ||
export * from './withPage' |
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,17 @@ | ||
import { ComponentType, forwardRef } from 'react' | ||
|
||
import { PageName } from 'src/options/options' | ||
import { useAppSelector } from '@/hooks' | ||
import { selectCurrentPage } from '@/pages/global/globalSlice' | ||
|
||
export const withPage = | ||
(pageName: PageName) => | ||
<T extends ComponentType<any>>(Component: T): T => { | ||
const App = forwardRef(function App(props: any, ref: any) { | ||
const currentPage = useAppSelector(selectCurrentPage) | ||
if (currentPage !== pageName) return null | ||
return <Component ref={ref} {...props} /> | ||
}) | ||
|
||
return App as any | ||
} |
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
Oops, something went wrong.