chore(client): set up body classes

This commit is contained in:
Elian Doran 2026-01-05 11:55:51 +02:00
parent b745fb476e
commit 688d197472
No known key found for this signature in database
2 changed files with 21 additions and 2 deletions

View File

@ -30,6 +30,7 @@
await setupGlob();
loadStylesheets();
loadIcons();
setBodyAttributes();
await loadScripts();
}
@ -74,6 +75,26 @@
document.head.appendChild(styleEl);
}
function setBodyAttributes() {
const { device, headingStyle, layoutOrientation, platform, isElectron, hasNativeTitleBar, hasBackgroundEffects, currentLocale } = window.glob;
const classesToSet = [
device,
`heading-style-${headingStyle}`,
`layout-${layoutOrientation}`,
`platform-${platform}`,
isElectron && "isElectron",
hasNativeTitleBar && "native-titlebar",
hasBackgroundEffects && "background-effects"
].filter(Boolean);
for (const classToSet of classesToSet) {
document.body.classList.add(classToSet);
}
document.body.lang = currentLocale.id;
document.body.dir = currentLocale.rtl ? "rtl" : "ltr";
}
async function loadScripts() {
const assetPath = glob.assetPath;
await import(`./${assetPath}/runtime.js`);

View File

@ -1,8 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<body
class="desktop heading-style-<%= headingStyle %> layout-<%= layoutOrientation %> platform-<%= platform %> <%= isElectron ? 'electron' : '' %> <%= hasNativeTitleBar ? 'native-titlebar' : '' %> <%= hasBackgroundEffects ? 'background-effects' : '' %>"
lang="<%= currentLocale.id %>" dir="<%= currentLocale.rtl ? 'rtl' : 'ltr' %>"
>
<link href="<%= assetPath %>/stylesheets/ckeditor-theme.css" rel="stylesheet">