Code Monkey home page Code Monkey logo

Comments (4)

frankieroberto avatar frankieroberto commented on July 30, 2024

@edwardhorsford screenshots might help explain this?

from nhsuk-frontend.

edwardhorsford avatar edwardhorsford commented on July 30, 2024

Here's a screenshot from my service. There's several h2s and a legend. The h2s get extra top padding when they follow a paragraph. However the legend (which should visually look like an h2) does not - this causes it to be too close to the proceeding paragraph.
Screenshot 2024-05-24 at 15 21 28

from nhsuk-frontend.

edwardhorsford avatar edwardhorsford commented on July 30, 2024

It's probably tricky to extend the current SASS to cover fieldset legends and labels because there's so many different combinations (and they're not direct siblings). I asked ChatGPT and it suggested a refactor like this:

@mixin nhsuk-heading-padding($large-elements, $small-elements) {
  @each $element in $large-elements {
    .nhsuk-body-l + #{$element},
    .nhsuk-body-m + #{$element},
    .nhsuk-body-s + #{$element},
    .nhsuk-list + #{$element},
    .nhsuk-body-l + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-body-m + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-body-s + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-list + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-body-l + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element},
    .nhsuk-body-m + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element},
    .nhsuk-body-s + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element},
    .nhsuk-list + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element} {
      @include nhsuk-responsive-padding(4, "top");
    }
  }

  @each $element in $small-elements {
    .nhsuk-body-l + #{$element},
    .nhsuk-body-m + #{$element},
    .nhsuk-body-s + #{$element},
    .nhsuk-list + #{$element},
    .nhsuk-body-l + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-body-m + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-body-s + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-list + .nhsuk-form-group > .nhsuk-label-wrapper > #{$element},
    .nhsuk-body-l + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element},
    .nhsuk-body-m + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element},
    .nhsuk-body-s + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element},
    .nhsuk-list + .nhsuk-form-group .nhsuk-fieldset > .nhsuk-fieldset__legend#{$element} {
      padding-top: nhsuk-spacing(1);

      @include mq($from: tablet) {
        padding-top: nhsuk-spacing(2);
      }
    }

    .nhsuk-lede-text + #{$element} {
      padding-top: 0;
    }
  }
}

@include nhsuk-heading-padding(
  ('.nhsuk-heading-l', '.nhsuk-label--l', '.nhsuk-fieldset__legend--l'),
  ('.nhsuk-heading-m', '.nhsuk-heading-s', '.nhsuk-label--m', '.nhsuk-fieldset__legend--m')
);

We probably wouldn't want exactly this, but the refactor might be clearer.

from nhsuk-frontend.

edwardhorsford avatar edwardhorsford commented on July 30, 2024

Have also raised on GOVUK-Frontend.

from nhsuk-frontend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.