-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move reader menu to top-right for desktop
- Loading branch information
1 parent
d850ed2
commit 1210ae1
Showing
6 changed files
with
85 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { FC } from "react"; | ||
import { Button, Popover, Switch } from "antd"; | ||
import { TooltipPlacement } from "antd/lib/tooltip"; | ||
import { useForceLight } from "lib/Dark"; | ||
import { useDrawCtrl, useUpdateDrawCtrl } from "lib/draw/DrawCtrl"; | ||
import { useMediaQuery } from "react-responsive"; | ||
import { MoreOutlined } from "@ant-design/icons"; | ||
import "./options.sass"; | ||
|
||
export const OptionButton: FC<{ | ||
placement?: TooltipPlacement; | ||
}> = ({ placement }) => { | ||
const { finger } = useDrawCtrl(); | ||
const updateDrawCtrl = useUpdateDrawCtrl(); | ||
const [forceLight, setForceLight] = useForceLight(); | ||
const isLight = useMediaQuery({ query: "(prefers-color-scheme: light)" }); | ||
|
||
const options = ( | ||
<div className="reader-options"> | ||
<div className="other-option"> | ||
<span>Pencil only</span> | ||
<Switch | ||
size="small" | ||
checked={!finger} | ||
onChange={(v) => updateDrawCtrl({ finger: !v })} | ||
/> | ||
</div> | ||
<div className="other-option"> | ||
<span>Light mode</span> | ||
<Switch | ||
size="small" | ||
checked={forceLight || isLight} | ||
disabled={isLight} | ||
onChange={setForceLight} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
|
||
return ( | ||
<Popover | ||
getPopupContainer={(e) => e.parentElement!} | ||
trigger="click" | ||
content={options} | ||
placement={placement} | ||
> | ||
<Button | ||
type="text" | ||
icon={<MoreOutlined />} | ||
className="reader-option-btn" | ||
/> | ||
</Popover> | ||
); | ||
}; |
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,15 @@ | ||
@import ../../../sass/_mixins | ||
@import ../../../sass/_var | ||
|
||
.reader-options .other-option | ||
width: 120px | ||
display: flex | ||
justify-content: space-between | ||
align-items: center | ||
padding-bottom: 10px | ||
&:last-of-type | ||
padding: 0 | ||
.ant-switch | ||
box-shadow: 0 0 0 1px #eee | ||
.ant-switch-handle::before | ||
border: $default-border |
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