118 lines
3.5 KiB
JavaScript
118 lines
3.5 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.functionalThemeClasses = functionalThemeClasses;
|
||
|
exports.default = void 0;
|
||
|
|
||
|
var _vue = _interopRequireDefault(require("vue"));
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||
|
|
||
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||
|
|
||
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||
|
|
||
|
function functionalThemeClasses(context) {
|
||
|
var vm = _objectSpread({}, context.props, {}, context.injections);
|
||
|
|
||
|
var isDark = Themeable.options.computed.isDark.call(vm);
|
||
|
return Themeable.options.computed.themeClasses.call({
|
||
|
isDark: isDark
|
||
|
});
|
||
|
}
|
||
|
/* @vue/component */
|
||
|
|
||
|
|
||
|
var Themeable = _vue.default.extend().extend({
|
||
|
name: 'themeable',
|
||
|
provide: function provide() {
|
||
|
return {
|
||
|
theme: this.themeableProvide
|
||
|
};
|
||
|
},
|
||
|
inject: {
|
||
|
theme: {
|
||
|
default: {
|
||
|
isDark: false
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
props: {
|
||
|
dark: {
|
||
|
type: Boolean,
|
||
|
default: null
|
||
|
},
|
||
|
light: {
|
||
|
type: Boolean,
|
||
|
default: null
|
||
|
}
|
||
|
},
|
||
|
data: function data() {
|
||
|
return {
|
||
|
themeableProvide: {
|
||
|
isDark: false
|
||
|
}
|
||
|
};
|
||
|
},
|
||
|
computed: {
|
||
|
appIsDark: function appIsDark() {
|
||
|
return this.$vuetify.theme.dark || false;
|
||
|
},
|
||
|
isDark: function isDark() {
|
||
|
if (this.dark === true) {
|
||
|
// explicitly dark
|
||
|
return true;
|
||
|
} else if (this.light === true) {
|
||
|
// explicitly light
|
||
|
return false;
|
||
|
} else {
|
||
|
// inherit from parent, or default false if there is none
|
||
|
return this.theme.isDark;
|
||
|
}
|
||
|
},
|
||
|
themeClasses: function themeClasses() {
|
||
|
return {
|
||
|
'theme--dark': this.isDark,
|
||
|
'theme--light': !this.isDark
|
||
|
};
|
||
|
},
|
||
|
|
||
|
/** Used by menus and dialogs, inherits from v-app instead of the parent */
|
||
|
rootIsDark: function rootIsDark() {
|
||
|
if (this.dark === true) {
|
||
|
// explicitly dark
|
||
|
return true;
|
||
|
} else if (this.light === true) {
|
||
|
// explicitly light
|
||
|
return false;
|
||
|
} else {
|
||
|
// inherit from v-app
|
||
|
return this.appIsDark;
|
||
|
}
|
||
|
},
|
||
|
rootThemeClasses: function rootThemeClasses() {
|
||
|
return {
|
||
|
'theme--dark': this.rootIsDark,
|
||
|
'theme--light': !this.rootIsDark
|
||
|
};
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
isDark: {
|
||
|
handler: function handler(newVal, oldVal) {
|
||
|
if (newVal !== oldVal) {
|
||
|
this.themeableProvide.isDark = this.isDark;
|
||
|
}
|
||
|
},
|
||
|
immediate: true
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var _default = Themeable;
|
||
|
exports.default = _default;
|
||
|
//# sourceMappingURL=index.js.map
|