-
Notifications
You must be signed in to change notification settings - Fork 499
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
Remove hardcoded bold font for first line in abstract #379
Remove hardcoded bold font for first line in abstract #379
Conversation
There are users that depend on this feature, so we can't remove it outright. The theme setting will need to be part of this change. I would prefer for the default theme to define the bold style for the first line as that is part of the design of the default theme, but I 100% agree it should be possible to control it. |
9fb26da
to
294b452
Compare
@mojavelinux I wasn't sure about the naming but went with |
That's close to the name I had in mind. How about
We don't need it in the base theme, just the default theme. Since it could be absent, can you write it as the following? prose_opts = { line_height: @theme.abstract_line_height }
if (first_line_font_style = @theme.abstract_first_line_font_style) && first_line_font_style != font_style
prose_opts[:first_line_options] = { styles: [font_style, first_line_font_style] }
end
It doesn't matter. That's just a coding styling. All the levels are flattened using an underscore. I tend to keep it flat until there are at least two keys. To summarize:
Then we'll be good to merge! |
That's definitely the long-term plan. As much of core CSS that we can replicate, the easier it is on the designer. But we'll take it a chunk at a time. |
cf61a2e
to
d510cc7
Compare
@mojavelinux Pushed. Your code snippet is missing a More than extra options for the first line, I'd like to see borders supported for |
prose_opts = { line_height: @theme.abstract_line_height, first_line_options: { styles: [font_style, :bold] } } | ||
prose_opts = { line_height: @theme.abstract_line_height } | ||
# FIXME control more first_line_options using theme | ||
if (first_line_font_style = @theme.abstract_first_line_font_style.to_sym) && first_line_font_style != font_style |
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.
Using .to_sym
in the assignment will throw an exception if this key is not present. Therefore, the .to_sym
need to be moved to where first_line_font_style
is referenced once the truthy check passes.
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.
Not having any idea how expensive to_map
is, I'll go with a nested if.
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.
Thanks!
The general rule of thumb with Ruby is to avoid method calls if there's another way to do it without one. So the nested if is the right choice in this case (or just call .to_sym
both times)!
We have support for putting borders around blocks but, like with all things in Prawn, we have to explicitly add the logic. Borders are a bit tricky though because they can span pages, so the abstraction is still a bit weak atm. Similar to #342, but no dedicated issue exists. |
d510cc7
to
07d7906
Compare
Thanks! |
resolves #378 Remove hardcoded bold font for first line in abstract
The feature could be re-introduced with theming support later on.
As it stands before this change, it limits the styling of abstract blocks too much.
Fixes #378.