diff --git a/code/controllers/subsystem/tgui.dm b/code/controllers/subsystem/tgui.dm index a3ef03f3e397..7df4e7ce9c2b 100644 --- a/code/controllers/subsystem/tgui.dm +++ b/code/controllers/subsystem/tgui.dm @@ -32,6 +32,7 @@ SUBSYSTEM_DEF(tgui) var/polyfill = file2text('tgui/public/tgui-polyfill.min.js') polyfill = "" basehtml = replacetextEx(basehtml, "", polyfill) + basehtml = replacetext(basehtml, "tgui:stylesheet", MAP_STYLESHEET) /datum/controller/subsystem/tgui/Shutdown() close_all_uis() diff --git a/code/modules/tgui/tgui.dm b/code/modules/tgui/tgui.dm index 123c0f5a6414..c30c0b1d984f 100644 --- a/code/modules/tgui/tgui.dm +++ b/code/modules/tgui/tgui.dm @@ -245,7 +245,6 @@ "status" = status, "interface" = interface, "refreshing" = refreshing, - "styles" = MAP_STYLESHEET, "window" = list( "key" = window_key, "size" = window_size, diff --git a/tgui/global.d.ts b/tgui/global.d.ts index 9cb8e37c2e8c..994632e499a3 100644 --- a/tgui/global.d.ts +++ b/tgui/global.d.ts @@ -158,6 +158,11 @@ type ByondType = { * Loads a script into the document. */ loadJs(url: string): void; + + /** + * The ByondCSS stylesheet to load into ByondUI components + */ + styleSheet: string; }; /** diff --git a/tgui/packages/tgui/backend.ts b/tgui/packages/tgui/backend.ts index 85e8f93b0f4e..9190d74dbe23 100644 --- a/tgui/packages/tgui/backend.ts +++ b/tgui/packages/tgui/backend.ts @@ -269,7 +269,6 @@ type BackendState = { name: string; observer: number; }; - styles: string; }; data: TData; shared: Record; diff --git a/tgui/packages/tgui/components/ByondUi.jsx b/tgui/packages/tgui/components/ByondUi.jsx index 721a31a74182..41304745509b 100644 --- a/tgui/packages/tgui/components/ByondUi.jsx +++ b/tgui/packages/tgui/components/ByondUi.jsx @@ -8,7 +8,6 @@ import { shallowDiffers } from 'common/react'; import { debounce } from 'common/timer'; import { Component, createRef } from 'react'; -import { useBackend } from '../backend'; import { createLogger } from '../logging'; import { computeBoxProps } from './Box'; @@ -30,13 +29,7 @@ const createByondUiElement = (elementId) => { logger.log(`rendering '${id}'`); byondUiStack[index] = id; - const { config } = useBackend(); - - const paramsWithStyle = { - ...params, - style: config.styles, - }; - Byond.winset(id, paramsWithStyle); + Byond.winset(id, { ...params, style: Byond.styleSheet }); }, unmount: () => { logger.log(`unmounting '${id}'`); diff --git a/tgui/public/tgui.html b/tgui/public/tgui.html index 807abca247f7..9db3acec2ebe 100644 --- a/tgui/public/tgui.html +++ b/tgui/public/tgui.html @@ -40,6 +40,8 @@ // Expose inlined metadata Byond.windowId = parseMetaTag('tgui:windowId'); + Byond.styleSheet = "tgui:stylesheet" + // Backwards compatibility window.__windowId__ = Byond.windowId;