Skip to content

Commit adf9050

Browse files
author
Emmanouil Konstantinidis
committed
Use bootstrap's collapsible accordions
1 parent 235bd76 commit adf9050

File tree

2 files changed

+58
-38
lines changed

2 files changed

+58
-38
lines changed

rest_framework_docs/static/less/style.less

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,38 @@ body {
3434

3535
.endpoint {
3636
padding: 5px 20px;
37-
margin: 20px 0;
37+
margin: 0;
3838
background-color: #ecf0f1;
3939

40-
.title {
41-
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
42-
word-wrap: break-word;
43-
}
40+
.panel-heading {
41+
padding: 5px;
42+
43+
.title {
44+
margin-top: 6px;
45+
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
46+
word-wrap: break-word;
47+
}
4448

45-
.methods {
46-
margin-bottom: 0;
49+
.methods {
50+
margin-bottom: 0;
4751

48-
.method {
49-
padding: 4px 8px;
50-
margin-top: 10.5px;
51-
color: #FFF;
52+
.method {
53+
padding: 4px 8px;
54+
color: #FFF;
5255

53-
&.get { background-color: @GetColor; }
54-
&.post { background-color: @PostColor; }
55-
&.patch { background-color: @PutColor; }
56-
&.put { background-color: @PatchColor; }
57-
&.delete { background-color: @DeleteColor; }
58-
&.options { background-color: @OptionsColor; }
56+
&.get { background-color: @GetColor; }
57+
&.post { background-color: @PostColor; }
58+
&.patch { background-color: @PutColor; }
59+
&.put { background-color: @PatchColor; }
60+
&.delete { background-color: @DeleteColor; }
61+
&.options { background-color: @OptionsColor; }
62+
}
5963
}
6064
}
65+
66+
.panel-body {
67+
padding: 0;
68+
}
6169
}
6270

6371
/* @end Endpoint */

rest_framework_docs/templates/rest_framework_docs/home.html

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,47 @@
2020
{% for group in endpoints_grouped %}
2121
<h1 id="{{ group.grouper|lower }}">{{group.grouper}}</h1>
2222

23+
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
24+
2325
{% for endpoint in group.list %}
24-
<div class="endpoint">
25-
<div class="row">
26-
<div class="col-md-7">
27-
<h4 class="title">{{ endpoint.path }}</h4>
26+
27+
<div class="panel panel-default endpoint">
28+
<div class="panel-heading" role="tab" id="headingOne">
29+
<div class="row">
30+
<div class="col-md-7">
31+
<h4 class="panel-title title">
32+
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#{{ endpoint.path|slugify }}" aria-expanded="true" aria-controls="{{ endpoint.path|slugify }}">{{ endpoint.path }}</a>
33+
</h4>
34+
</div>
35+
36+
<div class="col-md-5 text-right">
37+
<ul class="list-inline methods">
38+
{% for method in endpoint.allowed_methods %}
39+
<li class="method {{ method|lower }}">{{ method }}</li>
40+
{% endfor %}
41+
</ul>
42+
</div>
2843
</div>
29-
<div class="col-md-5 text-right">
30-
<ul class="list-inline methods">
31-
{% for method in endpoint.allowed_methods %}
32-
<li class="method {{ method|lower }}">{{ method }}</li>
44+
</div>
45+
<div id="{{ endpoint.path|slugify }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
46+
<div class="panel-body">
47+
{% if endpoint.fields %}
48+
<p>Fields:</p>
49+
<ul class="list fields">
50+
{% for field in endpoint.fields %}
51+
<li class="field">{{ field.name }}: {{ field.type }}</li>
3352
{% endfor %}
34-
</ul>
53+
</ul>
54+
{% else %}
55+
<p>No fields.</p>
56+
{% endif %}
3557
</div>
3658
</div>
37-
38-
{% if endpoint.fields %}
39-
<p>Fields:</p>
40-
<ul class="list fields">
41-
{% for field in endpoint.fields %}
42-
<li class="field">{{ field.name }}: {{ field.type }}</li>
43-
{% endfor %}
44-
</ul>
45-
{% else %}
46-
<p>No fields.</p>
47-
{% endif %}
48-
4959
</div>
5060
{% endfor %}
5161

62+
</div>
63+
5264
{% endfor %}
5365

5466
{% endblock %}

0 commit comments

Comments
 (0)