|
| 1 | +/** |
| 2 | +This component renders a block of complex information using headings and subheadings. |
| 3 | +It looks the same as the summaryList component in the design system, but doesn't use a dl. |
| 4 | +
|
| 5 | +Use it to display data that: |
| 6 | +
|
| 7 | +- is differently shaped depending on the key |
| 8 | +- has up to 2 dimensions |
| 9 | +
|
| 10 | +Example with a 2 column grid: |
| 11 | +
|
| 12 | +*Key* *Subkey 1* *Subkey 2* |
| 13 | + Data item Data item |
| 14 | +
|
| 15 | + *Subkey 3* |
| 16 | + Data item |
| 17 | +--------------------------------- |
| 18 | +
|
| 19 | +On a narrow screen / high zoom, this collapses to a vertical layout just like |
| 20 | +the summaryList component does. |
| 21 | +**/ |
| 22 | + |
| 23 | +@use "../vendor/nhsuk-frontend/base" as *; |
| 24 | + |
| 25 | +.app-nested-info { |
| 26 | + margin: 0; // Reset default user agent styles |
| 27 | + |
| 28 | + @include nhsuk-font($size: 19); |
| 29 | + @include nhsuk-responsive-margin(6, "bottom"); |
| 30 | + |
| 31 | + @include nhsuk-media-query($from: tablet) { |
| 32 | + display: table; |
| 33 | + width: 100%; |
| 34 | + table-layout: fixed; // Required to allow us to wrap words that overflow. |
| 35 | + border-collapse: collapse; |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +.app-nested-info__row { |
| 40 | + border-bottom: 1px solid $nhsuk-border-colour; |
| 41 | + |
| 42 | + @include nhsuk-media-query($until: tablet) { |
| 43 | + margin-bottom: nhsuk-spacing(3); |
| 44 | + } |
| 45 | + @include nhsuk-media-query($from: tablet) { |
| 46 | + display: table-row; |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +.app-nested-info__key, |
| 51 | +.app-nested-info__value { |
| 52 | + box-sizing: border-box; |
| 53 | + margin: 0; // Reset default user agent styles |
| 54 | + vertical-align: top; |
| 55 | + |
| 56 | + @include nhsuk-media-query($from: tablet) { |
| 57 | + display: table-cell; |
| 58 | + padding-top: nhsuk-spacing(2); |
| 59 | + padding-right: nhsuk-spacing(4); |
| 60 | + padding-bottom: nhsuk-spacing(2); |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +.app-nested-info__key, |
| 65 | +.app-nested-info__value { |
| 66 | + // Automatic wrapping for unbreakable text (e.g. URLs) |
| 67 | + @include nhsuk-text-break-word; |
| 68 | +} |
| 69 | + |
| 70 | +.app-nested-info__key { |
| 71 | + margin-bottom: nhsuk-spacing(1); |
| 72 | + |
| 73 | + @include nhsuk-typography-weight-bold; |
| 74 | + |
| 75 | + @include nhsuk-media-query($from: tablet) { |
| 76 | + width: 30%; |
| 77 | + } |
| 78 | + |
| 79 | + h1, |
| 80 | + h2, |
| 81 | + h3, |
| 82 | + h4, |
| 83 | + h5, |
| 84 | + h6 { |
| 85 | + margin-bottom: 0; |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +.app-nested-info__value { |
| 90 | + @include nhsuk-media-query($until: tablet) { |
| 91 | + margin-bottom: nhsuk-spacing(3); |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +.app-nested-info__value > :last-child { |
| 96 | + margin-bottom: 0; |
| 97 | +} |
| 98 | + |
| 99 | +// Remove the usual margin from paragraphs and lists, where it touches the border of the grid |
| 100 | +// leaving only the spacing from the .app-nested-info__value |
| 101 | +.app-nested-info__subvalue_row:last-child > .app-nested-info__subvalue > ul:last-child, |
| 102 | +.app-nested-info__subvalue_row:last-child > .app-nested-info__subvalue > p:last-child { |
| 103 | + @include nhsuk-media-query($from: tablet) { |
| 104 | + margin-bottom: 0; |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +// No border on specific rows |
| 109 | +.app-nested-info__row--no-border { |
| 110 | + border: 0; |
| 111 | + |
| 112 | + // Increase padding by 1px to compensate for 'missing' border |
| 113 | + @include nhsuk-media-query($from: tablet) { |
| 114 | + .app-nested-info__key, |
| 115 | + .app-nested-info__value { |
| 116 | + padding-bottom: nhsuk-spacing(2) + 1px; |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +.nhsuk-card__content { |
| 122 | + .app-nested-info:last-child .app-nested-info__row:last-of-type { |
| 123 | + margin-bottom: 0; |
| 124 | + } |
| 125 | +} |
0 commit comments