Skip to content

Commit

Permalink
add css for responsive table
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchdawson1982 committed Oct 11, 2024
1 parent c5b8459 commit 283d614
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
1 change: 1 addition & 0 deletions scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $govuk-new-typography-scale: true;
@import "./components/masthead";
@import "./glossary";
@import "./details";
@import "./components/table";

.js-required {
display: none;
Expand Down
35 changes: 35 additions & 0 deletions scss/components/_table.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@media (max-width: 600px) {
// table thead tr {
// display: none;
// }
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width:100%;
}

table tbody tr {
border-bottom: 3px solid #ddd;
display: block;
}

// table th, table td {
// padding: .5em;
// }

table tbody tr td {
border-bottom: 1px solid #ddd;
display: block;
text-align: right;
}

table td::before {
content: attr(data-label) ": ";
float: left;
}
}
2 changes: 1 addition & 1 deletion templates/details_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block extra_details %}
<div class="govuk-grid-row">
<div class="moj-scrollable-pane">
<div class="govuk-grid-column-full">
{% if charts %}
<table class="govuk-table">
<caption class="govuk-table__caption govuk-table__caption--m">{% translate "Dashboard content" %}</caption>
Expand Down
2 changes: 1 addition & 1 deletion templates/details_database.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block extra_details %}
<div class="govuk-grid-row">
<div class="moj-scrollable-pane">
<div class="govuk-grid-column-full">
{% if tables %}
<table class="govuk-table">
<caption class="govuk-table__caption govuk-table__caption--m">{% translate "Database content" %}</caption>
Expand Down
10 changes: 5 additions & 5 deletions templates/details_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% block extra_details %}
<div class="govuk-grid-row">
<div class="moj-scrollable-pane">
<div class="govuk-grid-column-full">
{% if entity.column_details %}
<table class="govuk-table">
<caption class="govuk-table__caption govuk-table__caption--m">{% translate "Table schema" %}</caption>
Expand All @@ -22,17 +22,17 @@
<tbody class="govuk-table__body">
{% for column in entity.column_details %}
<tr class="govuk-table__row">
<td class="govuk-table__cell">{{column.display_name}}</td>
<td class="govuk-table__cell column-description">
<td data-label="Column name" class="govuk-table__cell">{{column.display_name}}</td>
<td data-label="Description" class="govuk-table__cell column-description">
{% if column.description %}
{{column.description|default:''|markdown:3|truncatechars_html:300}}</td>
{% else %}
<p class="govuk-visually-hidden">A description for {{column.display_name}} does not exist</p>
{% endif %}
</td>
<td class="govuk-table__cell">{{column.type|title}}</td>
<td data-label="Type" class="govuk-table__cell">{{column.type|title}}</td>
{% switch 'show_is_nullable_in_table_details_column' %}
<td class="govuk-table__cell">{{column.nullable|yesno:"Yes,No,"}}</td>
<td data-label="Is Nullable" class="govuk-table__cell">{{column.nullable|yesno:"Yes,No,"}}</td>
{% endswitch %}
</tr>
{% endfor %}
Expand Down

0 comments on commit 283d614

Please sign in to comment.