From 7f63a88e9a036fd1eb7c0c2d234c2d83c09b7182 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 14 Feb 2022 04:56:34 +0100 Subject: [PATCH] Styling tweaks --- Docs/Schemas/ExtraLinkConfigJson.schema.json | 66 ++++++++++++++++++++ Docs/Schemas/ExtraLinkConfigJsonJSC.ts | 64 +++++++++++++++++++ UI/BigComponents/ExtraLinkButton.ts | 2 +- UI/DefaultGUI.ts | 27 ++++---- 4 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 Docs/Schemas/ExtraLinkConfigJson.schema.json create mode 100644 Docs/Schemas/ExtraLinkConfigJsonJSC.ts diff --git a/Docs/Schemas/ExtraLinkConfigJson.schema.json b/Docs/Schemas/ExtraLinkConfigJson.schema.json new file mode 100644 index 0000000000..9d232d1f21 --- /dev/null +++ b/Docs/Schemas/ExtraLinkConfigJson.schema.json @@ -0,0 +1,66 @@ +{ + "type": "object", + "properties": { + "icon": { + "type": "string" + }, + "text": {}, + "href": { + "type": "string" + }, + "newTab": { + "type": "boolean" + }, + "requirements": { + "type": "array", + "items": { + "enum": [ + "iframe", + "no-iframe", + "no-welcome-message", + "welcome-message" + ], + "type": "string" + } + } + }, + "required": [ + "href" + ], + "definitions": { + "AndOrTagConfigJson": { + "type": "object", + "properties": { + "and": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/AndOrTagConfigJson" + }, + { + "type": "string" + } + ] + } + }, + "or": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/AndOrTagConfigJson" + }, + { + "type": "string" + } + ] + } + } + }, + "additionalProperties": false + } + }, + "$schema": "http://json-schema.org/draft-07/schema#", + "additionalProperties": false +} \ No newline at end of file diff --git a/Docs/Schemas/ExtraLinkConfigJsonJSC.ts b/Docs/Schemas/ExtraLinkConfigJsonJSC.ts new file mode 100644 index 0000000000..b3175e1c4a --- /dev/null +++ b/Docs/Schemas/ExtraLinkConfigJsonJSC.ts @@ -0,0 +1,64 @@ +export default { + "type": "object", + "properties": { + "icon": { + "type": "string" + }, + "text": {}, + "href": { + "type": "string" + }, + "newTab": { + "type": "boolean" + }, + "requirements": { + "type": "array", + "items": { + "enum": [ + "iframe", + "no-iframe", + "no-welcome-message", + "welcome-message" + ], + "type": "string" + } + } + }, + "required": [ + "href" + ], + "definitions": { + "AndOrTagConfigJson": { + "type": "object", + "properties": { + "and": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/AndOrTagConfigJson" + }, + { + "type": "string" + } + ] + } + }, + "or": { + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/AndOrTagConfigJson" + }, + { + "type": "string" + } + ] + } + } + } + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" +} \ No newline at end of file diff --git a/UI/BigComponents/ExtraLinkButton.ts b/UI/BigComponents/ExtraLinkButton.ts index 3de7aa6b2b..4d7c6e06c2 100644 --- a/UI/BigComponents/ExtraLinkButton.ts +++ b/UI/BigComponents/ExtraLinkButton.ts @@ -64,7 +64,7 @@ export default class ExtraLinkButton extends UIElement{ link = new SubtleButton(img,c.text, {url: href, - newTab: c.newTab}).SetClass("w-64 block") + newTab: c.newTab}) } if(c.requirements.has("no-welcome-message")){ diff --git a/UI/DefaultGUI.ts b/UI/DefaultGUI.ts index 1993112076..7a9786787c 100644 --- a/UI/DefaultGUI.ts +++ b/UI/DefaultGUI.ts @@ -159,24 +159,25 @@ export default class DefaultGUI { const guiState = this._guiState; const self = this - Toggle.If(state.featureSwitchUserbadge, - () => new UserBadge(state) - ).AttachTo("userbadge") + new Combine([ + Toggle.If(state.featureSwitchUserbadge, + () => new UserBadge(state) + ), + Toggle.If(state.featureSwitchExtraLinkEnabled, + () => new ExtraLinkButton(state, state.layoutToUse.extraLink) + ) + ]).SetClass("flex flex-col") + .AttachTo("userbadge") Toggle.If(state.featureSwitchSearch, () => new SearchAndGo(state)) .AttachTo("searchbox"); - new Combine([ - Toggle.If(state.featureSwitchExtraLinkEnabled, - () => new ExtraLinkButton(state, state.layoutToUse.extraLink).SetClass("pointer-events-auto") - ) - , - Toggle.If( - state.featureSwitchWelcomeMessage, - () => self.InitWelcomeMessage() - )]) - .SetClass("flex flex-col") + + Toggle.If( + state.featureSwitchWelcomeMessage, + () => self.InitWelcomeMessage() + ) .AttachTo("messagesbox");