Skip to content

Commit

Permalink
Feat: Added Settings Addon (#1441)
Browse files Browse the repository at this point in the history
The Settings Addon is an Addon where you can define Settings for OpenSCD.
Currently, all these settings are static.
The dialog to alter settings can be opened or close by emitting an `SettingsUIEvent` with true/false.
  • Loading branch information
pascalwilbrink authored Feb 23, 2024
1 parent 91a2ca9 commit 7ab3553
Show file tree
Hide file tree
Showing 15 changed files with 1,819 additions and 1,852 deletions.
15 changes: 9 additions & 6 deletions packages/open-scd/src/Hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ import { Drawer } from '@material/mwc-drawer';
import { ActionDetail, List } from '@material/mwc-list';
import { ListItem } from '@material/mwc-list/mwc-list-item';

import { Mixin, newPendingStateEvent } from './foundation.js';
import {
Mixin,
newPendingStateEvent,
newSettingsUIEvent,
} from './foundation.js';
import { HistoringElement } from './Historing.js';
import { Plugin, PluggingElement, pluginIcons } from './Plugging.js';
import { SettingElement } from './Setting.js';

interface MenuItem {
icon: string;
Expand All @@ -43,9 +46,7 @@ interface MenuPlugin {
export type HostingElement = Mixin<typeof Hosting>;

export function Hosting<
TBase extends new (...args: any[]) => PluggingElement &
HistoringElement &
SettingElement
TBase extends new (...args: any[]) => PluggingElement & HistoringElement
>(Base: TBase) {
class HostingElement extends Base {
/** The currently active editor tab. */
Expand Down Expand Up @@ -201,7 +202,9 @@ export function Hosting<
{
icon: 'settings',
name: 'settings.title',
action: (): void => this.settingsUI.show(),
action: (): void => {
this.dispatchEvent(newSettingsUIEvent(true));
},
kind: 'static',
},
...bottomMenu,
Expand Down
Loading

0 comments on commit 7ab3553

Please sign in to comment.