Skip to content

A full-featured download manager.

refactor: new title-bar component

Dr_rOotf5b30efc7d4b
diff --git a/src/renderer/assets/icons/win-close.svg b/src/renderer/assets/icons/win-close.svg
new file mode 100644
index 00000000..c6b45a3c
--- /dev/null
+++ b/src/renderer/assets/icons/win-close.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" width="12" height="12">
+ <g class="nc-icon-wrapper" stroke-width="1" fill="#111111" stroke="#111111">
+ <line x1="1.5" y1="1.5" x2="10.5" y2="10.5" fill="none" stroke="#111111" stroke-linecap="round" stroke-linejoin="round"/>
+ <line x1="10.5" y1="1.5" x2="1.5" y2="10.5" fill="none" stroke="#111111" stroke-linecap="round" stroke-linejoin="round"/>
+ </g>
+</svg>
diff --git a/src/renderer/assets/icons/win-maximize.svg b/src/renderer/assets/icons/win-maximize.svg
new file mode 100644
index 00000000..1d3210e6
--- /dev/null
+++ b/src/renderer/assets/icons/win-maximize.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" width="12" height="12">
+ <g class="nc-icon-wrapper" stroke-width="1" fill="#111111" stroke="#111111">
+ <polyline points="5.5 1.5 10.5 1.5 10.5 6.5" fill="none" stroke="#111111" stroke-linecap="round" stroke-linejoin="round"/>
+ <polyline points="1.5 5.5 1.5 10.5 6.5 10.5" fill="none" stroke-linecap="round" stroke-linejoin="round" data-color="color-2"/>
+ </g>
+</svg>
diff --git a/src/renderer/assets/icons/win-minimize.svg b/src/renderer/assets/icons/win-minimize.svg
new file mode 100644
index 00000000..a59644be
--- /dev/null
+++ b/src/renderer/assets/icons/win-minimize.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" width="12" height="12">
+ <g class="nc-icon-wrapper" stroke-width="1" fill="#111111" stroke="#111111">
+ <line x1="1" y1="6" x2="11" y2="6" fill="none" stroke="#111111" stroke-linecap="round" stroke-linejoin="round"/>
+ </g>
+</svg>
diff --git a/src/renderer/components/Icons/win-close.js b/src/renderer/components/Icons/win-close.js
new file mode 100644
index 00000000..bd6c5824
--- /dev/null
+++ b/src/renderer/components/Icons/win-close.js
@@ -0,0 +1,16 @@
+import Icon from '@/components/Icons/Icon'
+
+Icon.register({
+ 'win-close': {
+ 'width': 12,
+ 'height': 12,
+ 'raw': `<line x1="1.5" y1="1.5" x2="10.5" y2="10.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
+ <line x1="10.5" y1="1.5" x2="1.5" y2="10.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`,
+ 'g': {
+ 'stroke': 'currentColor',
+ 'stroke-linecap': 'round',
+ 'stroke-linejoin': 'round',
+ 'stroke-width': '1'
+ }
+ }
+})
diff --git a/src/renderer/components/Icons/win-maximize.js b/src/renderer/components/Icons/win-maximize.js
new file mode 100644
index 00000000..77ccb637
--- /dev/null
+++ b/src/renderer/components/Icons/win-maximize.js
@@ -0,0 +1,16 @@
+import Icon from '@/components/Icons/Icon'
+
+Icon.register({
+ 'win-maximize': {
+ 'width': 12,
+ 'height': 12,
+ 'raw': `<polyline points="5.5 1.5 10.5 1.5 10.5 6.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
+ <polyline points="1.5 5.5 1.5 10.5 6.5 10.5" fill="none" stroke-linecap="round" stroke-linejoin="round" />`,
+ 'g': {
+ 'stroke': 'currentColor',
+ 'stroke-linecap': 'round',
+ 'stroke-linejoin': 'round',
+ 'stroke-width': '1'
+ }
+ }
+})
diff --git a/src/renderer/components/Icons/win-minimize.js b/src/renderer/components/Icons/win-minimize.js
new file mode 100644
index 00000000..d6aaea8c
--- /dev/null
+++ b/src/renderer/components/Icons/win-minimize.js
@@ -0,0 +1,15 @@
+import Icon from '@/components/Icons/Icon'
+
+Icon.register({
+ 'win-minimize': {
+ 'width': 12,
+ 'height': 12,
+ 'raw': `<line x1="1" y1="6" x2="11" y2="6" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`,
+ 'g': {
+ 'stroke': 'currentColor',
+ 'stroke-linecap': 'round',
+ 'stroke-linejoin': 'round',
+ 'stroke-width': '1'
+ }
+ }
+})
diff --git a/src/renderer/components/Native/TitleBar.vue b/src/renderer/components/Native/TitleBar.vue
new file mode 100644
index 00000000..67402f50
--- /dev/null
+++ b/src/renderer/components/Native/TitleBar.vue
@@ -0,0 +1,68 @@
+<template>
+ <div class="title-bar">
+ <ul v-if="showActions" class="window-actions">
+ <li @click="handleMinimize">
+ <mo-icon name="win-minimize" width="12" height="12" />
+ </li>
+ <li @click="handleMaximize">
+ <mo-icon name="win-maximize" width="12" height="12" />
+ </li>
+ <li @click="handleClose">
+ <mo-icon name="win-close" width="12" height="12" />
+ </li>
+ </ul>
+ </div>
+</template>
+
+<script>
+ import '@/components/Icons/win-minimize'
+ import '@/components/Icons/win-maximize'
+ import '@/components/Icons/win-close'
+
+ export default {
+ name: 'mo-title-bar',
+ props: {
+ showActions: {
+ type: Boolean
+ }
+ },
+ computed: {
+ win: function () {
+ return this.$electron.remote.getCurrentWindow()
+ }
+ },
+ methods: {
+ handleMinimize: function () {
+ this.win.minimize()
+ },
+ handleMaximize: function () {
+ if (this.win.isMaximized()) {
+ this.win.unmaximize()
+ } else {
+ this.win.maximize()
+ }
+ },
+ handleClose: function () {
+ this.win.close()
+ }
+ }
+ }
+</script>
+
+<style lang="scss">
+ .window-actions {
+ position: fixed;
+ top: 0;
+ right: 24px;
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ > li {
+ float: left;
+ padding: 5px 10px;
+ &:hover {
+ background-color: #eee;
+ }
+ }
+ }
+</style>