Skip to content

Commit e034046

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 1dd0278 commit e034046

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
@@ -615,23 +615,21 @@ main .method-detail:target {
615615
border-left: 10px solid #f1edba;
616616
}
617617

618+
main .method-header {
619+
display: inline-block;
620+
}
621+
618622
main .method-heading {
619623
position: relative;
620624
font-family: var(--font-code);
621625
font-size: 110%;
622626
font-weight: bold;
623627
color: var(--text-color);
624628
}
625-
main .method-heading :link,
626-
main .method-heading :visited {
627-
color: inherit;
628-
}
629-
main .method-source-toggle {
630-
position: absolute;
631-
top: 2px;
632-
right: 0px;
633-
padding-right: 20px;
629+
630+
main .method-controls {
634631
line-height: 20px;
632+
float: right;
635633
color: var(--secondary-color);
636634
cursor: pointer;
637635
}
@@ -739,13 +737,9 @@ main .attribute-access-type {
739737
white-space: nowrap;
740738
}
741739

742-
.method-controls {
743-
position: static;
744-
}
745-
746-
main .method-source-toggle {
747-
position: static;
748-
display: inline-block;
740+
main .method-controls {
741+
margin-top: 10px;
742+
float: none;
749743
}
750744
}
751745
/* @end */

0 commit comments

Comments
 (0)