-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df6e13d
commit ebc5edc
Showing
15 changed files
with
260 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.settings-container { | ||
display: flex; | ||
} | ||
|
||
.settings-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
margin: 1.5rem 0.5rem; | ||
width: 100%; | ||
color: hsl(var(--text)); | ||
|
||
.item { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
user-select: none; | ||
|
||
.value { | ||
transition: .1s; | ||
} | ||
} | ||
|
||
& > .item { | ||
margin-bottom: 1rem; | ||
|
||
&:last-child { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} |
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,28 @@ | ||
import * as React from "react" | ||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox" | ||
import { Check } from "lucide-react" | ||
|
||
import { cn } from "@/components/ui/lib/utils" | ||
|
||
const Checkbox = React.forwardRef< | ||
React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<CheckboxPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<CheckboxPrimitive.Indicator | ||
className={cn("flex items-center justify-center text-current")} | ||
> | ||
<Check className="h-4 w-4" /> | ||
</CheckboxPrimitive.Indicator> | ||
</CheckboxPrimitive.Root> | ||
)) | ||
Checkbox.displayName = CheckboxPrimitive.Root.displayName | ||
|
||
export { 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
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,51 @@ | ||
import "@/assets/settings.less"; | ||
import {useTranslation} from "react-i18next"; | ||
import {useDispatch, useSelector} from "react-redux"; | ||
import {alignSelector, contextSelector, dialogSelector, setAlign, setContext, setDialog} from "@/store/settings.ts"; | ||
import {Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle} from "@/components/ui/dialog.tsx"; | ||
import {Checkbox} from "@/components/ui/checkbox.tsx"; | ||
|
||
function Settings() { | ||
const { t } = useTranslation(); | ||
const dispatch = useDispatch(); | ||
const open = useSelector(dialogSelector); | ||
|
||
const align = useSelector(alignSelector); | ||
const context = useSelector(contextSelector); | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={(open) => dispatch(setDialog(open))}> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>{t("settings.title")}</DialogTitle> | ||
<DialogDescription> | ||
<div className={`settings-container`}> | ||
<div className={`settings-wrapper`}> | ||
<div className={`item`}> | ||
<div className={`name`}> | ||
{t('settings.align')} | ||
</div> | ||
<div className={`grow`} /> | ||
<Checkbox className={`value`} checked={align} onCheckedChange={(state: boolean) => { | ||
dispatch(setAlign(state)); | ||
}} /> | ||
</div> | ||
<div className={`item`}> | ||
<div className={`name`}> | ||
{t('settings.context')} | ||
</div> | ||
<div className={`grow`} /> | ||
<Checkbox className={`value`} checked={context} onCheckedChange={(state: boolean) => { | ||
dispatch(setContext(state)); | ||
}} /> | ||
</div> | ||
</div> | ||
</div> | ||
</DialogDescription> | ||
</DialogHeader> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default Settings; |
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,48 @@ | ||
import {createSlice} from "@reduxjs/toolkit"; | ||
import {getMemory, setMemory} from "@/utils/memory.ts"; | ||
import {RootState} from "@/store/index.ts"; | ||
|
||
export const settingsSlice = createSlice({ | ||
name: "settings", | ||
initialState: { | ||
dialog: false, | ||
context: getMemory("context") !== "false", | ||
align: getMemory("align") !== "false", | ||
}, | ||
reducers: { | ||
toggleDialog: (state) => { | ||
state.dialog = !state.dialog; | ||
}, | ||
setDialog: (state, action) => { | ||
state.dialog = action.payload as boolean; | ||
}, | ||
openDialog: (state) => { | ||
state.dialog = true; | ||
}, | ||
closeDialog: (state) => { | ||
state.dialog = false; | ||
}, | ||
setContext: (state, action) => { | ||
state.context = action.payload as boolean; | ||
setMemory("context", String(action.payload)); | ||
}, | ||
setAlign: (state, action) => { | ||
state.align = action.payload as boolean; | ||
setMemory("align", String(action.payload)); | ||
} | ||
}, | ||
}) | ||
|
||
export const { | ||
toggleDialog, | ||
setDialog, | ||
openDialog, | ||
closeDialog, | ||
setContext, | ||
setAlign, | ||
} = settingsSlice.actions; | ||
export default settingsSlice.reducer; | ||
|
||
export const dialogSelector = (state: RootState): boolean => state.settings.dialog; | ||
export const contextSelector = (state: RootState): boolean => state.settings.context; | ||
export const alignSelector = (state: RootState): boolean => state.settings.align; |
Oops, something went wrong.