Skip to content

Commit

Permalink
inserting head at plugin startup
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-jg committed Sep 6, 2021
1 parent d1d24d5 commit 51d78d4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/disabled/disabled-ui.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import 'colors';

.edit-button {
font-family: sans-serif;
font-family: Lato, sans-serif;
position: absolute;
top: 0;
left: 0;
Expand Down
1 change: 0 additions & 1 deletion src/editor-view/editor-view.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');
@import 'colors';

phred-editor-view {
Expand Down
5 changes: 0 additions & 5 deletions src/editor-view/editor-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ export class EditorView extends Widget {

Editor.data.onSelectedObjectChanged.add(this.selectObject, this);

const script = document.createElement('script');
script.src = 'https://kit.fontawesome.com/7ba4e59e46.js';
script.crossOrigin = 'anonymous';
document.head.appendChild(script);

const leftPanel = this.appendChild(document.createElement(Panel.tagName) as Panel);
leftPanel.classList.add('left', 'small');
this.panels.push(leftPanel);
Expand Down
2 changes: 1 addition & 1 deletion src/editor.window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BooleanPropertyEditor } from 'editor-view/properties/editors/boolean/bo
import { NumberPropertyEditor } from 'editor-view/properties/editors/number/number-property-editor';
import { PointPropertyEditor } from 'editor-view/properties/editors/point/point-property-editor';
import { StringPropertyEditor } from 'editor-view/properties/editors/string/string-property-editor';
import { ReferenceImage } from 'index';
import { ReferenceImage } from 'scene-view/reference-image';
import { SceneView } from 'scene-view/scene-view';
import { Plugin } from './plugin';

Expand Down
22 changes: 22 additions & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,34 @@ export class Plugin extends Phaser.Plugin {

public constructor(game: Phaser.Game) {
super(game, game.plugins);
this.insertHead();

this.editorWindow = new EditorWindow();
this.disabledUI = new DisabledUI();
this.disabledUI.onclick = this.enableEditor.bind(this);
}

private insertHead() {
const head = document.head;
const script = document.createElement('script');
script.src = 'https://kit.fontawesome.com/7ba4e59e46.js';
script.crossOrigin = 'anonymous';
head.appendChild(script);

let link = head.appendChild(document.createElement('link'));
link.rel = 'preconnect';
link.href = 'https://fonts.googleapis.com';

link = head.appendChild(document.createElement('link'));
link.rel = 'preconnect';
link.href = 'https://fonts.gstatic.com';
link.crossOrigin = 'true';

link = head.appendChild(document.createElement('link'));
link.rel = 'stylesheet';
link.href = 'https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap';
}

private enableEditor() {
this.editorWindow.show(this);
}
Expand Down

0 comments on commit 51d78d4

Please sign in to comment.