Skip to content

Commit

Permalink
feat: primary theme picker
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Bassett <[email protected]>
  • Loading branch information
cadriel committed Feb 26, 2021
1 parent 4543543 commit b1e38cc
Show file tree
Hide file tree
Showing 23 changed files with 209 additions and 92 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ You can download the latest release [here](https://github.com/cadriel/fluidd/rel

Older releases can be found [here](https://github.com/cadriel/fluidd/releases).

## Docker
We have an official docker image. This is updated for each release.
https://hub.docker.com/r/cadriel/fluidd

## How to use?
Fluidd is distributed as a RaspbiOS image, with Fluidd pre-installed and setup alongside its dependencies.
Expand All @@ -30,9 +33,6 @@ Please see the [docs](/docs/README.md) for help with setup.

Please see https://github.com/cadriel/FluiddPI for further instruction.

### ⏳ Manual Installation
Coming soon.

### Credit
A big thank you to;
- the [Voron Community](http://vorondesign.com/)
Expand Down
2 changes: 1 addition & 1 deletion public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"fluidd.xyz",
"fluidd.net"
],
"skipClientUpdates": false
"hosted": false
}
2 changes: 1 addition & 1 deletion server/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"fluidd.xyz",
"fluidd.net"
],
"skipClientUpdates": true
"hosted": true
}
52 changes: 20 additions & 32 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ export default class App extends Mixins(UtilsMixin) {
// }
// }
// async accept () {
// this.showUpdateUI = false
// if (this.$workbox) {
// await this.$workbox.messageSW({ type: 'SKIP_WAITING' })
// }
// }
mounted () {
this.$vuetify.theme.dark = this.$store.state.config.uiSettings.general.darkMode
this.$vuetify.theme.dark = this.$store.state.config.uiSettings.theme.darkMode
EventBus.$on('flashMessage', (payload: FlashMessageType) => {
this.flashMessage.text = (payload && payload.text) || undefined
this.flashMessage.type = (payload && payload.type) || undefined
Expand All @@ -76,13 +83,6 @@ export default class App extends Mixins(UtilsMixin) {
})
}
// async accept () {
// this.showUpdateUI = false
// if (this.$workbox) {
// await this.$workbox.messageSW({ type: 'SKIP_WAITING' })
// }
// }
get updating () {
return this.$store.state.version.busy
}
Expand All @@ -105,18 +105,18 @@ export default class App extends Mixins(UtilsMixin) {
}
get pageIcon () {
let iconUrl
let icon
const theme = this.$store.getters['config/getTheme']
if (this.printerPrinting) {
// Render the progress indicator.
const favIconSize = 64
const percent = this.progress
const primaryColor = this.$vuetify.theme.currentTheme.primary as string
const primaryColor = theme.colors.primary
const secondaryColor = 'rgba(255, 255, 255, 0.10)'
const canvas = document.createElement('canvas') as HTMLCanvasElement
const context = canvas.getContext('2d') as CanvasRenderingContext2D
canvas.width = favIconSize
canvas.height = favIconSize
const context = canvas.getContext('2d') as CanvasRenderingContext2D
const percent = this.progress
const centerX = canvas.width / 2
const centerY = canvas.height / 2
const lineWidth = 8
Expand All @@ -141,15 +141,18 @@ export default class App extends Mixins(UtilsMixin) {
context.lineWidth = lineWidth
context.stroke()
iconUrl = canvas.toDataURL('image/png')
icon = canvas.toDataURL('image/png')
}
// Build a base64 encoded version of our svg with the correct theme color.
const svg_xml = 'data:image/svg+xml;base64,' + btoa(`<svg width="56" height="64" viewBox="0 0 314 361" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g transform="translate(-162.000000, -110.000000)"><path d="M234.444,327.531 L309.066,389.594 C309.906,390.313 310.81,390.928 311.759,391.436 L311.759,391.436 L311.771,391.442 L312.055,391.589 L312.163,391.643 L312.356,391.737 L312.534,391.821 L312.668,391.883 L312.902,391.987 L312.974,392.017 C314.656,392.733 316.433,393.128 318.217,393.206 L318.217,393.206 L318.278,393.209 L318.562,393.218 L318.674,393.22 L318.904,393.221 L319.104,393.22 L319.231,393.218 L319.529,393.208 L319.571,393.207 C321.359,393.128 323.142,392.733 324.829,392.013 L324.829,392.013 L324.877,391.993 L325.143,391.875 L325.244,391.829 L325.438,391.737 L325.643,391.638 L325.731,391.593 L326.012,391.447 L326.042,391.432 C326.989,390.925 327.891,390.311 328.729,389.593 L328.729,389.593 L398.493,331.574 L434.768,355.517 L318.896,470.422 L198.4,350.923 L234.444,327.531 Z M237.067,234.697 L310.465,281.908 C313.075,283.623 315.986,284.481 318.897,284.482 C321.805,284.482 324.713,283.626 327.325,281.912 L327.325,281.912 L400.727,234.702 L456.849,263.367 L318.897,378.093 L180.945,263.359 L237.067,234.697 Z M318.897,110.68 L475.771,168.448 L318.897,269.344 L162.024,168.44 L318.897,110.68 Z" id="Combined-Shape" fill="${theme.colors.primaryOffset}"></path><path d="M318.897,110.68 L475.771,168.448 L319,269.278 L319,111 L318.028,111 L318.897,110.68 Z" id="Combined-Shape" fill="${theme.colors.primary}"></path><path d="M400.727,234.702 L456.849,263.367 L319,378.007 L319.000106,284.481641 C321.735222,284.46261 324.467243,283.686291 326.949875,282.151021 L327.325,281.912 L400.727,234.702 Z" id="Combined-Shape" fill="${theme.colors.primary}"></path><path d="M398.493,331.574 L434.768,355.517 L319,470.319 L319,393.22 L319.104,393.22 L319.231,393.218 L319.529,393.208 L319.571,393.207 C321.359,393.128 323.142,392.733 324.829,392.013 L324.829,392.013 L324.877,391.993 L325.143,391.875 L325.244,391.829 L325.438,391.737 L325.643,391.638 L325.731,391.593 L326.012,391.447 L326.042,391.432 C326.989,390.925 327.891,390.311 328.729,389.593 L328.729,389.593 L398.493,331.574 Z" id="Combined-Shape" fill="${theme.colors.primary}"></path></g></svg>`)
return {
'link[rel="icon"][sizes="32x32"]': {
href: iconUrl || `${process.env.BASE_URL}img/icons/favicon-32x32.png`
href: icon || svg_xml
},
'link[rel="icon"][sizes="16x16"]': {
href: iconUrl || `${process.env.BASE_URL}img/icons/favicon-16x16.png`
href: icon || svg_xml
}
}
}
Expand All @@ -159,18 +162,3 @@ export default class App extends Mixins(UtilsMixin) {
}
}
</script>

<style lang="scss" scoped>
.title {
background: linear-gradient(45deg, #1970b5, #9accf5);
background-clip: text;
-webkit-text-fill-color: transparent;
}
.logo {
margin-right: 12px;
max-height: 40px;
max-width: 40px;
object-fit: contain;
}
</style>
24 changes: 17 additions & 7 deletions src/components/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
>
<v-container fluid class="flex-nowrap constrained-width pa-0 fill-height">
<router-link to="/">
<v-img
alt="Fluidd"
class="shrink mr-4"
contain
:src="require('@/assets/logo.svg')"
transition="scale-transition"
<fluidd-icon
class="shrink mr-4 mt-1 color-filter"
width="35"
height="40"
/>
:primary-color="theme.colors.primary"
:secondary-color="theme.colors.primaryOffset"
></fluidd-icon>
</router-link>
<v-toolbar-title
class="printer-title text--secondary mr-5"
Expand Down Expand Up @@ -101,6 +99,10 @@ export default class AppBar extends Mixins(UtilsMixin) {
return this.$store.getters['version/hasUpdates']
}
get theme () {
return this.$store.getters['config/getTheme']
}
hasUpdate (component: 'klipper' | 'moonraker' | 'client') {
return this.$store.getters['version/hasUpdate'](component)
}
Expand All @@ -127,6 +129,14 @@ export default class AppBar extends Mixins(UtilsMixin) {
</script>

<style lang="scss" scoped>
.fill1 {
fill: #2E75AE;
}
.fill2 {
fill: #2196F3;
}
.printer-title {
font-size: 1.25rem;
font-weight: 300;
Expand Down
37 changes: 37 additions & 0 deletions src/components/FluiddIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<svg
alt="Fluidd"
:width="width"
:height="height"
viewBox="0 0 314 361"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g transform="translate(-162.000000, -110.000000)">
<path d="M234.444,327.531 L309.066,389.594 C309.906,390.313 310.81,390.928 311.759,391.436 L311.759,391.436 L311.771,391.442 L312.055,391.589 L312.163,391.643 L312.356,391.737 L312.534,391.821 L312.668,391.883 L312.902,391.987 L312.974,392.017 C314.656,392.733 316.433,393.128 318.217,393.206 L318.217,393.206 L318.278,393.209 L318.562,393.218 L318.674,393.22 L318.904,393.221 L319.104,393.22 L319.231,393.218 L319.529,393.208 L319.571,393.207 C321.359,393.128 323.142,392.733 324.829,392.013 L324.829,392.013 L324.877,391.993 L325.143,391.875 L325.244,391.829 L325.438,391.737 L325.643,391.638 L325.731,391.593 L326.012,391.447 L326.042,391.432 C326.989,390.925 327.891,390.311 328.729,389.593 L328.729,389.593 L398.493,331.574 L434.768,355.517 L318.896,470.422 L198.4,350.923 L234.444,327.531 Z M237.067,234.697 L310.465,281.908 C313.075,283.623 315.986,284.481 318.897,284.482 C321.805,284.482 324.713,283.626 327.325,281.912 L327.325,281.912 L400.727,234.702 L456.849,263.367 L318.897,378.093 L180.945,263.359 L237.067,234.697 Z M318.897,110.68 L475.771,168.448 L318.897,269.344 L162.024,168.44 L318.897,110.68 Z" id="Combined-Shape" :fill="secondaryColor"></path>
<path d="M318.897,110.68 L475.771,168.448 L319,269.278 L319,111 L318.028,111 L318.897,110.68 Z" id="Combined-Shape" :fill="primaryColor"></path>
<path d="M400.727,234.702 L456.849,263.367 L319,378.007 L319.000106,284.481641 C321.735222,284.46261 324.467243,283.686291 326.949875,282.151021 L327.325,281.912 L400.727,234.702 Z" id="Combined-Shape" :fill="primaryColor"></path>
<path d="M398.493,331.574 L434.768,355.517 L319,470.319 L319,393.22 L319.104,393.22 L319.231,393.218 L319.529,393.208 L319.571,393.207 C321.359,393.128 323.142,392.733 324.829,392.013 L324.829,392.013 L324.877,391.993 L325.143,391.875 L325.244,391.829 L325.438,391.737 L325.643,391.638 L325.731,391.593 L326.012,391.447 L326.042,391.432 C326.989,390.925 327.891,390.311 328.729,389.593 L328.729,389.593 L398.493,331.574 Z" id="Combined-Shape" :fill="primaryColor"></path>
</g>
</svg>
</template>

<script lang="ts">
import Vue from 'vue'
import { Component, Prop } from 'vue-property-decorator'
@Component({})
export default class FluiddIcon extends Vue {
@Prop({ type: String, default: 'success' })
width!: string;
@Prop({ type: String, default: 'Saved!' })
height!: string;
@Prop({ type: String, required: true })
primaryColor!: string;
@Prop({ type: String, required: true })
secondaryColor!: string;
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<v-icon
:small="small"
>
{{ (type === 'info') ? '$help' : '$alert' }}
{{ (type === 'error' || type === 'warning') ? '$alert' : '$help' }}
</v-icon>
</v-btn>
</template>
Expand All @@ -30,7 +30,7 @@ export default class InlineHelpIcon extends Vue {
@Prop({ type: String, required: false })
tooltip!: string
@Prop({ type: String, default: 'info' })
@Prop({ type: String, default: 'primary' })
type!: string
@Prop({ type: Boolean, default: false })
Expand Down
92 changes: 72 additions & 20 deletions src/components/cards/settings/ThemeSettingsCard.vue
Original file line number Diff line number Diff line change
@@ -1,46 +1,98 @@

<template>
<collapsable-card
title="Themes"
title="Theme"
subTitle="Define a primary color, and whether to show in dark mode or not."
cardKey="ThemeSettings"
icon="$cogs">
<v-card-text>
<v-select
label="Theme"
v-model="theme"
:items="['dark', 'light']">
</v-select>
<!-- <v-switch
<!-- <pre>{{ $vuetify.theme.themes.dark }}</pre> -->
<!-- <pre>{{ color }}</pre> -->

<v-color-picker
:value="theme.colors.primary"
@update:color="handlePrimaryColorChange"
mode="hexa"
hide-mode-switch
hide-inputs
canvas-height="100"
dot-size="25"
>
</v-color-picker>

<v-switch
@click.native.stop
v-model="darkmode"
label="Dark Mode"
v-model="theme.darkMode"
@change="handleDarkModeChange"
hide-details
class="mr-5 d-none d-sm-block"
></v-switch> -->
class="mb-5"
></v-switch>

<v-btn
color="secondary"
@click="handleReset"
>
Reset to default
</v-btn>

</v-card-text>
</collapsable-card>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator'
import { debounce } from 'lodash-es'
import UtilsMixin from '@/mixins/utils'
import { ThemeConfig } from '@/store/config/types'
@Component({
components: {}
})
export default class ThemeSettingsCard extends Mixins(UtilsMixin) {
// Theme is currently restricted to dark / light.
// This starts impl thought on more options.
get theme () {
const darkMode = this.$store.state.config.uiSettings.general.darkMode
return (darkMode)
? 'dark'
: 'light'
return this.$store.getters['config/getTheme']
}
setTheme (value: ThemeConfig) {
this.$vuetify.theme.dark = value.darkMode
this.$vuetify.theme.currentTheme.primary = value.colors.primary
}
handlePrimaryColorChange = debounce((value: { hex: string }) => {
this.setTheme({
darkMode: this.theme.darkMode,
colors: {
primary: value.hex
}
})
this.$store.dispatch('config/saveGeneric', { key: 'uiSettings.theme.colors.primary', value: value.hex })
}, 500)
handleDarkModeChange (value: boolean) {
this.setTheme({
darkMode: value,
colors: {
primary: this.theme.colors.primary
}
})
this.$store.dispatch('config/saveGeneric', { key: 'uiSettings.theme.darkMode', value })
}
set theme (val: string) {
const darkMode = (val === 'dark')
this.$vuetify.theme.dark = darkMode
this.$store.dispatch('config/saveGeneric', { key: 'uiSettings.general.darkMode', value: darkMode })
handleReset () {
const theme: ThemeConfig = {
darkMode: true,
colors: {
primary: '#2196F3'
}
}
this.setTheme(theme)
this.$store.dispatch('config/saveGeneric', {
key: 'uiSettings.theme',
value: theme
})
}
}
</script>
2 changes: 1 addition & 1 deletion src/components/widgets/EChartsWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class EChartsWidget extends Vue {
}
initOptions () {
const darkMode = this.$store.state.config.uiSettings.general.darkMode
const darkMode = this.$store.state.config.uiSettings.theme.darkMode
const fontSize = 16
const lineOpacity = 0.2
let labelBackground = 'rgba(10,10,10,0.90)'
Expand Down
5 changes: 5 additions & 0 deletions src/components/widgets/SystemCommandsWidget.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div>
<v-list-group
v-if="!hosted"
prepend-icon="$host"
no-action>
<template v-slot:activator>
Expand Down Expand Up @@ -131,6 +132,10 @@ export default class SystemCommandsWidget extends Mixins(UtilsMixin) {
open: false
}
get hosted () {
return this.$store.state.config.hostConfig.hosted
}
get powerDevices () {
return this.$store.state.devicePower.devices
}
Expand Down
Loading

0 comments on commit b1e38cc

Please sign in to comment.