diff --git a/scss/base.scss b/scss/base.scss index 9f15638e..6386e81f 100644 --- a/scss/base.scss +++ b/scss/base.scss @@ -13,6 +13,7 @@ $govuk-new-typography-scale: true; @import "./components/masthead"; @import "./glossary"; @import "./details"; +@import "./components/table"; .js-required { display: none; diff --git a/scss/components/_table.scss b/scss/components/_table.scss new file mode 100644 index 00000000..6e3efe8b --- /dev/null +++ b/scss/components/_table.scss @@ -0,0 +1,80 @@ +/** + This component is based on the NHS design system's responsive + tables: + https://github.com/nhsuk/nhsuk-frontend/blob/e8928ebe19d39fe6137a5ca046217f9ac043b29b/packages/components/tables/_tables.scss + + * 1. Hiding the thead on tablet + * 2. Displaying the thead on tablet + * 3. Removing default screen reader behaviour + * 4. Assigning role of table-row on tablet to give default screen reader behaviour + * 5. Using justify content to space out elements in the row on tablet + * 6. Assigning a minimum width in case of black cell + * 7. Aligning content to the right on tablet + * 8. Aligning tablet header to left to split it from the data + * 9. Hiding tablet specific header from tablet view + * 10. Adding a display block value due to IE 11 not having full flex support + */ +.app-table-responsive { + width: 100%; + + thead { + @include govuk-media-query($until: tablet) { + @include govuk-visually-hidden; /* [1] */ + } + } + + .app-table-responsive__body { + .app-table-responsive__heading { + @include govuk-typography-weight-bold(); + padding-right: govuk-spacing(3); + text-align: left; /* [8] */ + + @include govuk-media-query($from: tablet) { + display: none; /* [9] */ + } + } + + .app-table-responsive__row { + display: block; /* [3] */ + margin-bottom: govuk-spacing(4); + + &:last-child { + margin-bottom: 0; + } + + @include govuk-media-query($from: tablet) { + display: table-row; /* [4] */ + } + + th { + text-align: right; + @include govuk-media-query($from: tablet) { + text-align: left; + } + } + + td { + display: block; // For browsers that don't support flexbox + display: flex; + justify-content: space-between; /* [5] */ + min-width: 1px; /* [6] */ + @media all and (-ms-high-contrast: none) { + /* [10] */ + display: block; + } + + @include govuk-media-query($from: tablet) { + display: table-cell; + } + + @include govuk-media-query($until: tablet) { + padding-right: 0; + text-align: right; /* [7] */ + &:last-child { + border-bottom: 3px solid $govuk-border-colour; + } + } + } + } + } +} diff --git a/templates/details_dashboard.html b/templates/details_dashboard.html index 26341c98..5e180fce 100644 --- a/templates/details_dashboard.html +++ b/templates/details_dashboard.html @@ -6,7 +6,7 @@
{% translate "Description" %} | |||||
---|---|---|---|---|---|
{{chart.entity_ref.display_name}} | -+ | ||||
Chart name:{{chart.entity_ref.display_name}} | +Description:
{% if chart.description %}
- {{ chart.description|markdown:3 }}
+
+ {{ chart.description|markdown:3|truncatewords_html:25 }}
+
{% else %}
- A description for {{chart.entity_ref.display_name}} does not exist +A description for {{chart.entity_ref.display_name}} does not exist {% endif %} |
{% translate "Description" %} | |||||
---|---|---|---|---|---|
{{table.entity_ref.display_name}} | -+ | ||||
Table name:{{table.entity_ref.display_name}} | +Description:
{% if table.description %}
{% if table.description|length > 200 %}
- {{ table.description|slice:":200"|add:"..."|markdown:3 }}
+
+ {{ table.description|markdown:3|truncatewords_html:25 }}
+
{% else %}
+
{{ table.description|markdown:3 }}
+
{% endif %}
{% else %}
- A description for {{table.entity_ref.display_name}} does not exist +A description for {{table.entity_ref.display_name}} does not exist {% endif %} |
{{column.display_name}} | -+ | ||||
Column name:{{column.display_name}} | +Description: {% if column.description %} - {{column.description|default:''|markdown:3|truncatechars_html:300}} | +{{column.type|title}} | +Type:{{column.type|title}} | {% switch 'show_is_nullable_in_table_details_column' %} -{{column.nullable|yesno:"Yes,No,"}} | +Is Nullable:{{column.nullable|yesno:"Yes,No,"}} | {% endswitch %}