add main ui module and id to dom

This commit is contained in:
Jiiks 2018-01-29 19:56:48 +02:00
parent 88ad25ecc7
commit 5791368a75
6 changed files with 46 additions and 5 deletions

View File

@ -8,12 +8,18 @@
* LICENSE file in the root directory of this source tree.
*/
import { DOM } from './ui';
import { DOM, BdUI } from './ui';
import BdCss from './styles/index.scss';
import { Events } from './modules';
class BetterDiscord {
constructor() {
DOM.injectStyle(BdCss, 'bdmain');
Events.on('global-ready', this.globalReady.bind(this));
}
globalReady() {
BdUI.injectUi();
}
}

26
client/src/ui/bdui.js Normal file
View File

@ -0,0 +1,26 @@
/**
* BetterDiscord Client UI Module
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import Dom from './dom';
import Vue from 'vue';
import { BdSettingsWrapper } from './components';
export default class {
static injectUi() {
Dom.createElement('div', null, 'bd-settings').appendTo(Dom.bdBody);
const vueInstance = new Vue({
el: '#bd-settings',
components: { BdSettingsWrapper },
template: '<BdSettingsWrapper/>'
});
}
}

View File

@ -0,0 +1,6 @@
<template>
<div>Hi!</div>
</template>
<script>
export default {}
</script>

View File

@ -0,0 +1 @@
export { default as BdSettingsWrapper } from './BdSettingsWrapper.vue';

View File

@ -9,9 +9,10 @@
*/
class BdNode {
constructor(tag, className) {
constructor(tag, className, id) {
this.element = document.createElement(tag);
if (className) this.element.className = className;
if (id) this.element.id = id;
}
appendTo(e) {
@ -54,8 +55,8 @@ class DOM {
return document.querySelector(e);
}
static createElement(tag = 'div', className = null) {
return new BdNode(tag, className);
static createElement(tag = 'div', className = null, id = null) {
return new BdNode(tag, className, id);
}
static deleteStyle(id) {

View File

@ -1 +1,2 @@
export { default as DOM } from './dom';
export { default as BdUI } from './bdui';