From fc8c1ab74ecca8319a97e4e0da7f5eb6c18a6304 Mon Sep 17 00:00:00 2001 From: cristij Date: Fri, 24 Aug 2018 09:07:52 +0300 Subject: [PATCH] Initial support for RTL page --- src/components/Cards/Card.vue | 7 +- src/layout/dashboard/TopNavbar.vue | 3 + src/pages/RTLSupport.vue | 254 +++++++++++++++++++++++++++++ src/plugins/RTLPlugin.js | 28 ++++ src/plugins/blackDashboard.js | 2 + src/router/routes.js | 8 +- 6 files changed, 300 insertions(+), 2 deletions(-) create mode 100644 src/pages/RTLSupport.vue create mode 100644 src/plugins/RTLPlugin.js diff --git a/src/components/Cards/Card.vue b/src/components/Cards/Card.vue index 8b9f67d..39c8d17 100644 --- a/src/components/Cards/Card.vue +++ b/src/components/Cards/Card.vue @@ -3,7 +3,7 @@
-
+

{{title}}

{{subTitle}}

@@ -25,6 +25,11 @@ export default { title: String, subTitle: String, type: String + }, + computed: { + isRTL() { + return this.$rtl.isRTL; + } } }; diff --git a/src/layout/dashboard/TopNavbar.vue b/src/layout/dashboard/TopNavbar.vue index a042779..4a44d4a 100644 --- a/src/layout/dashboard/TopNavbar.vue +++ b/src/layout/dashboard/TopNavbar.vue @@ -43,6 +43,9 @@ export default { routeName() { const { name } = this.$route; return this.capitalizeFirstLetter(name); + }, + isRTL() { + return this.$rtl.isRTL; } }, data() { diff --git a/src/pages/RTLSupport.vue b/src/pages/RTLSupport.vue new file mode 100644 index 0000000..09514f2 --- /dev/null +++ b/src/pages/RTLSupport.vue @@ -0,0 +1,254 @@ + + + diff --git a/src/plugins/RTLPlugin.js b/src/plugins/RTLPlugin.js new file mode 100644 index 0000000..600ab65 --- /dev/null +++ b/src/plugins/RTLPlugin.js @@ -0,0 +1,28 @@ +export default { + install(Vue) { + let app = new Vue({ + data() { + return { + isRTL: false + } + }, + methods: { + getDocClasses() { + return document.body.classList + }, + enableRTL() { + this.isRTL = true; + this.getDocClasses().add('rtl'); + this.getDocClasses().add('menu-on-right'); + }, + disableRTL() { + this.isRTL = false; + this.getDocClasses().add('rtl'); + this.getDocClasses().add('menu-on-right'); + } + } + }); + + Vue.prototype.$rtl = app; + } +} diff --git a/src/plugins/blackDashboard.js b/src/plugins/blackDashboard.js index 403a6b7..3e101a5 100644 --- a/src/plugins/blackDashboard.js +++ b/src/plugins/blackDashboard.js @@ -2,6 +2,7 @@ import SideBar from "@/components/SidebarPlugin"; import Notify from "@/components/NotificationPlugin"; import GlobalComponents from "./globalComponents"; import GlobalDirectives from "./globalDirectives"; +import RTLPlugin from "./RTLPlugin"; import "es6-promise/auto"; //css assets @@ -16,5 +17,6 @@ export default { Vue.use(GlobalDirectives); Vue.use(SideBar); Vue.use(Notify); + Vue.use(RTLPlugin); } } diff --git a/src/router/routes.js b/src/router/routes.js index 4ae27e4..744162e 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -4,6 +4,7 @@ import NotFound from "@/pages/NotFoundPage.vue"; // Admin pages import Dashboard from "@/pages/Dashboard.vue"; +import RTLSupport from "@/pages/RTLSupport.vue"; import Profile from "@/pages/Profile.vue"; import Notifications from "@/pages/Notifications.vue"; import Icons from "@/pages/Icons.vue"; @@ -51,7 +52,12 @@ const routes = [ path: "table-list", name: "table-list", component: TableList - } + }, + { + path: "rtl-support", + name: "RTLSupport", + component: RTLSupport + }, ] }, { path: "*", component: NotFound },