From a2cdbbc833a87117cbd5757dc864b8ba4c93b7bc Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Wed, 13 May 2020 15:25:03 +0300 Subject: [PATCH] Dark theme support for charts --- src/App.vue | 9 ++ src/AppConfigurator.vue | 46 +++---- src/AppTopBar.vue | 28 ++-- src/EventBus.js | 3 + src/views/chart/BarChartDemo.vue | 179 +++++++++++++++++++++++-- src/views/chart/BarChartDoc.vue | 22 +-- src/views/chart/ComboChartDemo.vue | 72 +++++++++- src/views/chart/ComboChartDoc.vue | 6 +- src/views/chart/DoughnutChartDemo.vue | 35 ++++- src/views/chart/DoughnutChartDoc.vue | 18 +-- src/views/chart/LineChartDemo.vue | 141 +++++++++++++++++-- src/views/chart/LineChartDoc.vue | 11 +- src/views/chart/PieChartDemo.vue | 47 ++++++- src/views/chart/PieChartDoc.vue | 18 +-- src/views/chart/PolarAreaChartDemo.vue | 57 +++++++- src/views/chart/PolarAreaChartDoc.vue | 10 +- src/views/chart/RadarChartDemo.vue | 47 ++++++- 17 files changed, 628 insertions(+), 121 deletions(-) create mode 100644 src/EventBus.js diff --git a/src/App.vue b/src/App.vue index 3e0e3f8c8..5ddc4e3cd 100755 --- a/src/App.vue +++ b/src/App.vue @@ -30,6 +30,7 @@ import AppTopBar from '@/AppTopBar.vue'; import AppMenu from '@/AppMenu.vue'; import AppFooter from '@/AppFooter.vue'; import AppConfigurator from '@/AppConfigurator.vue'; +import EventBus from '@/EventBus'; export default { data() { @@ -70,6 +71,14 @@ export default { this.theme = event.theme; this.activeMenuIndex = null; + + EventBus.$emit('change-theme', event); + + if (event.dark) + document.body.setAttribute('data-darktheme', 'true'); + else + document.body.removeAttribute('data-darktheme') + }, addClass(element, className) { if (!this.hasClass(element, className)) { diff --git a/src/AppConfigurator.vue b/src/AppConfigurator.vue index b86a4134f..df05e2446 100755 --- a/src/AppConfigurator.vue +++ b/src/AppConfigurator.vue @@ -16,28 +16,28 @@
Saga Blue
Saga Cyan
Saga Deep Purple
Saga Green @@ -51,133 +51,133 @@
Saga Orange
Saga Purple
Saga Teal
Vela Blue
Vela Cyan
Vela Deep Purple
Vela Green
Vela Indigo
Vela Orange
Vela Purple
Vela Teal
Nova Light
Nova Dark
Nova Colored
Nova Vue
Luna Blue
Luna Green
Luna Amber
Luna Pink diff --git a/src/AppTopBar.vue b/src/AppTopBar.vue index e0c18d85b..abd70c60b 100755 --- a/src/AppTopBar.vue +++ b/src/AppTopBar.vue @@ -25,22 +25,22 @@
  • Saga OrangeSaga Orange
  • Saga PurpleSaga Purple
  • Saga TealSaga Teal
  • -
  • Vela BlueVela Blue
  • -
  • Vela CyanVela Cyan
  • -
  • Vela Deep PurpleVela Deep Purple
  • -
  • Vela GreenVela Green
  • -
  • Vela IndigoVela Indigo
  • -
  • Vela OrangeVela Orange
  • -
  • Vela PurpleVela Purple
  • -
  • Vela TealVela Teal
  • +
  • Vela BlueVela Blue
  • +
  • Vela CyanVela Cyan
  • +
  • Vela Deep PurpleVela Deep Purple
  • +
  • Vela GreenVela Green
  • +
  • Vela IndigoVela Indigo
  • +
  • Vela OrangeVela Orange
  • +
  • Vela PurpleVela Purple
  • +
  • Vela TealVela Teal
  • Nova LightNova Light
  • Nova DarkNova Dark
  • Nova ColoredNova Colored
  • Nova VueNova Vue
  • -
  • Luna AmberLuna Amber
  • -
  • Luna BlueLuna Blue
  • -
  • Luna GreenLuna Green
  • -
  • Luna PinkLuna Pink
  • +
  • Luna AmberLuna Amber
  • +
  • Luna BlueLuna Blue
  • +
  • Luna GreenLuna Green
  • +
  • Luna PinkLuna Pink
  • RheaRhea
  • @@ -97,8 +97,8 @@ export default { } }, methods: { - changeTheme(event, theme) { - this.$emit('change-theme', {theme: theme}); + changeTheme(event, theme, dark) { + this.$emit('change-theme', {theme: theme, dark: dark}); this.activeMenuIndex = null; event.preventDefault(); }, diff --git a/src/EventBus.js b/src/EventBus.js new file mode 100644 index 000000000..27f698ab7 --- /dev/null +++ b/src/EventBus.js @@ -0,0 +1,3 @@ +import Vue from 'vue'; +const EventBus = new Vue(); +export default EventBus; \ No newline at end of file diff --git a/src/views/chart/BarChartDemo.vue b/src/views/chart/BarChartDemo.vue index f69bb51a0..e886942dc 100755 --- a/src/views/chart/BarChartDemo.vue +++ b/src/views/chart/BarChartDemo.vue @@ -9,16 +9,16 @@

    Vertical

    - +

    Horizontal

    - +

    Multi Axis

    - +

    Stacked

    - +
    @@ -27,8 +27,21 @@