-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic styling for typographic elements #382
Conversation
I like the intention of this PR. For me, coming onboard very recently it's very hard to get your head around all the different gems/packages that include varies components and styles so I'd personally prefer to see a gov.uk normalise file(like normalise.css or reset.css) that includes all these basic rules, since they are gov.uk styles then there shouldn't be a case where someone wouldn't need to use it. I agree that's it's cumbersome to add 'heading-large' to all H1's when we have a strict rules on how H1's are styled anyway. |
👍 to the overal idea As you mentioned it's pretty similar to the GOV.UK Publishing Small nitpick on the naming - is there anything more descriptive than One of the things isolated components depend on (including GOV.UK Publishing components, and future GOV.UK Frontend Components) is that element level styles aren't widely applied, or they risk overriding internal styles of a component. How do you see this working when applied to a
For a Appreciate it's a long reply with a fair bit of detail, happy to chat about this in person if it's more useful :) |
gonna ask the question, in an ideal world, should the style not just be on the h1, h2 etc? bootstrap style. The styles on our website are pretty simple, and in a normal run of things, i don't think we should need to write any css (or use classes for css) i have no idea how we would get to that though without essentially just having an major version number revision |
This feels reasonably sensible, and I'd likely use it. However, I'm wary of going down a path of having two ways of doing everything. I feel like we'd get to a point where some pages in a service would use this, and some would use the classes, purely depending on when the page was built. Do we want that? Other comments:
We're considering extending markdown support to the rest of the kit, so a
Edit: also curious why this doesn't style body or paragraph with |
We want to be as close as possible, while balancing maintainability and the ability to iterate frontend code. I think having a 'texty' (or 'prose' as @gemmaleigh suggested) scope, that can be tightly applied, gives us the ability to write 'normal' HTML. The difficulty to applying element styles globally is that it makes it very difficult to build on top of them. If all This PR would be a good topic for the next FE meeting, lets side some time aside and we can discussion the topics raised here. I think it'd be more productive in person than back and forth over GH. |
^ @dsingleton took some of my words out of my mouth here.
@edwardhorsford I don't think you can completely avoid that, because the web platfom is a tool that is widely used for different usecases. IMO chiefly among them are Documents and Applications, which have different needs. To over simplify what I think:
@dsingleton I think the reason this is difficult on the web platform is because of how easy it makes it to almost irreversibly override the primitives, and there's no easy way to explicitly request the basic ones afterwards. I'm not a native developer, but I assume that if you tried to monkey patch the default behaviour of UITextView and every other base class in the iOS toolkit you'd get some confused eyebrows, in most applications. Unless, you were creating a Bootstrap type abstraction layer that makes it easier to create your specific flavour of applications. While I initially knee-jerkingly had my nose up at this (as a primarily Applications-concerned web developer), I can see how it would be useful and save a lot of time for most of our use cases, which are Documents. |
@dsingleton, I'm fine with changing the name, I wasn't too sure about that myself. Although I would be fine with calling it something related to copy/document I would find it a bit odd because we're only giving back the styles we have deliberately removed (i.e. the default browser styles). On the one hand I think there should be a default styling for form elements as well, but on the other hand I understand that it's not quite the same. Basic styling of e.g. inputs and labels brings the problem with it that you would need to override those in case of checkboxes and radio buttons. I mentioned putting the scope on various elements as examples. Although putting it on the I can see multiple solutions to the isolated components vs global styles issue:
I personally don't like the idea that components set all the possible styles. There are some basic things they should inherit, e.g. the font, font size and text colour. That way it will be much less code and easier to keep consistent. They should only override those if their styling diverges from that. I have only ever seen issues with basic styles in rare cases in the past if they include something fancy which is hard to override. I've heard multiple times from other GDS developers that it was causing issues (@dsingleton said "it makes it very difficult to build on top of them"). I'd be interested to know, do you have any real life examples when it was causing problems? In an ideal world I would also prefer to not use two different ways of styling typographic elements. I would prefer to only style
Although @cfq pointed out to me that it will be more difficult to override the basic styles because they are scoped. @edwardhorsford, I came up with a similar solution as linked in the description above: https://github.com/alphagov/content-performance-manager/blob/master/app/assets/stylesheets/_base.scss
Paragraphs are already styled accordingly. The @tvararu, your apps vs documents comparison makes sense to me. Maybe I'm only such a strong believer in basic styles because I've never built a proper modern web app (not counting DokuWiki as its main purpose is to provide documents and its "appy" part is not very extensive). |
To try and summarise where this is at: I think everyone agrees some kind of basic-styles scope is useful, and there's solid prior art inside and outside GDS. I think the questions raised are:
(* at this point I think it's actually strongly opinionated reset/baseline set of styles, rather than a scope) |
I'm happy to keep the discussion about a body/html scope out of this PR. Although during our frontend meeting it was clear that some people would like to explore that, at least to the extend of experimenting with it. @dsingleton suggested that someone could provide a demo with which we could experiment. I'd be happy to provide that, although it's likely to happen only in 2 or 3 weeks. (I'm in a new team and should concentrate on work within the team at least in the beginning.) What was also discussed (later after the meeting and in Slack) was to have at least some rudimentary, less opinionated basic styles which should at least let components inherit very basic things for easier consistency, like font, font size and colour. I have removed the to do list item "basic styles for form elements and buttons" from the description. I think it makes more sense to potentially discuss that separately in a separate PR. |
👍 I'm happy with this as a scope 'texty' content. I think it would make sense to update the name to like If folks want to apply it at that level they still can, but we should make clear we're not supporting that, and the potential risks. @gemmaleigh: where's a good place in elements docs for that? I think the outstanding steps here are agreeing a name, and documenting the usage. I think thats it, and then this is mergable?
I think some code demos would help focus the discussion :) I'd be interested in seeing how:
|
I guess finding a good name is the most difficult bit of this PR. ;-)
Regarding the documentation, I think it either belongs to the top or the bottom of the Elements typography page. I'm leaning towards the top. I will update this within the next few days. |
In the interest of readability, something like |
In the frontend meeting the majority just decided to go with |
bbe6a76
to
b6c3450
Compare
Sorry for the long wait. I have finally found some time to finish this. A couple of things I was unsure of when I wrote the documentation:
|
app/views/guide_typography.html
Outdated
@@ -214,6 +215,23 @@ <h3 class="heading-medium" id="typography-hidden-text">Hidden text (progressive | |||
</div> | |||
|
|||
|
|||
<h3 class="heading-medium" id="typography-class">Use styling automatically</h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about - Use scoped typographic styles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the word 'scoped' in there is good. But I'm not sure if the whole expression makes it clear to people what it means, especially what the consequences and benefits are.
Thinking from a different angle, maybe this would fit?
"How to not use classes on every element"
app/views/guide_typography.html
Outdated
<h3 class="heading-medium" id="typography-class">Use styling automatically</h3> | ||
<div class="text"> | ||
<p>You can use the <code class="code">govuk-prose</code> class around a body of prose. Then certain elements inside will be styled automatically without the need to add specific classes to each of them.</p> | ||
<p>That will apply to most typographic elements: headings, lists, links (without govuk_template), code and strong. Tables, paragraphs, links (with govuk_template) and horizontal rules are already always styled without that class.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is clear.
The new scope, .govuk-prose
will apply styles to headings, lists, links and code and strong elements.
We should include examples of each of these in the snippet.
GOV.UK template sets global link styles, in addition to this GOV.UK elements sets global styles for tables, paragraphs and horizontal rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that especially the mentioning of govuk_template is unclear. I'm not sure how important the distinction is because I don't know how many services are using Elements without govuk_template.
What about the following?
That will apply to most typographic elements: headings, lists, links, code and strong. Tables, paragraphs and horizontal rules are already always styled without that class (and if you are using govuk_template, that includes links).
I have used examples of all of those in the snippet, except
- most headings -- I thought just one type of heading (
h3
in this case) is enough and adding more might be distracting - links -- the app which displays the example snippet includes govuk_template, so there won't be any difference for links if they are within the
govuk-prose
class or not
I have just had another stab at this. A few weeks ago I met with Jen Lambourne, a technical writer here at GDS, to discuss improvements to the documentation for this PR. Unfortunately I forgot some of the things she said and the notes she sent me were not complete. She said she'd prefer it if that section was at the top:
If you're unhappy with that, I'd suggest moving the section to the bottom again but leaving a paragraph where the section is now and linking it to the bottom section. About warning people to not put the class on the body or not:
I tried to rephrase the text about which elements are affected. I hope it's clearer now, but am not sure it's clear enough. |
This adds styling to standard typographic elements without the need to use classes directly on the elements. This is done scoped under the `govuk-prose` class which can be added to the `body` or `main` or just a single component. That makes it backwards-compatible and people can opt in to use them.
Also add examples of h1 and h2 styles within this scope.
This combines the styling from headings, body copy, links and lists.
I've renamed this section to 'Scoped typographic styles'. I'd like it to sit underneath lists - as i'd prefer it if examples of each of these were shown first, before an example of using a the I'm still wary of this as it'll mean these styles are harder to override, as @cfq mentioned. Here's a screenshot of the updated example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement IMO
We discussed this in the GDS frontend meeting on 21 June. Here is the part of the meeting minutes provided by @maxf:
|
I have decided to give up on this. There seems to be too much resistance. |
Hi folks 👋 I unsubscribed from notifications for this PR 😢 - but it's still showing up in my https://github.com/pulls/mentioned It looks like this PR isn't actively owned, a tag out of date, and is conflicting with |
Hey David! :) We're investigating a similar feature in GOV.UK Frontend with https://github.com/alphagov/govuk-frontend/blob/master/docs/installation/installing-with-npm.md#global-styles and we'll be investigating this use case more. So I'll close this out for now, thanks everyone. |
💖 |
This adds styling to standard typographic elements without the need to use classes directly on the elements.
Please discuss.What problem does the pull request solve?
I find having all HTML elements styled in a sensible way really important. I call that "basic styles".
It is important because it makes it easier for non-frontend developers to use the correct markup. It makes the general look and feel more consistent. It reduced the amount of markup and CSS necessary. And it saves time by making simple markup look good by default.
It is similar to what the
govuk-govspeak
class from GOV.UK Components provides, although that had a different intention.When I set up my first project with Elements I overcame this restriction in a way which some people didn't like. This PR would make that unnecessary (unless we're using slimmer/static and can use
govuk-govspeak
).What does it do?
This adds styling to standard typographic elements (i.e. headings, lists, links, code, strong) without the need to use classes directly on the elements.
This is done scoped under the
govuk-basic-styles
govuk-prose
class which can be added to thebody
ormain
or just a single component. That makes it backwards-compatible and people can opt in to use them.Inconsistently, some basic (but non-scoped) styles already exist for:
After this change, it would stay inconsistent that one type of styles are scoped and others are not. To change that would be a breaking change whether you chose all of them to be opt in or opt out.
This is not a full PR as it is meant to start a discussion.What would be necessary to complete this PR:Later other missing elements could also be styled (e.g. definition lists or quotes) which you would expect to be styled.
How has this been tested?
This has not been tested yet as this PR was created to have a discussion about the basic idea first. I will test properly and write documentation if people are happy with the basic idea.I have tested all the relevant elements inside a div with the new class in the styleguide that comes with Elements. I have only tested in one browser as I don't believe there will be any browser-related issues. Please let me know if I should test anything more.
What type of change is it?
Put an
x
in all the boxes that apply