Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat: add ability to open a project
Browse files Browse the repository at this point in the history
  • Loading branch information
Lasse Küchler committed Dec 14, 2017
1 parent 4dc294c commit 0f522b2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
build
package-lock.json
8 changes: 0 additions & 8 deletions src/component/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ class App extends React.Component<AppProps> {
this.handleMainWindowClick = this.handleMainWindowClick.bind(this);
}

public componentDidMount(): void {
const webviewTag: WebviewTag = document.getElementById('preview') as WebviewTag;
webviewTag.addEventListener('did-stop-loading', () => {
store.openStyleguide('../designkit');
store.openPage('homepage');
});
}

private handleMainWindowClick(): void {
this.props.store.setElementFocus(false);
createMenu(store);
Expand Down
11 changes: 10 additions & 1 deletion src/component/menu.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import { BrowserWindow, MenuItem, MenuItemConstructorOptions, remote, WebContents } from 'electron';
import { PageElement } from '../store/page/page_element';
import { Store } from '../store';
const { Menu, shell, app } = remote;
const { Menu, shell, app, dialog } = remote;

export function createMenu(store: Store): void {
const template: MenuItemConstructorOptions[] = [
{
label: '&File',
submenu: [
{
label: '&Open Project',
click: () => {
dialog.showOpenDialog({ properties: ['openDirectory'] }, filePaths => {
store.openStyleguide(filePaths[0]);
store.openPage('homepage');
});
}
},
{
label: 'New &Page',
accelerator: 'CmdOrCtrl+N'
Expand Down
2 changes: 1 addition & 1 deletion src/electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function createWindow(): void {
// and load the index.html of the app.
win.loadURL(
url.format({
pathname: PathUtils.join(__dirname, '..', '..', 'src', 'electron', 'index.html'),
pathname: PathUtils.join(__dirname, '..', 'electron', 'index.html'),
protocol: 'file:',
slashes: true
})
Expand Down
2 changes: 1 addition & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class Store {
MobX.transaction(() => {
if (!PathUtils.isAbsolute(styleGuidePath)) {
// Currently, store is two levels below alva, so go two up
styleGuidePath = PathUtils.join(__dirname, '..', '..', styleGuidePath);
styleGuidePath = PathUtils.join(styleGuidePath);
}
this.styleGuidePath = styleGuidePath;
this.currentPage = undefined;
Expand Down

0 comments on commit 0f522b2

Please sign in to comment.