-
Notifications
You must be signed in to change notification settings - Fork 188
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
data-background attributes rework #52
data-background attributes rework #52
Conversation
.content | ||
- if attr? :link | ||
a.image href=(attr :link) | ||
- unless attr(1) == 'background' |
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 patch looks larger than it should due to diff being confused. all I did is inject this unless statement.
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.
You can write this as (attr :alt)
instead of (attr 1)
. The first positional attribute is always mapped to the alt
attribute for images.
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.
Giving it some more thought, if you stick with (attr 1), then it still would be possible to provide alt text using the alt
attribute explicitly. So now I'm inclined to say keep it how it is.
I forgot backwards compatibility. Any pointers about how to do it without hurting readability too much? |
@mojavelinux do you think the premises for that change are sound? If so, I would finish up the docs and merge this. As a reminder, have a look at the old markup (that will still work) and the new proposed markup to get a feel of what this PR proposes. An additional benefit I just noticed is that you see the background images for slides in github's asciidoc preview (since they are image macros instead of hidden away in section attributes). |
I did not look deeply into the changes but I like the PR's direction (especially the |
I'm waiting on the approval of contributors and users. On Sat, Mar 19, 2016, 2:32 AM Nicolai Parlog [email protected]
|
Nice work!
That's exactly the idea. Visible content should be content. Attributes should modify. Overall, I'd say it looks good. I tested it and I can confirm it works. At first, I was a little reserved about overloading the alt text to promote the image to the background. In the Bespoke converter, I'm using a role for this purpose:
or as two lines:
Giving it some more thought, I realize that the alt text is usually superfluous and just getting in the way. Taking the approach you are proposing, my example could be simplified to:
That's probably a lot cleaner. I could still provide alt text if necessary:
I tend to prefer the word "canvas" over "background" since it indicates the layer to which the image is applied as a background. (The canvas being the whole viewport). So, after letting this sink in, I like the approach. My only change request is to use "canvas" instead of "background", though if you think background fits better for reveal.js users, then I'll let you make that call. |
Since Thanks for the feedback @mojavelinux. It's time to rebase the branch and start ticking off items in the TODO and get this merged. |
Rebase is done. Tasks are up-to-date. I'll be writing the docs in the coming days/weeks. I don't think we should be concerned about the |
👍
Agreed. |
I like
Maybe have both? |
Both: that's the plan On Mon, Mar 21, 2016, 10:40 AM Nicolai Parlog [email protected]
|
@@ -1,6 +1,9 @@ | |||
/ hide slides on %conceal, %notitle and named "!" | |||
- titleless = (title = self.title) == '!' | |||
- hide_title = (titleless || (option? :notitle) || (option? :conceal)) | |||
|
|||
/ slide options processing | |||
- data_background = (attr? 'background') ? (image_uri(attr 'background')) : nil |
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 non image backgrounds? For reveal.js we have an option which doesn't seem supported
<section data-background="#ff0000">
<h2>All CSS color formats are supported, like rgba() or hsl().</h2>
</section>
[background="#eee"]
== What are we doing?
is currently rendered into
<section data-background="images/#eee">
<h2>What are we doing?</h2>
</section>
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.
Great point. In my old patch, I had the following:
- if (bg = attr 'data-background') && bg =~ /\.(bmp|gif|jpe?g|png|svg)$/
- bg_image = image_uri bg
- bg = nil
- else
- bg_image = (attr? 'data-background-image') ? image_uri(attr 'data-background-image') : nil
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.
Agreed. This must definitely go in. I use background colors all the time.
How could I forget...
On Tue, Mar 29, 2016, 4:52 PM Dan Allen [email protected] wrote:
In templates/slim/section.html.slim
#52 (comment)
:@@ -1,6 +1,9 @@
/ hide slides on %conceal, %notitle and named "!"
- titleless = (title = self.title) == '!'
- hide_title = (titleless || (option? :notitle) || (option? :conceal))
+
+/ slide options processing
+- data_background = (attr? 'background') ? (image_uri(attr 'background')) : nilGreat point. In my old patch, I had the following:
- if (bg = attr 'data-background') && bg =~ /.(bmp|gif|jpe?g|png|svg)$/
- bg_image = image_uri bg
- bg = nil
- else
- bg_image = (attr? 'data-background-image') ? image_uri(attr 'data-background-image') : nil
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/asciidoctor/asciidoctor-reveal.js/pull/52/files/e5bb7247eeab4a03bdab87c4705ac650f515b60b..d3534081ef6ce16c36251e98b309a4a38b5b31bb#r57797873
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.
Additionally (as I'm testing my old'ish slide decks with this PR), I was able to setup slides as follows
[data-background="#eee", data-background-image=images/done-part1.gif, data-background-size=cover]
== No more Word design docs!
which resulted with a section
having a class has-light-background
. As per reveal.js release notes (version 3.0.0)
The .reveal element is given a "has-light-background" or "has-dark-background" class when a per-slide background color is detected
Do you have any idea how it's possible now. I'm unable to set up a class
attribute on section
element, but having a <section class="has-light-background">
will do the trick
👍 - would like to see that merged. Would be able to drop my hacky personal backend with the background images implementation. |
As for the syntax, can we make it exactly the same as for asciidoctor-bespoke.js Dan is working on? Slides wise I think there will be two engines: reveal and bespoke and making the slides documents as universal as possible asciidoc wise seems like a tempting option |
I think we agreed on the compatible syntax as:
The reveal.js converter will also permit "background" in place of "canvas". I haven't yet implemented this in the Bespoke.js converter. |
The Bespoke.js converter will also support all the background attributes on the section as soon as that integration is complete. In other words, I'll track reveal.js and try to keep it aligned. |
At the same time, we should recognize that we are still in the design phase and there will be differences between the converters as we explore new ideas. Eventually, everything will come into alignment as we learn the best way to write the AsciiDoc. I just want to make sure we don't tie our hands down too early. |
On 30 Mar 2016 10:24, "Dan Allen" [email protected] wrote:
Great! I'll catchup with the docs and examples to get this one merge in. Kuba |
More consistent with reveal.js' internals and documentation.
background attribute is no longer guessed to be either a color or an image in reveal.js. Aligned our behavior accordingly.
This is ready to go in. Can someone acknowledge it please? There are test cases to be rendered in |
section id=(titleless ? nil : @id) data-transition=(attr 'data-transition') data-transition-speed=(attr 'data-transition-speed') data-background=(attr 'data-background') data-background-size=(attr 'data-background-size') data-background-repeat=(attr 'data-background-repeat') data-background-transition=(attr 'data-background-transition') | ||
/ TODO: try to get rid of duplication w/ standalone slide section | ||
section(id=(titleless ? nil : @id) | ||
class=[@style,role] |
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 don't think @style
is really needed there. The style of a section is mostly reserved for special sections in DocBook. You can simply write this as:
class=roles
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.
Fixed
|
||
== hey | ||
|
||
image::bio.jpg[background,size="100px"] |
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.
Technically, the quotes around an attribute value are only required if the value has commas or spaces. Just FYI.
I added some inline comments. Other than that, I think we're good to go. |
There's one thing I want to point out, but it's not specific to this change. The Generally, you only want to enable inheritance if you intend to allow an attribute of the same name to be controlled globally. That might be good for configuring transitions. For instance:
However, there may be attributes that you don't want to inherit. If that's the case, you generally use the form:
The second parameter value is the default attribute value, which is |
The text was written by Dan on a pull-request: #52 (comment)
I added the attribute inheritance note to |
👍 |
* Removed data- prefixes from all reveal.js features * image block macro now has a background (or canvas) feature that will fill in a background-image attribute for that slide (shorter syntax) * imagesdir attribute is consistently used
Integrated the work in #38 and the ideas I proposed in #34 for background image support as block image attributes. The PoC is there but the documentation is missing, I'll be waiting on feedback. There are suboptimal and non-rubyish things in there since I'm not familiar with that language.
Breaking changes:
data-background-image
is nowbackground
referring to the CSS attribute that reveal.js supportsdata-transition
,data-transition-speed
,data-background-size
,data-background-repeat
,data-background-transition
all lost their data- prefix since it was not required and seen as redundant (see Drop the data- prefix on the slide attributes #38 and Drop the data- prefix on the slide background attributes #18):imagesdir:
is now honored on background attribute making image handling more consistentTODO:
background
,canvas
should be supported when looking for background imageslink to the relevant moz doc attributes since reveal.js hasn't documented themupstream did itI pushed my test slides so you can try to reproduce in your environments:
If accepted, I'll merge Dan's title-slide work and apply the same block_image syntax too.
Edit: added elements to doc TODO