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

feat: more buttons in header for desktop #9

Merged
merged 1 commit into from
Aug 8, 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
41 changes: 30 additions & 11 deletions src/pages/reader/Header/Middle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const HeaderMiddle: FC<{
/>
<PenButton />
<EraserButton />
<AddMoreButtons />
<SelectButton />
<AddButton />
</div>
);

Expand Down Expand Up @@ -146,14 +146,19 @@ const SelectButton = () => {
);
};

const AddButton: FC = () => {
const AddMoreButtons: FC = () => {
const drawCtrl = useDrawCtrl();
const updateDrawCtrl = useUpdateDrawCtrl();
const { mode, imageSrc } = drawCtrl;

const getButton = (modeName: DrawCtrl["mode"], icon: ReactNode) => (
const getButton = (
modeName: DrawCtrl["mode"],
icon: ReactNode,
className?: string
) => (
<Button
key={modeName}
className={className}
type={mode === modeName ? "link" : "text"}
onClick={() => updateDrawCtrl({ mode: modeName })}
icon={icon}
Expand Down Expand Up @@ -205,13 +210,27 @@ const AddButton: FC = () => {
</div>
);
return (
<Popover
content={content}
trigger="click"
placement="bottomRight"
getPopupContainer={(e) => e.parentElement!}
>
{buttons[mode] ?? <Button type="text" icon={<PlusCircleOutlined />} />}
</Popover>
<>
{Object.entries(buttons).map(([key, btn]) => (
<Popover
className="btn-for-desktop"
content={optionPanels[key]}
trigger="click"
placement="bottomRight"
getPopupContainer={(e) => e.parentElement!}
>
{btn}
</Popover>
))}
<Popover
className="btn-for-phone"
content={content}
trigger="click"
placement="bottomRight"
getPopupContainer={(e) => e.parentElement!}
>
{buttons[mode] ?? <Button type="text" icon={<PlusCircleOutlined />} />}
</Popover>
</>
);
};
40 changes: 20 additions & 20 deletions src/pages/reader/Header/header.sass
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
> .right
grid-template-columns: repeat(3, 1fr)
> .middle
grid-template-columns: repeat(7, 1fr)
grid-template-columns: repeat(9, 1fr)
.redo-btn
grid-column: span 2
> .middle
Expand All @@ -56,25 +56,25 @@
border-top: $default-border
margin-top: 10px
padding-top: 10px
.text-option
width: 200px
color: #555
.picture-option
width: 200px
display: flex
flex-direction: column
align-items: center
&[data-mode=rect]
.width-seg
margin-left: auto
margin-right: auto
.hi-wrapper
display: none
img
margin-top: 10px
max-width: 200px
&[data-show=false]
display: none
.text-option
width: 200px
color: #555
.picture-option
width: 200px
display: flex
flex-direction: column
align-items: center
img
margin-top: 10px
max-width: 200px
&[data-show=false]
display: none
>.btn-for-phone
@include for-desktop
display: none
>.btn-for-desktop
@include for-phone
display: none
> .right .reader-option-btn
@include for-phone
display: none
Expand Down
9 changes: 7 additions & 2 deletions src/pages/reader/tools/PenPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ export const PenPanel: FC<{
updateDrawCtrl: (updated: Partial<DrawCtrl>) => void;
drawCtrl: Partial<DrawCtrl>;
}> = ({ updateDrawCtrl, drawCtrl }) => {
const { highlight, color } = drawCtrl;
const { highlight, color, mode } = drawCtrl;
const [panelBlur, setPanelBlur] = useState(false);

return (
<div className="pen-panel" data-blur={panelBlur} data-hi={highlight}>
<div
className="pen-panel"
data-blur={panelBlur}
data-hi={highlight}
data-mode={mode}
>
<div className="pen-status">
<WidthSelect
updateDrawCtrl={updateDrawCtrl}
Expand Down
6 changes: 6 additions & 0 deletions src/pages/reader/tools/pen-panel.sass
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
justify-content: space-between
.width-seg
margin-right: 20px
&[data-mode=rect]
.width-seg
margin-left: auto
margin-right: auto
.hi-wrapper
display: none

.hi-wrapper
display: block
Expand Down
Loading