mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Implemented responsive tables, removed bootstrap
No need for all of bootstrap since we only need to style a few elements. Implemented responsive table pattern from here: https://css-tricks.com/responsive-data-tables/ Refs #16
This commit is contained in:
parent
21c9c04310
commit
7d81083d40
8 changed files with 112 additions and 57 deletions
|
|
@ -2,21 +2,17 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<link rel="stylesheet" href="/-/static/bootstrap-4.0.0-beta.2.min.css">
|
||||
<style>
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="/-/static/app.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
{% block extra_head %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
{% if error %}
|
||||
<div style="padding: 1em; margin: 1em; border: 3px solid red;">{{ error }}</div>
|
||||
{% endif %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -7,17 +7,13 @@
|
|||
|
||||
<p><a href="/{{ database }}-{{ database_hash }}.db">download {{ database }}.db</a></p>
|
||||
|
||||
<style>
|
||||
td {
|
||||
vertical-align: top;
|
||||
border-top: 1px solid #666;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
</style>
|
||||
<table>
|
||||
<tr>
|
||||
{% for column in columns %}<th scope="col">{{ column }}</th>{% endfor %}
|
||||
</tr>
|
||||
<thead>
|
||||
<tr>
|
||||
{% for column in columns %}<th scope="col">{{ column }}</th>{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
<tr>
|
||||
{% for td in row %}
|
||||
|
|
@ -31,5 +27,6 @@ td {
|
|||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -2,34 +2,36 @@
|
|||
|
||||
{% block title %}{{ database }}: {{ table }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<style>
|
||||
@media only screen and (max-width: 576px) {
|
||||
{% for column in columns %}
|
||||
td:nth-of-type({{ loop.index }}):before { content: "{{ column|escape_css_string }}"; }
|
||||
{% endfor %}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 style="padding-left: 10px; border-left: 10px solid #{{ database_hash[:6] }}"><a href="/{{ database }}-{{ database_hash }}">{{ database }}</a></h1>
|
||||
|
||||
<h2><a href="/{{ database }}-{{ database_hash }}/{{ table }}">{{ table }}</a></h2>
|
||||
|
||||
<style>
|
||||
td {
|
||||
white-space: pre;
|
||||
vertical-align: top;
|
||||
border-top: 1px solid #666;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
</style>
|
||||
<table>
|
||||
<tr>
|
||||
{% if primary_keys and row_link %}<th scope="col">Link</th>{% endif %}
|
||||
{% for column in columns %}<th scope="col">{{ column }}</th>{% endfor %}
|
||||
</tr>
|
||||
<thead>
|
||||
<tr>
|
||||
{% for column in columns %}<th scope="col">{{ column }}</th>{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
<tr>
|
||||
{% if primary_keys and row_link %}
|
||||
<td><a href="/{{ database }}-{{ database_hash }}/{{ table }}/{{ row_link(row) }}">{{ row_link(row) }}</a></td>
|
||||
{% endif %}
|
||||
{% for td in row %}
|
||||
<td>{{ td }}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if took_ms %}<small>Took {{ took_ms }}</small>{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -2,37 +2,41 @@
|
|||
|
||||
{% block title %}{{ database }}: {{ table }}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
<style>
|
||||
@media only screen and (max-width: 576px) {
|
||||
td:nth-of-type(1):before { content: "{% if use_rowid %}rowid{% else %}Link{% endif %}"; }
|
||||
{% for column in display_columns %}
|
||||
td:nth-of-type({{ loop.index + 1 }}):before { content: "{{ column|escape_css_string }}"; }
|
||||
{% endfor %}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 style="padding-left: 10px; border-left: 10px solid #{{ database_hash[:6] }}"><a href="/{{ database }}-{{ database_hash }}">{{ database }}</a></h1>
|
||||
|
||||
<h2>{{ table }}{% if total_rows != None %} ({{ "{:,}".format(total_rows) }} total row{% if total_rows == 1 %}{% else %}s{% endif %} in this table){% endif %}</h2>
|
||||
|
||||
<style>
|
||||
th {
|
||||
padding-right: 1em;
|
||||
}
|
||||
td {
|
||||
white-space: pre;
|
||||
vertical-align: top;
|
||||
border-top: 1px solid #666;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
</style>
|
||||
<table>
|
||||
<tr>
|
||||
<th scope="col">{% if use_rowid %}rowid{% else %}Link{% endif %}</th>
|
||||
{% for column in display_columns %}<th scope="col">{{ column }}</th>{% endfor %}
|
||||
</tr>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% if use_rowid %}rowid{% else %}Link{% endif %}</th>
|
||||
{% for column in display_columns %}<th scope="col">{{ column }}</th>{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
<tr>
|
||||
<td><a href="/{{ database }}-{{ database_hash }}/{{ table }}/{{ row_link(row) }}">{{ row_link(row) }}</a></td>
|
||||
{% for td in row %}
|
||||
{% if not use_rowid or (use_rowid and not loop.first) %}
|
||||
<td>{{ td }}</td>
|
||||
<td>{{ td or " " }}</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if after_link %}
|
||||
<p><a href="{{ after_link }}">Next page</a></p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue