Skip to content

Commit

Permalink
[CI] Format Code!
Browse files Browse the repository at this point in the history
Format code using Prettier
  • Loading branch information
renovate[bot] authored and actions-user committed Jul 12, 2023
1 parent a0694aa commit 816e8df
Show file tree
Hide file tree
Showing 4 changed files with 236 additions and 197 deletions.
166 changes: 85 additions & 81 deletions theme/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function playground_text(playground) {
return Promise.race([
fetch(url, options),
new Promise((_, reject) =>
setTimeout(() => reject(new Error("timeout")), timeout)
setTimeout(() => reject(new Error("timeout")), timeout),
),
]);
}
Expand All @@ -38,10 +38,10 @@ function playground_text(playground) {
.then((response) => {
// get list of crates available in the rust playground
let playground_crates = response.crates.map(
(item) => item["id"]
(item) => item["id"],
);
playgrounds.forEach((block) =>
handle_crate_list_update(block, playground_crates)
handle_crate_list_update(block, playground_crates),
);
});
}
Expand Down Expand Up @@ -154,7 +154,7 @@ function playground_text(playground) {
.catch(
(error) =>
(result_block.innerText =
"Playground Communication: " + error.message)
"Playground Communication: " + error.message),
);
}

Expand Down Expand Up @@ -238,88 +238,92 @@ function playground_text(playground) {
block.classList.add("hide-boring");
}
});
}
},
);

if (window.playground_copyable) {
Array.from(document.querySelectorAll("pre code")).forEach(function (
block
) {
var pre_block = block.parentNode;
if (!pre_block.classList.contains("playground")) {
var buttons = pre_block.querySelector(".buttons");
if (!buttons) {
buttons = document.createElement("div");
buttons.className = "buttons";
pre_block.insertBefore(buttons, pre_block.firstChild);
}
Array.from(document.querySelectorAll("pre code")).forEach(
function (block) {
var pre_block = block.parentNode;
if (!pre_block.classList.contains("playground")) {
var buttons = pre_block.querySelector(".buttons");
if (!buttons) {
buttons = document.createElement("div");
buttons.className = "buttons";
pre_block.insertBefore(buttons, pre_block.firstChild);
}

var clipButton = document.createElement("button");
clipButton.className = "fa fa-copy clip-button";
clipButton.title = "Copy to clipboard";
clipButton.setAttribute("aria-label", clipButton.title);
clipButton.innerHTML = '<i class="tooltiptext"></i>';
var clipButton = document.createElement("button");
clipButton.className = "fa fa-copy clip-button";
clipButton.title = "Copy to clipboard";
clipButton.setAttribute("aria-label", clipButton.title);
clipButton.innerHTML = '<i class="tooltiptext"></i>';

buttons.insertBefore(clipButton, buttons.firstChild);
}
});
buttons.insertBefore(clipButton, buttons.firstChild);
}
},
);
}

// Process playground code blocks
Array.from(document.querySelectorAll(".playground")).forEach(function (
pre_block
) {
// Add play button
var buttons = pre_block.querySelector(".buttons");
if (!buttons) {
buttons = document.createElement("div");
buttons.className = "buttons";
pre_block.insertBefore(buttons, pre_block.firstChild);
}
Array.from(document.querySelectorAll(".playground")).forEach(
function (pre_block) {
// Add play button
var buttons = pre_block.querySelector(".buttons");
if (!buttons) {
buttons = document.createElement("div");
buttons.className = "buttons";
pre_block.insertBefore(buttons, pre_block.firstChild);
}

var runCodeButton = document.createElement("button");
runCodeButton.className = "fa fa-play play-button";
runCodeButton.hidden = true;
runCodeButton.title = "Run this code";
runCodeButton.setAttribute("aria-label", runCodeButton.title);
var runCodeButton = document.createElement("button");
runCodeButton.className = "fa fa-play play-button";
runCodeButton.hidden = true;
runCodeButton.title = "Run this code";
runCodeButton.setAttribute("aria-label", runCodeButton.title);

buttons.insertBefore(runCodeButton, buttons.firstChild);
runCodeButton.addEventListener("click", function (e) {
run_rust_code(pre_block);
});
buttons.insertBefore(runCodeButton, buttons.firstChild);
runCodeButton.addEventListener("click", function (e) {
run_rust_code(pre_block);
});

if (window.playground_copyable) {
var copyCodeClipboardButton = document.createElement("button");
copyCodeClipboardButton.className = "fa fa-copy clip-button";
copyCodeClipboardButton.innerHTML = '<i class="tooltiptext"></i>';
copyCodeClipboardButton.title = "Copy to clipboard";
copyCodeClipboardButton.setAttribute(
"aria-label",
copyCodeClipboardButton.title
);
if (window.playground_copyable) {
var copyCodeClipboardButton = document.createElement("button");
copyCodeClipboardButton.className = "fa fa-copy clip-button";
copyCodeClipboardButton.innerHTML =
'<i class="tooltiptext"></i>';
copyCodeClipboardButton.title = "Copy to clipboard";
copyCodeClipboardButton.setAttribute(
"aria-label",
copyCodeClipboardButton.title,
);

buttons.insertBefore(copyCodeClipboardButton, buttons.firstChild);
}
buttons.insertBefore(
copyCodeClipboardButton,
buttons.firstChild,
);
}

let code_block = pre_block.querySelector("code");
if (window.ace && code_block.classList.contains("editable")) {
var undoChangesButton = document.createElement("button");
undoChangesButton.className = "fa fa-history reset-button";
undoChangesButton.title = "Undo changes";
undoChangesButton.setAttribute(
"aria-label",
undoChangesButton.title
);
let code_block = pre_block.querySelector("code");
if (window.ace && code_block.classList.contains("editable")) {
var undoChangesButton = document.createElement("button");
undoChangesButton.className = "fa fa-history reset-button";
undoChangesButton.title = "Undo changes";
undoChangesButton.setAttribute(
"aria-label",
undoChangesButton.title,
);

buttons.insertBefore(undoChangesButton, buttons.firstChild);
buttons.insertBefore(undoChangesButton, buttons.firstChild);

undoChangesButton.addEventListener("click", function () {
let editor = window.ace.edit(code_block);
editor.setValue(editor.originalCode);
editor.clearSelection();
});
}
});
undoChangesButton.addEventListener("click", function () {
let editor = window.ace.edit(code_block);
editor.setValue(editor.originalCode);
editor.clearSelection();
});
}
},
);
})();

(function themes() {
Expand Down Expand Up @@ -380,7 +384,7 @@ function playground_text(playground) {

setTimeout(function () {
themeColorMetaTag.content = getComputedStyle(
document.body
document.body,
).backgroundColor;
}, 1);

Expand Down Expand Up @@ -537,14 +541,14 @@ function playground_text(playground) {
if (html.classList.contains("sidebar-hidden")) {
var current_width = parseInt(
document.documentElement.style.getPropertyValue(
"--sidebar-width"
"--sidebar-width",
),
10
10,
);
if (current_width < 150) {
document.documentElement.style.setProperty(
"--sidebar-width",
"150px"
"150px",
);
}
showSidebar();
Expand Down Expand Up @@ -577,7 +581,7 @@ function playground_text(playground) {
pos = Math.min(pos, window.innerWidth - 100);
document.documentElement.style.setProperty(
"--sidebar-width",
pos + "px"
pos + "px",
);
}
}
Expand All @@ -596,7 +600,7 @@ function playground_text(playground) {
time: Date.now(),
};
},
{ passive: true }
{ passive: true },
);

document.addEventListener(
Expand All @@ -620,7 +624,7 @@ function playground_text(playground) {
firstContact = null;
}
},
{ passive: true }
{ passive: true },
);

// Scroll sidebar to current active section
Expand Down Expand Up @@ -653,7 +657,7 @@ function playground_text(playground) {
case "ArrowLeft":
e.preventDefault();
var previousButton = document.querySelector(
".nav-chapters.previous"
".nav-chapters.previous",
);
if (previousButton) {
window.location.href = previousButton.href;
Expand Down Expand Up @@ -755,7 +759,7 @@ function playground_text(playground) {
}
prevScrollTop = scrollTop;
},
{ passive: true }
{ passive: true },
);
})();
(function controllBorder() {
Expand All @@ -769,7 +773,7 @@ function playground_text(playground) {
menu.classList.add("bordered");
}
},
{ passive: true }
{ passive: true },
);
})();
})();
38 changes: 28 additions & 10 deletions theme/css/chrome.css
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,31 @@ a > .hljs {
-ms-flex-direction: column;
flex-direction: column;

-webkit-transition: color 0.5s, background-color 0.5s;
-webkit-transition:
color 0.5s,
background-color 0.5s;

-o-transition: color 0.5s, background-color 0.5s;
-o-transition:
color 0.5s,
background-color 0.5s;

transition: color 0.5s, background-color 0.5s;
transition:
color 0.5s,
background-color 0.5s;
}

.nav-chapters:hover {
text-decoration: none;
background-color: var(--theme-hover);
-webkit-transition: background-color 0.15s, color 0.15s;
-o-transition: background-color 0.15s, color 0.15s;
transition: background-color 0.15s, color 0.15s;
-webkit-transition:
background-color 0.15s,
color 0.15s;
-o-transition:
background-color 0.15s,
color 0.15s;
transition:
background-color 0.15s,
color 0.15s;
}

.nav-wrapper {
Expand Down Expand Up @@ -307,9 +319,11 @@ mark.fade-out {
transition: -webkit-box-shadow 300ms ease-in-out;
-o-transition: box-shadow 300ms ease-in-out;
transition: box-shadow 300ms ease-in-out;
transition: box-shadow 300ms ease-in-out,
transition:
box-shadow 300ms ease-in-out,
-webkit-box-shadow 300ms ease-in-out;
transition: box-shadow 300ms ease-in-out,
transition:
box-shadow 300ms ease-in-out,
-webkit-box-shadow 300ms ease-in-out;
border: 1px solid var(--searchbar-border-color);
border-radius: 3px;
Expand Down Expand Up @@ -387,7 +401,9 @@ ul#searchresults span.teaser em {
transition: -webkit-transform 0.3s;
-o-transition: transform 0.3s;
transition: transform 0.3s;
transition: transform 0.3s, -webkit-transform 0.3s; /* Animation: slide away */
transition:
transform 0.3s,
-webkit-transform 0.3s; /* Animation: slide away */
}
.sidebar code {
line-height: 2em;
Expand Down Expand Up @@ -491,7 +507,9 @@ ul#searchresults span.teaser em {
transition: -webkit-transform 0.5s;
-o-transition: transform 0.5s;
transition: transform 0.5s;
transition: transform 0.5s, -webkit-transform 0.5s;
transition:
transform 0.5s,
-webkit-transform 0.5s;
}

/* collapse the section */
Expand Down
28 changes: 21 additions & 7 deletions theme/css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
}

html {
font-family: Vazirmatn RD UI FD, sans-serif;
font-family:
Vazirmatn RD UI FD,
sans-serif;
color: var(--fg);
background-color: var(--bg);
-moz-text-size-adjust: none;
Expand Down Expand Up @@ -125,13 +127,25 @@ h2 a.header {
}

.js:not(.sidebar-resizing) .page-wrapper {
-webkit-transition: margin-right 0.3s ease, -webkit-transform 0.3s ease;
transition: margin-right 0.3s ease, -webkit-transform 0.3s ease;
-o-transition: margin-right 0.3s ease, transform 0.3s ease;
transition: margin-right 0.3s ease, transform 0.3s ease;
transition: margin-right 0.3s ease, transform 0.3s ease,
-webkit-transition:
margin-right 0.3s ease,
-webkit-transform 0.3s ease;
transition: margin-right 0.3s ease, transform 0.3s ease,
transition:
margin-right 0.3s ease,
-webkit-transform 0.3s ease;
-o-transition:
margin-right 0.3s ease,
transform 0.3s ease;
transition:
margin-right 0.3s ease,
transform 0.3s ease;
transition:
margin-right 0.3s ease,
transform 0.3s ease,
-webkit-transform 0.3s ease;
transition:
margin-right 0.3s ease,
transform 0.3s ease,
-webkit-transform 0.3s ease; /* Animation: slide away */
}

Expand Down
Loading

0 comments on commit 816e8df

Please sign in to comment.