Skip to content

Commit 02b630f

Browse files
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
Allow to click on setting text You can test it [here](https://rustdoc.crud.net/imperio/gui-settings-text-click/doc/foo/index.html). This PR allows to click on the text alongside the toggle to change it. r? `@jsha`
2 parents 1b5e121 + f4f14f6 commit 02b630f

File tree

6 files changed

+65
-40
lines changed

6 files changed

+65
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.3
1+
0.9.5

src/librustdoc/html/static/css/rustdoc.css

-24
Original file line numberDiff line numberDiff line change
@@ -1415,30 +1415,6 @@ pre.rust {
14151415
#settings-menu.rotate > a img {
14161416
animation: rotating 2s linear infinite;
14171417
}
1418-
#settings-menu #settings {
1419-
position: absolute;
1420-
right: 0;
1421-
z-index: 1;
1422-
display: block;
1423-
margin-top: 7px;
1424-
border-radius: 3px;
1425-
border: 1px solid;
1426-
}
1427-
#settings-menu #settings .setting-line {
1428-
margin: 0.6em;
1429-
}
1430-
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
1431-
#settings-menu #settings::before {
1432-
content: '';
1433-
position: absolute;
1434-
right: 11px;
1435-
border: solid;
1436-
border-width: 1px 1px 0 0;
1437-
display: inline-block;
1438-
padding: 4px;
1439-
transform: rotate(-45deg);
1440-
top: -5px;
1441-
}
14421418

14431419
#help-button {
14441420
font-family: "Fira Sans", Arial, sans-serif;

src/librustdoc/html/static/css/settings.css

+34-6
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@
4646
.toggle {
4747
position: relative;
4848
display: inline-block;
49-
width: 45px;
49+
width: 100%;
5050
height: 27px;
5151
margin-right: 20px;
52+
display: flex;
53+
align-items: center;
54+
cursor: pointer;
5255
}
5356

5457
.toggle input {
@@ -57,12 +60,12 @@
5760
}
5861

5962
.slider {
60-
position: absolute;
63+
position: relative;
64+
width: 45px;
65+
display: block;
66+
height: 28px;
67+
margin-right: 20px;
6168
cursor: pointer;
62-
top: 0;
63-
left: 0;
64-
right: 0;
65-
bottom: 0;
6669
background-color: #ccc;
6770
transition: .3s;
6871
}
@@ -95,3 +98,28 @@ input:checked + .slider:before {
9598
width: 100%;
9699
display: block;
97100
}
101+
102+
div#settings {
103+
position: absolute;
104+
right: 0;
105+
z-index: 1;
106+
display: block;
107+
margin-top: 7px;
108+
border-radius: 3px;
109+
border: 1px solid;
110+
}
111+
#settings .setting-line {
112+
margin: 1.2em 0.6em;
113+
}
114+
/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */
115+
div#settings::before {
116+
content: '';
117+
position: absolute;
118+
right: 11px;
119+
border: solid;
120+
border-width: 1px 1px 0 0;
121+
display: inline-block;
122+
padding: 4px;
123+
transform: rotate(-45deg);
124+
top: -5px;
125+
}

src/librustdoc/html/static/js/settings.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,11 @@
130130
} else {
131131
// This is a toggle.
132132
const checked = setting["default"] === true ? " checked" : "";
133-
output += `
134-
<label class="toggle">
135-
<input type="checkbox" id="${js_data_name}"${checked}>
136-
<span class="slider"></span>
137-
</label>
138-
<div>${setting_name}</div>`;
133+
output += `<label class="toggle">\
134+
<input type="checkbox" id="${js_data_name}"${checked}>\
135+
<span class="slider"></span>\
136+
<span class="label">${setting_name}</span>\
137+
</label>`;
139138
}
140139
output += "</div>";
141140
}

src/test/rustdoc-gui/settings.goml

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ wait-for: "#settings"
3434

3535
// We check that the "Use system theme" is disabled.
3636
assert-property: ("#use-system-theme", {"checked": "false"})
37-
assert: "//*[@class='setting-line']/*[text()='Use system theme']"
37+
assert: "//*[@class='setting-line']//span[text()='Use system theme']"
3838
// Meaning that only the "theme" menu is showing up.
3939
assert: ".setting-line:not(.hidden) #theme"
4040
assert: ".setting-line.hidden #preferred-dark-theme"
@@ -55,7 +55,13 @@ assert: ".setting-line.hidden #theme"
5555
assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme")
5656
assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme")
5757

58+
// We now check that clicking on the "sliders"' text is like clicking on the slider.
59+
// To test it, we use the "Disable keyboard shortcuts".
60+
local-storage: {"rustdoc-disable-shortcuts": "false"}
61+
click: ".setting-line:last-child .toggle .label"
62+
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
63+
5864
// Now we go to the settings page to check that the CSS is loaded as expected.
5965
goto: file://|DOC_PATH|/settings.html
6066
wait-for: "#settings"
61-
assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"})
67+
assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"})

src/tools/rustdoc-gui/tester.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function showHelp() {
1919
console.log(" --help : show this message then quit");
2020
console.log(" --tests-folder [PATH] : location of the .GOML tests folder");
2121
console.log(" --jobs [NUMBER] : number of threads to run tests on");
22+
console.log(" --executable-path [PATH] : path of the browser's executable to be used");
2223
}
2324

2425
function isNumeric(s) {
@@ -34,20 +35,25 @@ function parseOptions(args) {
3435
"show_text": false,
3536
"no_headless": false,
3637
"jobs": -1,
38+
"executable_path": null,
39+
"no_sandbox": false,
3740
};
3841
var correspondances = {
3942
"--doc-folder": "doc_folder",
4043
"--tests-folder": "tests_folder",
4144
"--debug": "debug",
4245
"--show-text": "show_text",
4346
"--no-headless": "no_headless",
47+
"--executable-path": "executable_path",
48+
"--no-sandbox": "no_sandbox",
4449
};
4550

4651
for (var i = 0; i < args.length; ++i) {
4752
if (args[i] === "--doc-folder"
4853
|| args[i] === "--tests-folder"
4954
|| args[i] === "--file"
50-
|| args[i] === "--jobs") {
55+
|| args[i] === "--jobs"
56+
|| args[i] === "--executable-path") {
5157
i += 1;
5258
if (i >= args.length) {
5359
console.log("Missing argument after `" + args[i - 1] + "` option.");
@@ -68,6 +74,9 @@ function parseOptions(args) {
6874
} else if (args[i] === "--help") {
6975
showHelp();
7076
process.exit(0);
77+
} else if (args[i] === "--no-sandbox") {
78+
console.log("`--no-sandbox` is being used. Be very careful!");
79+
opts[correspondances[args[i]]] = true;
7180
} else if (correspondances[args[i]]) {
7281
opts[correspondances[args[i]]] = true;
7382
} else {
@@ -147,10 +156,17 @@ async function main(argv) {
147156
if (opts["show_text"]) {
148157
args.push("--show-text");
149158
}
159+
if (opts["no_sandbox"]) {
160+
args.push("--no-sandbox");
161+
}
150162
if (opts["no_headless"]) {
151163
args.push("--no-headless");
152164
headless = false;
153165
}
166+
if (opts["executable_path"] !== null) {
167+
args.push("--executable-path");
168+
args.push(opts["executable_path"]);
169+
}
154170
options.parseArguments(args);
155171
} catch (error) {
156172
console.error(`invalid argument: ${error}`);

0 commit comments

Comments
 (0)