Skip to content

Commit ac7409b

Browse files
committed
Improve method controls' display on mobile
By moving the method controls out of the method header, we can display them to the right of the method name on desktop, and below the method name on mobile.
1 parent 57a4738 commit ac7409b

File tree

2 files changed

+32
-44
lines changed

2 files changed

+32
-44
lines changed

lib/rdoc/generator/template/darkfish/class.rhtml

+22-28
Original file line numberDiff line numberDiff line change
@@ -101,41 +101,35 @@
101101
<div id="<%= method.aref %>" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
102102
<div class="method-header">
103103
<%- if (call_seq = method.call_seq) then -%>
104-
<%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
105-
<div class="method-heading">
106-
<span class="method-callseq">
107-
<%= h(call_seq.strip.
108-
gsub( /^\w+\./m, '')).
109-
gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
110-
</span>
111-
<%- if i == 0 and method.token_stream then -%>
112-
<div class="method-controls">
113-
<details class="method-source-toggle">
114-
<summary>Source</summary>
115-
</details>
116-
</div>
104+
<%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
105+
<div class="method-heading">
106+
<span class="method-callseq">
107+
<%= h(call_seq.strip.
108+
gsub( /^\w+\./m, '')).
109+
gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
110+
</span>
111+
</div>
117112
<%- end -%>
118-
</div>
119-
<%- end -%>
120113
<%- elsif method.has_call_seq? then -%>
121-
<div class="method-heading">
122-
<span class="method-name"><%= h method.name %></span>
123-
</div>
114+
<div class="method-heading">
115+
<span class="method-name"><%= h method.name %></span>
116+
</div>
124117
<%- else -%>
125-
<div class="method-heading">
126-
<span class="method-name"><%= h method.name %></span>
127-
<span class="method-args"><%= h method.param_seq %></span>
128-
<%- if method.token_stream then -%>
129-
<div class="method-controls">
130-
<details class="method-source-toggle">
131-
<summary>Source</summary>
132-
</details>
118+
<div class="method-heading">
119+
<span class="method-name"><%= h method.name %></span>
120+
<span class="method-args"><%= h method.param_seq %></span>
133121
</div>
134-
<%- end -%>
135-
</div>
136122
<%- end -%>
137123
</div>
138124

125+
<%- if method.token_stream -%>
126+
<div class="method-controls">
127+
<details class="method-source-toggle">
128+
<summary>Source</summary>
129+
</details>
130+
</div>
131+
<%- end -%>
132+
139133
<%- unless method.skip_description? then -%>
140134
<div class="method-description">
141135
<%- if method.token_stream then -%>

lib/rdoc/generator/template/darkfish/css/rdoc.css

+10-16
Original file line numberDiff line numberDiff line change
@@ -611,23 +611,21 @@ main .method-detail:target {
611611
border-left: 10px solid #f1edba;
612612
}
613613

614+
main .method-header {
615+
display: inline-block;
616+
}
617+
614618
main .method-heading {
615619
position: relative;
616620
font-family: var(--font-code);
617621
font-size: 110%;
618622
font-weight: bold;
619623
color: var(--text-color);
620624
}
621-
main .method-heading :link,
622-
main .method-heading :visited {
623-
color: inherit;
624-
}
625-
main .method-source-toggle {
626-
position: absolute;
627-
top: 2px;
628-
right: 0px;
629-
padding-right: 20px;
625+
626+
main .method-controls {
630627
line-height: 20px;
628+
float: right;
631629
color: var(--secondary-color);
632630
cursor: pointer;
633631
}
@@ -735,13 +733,9 @@ main .attribute-access-type {
735733
white-space: nowrap;
736734
}
737735

738-
.method-controls {
739-
position: static;
740-
}
741-
742-
main .method-source-toggle {
743-
position: static;
744-
display: inline-block;
736+
main .method-controls {
737+
margin-top: 10px;
738+
float: none;
745739
}
746740
}
747741
/* @end */

0 commit comments

Comments
 (0)