-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
6 changed files
with
154 additions
and
14 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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
div.light-dark-switch { | ||
left: 20px; | ||
left: 242px; | ||
bottom: 70px; | ||
padding: 10px 10px; | ||
} | ||
|
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,30 @@ | ||
div.settings-ui { | ||
left: 20px; | ||
bottom: 70px; | ||
padding: 10px 10px; | ||
min-width: 190px; | ||
} | ||
|
||
#settings-ui-accordion-label .accordion-button::before { | ||
content: ""; | ||
background-image: url("@fortawesome/fontawesome-free/svgs/solid/gear.svg"); | ||
display: inline-block; | ||
filter: invert(var(--dark-mode)); | ||
height: 16px; | ||
width: 16px; | ||
background-size: 16px 16px; | ||
vertical-align: text-top; | ||
} | ||
|
||
#settings-content { | ||
display: grid; | ||
} | ||
|
||
#settings-content > label { | ||
grid-column-start: 1; | ||
} | ||
|
||
#settings-content > input, | ||
#settings-content > select { | ||
grid-column-start: 2; | ||
} |
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,70 @@ | ||
import { AbstractUIExtension } from "sprotty"; | ||
import { inject, injectable } from "inversify"; | ||
|
||
import "./settingsMenu.css"; | ||
|
||
@injectable() | ||
export class SettingsManager { | ||
public layoutMethod: LayoutMethod = LayoutMethod.LINES; | ||
} | ||
|
||
@injectable() | ||
export class SettingsUI extends AbstractUIExtension { | ||
static readonly ID = "settings-ui"; | ||
|
||
constructor(@inject(SettingsManager) protected readonly settings: SettingsManager) { | ||
super(); | ||
} | ||
|
||
id(): string { | ||
return SettingsUI.ID; | ||
} | ||
|
||
containerClass(): string { | ||
return SettingsUI.ID; | ||
} | ||
|
||
protected initializeContents(containerElement: HTMLElement): void { | ||
containerElement.classList.add("ui-float"); | ||
containerElement.innerHTML = ` | ||
<input type="checkbox" id="accordion-state-settings" class="accordion-state" hidden> | ||
<label id="settings-ui-accordion-label" for="accordion-state-settings"> | ||
<div class="accordion-button flip-arrow"> | ||
Settings | ||
</div> | ||
</label> | ||
<div class="accordion-content"> | ||
<div id="settings-content"> | ||
<label for="setting-layout-option">Layout Method:</label> | ||
<select name="setting-layout-option" id="setting-layout-option"> | ||
<option value="${LayoutMethod.LINES}">Lines</option> | ||
<option value="${LayoutMethod.WRAPPING}">Wrapping Lines</option> | ||
<option value="${LayoutMethod.CIRCLES}">Circles</option> | ||
</select> | ||
</div> | ||
</div> | ||
`; | ||
|
||
// Set `settings-enabled` class on body element when keyboard shortcut overview is open. | ||
const checkbox = containerElement.querySelector("#accordion-state-settings") as HTMLInputElement; | ||
const bodyElement = document.querySelector("body") as HTMLBodyElement; | ||
checkbox.addEventListener("change", () => { | ||
if (checkbox.checked) { | ||
bodyElement.classList.add("settings-enabled"); | ||
} else { | ||
bodyElement.classList.remove("settings-enabled"); | ||
} | ||
}); | ||
|
||
const layoutOptionSelect = containerElement.querySelector("#setting-layout-option") as HTMLSelectElement; | ||
layoutOptionSelect.addEventListener("change", () => { | ||
this.settings.layoutMethod = layoutOptionSelect.value as LayoutMethod; | ||
}); | ||
} | ||
} | ||
|
||
export enum LayoutMethod { | ||
LINES = "Lines", | ||
WRAPPING = "Wrapping Lines", | ||
CIRCLES = "Circles", | ||
} |
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