-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2a042a
commit 09f71d3
Showing
6 changed files
with
72 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/editor-view/actions/reference-image/group/reference-image-group.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
phred-reference-image-group { | ||
display: flex; | ||
align-items: stretch; | ||
justify-content: stretch; | ||
} |
58 changes: 58 additions & 0 deletions
58
src/editor-view/actions/reference-image/group/reference-image-group.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Action, ActionHandler } from 'core/action-handler'; | ||
import { Actions } from 'core/actions'; | ||
import { Editor } from 'core/editor'; | ||
import { PreferenceKey } from 'core/preferences/preferences.model'; | ||
import { PreferencesUtil } from 'core/preferences/preferences.util'; | ||
import { ActionButton } from 'editor-view/actions/button/action-button'; | ||
import './reference-image-group.scss'; | ||
|
||
export class ReferenceImageGroup extends HTMLElement { | ||
public static readonly tagName = 'phred-reference-image-group'; | ||
|
||
private optionsButton: HTMLElement; | ||
|
||
public init(actions: ActionHandler) { | ||
this.classList.add('reference-image-group'); | ||
|
||
this.createButton(actions.getAction(Actions.TOGGLE_REF_IMAGE)); | ||
|
||
const optionsButton = this.appendChild(document.createElement('div')); | ||
optionsButton.classList.add('open-options-button', 'button', 'action-button'); | ||
|
||
optionsButton.appendChild(document.createElement('i')) | ||
.classList.add('fas', 'fa-caret-down'); | ||
|
||
optionsButton.addEventListener('click', () => { | ||
Editor.referenceImageController.openOptionsPanel(optionsButton); | ||
}); | ||
|
||
this.optionsButton = optionsButton; | ||
|
||
PreferencesUtil.setupPreferences( | ||
['referenceImageEnabled', 'referenceImageVisible'], | ||
this.onPreferencesChanged, | ||
this | ||
); | ||
} | ||
|
||
private createButton(action: Action) { | ||
if (!action) return null; | ||
const btn = document.createElement(ActionButton.tagName) as ActionButton; | ||
btn.setAction(action); | ||
this.appendChild(btn); | ||
return btn; | ||
} | ||
|
||
private onPreferencesChanged(pref: PreferenceKey, value: any) { | ||
if (pref === 'referenceImageEnabled') { | ||
this.classList.addOrRemove('disabled', value !== true); | ||
return; | ||
} | ||
|
||
if (pref === 'referenceImageVisible') { | ||
this.optionsButton.classList.addOrRemove('disabled', value !== true); | ||
} | ||
} | ||
} | ||
|
||
customElements.define(ReferenceImageGroup.tagName, ReferenceImageGroup); |
File renamed without changes.
File renamed without changes.