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

Add action to close window on exit menu item #132

Merged
merged 1 commit into from
Jun 26, 2022
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
9 changes: 7 additions & 2 deletions app/renderer/components/MoreOptionsSidebarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const MoreOptionsSidebarMenu = () => {
const previewEnabled = useStore((state) => state.previewEnabled);
const setPreviewEnabled = useStore((state) => state.setPreviewEnabled);
const setNewBookModalOpen = useStore((state) => state.setNewBookModalOpen);
const setGenerateBookModalOpen = useStore((state) => state.setGenerateBookModalOpen);
const setGenerateBookModalOpen = useStore(
(state) => state.setGenerateBookModalOpen
);
const [menuPosition, setMenuPosition] = useState({ x: 0, y: 0 });

const getMenuPosition = (): Position => {
Expand Down Expand Up @@ -121,7 +123,7 @@ const MoreOptionsSidebarMenu = () => {
altColor
onChange={setPreviewEnabled}
defaultValue={previewEnabled}
disabled={activeSectionId === ""}
disabled={activeSectionId === ''}
/>
}
label="Preview"
Expand Down Expand Up @@ -150,6 +152,9 @@ const MoreOptionsSidebarMenu = () => {
iconElement={<ExitIcon />}
iconColorOverride={theme.contextMenuExit}
label="Exit"
onClick={() => {
window.windowApi.closeWindow();
}}
/>
</div>
</ContextMenu>
Expand Down
20 changes: 10 additions & 10 deletions app/renderer/controls/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { BounceLoader } from 'react-spinners';
type StyledButtonProps = {
hoverBackgroundcolor?: string;
activeBackgroundColor?: string;
loading?: boolean;
disabled?: boolean;
isLoading?: boolean;
isDisabled?: boolean;
};

const StyledButton = styled.span<StyledButtonProps>`
Expand All @@ -26,8 +26,8 @@ const StyledButton = styled.span<StyledButtonProps>`
font-size: 0.9em;

${(p) =>
!p.loading &&
!p.disabled &&
!p.isLoading &&
!p.isDisabled &&
css`
cursor: pointer;
&:hover {
Expand All @@ -41,8 +41,8 @@ const StyledButton = styled.span<StyledButtonProps>`
`;

type StyledLoaderProps = {
loading: boolean;
disabled: boolean;
isLoading: boolean;
isDisabled: boolean;
};
const StyledLoader = styled.div<StyledLoaderProps>`
position: absolute;
Expand All @@ -58,7 +58,7 @@ const StyledLoader = styled.div<StyledLoaderProps>`
align-content: center;
opacity: 0;
${(p) =>
(p.loading || p.disabled) &&
(p.isLoading || p.isDisabled) &&
css`
opacity: 1;
`}
Expand Down Expand Up @@ -90,11 +90,11 @@ const Button = ({
onClick();
}
}}
loading={loading}
disabled={disabled}
isLoading={loading}
isDisabled={disabled}
>
{children}
<StyledLoader loading={loading} disabled={disabled}>
<StyledLoader isLoading={loading} isDisabled={disabled}>
<BounceLoader
loading={loading}
size={20}
Expand Down