Skip to content

Commit

Permalink
Improved UX of syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
nwittwer committed Feb 2, 2019
2 parents c52c22c + f86a372 commit c73c465
Show file tree
Hide file tree
Showing 9 changed files with 520 additions and 336 deletions.
105 changes: 51 additions & 54 deletions src/main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,71 +116,68 @@ export function setMenu(window) {
}
]

if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [{
role: 'about'
},
{
type: 'separator'
},
{
role: 'services'
},
{
type: 'separator'
},
{
role: 'hide'
},
{
role: 'hideothers'
},
{
role: 'unhide'
},
{
type: 'separator'
},
{
role: 'quit'
}
]
})

// Edit menu
template[1].submenu.push({
type: 'separator'
}, {
label: 'Speech',
submenu: [{
role: 'startspeaking'
},
{
role: 'stopspeaking'
}
]
})

// Window menu
template[3].submenu = [{
role: 'close'
// if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [{
role: 'about'
},
{
type: 'separator'
},
{
role: 'services'
},
{
role: 'minimize'
type: 'separator'
},
{
role: 'hide'
},
{
role: 'zoom'
role: 'hideothers'
},
{
role: 'unhide'
},
{
type: 'separator'
},
{
role: 'front'
role: 'quit'
}
]
}
})

// Edit menu
template[1].submenu.push({
type: 'separator'
}, {
label: 'Speech',
submenu: [{
role: 'startspeaking'
},
{
role: 'stopspeaking'
}
]
})

// Window menu
template[3].submenu = [{
role: 'minimize'
},
{
role: 'zoom'
},
{
type: 'separator'
},
{
role: 'front'
}
]
// }

const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/components/Artboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export default {
// When loading of webview starts
function loadstart() {
_this.state.isLoading = true // Show loading spinner
_this.$store.commit('changeSiteData', {
title: 'Loading...'
})
}
// Once webview content is loaded
Expand Down
68 changes: 28 additions & 40 deletions src/renderer/components/SidePanel/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@
<transition name="sidebar-transition">
<div class="side-panel">
<div class="side-panel__track">
<div
class="station"
title="Screens"
@click="setActive('Screens')"
>
<div class="station" title="Screens" @click="setActive('Screens')">
<div
class="station__button button"
:class="{ 'button--is-active' : isActive('Screens') }"
>
<img
src="@/assets/icons/screens.svg"
alt="Screens"
>
<img src="@/assets/icons/screens.svg" alt="Screens">
</div>
<span class="station__title">
Screens
</span>
<span class="station__title">Screens</span>
</div>
<div
<!-- <div
v-if="artboards.length"
class="station"
title="Sync"
Expand All @@ -38,77 +29,74 @@
<div class="station__title">
Sync
</div>
</div>
</div>-->
<!-- <div class="station button" @click="setActive('Screenshot')">3</div> -->
</div>
<div
v-if="sidebar===true"
class="side-panel__content"
>
<PanelComponent :title="activeStation" />
<div v-if="sidebar===true" class="side-panel__content">
<PanelComponent :title="activeStation"/>
</div>
</div>
</transition>
</template>

<script>
import PanelComponent from './PanelComponent.vue'
import PanelComponent from "./PanelComponent.vue";
export default {
name: 'SidePanel',
name: "SidePanel",
components: {
PanelComponent
},
data () {
data() {
return {
activeStation: 'Screens'
}
activeStation: "Screens"
};
},
computed: {
// Bind to our Vuex Store's URL value
artboards: function () {
return this.$store.state.artboards
artboards: function() {
return this.$store.state.artboards;
},
sidebar () {
return this.$store.state.gui.sidebar
sidebar() {
return this.$store.state.gui.sidebar;
}
},
methods: {
setActive: function (val) {
setActive: function(val) {
// Handle hide/show side panel
if (this.sidebar && this.activeStation !== val) {
// Normal State
// Simply set the clicked station to active
this.activeStation = val
this.activeStation = val;
} else if (this.sidebar && this.activeStation === val) {
// Close State
// When clicking on the same station,
// it should close the sidebar
this.toggleSidebar(false)
this.activeStation = ''
this.toggleSidebar(false);
this.activeStation = "";
} else if (this.sidebar === false) {
// Closed State
// Sidebar is closed, re-open
this.toggleSidebar(true)
this.activeStation = val
this.toggleSidebar(true);
this.activeStation = val;
}
},
isActive: function (val) {
isActive: function(val) {
// Make sure to open the sidebar
// if it was open in last session
// Otherwise, don't set an active state
if (this.sidebar === true) {
return this.activeStation === val
return this.activeStation === val;
} else {
return ''
return "";
}
},
toggleSidebar () {
this.$store.commit('toggleSidebar')
toggleSidebar() {
this.$store.commit("toggleSidebar");
}
}
}
};
</script>

<style lang="scss" scoped>
Expand Down
122 changes: 122 additions & 0 deletions src/renderer/components/ToolBar/SyncButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<template>
<div id="sync-button" :class="{ 'is-active' : isOnSyncURL }">
<div @click="syncSite()">
<img src="@/assets/icons/sync.svg" alt>
</div>
</div>
</template>

<script>
// Synchronization server
import * as electron from "electron";
import * as sync from "../../mixins/sync.js";
const currentWindow = electron.remote.getCurrentWindow();
export default {
name: "SyncButton",
data() {
return {
syncServer: ""
};
},
computed: {
url() {
// Bind to our Vuex Store's URL value
return this.$store.state.site.url;
},
isOnSyncURL() {
// Provides simple logic for when to
// show/hide the "Sync" button
if (this.url === this.syncServer) {
return true;
} else {
return false;
}
}
},
watch: {
url: function() {
// When the URL changes...
// update notBrowserSyncURL
// this.syncSite()
}
},
mounted() {
const vm = this;
vm.$nextTick().then(async function() {
// Start our synchronization server
const setup = await sync.startServer();
console.log("setup", setup);
// Fill in syncServer URL
vm.syncServer = setup.proxy;
console.log("sync server", vm.syncServer);
});
},
methods: {
async syncSite() {
// Avoid cyclical server
function compareHosts(url1, url2) {
function returnHost(url) {
var pathArray = url.split("/");
var protocol = pathArray[0];
var host = pathArray[2];
return host;
}
const host1 = returnHost(url1);
const host2 = returnHost(url2);
console.log(host1, host2);
if (host1 === host2) {
return true;
} else {
return false;
}
}
// Changes the BrowserSync proxy URL
if (compareHosts(this.url, this.syncServer) === false) {
// Trigger the NodeJS change
// Send request to change the URL being proxied
await sync.changeURL(this.url);
// Update the global URL
this.$store.commit("changeSiteData", {
url: this.syncServer
});
console.log(this.syncServer);
console.log(this.$store.state.site.url);
return true;
} else {
console.log("Contains sync server", this.url, this.syncServer);
return false;
}
}
}
};
</script>

<style lang="scss" scoped>
@import "../../scss/_variables";
#sync-button {
display: flex;
align-items: center;
background: darkgray;
padding: 0.3rem 0.5rem;
&.is-active {
background: #d1cff5;
}
}
</style>
Loading

0 comments on commit c73c465

Please sign in to comment.