-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Vertical rhythm in Foundation 6 #8164
Comments
+1 for that. I'd also suggest a consistent naming scheme for line-height variables |
+1 |
I had to remove some of the vertical padding & line-heights in some of of my page sections. A vertical |
I like the idea of a Here's a recent article that might help alleviate any concerns about pixel-perfect baseline grids: |
+1 |
I'd quite like to pick this up unless anyone else from the original discussion wants to submit a PR? |
@brettsmason happy to help with this if you want to kick it off. |
Initially I was checking with ZURB if this is desired. I still think Vertical Rhythm would be a real nice and useful addition. I have not taken the time to work on a complete solution. At the moment I am just using a quick and dirty approach with @mixin myfoundation-vertical-rhythm {
// Heading line-heights
@each $size, $headerlhs in $header-lineheights {
@include breakpoint($size) {
@each $headerlh, $lheight in $headerlhs {
#{$headerlh} {
line-height: $lheight;
}
}
}
}
} My $header-lineheights: (
small: (
'h1': 1.5 * $base-line-height,
'h2': 1.5 * $base-line-height,
'h3': 1 * $base-line-height,
'h4': 1 * $base-line-height,
'h5': 1 * $base-line-height,
'h6': 1 * $base-line-height,
),
medium: (
'h1': 3 * $base-line-height,
'h2': 2 * $base-line-height,
'h3': 1.5 * $base-line-height,
'h4': 1 * $base-line-height,
'h5': 1 * $base-line-height,
'h6': 1 * $base-line-height,
),
);
// Vertical Rhythm
$global-lineheight: $base-line-height;
$header-lineheight: $base-line-height;
$header-margin-bottom: $base-line-height;
$lead-lineheight: $base-line-height;
$list-lineheight: $base-line-height;
$list-margin-bottom: $base-line-height;
$paragraph-lineheight: $base-line-height;
$paragraph-margin-bottom: $base-line-height;
$subheader-lineheight: $base-line-height;
$subheader-margin-bottom: $base-line-height;
$subheader-margin-top: 0; Great, if you want to take this up. I am happy to add/support. I also looked at a couple of VR libraries for ideas out of which I particularly liked https://github.com/Pushplaybang/knife/. |
@karland Great thanks for that and the link, very interesting. I'd love to work through this with you and get this implemented. My initial thought was to have a separate map, exactly like you have done for line heights, along with maybe margins. Then have the option of assigning this map to the default What do you think? Do you think we also need to account for top margins or assume this is set for all headers globally? |
@brettsmason Great. At the moment is not a good time for me to work on this, so just push ahead. However, here are some comments:
// 4. Base Typography or if all vertical ryhthm parameters go to // ??. Vertical Rhythm In any case your solution with checking for the map sounds good to me in order to not introduce breaking changes. Having said the before, also the form elements need some re-work, because they are particularly unvertical-rhythm-like. Especially the form-elements strongly rely on a parameter $form-label-line-height: $base-line-height;
$form-spacing: 0;
$form-element-height: $base-line-height;
$form-element-margin: 0 0 $base-line-height 0;
$form-element-padding: 0 0 0 $base-line-height/4;
$form-error-margin: -$base-line-height 0 $base-line-height 0; What do you think? |
@karland I'll reply in greater depth later (and thanks for a great reply!) but my first idea was something like this: http://codepen.io/brettsmason/pen/WGXKdE Basically extend the I'm happy to do all the work but value your input on it to take it in the right direction! I'll have a chat with some of the Zurb guys and see what they think too. Also I agree forms needs tackling too, but I'd like to concentrate on headings first and do forms after. |
Just a quick update. I have this: http://codepen.io/brettsmason/pen/rrYkBo as an evolution of the above Codepen. See what you think of this idea. I feel like it would be quite flexible, as you can set a value to null to not include it in the output - eg to inherit the styling from a smaller breakpoint. However the first option is probably easier for the user I guess? |
@brettsmason Yeah, extending the |
The simplest change would be to simply add a responsive Here's an idea… What about creating an optional You could give elements whatever line-height you want, as you currently do. And with |
Heh. Or even simpler, the |
@andycochran that's an interesting idea. I guess we need to establish exactly how to approach this. I don't mind either approach, but it would need to work with other items too (eg forms that @karland mentioned) if we expand what this is applicable to. |
We shouldn't enforce vertical rhythm (or over-engineer it). But we should make it easier to implement. For headers, it'd be enough to provide a We should also do this for other elements—e.g. allow the line height of |
I think we need more than just line heights, at least for typography. We also need control over top/bottom margins if we are going to do it right. I still think something in this direction might be better: http://codepen.io/brettsmason/pen/WGXKdE The biggest problem I see at the moment is we cant control margins/line heights individually - dont we just need a way to access and change these if required? |
Having said that I still like your idea of a function and would love to explore how that could work if you have time to discuss further? |
Agreed, we'll need more than line heights. I like the idea of expanding Might it be easier to create a new As far as organizing the variables, what you suggest in your codepen is nice and compact. But it might be confusing to have to reference the order of the properties. I'm not sure if either of the following suggestions are better; I just wanted to throw 'em out there to spark discussion. We could group by styles instead of by element: $header-styles: (
small: (
'font-sizes': (24, 20, 19, 18, 17, 16),
'line-heights': (28, 24, 20, 20, 20, 16),
'top-margins': (0, 0, 0, 0, 0, 0),
'bottom-margins': (24, 20, 20, 16, 16, 16),
),
medium: ( … ^ But that requires you know that the six values are for h1-h6. (We could handle being provided fewer than six values — e.g. h6 is the same size as h5 if you only provide five sizes.) Or we could be more explicit: $header-styles: (
small: (
'h1': (
'size': 24,
'line-height': 28,
'top-margin': 12,
'bottom-margin': 24,
),
'h2': (
'size': 20,
'line-height': 24,
'top-margin': 8,
'bottom-margin': 20,
),
'h3': ( … ^ This would be very long, but it's very clear. |
@andycochran I agree about I'm trying to also think ahead of how we would treat other components with similar functionality once headers are done - do you think Out of your examples, I like the simplicity of number 1 (similar to my first example). However number 2 (same as mine here: http://codepen.io/brettsmason/pen/rrYkBo) is a lot more readable. However I think its going to end up being far too long going forward, but happy to discuss that further. On the one hand your first example would work well if we were to expand to forms in terms of the labels being clear, but I dont know how you would associate the values with anything in that scenario, so we end up with the same issue as my first example. With comments and good documentation do you think we can adapt one of first examples to work? Like you also mentioned, inheritance is taken care of by not entering a value. I'm wondering if a vertical rythm function would also be useful. So instead of having to look at modularscale.com etc, we can work it out for them (not sure how needed this is or not). What about a |
So sth. like this
is basically just plain variables, right? Don't get me wrong, I am just trying to understand, how this is helping with the rythm issue? Also since we are having px/rem and not em's, how does it support the idea of easy and scaled changes in font-size for example? Say for example I have to change h1 from 50 to 70px. Now I also have to change the other values, since they are fix and don't scale proportionaly (as em's do). Maybe I just don't get vertical rythms and all that, then just ignore my comment :) I am just trying to follow along. Thanks! |
@phifa Thanks for chipping in, the more the merrier 😄 So the first problem is the user doesn't currently have access to alter the line heights and margins of header elements, hence the need for a new map. That's the underlying issue in my opinion. I guess this is kind of a vertical rhythm/flexibility change really. Someone may just want to have access to those values, whilst some users may want to go fully into setting a vertical rhythm. Some users may want to input their own values from http://www.gridlover.net/try or http://www.modularscale.com, but it would be a nice bonus if we could provide a function that could do the maths for them, they just enter a value in the scale, eg |
Saw this today, codepen included: https://twitter.com/trentwalton/status/788810698008637440?refsrc=email&s=11 |
@brettsmason Yeah, my first suggestion is definitely more compact. The second one is 38 lines of code for each breakpoint, and you might as well just write raw CSS (which it almost is). I don't like the idea of a It would be cool to be able to plug in e.g. Maybe we could eventually get there (plugging in rhythms). But there are several things that need to happen first. I say we tackle it like this:
@phifa, maybe the With these two things in place, we're then set up to get more exact with vertical rhythm. Maybe we write a separate pluggable module for vertical rhythm. Something you could |
@karland @andycochran I had a spare hour this afternoon to start looking at this. I thought I'd create the So far I have this, what do you think?
It allows you to pass in a value to convert, as well as an optional font size to use. I also wonder if we could set the |
This is a great start, @brettsmason. Do you think it could be beneficial to abstract this function for purposes other than line height? Not sure what it might be used for. Might there might be a future case where we need to get a number based on a font-size? Maybe call it |
@andycochran i actually thought about calling it 'unitless-calc' to tie in with rem-calc. What do you think? If you reckon this is good to go I'll start putting everything together. What do you think about the base/global font size issue - introduce a new variable? |
👍 |
Doesn't this assume that the default font size of every browser is 16px? |
@andycochran So most of that code was taken from the |
@brettsmason @andycochran Great stuff. To test the end result, I have started to think about how to produce a visual test for vertical rhythm to see if all F6 elements eventually align to a vertical rhythm. However, I am not really sure how to deal with this in the current test environment. Currently none of the foundation visual test cases is generated on the fly. So, for the moment I have just come up with a little jsfiddle. Any ideas? |
@karland Sorry for the delay! So firstly I have finally started work on this: https://github.com/brettsmason/foundation-sites/tree/vertical-rhythm So far I have added the new map, and decided to add it in a format that matches the current setup. I also kept pretty much all your code as it was spot on - I just wrapped the values in What I'm not sure of is how we depreciate the old I'd appreciate if you could take a look at the work so far and see what you think 😄 As far as visual tests go, what do you mean by generated dynamically? |
@brettsmason I have been working on the code, but cannot PR to your |
@karland yes of course give me an hour to get home and I'll do that! |
@karland I've added the branch and pushed the changes I've made so far: https://github.com/zurb/foundation-sites/tree/vertical-rhythm |
@brettsmason Excellent. Thank you. I have submitted a PR #9386. Now for the unitless-calc(), I am not sure, why your |
@karland Great I'll take a look later today at your PR. The The function takes a base value (eg Is that not what you were thinking? |
@brettsmason Thanks. I understood the logic of the My understanding of vertical-rhythm is that line-heights are always an integer multiple of a base-line-height across all elements. So an elements line-height does not depend on the elements font-size. As a result line-heights usually get an absolute number (with 'rem's or 'px's). At least, this is also how gridlover and others (e.g. knife) are implementing it. I changed your |
@karland Sorry I'm struggling for time as I'm going away for 3 days after today. However I'd still love to get this moving along and included in 6.3, though the deadline is next Thursday so we are pushing it a bit! I'm not sold on having line heights with values yet, as everything I'm used to and have read suggests unitless is the best way to go. I probably need some more info on why we can't use unitless I guess... Maybe @andycochran you could chime in with your opinion too? |
I'd stick with unitless line heights because of unforeseen inheritance issues. For now, we're just talking about adding |
@brettsmason I am not sure about unitless-lineheights in the context of vertical-ryhthms. Maybe it just has not yet crossed my path. I have to think this over and play around with it. In any case, I think we have made some good progress moving from I can see the point of @andycochran. In any way, I am not suggesting to introduce fixed line-heights to every element. On the other hand, the I am happy to work on this a bit, but I cannot promise to have a working solution by Thursday. One open question is still how to depreciate |
@brettmason @andycochran I have played around with unitless lineheights and I am happy with this approach. I closed my previous PR and worked out an according PR #9397. While I was working on this PR #9397, I discovered some other issues that I have also put in separate PRs: PR #9396 and PR #9395 |
There is related work on typographic baseline https://github.com/michaeltaranto/basekick, maybe it will be helpful |
This is something I would personally very much like to include in V7 but we aren't adding any new features for V6 going forward. |
I haven't been satisfied with foundations's vertical rhythm either, and I've implemented this example of Mike's: https://codepen.io/MadeByMike/pen/bEEGvv?editors%3D0100. See his matching article here: https://www.smashingmagazine.com/2016/05/fluid-typography/. Ideally you could mix his appriach of fluid typography and vertical rhythm, however this approch seems to take up a lot of calculating power. |
@gakimball @rafibomb A lot of people love vertical rhythms in their sites, me included. There are external tools to achieve this, but I think it would be nice if F6 would make it a little easier to actually make the appropriate settings in
_settings.scss
without external dependencies.The basic idea for achieving vertical rhythm in F6 would be to have all all top/bottom margins and paddings and all
line-heights
to be a multiple of the$global-lineheight
. This is almost already possible now, but here are some necessary changes:$header-line-heights
similar to$header-sizes
. This allows to choose the line-height, when header-sizes change responsively$form-element-padding
and$form-element-margin
(the$form-spacing
would then play a less important role)I am happy to make a PR, but before I would like to check with ZURB if this is actually desired.
The old default values for the current line-height-settings and margins or paddings would remain.
The text was updated successfully, but these errors were encountered: