This repository has been archived by the owner on Jun 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add magnify icons * Add dialog and toolbarButton (Currently not doing anything) * Make dialog actually render * Make dialog actually do something * Fix some mistakes
- Loading branch information
Showing
16 changed files
with
302 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { AppWindow } from '../windows'; | ||
import { Dialog } from '.'; | ||
import { DIALOG_MARGIN, DIALOG_MARGIN_TOP } from '~/constants/design'; | ||
|
||
const WIDTH = 280; | ||
|
||
export class ZoomDialog extends Dialog { | ||
public visible = false; | ||
|
||
public left = 0; | ||
public top = 0; | ||
|
||
constructor(appWindow: AppWindow) { | ||
super(appWindow, { | ||
name: 'zoom', | ||
bounds: { | ||
width: WIDTH, | ||
height: 100, | ||
}, | ||
}); | ||
} | ||
|
||
public rearrange() { | ||
super.rearrange({ | ||
x: Math.round(this.left - WIDTH + DIALOG_MARGIN), | ||
y: Math.round(this.top - DIALOG_MARGIN_TOP), | ||
}); | ||
} | ||
|
||
public async show() { | ||
await super.show(); | ||
this.send('visible', true); | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,77 @@ | ||
import * as React from 'react'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { ThemeProvider } from 'styled-components'; | ||
import { hot } from 'react-hot-loader/root'; | ||
|
||
import { StyledApp, Label, Buttons, Spacer } from './style'; | ||
import { ToolbarButton } from '../../../app/components/ToolbarButton'; | ||
import store from '../../store'; | ||
import { Button } from '~/renderer/components/Button'; | ||
import { ipcRenderer } from 'electron'; | ||
import { UIStyle } from '~/renderer/mixins/default-styles'; | ||
|
||
import { | ||
ICON_UP, | ||
ICON_DOWN, | ||
} from '~/renderer/constants/icons'; | ||
|
||
const onPlus = () => { | ||
ipcRenderer.send('change-zoom', 'in'); | ||
}; | ||
|
||
const onMinus = () => { | ||
ipcRenderer.send('change-zoom', 'out'); | ||
}; | ||
|
||
const onReset = () => { | ||
ipcRenderer.send('reset-zoom'); | ||
}; | ||
|
||
ipcRenderer.on('zoom-factor-updated', (e, zoomFactor) => { | ||
store.zoomFactor = zoomFactor; | ||
}); | ||
|
||
export const App = hot( | ||
observer(() => { | ||
return ( | ||
<ThemeProvider theme={{ ...store.theme }}> | ||
<StyledApp visible={store.visible} onMouseEnter={() => store.stopHideTimer()} onMouseLeave={() => store.resetHideTimer()}> | ||
<UIStyle /> | ||
<Buttons> | ||
<ToolbarButton | ||
toggled={false} | ||
icon={ICON_UP} | ||
size={18} | ||
dense | ||
iconStyle={{ transform: 'scale(-1,1)' }} | ||
onClick={onPlus} | ||
/> | ||
<Label>{(store.zoomFactor * 100).toFixed(0) + "%"}</Label> | ||
<ToolbarButton | ||
toggled={false} | ||
icon={ICON_DOWN} | ||
size={18} | ||
dense | ||
iconStyle={{ transform: 'scale(-1,1)' }} | ||
onClick={onMinus} | ||
/> | ||
<Spacer /> | ||
<Button | ||
onClick={onReset} | ||
background={ | ||
store.theme['dialog.lightForeground'] | ||
? 'rgba(255, 255, 255, 0.08)' | ||
: 'rgba(0, 0, 0, 0.08)' | ||
} | ||
foreground={ | ||
store.theme['dialog.lightForeground'] ? 'white' : 'black' | ||
} | ||
> | ||
Reset | ||
</Button> | ||
</Buttons> | ||
</StyledApp> | ||
</ThemeProvider> | ||
); | ||
}), | ||
); |
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,37 @@ | ||
import styled, { css } from 'styled-components'; | ||
|
||
import { ITheme } from '~/interfaces'; | ||
import { DialogStyle } from '~/renderer/mixins/dialogs'; | ||
|
||
export const StyledApp = styled(DialogStyle)` | ||
padding: 16px; | ||
${({ theme }: { theme?: ITheme; visible: boolean }) => css` | ||
color: ${theme['dialog.lightForeground'] ? '#fff' : '#000'}; | ||
`} | ||
`; | ||
|
||
export const Label = styled.div` | ||
font-size: 16px; | ||
min-width: 45px; | ||
text-align: center; | ||
`; | ||
|
||
export const Spacer = styled.div` | ||
flex-grow: 1; | ||
`; | ||
|
||
export const Buttons = styled.div` | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-end; | ||
& .button:not(:last-child) { | ||
margin-right: 8px; | ||
} | ||
`; | ||
|
||
export const Container = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
`; |
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,3 @@ | ||
import { App } from './components/App'; | ||
import { renderUI } from '~/utils/ui-entry'; | ||
renderUI(App); |
Oops, something went wrong.