Skip to content

Commit ab04045

Browse files
committed
Libdoc: Fine-tune shortcut list style toggle
- Make the switch and the text around it a bit smaller. - Change text to: `List style: Compact [x ] Expanded` - Keep same background color regardless the switch position. - Add same functionality to tags. - Toggle separator between items (`&middot;` or `<br>`) instead of rendering both lists and toggling which is shown. This is an update to PR robotframework#3634 related to issue robotframework#3635.
1 parent 2b7141a commit ab04045

File tree

2 files changed

+43
-40
lines changed

2 files changed

+43
-40
lines changed

src/robot/htmldata/libdoc/libdoc.css

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,37 @@ a:hover {
3939
font-weight: bold;
4040
letter-spacing: 0.1em;
4141
}
42-
label.switch {
43-
background-color: white;
44-
cursor: pointer;
45-
position: relative;
42+
.normal-first-letter::first-letter {
43+
font-weight: normal !important;
44+
letter-spacing: 0 !important;
45+
}
46+
.list-style-toggle {
47+
margin-bottom: 1em;
48+
font-size: 0.9em;
4649
}
4750
input.switch {
4851
display: none;
4952
}
5053
.slider {
5154
background-color: grey;
5255
display: inline-block;
53-
height: 20px;
5456
position: relative;
5557
top: 5px;
56-
width: 40px;
58+
height: 18px;
59+
width: 36px;
5760
}
5861
.slider:before {
5962
background-color: white;
6063
content: "";
61-
height: 14px;
62-
left: 3px;
6364
position: absolute;
6465
top: 3px;
65-
width: 14px;
66+
left: 3px;
67+
height: 12px;
68+
width: 12px;
6669
}
6770
input.switch:checked + .slider::before {
6871
background-color: white;
69-
left: 22px;
70-
}
71-
input.switch:checked + .slider {
72-
background-color: #c30;
73-
}
74-
.shortcuts .one-per-line {
75-
display: none;
76-
}
77-
.normal-first-letter::first-letter {
78-
font-weight: normal !important;
79-
letter-spacing: 0 !important;
72+
left: 21px;
8073
}
8174
.keywords {
8275
border: 1px solid #ccc;

src/robot/htmldata/libdoc/libdoc.html

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ <h1>Opening library documentation failed</h1>
8181
$('.shortcuts a').width('max-content');
8282
}
8383

84+
function toggleListStyle(locator) {
85+
var separator = $(locator).text()[0];
86+
$(locator).html(separator == '\u00b7' ? '<br>' : '&middot;');
87+
}
88+
8489
function handleKeyDown(event) {
8590
event = event || window.event;
8691
var keyCode = event.keyCode || event.which;
@@ -320,39 +325,44 @@ <h2 id="Importing">Importing</h2>
320325
<script type="text/x-jquery-tmpl" id="shortcuts-template">
321326
<h2 id="Shortcuts">Shortcuts</h2>
322327
{{if keywords.length > 3}}
323-
<span>Expanded shortcut list</span>
324-
<label class="switch" title="Switch between compact list or expanded list">
325-
<input type="checkbox" class="switch" onclick="$('.shortcuts .all-in-one').toggle();$('.shortcuts .one-per-line').toggle();">
328+
<div class="list-style-toggle">
329+
<b>List style:</b>&nbsp; Compact
330+
<label title="Switch between compact list and expanded list">
331+
<input type="checkbox" class="switch" onclick="toggleListStyle('.shortcut-separator');">
326332
<span class="slider"></span>
327333
</label>
334+
Expanded
335+
</div>
328336
{{/if}}
329337
<div class='shortcuts'>
330-
<div class='all-in-one'>
331-
{{each keywords}}
332-
<a href="#${encodeURIComponent($value.name)}"
333-
class="{{if $value.matched === false}}no-{{/if}}match"
334-
title="${$value.shortdoc}">${$value.name}</a>
335-
{{if $index < keywords.length-1}}&middot;{{/if}}
336-
{{/each}}
337-
</div>
338-
<div class='one-per-line'>
339-
{{each keywords}}
340-
<a href="#${encodeURIComponent($value.name)}"
341-
class="{{if $value.matched === false}}no-{{/if}}match"
342-
title="${$value.shortdoc}">${$value.name}</a>
343-
{{if $index < keywords.length-1}}<br>{{/if}}
344-
{{/each}}
345-
</div>
338+
{{each keywords}}
339+
<a href="#${encodeURIComponent($value.name)}"
340+
class="{{if $value.matched === false}}no-{{/if}}match"
341+
title="${$value.shortdoc}">${$value.name}</a>
342+
{{if $index < keywords.length-1}}
343+
<span class="shortcut-separator">&middot;</span>
344+
{{/if}}
345+
{{/each}}
346346
</div>
347347
</script>
348348

349349
<script type="text/x-jquery-tmpl" id="tags-template">
350350
<h2 id="Tags">Tags</h2>
351+
{{if all_tags.length > 3}}
352+
<div class="list-style-toggle">
353+
<b>List style:</b>&nbsp; Compact
354+
<label title="Switch between compact list and expanded list">
355+
<input type="checkbox" class="switch" onclick="toggleListStyle('.tag-separator');">
356+
<span class="slider"></span>
357+
</label>
358+
Expanded
359+
</div>
360+
{{/if}}
351361
<div class='shortcuts'>
352362
{{each all_tags}}
353363
<a href="javascript:tagSearch('${$value}')"
354364
title="Show keywords with this tag">${$value}</a>
355-
&middot;
365+
<span class="tag-separator">&middot;</span>
356366
{{/each}}
357367
<a href="javascript:resetKeywords()" class="normal-first-letter"
358368
title="Show all keywords">[Reset]</a>

0 commit comments

Comments
 (0)