Skip to content

Commit 88dcfdc

Browse files
committed
fix: amélioration gestion footer (hide, setContent, resize)
1 parent 574140a commit 88dcfdc

4 files changed

Lines changed: 32 additions & 14 deletions

File tree

js/processMarkdown/yaml.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { config } from "../config.js";
22
import { load as loadYAML } from "../externals/js-yaml.js";
33
import { loadScript, loadCSS } from "../utils/urls.js";
44
import { deepMerge } from "../utils/objects.js";
5-
import { footerElement, hideFooter } from "../utils/ui.js";
5+
import { hideFooter, setContentOfFooter } from "../utils/ui.js";
66
import { decodeApiKey } from "../LLM/decodeApiKey.js";
77

88
export let yaml = {
@@ -152,9 +152,10 @@ export function processYAML(markdownContent) {
152152
}
153153
}
154154
if (yaml.footer === false) {
155-
hideFooter(yaml.userInput);
155+
const isUserInputVisible = yaml.userInput;
156+
hideFooter(isUserInputVisible);
156157
} else if (typeof yaml.footer == "string") {
157-
footerElement.innerHTML = yaml.footer;
158+
setContentOfFooter(yaml.footer);
158159
}
159160
if (yaml.theme) {
160161
const cssFile = yaml.theme.endsWith(".css")

js/utils/ui.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,34 @@ export function scrollWindow(option) {
2929
}
3030
}
3131

32-
export const footerElement = document.getElementById("footer");
32+
// Pour redimensionner le footer sur des petits écrans
33+
function resizeFooterForSmallScreenToSpecificHeight(CSSheight) {
34+
const style = document.createElement("style");
35+
style.id = "styleControlsIfNoFooter";
36+
style.textContent = `
37+
@media screen and (max-width: 500px) {
38+
#controls {
39+
height: ${CSSheight}!important;
40+
}
41+
}
42+
`;
43+
document.head.appendChild(style);
44+
}
3345

3446
// Pour cacher le footer
35-
export function hideFooter(userInput) {
47+
export function hideFooter(isUserInputVisible) {
3648
const controlsElement = document.getElementById("controls");
49+
const footerElement = document.getElementById("footer");
50+
3751
footerElement.style.display = "none";
38-
controlsElement.style.height = "70px!important";
39-
const styleControls = userInput
40-
? "@media screen and (max-width: 500px) { #controls {height:110px!important}}"
41-
: "@media screen and (max-width: 500px) { #controls {height:70px!important}}";
42-
const styleSheet = document.createElement("style");
43-
styleSheet.innerText = styleControls;
44-
document.head.appendChild(styleSheet);
52+
controlsElement.style.height = "70px";
53+
54+
const smallScreenFooterHeight = isUserInputVisible ? "110px" : "50px";
55+
resizeFooterForSmallScreenToSpecificHeight(smallScreenFooterHeight);
56+
}
57+
58+
// Pour définir le contenu du footer
59+
export function setContentOfFooter(html) {
60+
const footerElement = document.getElementById("footer");
61+
footerElement.innerHTML = html;
4562
}

script.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

script.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)