Skip to content
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

Merged
merged 14 commits into from
Sep 2, 2016
Merged

data-background attributes rework #52

merged 14 commits into from
Sep 2, 2016

Conversation

obilodeau
Copy link
Member

@obilodeau obilodeau commented Oct 6, 2015

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:

TODO:

I 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

.content
- if attr? :link
a.image href=(attr :link)
- unless attr(1) == 'background'
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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.

@obilodeau
Copy link
Member Author

I forgot backwards compatibility. Any pointers about how to do it without hurting readability too much?

@obilodeau
Copy link
Member Author

@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).

@nipafx
Copy link
Contributor

nipafx commented Mar 19, 2016

I did not look deeply into the changes but I like the PR's direction (especially the :imagesdir: inclusion). Any ETA on when this might get merged?

@obilodeau
Copy link
Member Author

I'm waiting on the approval of contributors and users.

On Sat, Mar 19, 2016, 2:32 AM Nicolai Parlog [email protected]
wrote:

I did not look deeply into the changes but I like the PR's direction
(especially the :imagesdir: inclusion). Any ETA on when this might get
merged?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#52 (comment)

@mojavelinux
Copy link
Member

Nice work!

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).

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:

image::cover.jpg[Background image,1024,640,role=cover canvas]

or as two lines:

[.cover.canvas]
image::cover.jpg[Background image,1024,640]

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:

image::cover.jpg[canvas,1024,640,size=cover]

That's probably a lot cleaner. I could still provide alt text if necessary:

image::cover.jpg[canvas,1024,640,size=cover,alt=Background image]

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.

@obilodeau
Copy link
Member Author

Since background is the upstream revealjs term I would keep it but I think we can support canvas also. I'll aim for both.

Thanks for the feedback @mojavelinux. It's time to rebase the branch and start ticking off items in the TODO and get this merged.

@obilodeau
Copy link
Member Author

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 data-background backwards compatibility breakage at this point. The day we will tag some version then we should start worrying about it. What do you guys think?

@mojavelinux
Copy link
Member

👍

I don't think we should be concerned about the data-background backwards compatibility breakage at this point.

Agreed.

@nipafx
Copy link
Contributor

nipafx commented Mar 21, 2016

I like background because

  1. as a non-Web-Developer it is much more obvious to me what it means (compared to canvas)
  2. I appreciate the symmetry to reveal.js' data-background (a symmetry shared by all attributes)

Maybe have both?

@obilodeau
Copy link
Member Author

Both: that's the plan

On Mon, Mar 21, 2016, 10:40 AM Nicolai Parlog [email protected]
wrote:

I like background because

  1. as a non-Web-Developer it is much more obvious to me what it means
    (compared to canvas)
  2. I appreciate the symmetry to reveal.js' data-background (a symmetry
    shared by all attributes)

Maybe have both?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#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')) : nil
Copy link
Contributor

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>

Copy link
Member

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

Copy link
Member Author

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')) : nil

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


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

Copy link
Contributor

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

@kubamarchwicki
Copy link
Contributor

👍 - would like to see that merged. Would be able to drop my hacky personal backend with the background images implementation.

@kubamarchwicki
Copy link
Contributor

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

@mojavelinux
Copy link
Member

I think we agreed on the compatible syntax as:

image::cover.jpg[canvas,1024,640,size=cover,alt=Background image]

The reveal.js converter will also permit "background" in place of "canvas".

I haven't yet implemented this in the Bespoke.js converter.

@mojavelinux
Copy link
Member

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.

@mojavelinux
Copy link
Member

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.

@kubamarchwicki
Copy link
Contributor

On 30 Mar 2016 10:24, "Dan Allen" [email protected] wrote:

I think we agreed on the compatible syntax as:

image::cover.jpg[canvas,1024,640,size=cover,alt=Background image]

The reveal.js converter will also permit "background" in place of
"canvas".

Great! I'll catchup with the docs and examples to get this one merge in.
Least I can do :)

Kuba

@obilodeau
Copy link
Member Author

This is ready to go in. Can someone acknowledge it please? There are test cases to be rendered in test/ you can use make to run asciidoctor on all of them.

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]
Copy link
Member

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

Copy link
Member Author

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"]
Copy link
Member

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.

@mojavelinux
Copy link
Member

I added some inline comments. Other than that, I think we're good to go.

@mojavelinux
Copy link
Member

mojavelinux commented Aug 31, 2016

There's one thing I want to point out, but it's not specific to this change. The attr and attr? methods inherit by default. That means if they don't find the attribute defined on the node, they look on the document.

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:

= My Slides
:transition-speed: fast

== First Slide

However, there may be attributes that you don't want to inherit. If that's the case, you generally use the form:

attr('name', nil, false)

The second parameter value is the default attribute value, which is nil by default.

@obilodeau
Copy link
Member Author

I added the attribute inheritance note to HACKING.adoc as I am afraid I'll forget. Also did the cleanup. I'm merging this. Thanks!

@mojavelinux
Copy link
Member

👍

@obilodeau obilodeau merged commit 1c14be7 into asciidoctor:master Sep 2, 2016
obilodeau added a commit that referenced this pull request Sep 2, 2016
* 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
@obilodeau obilodeau deleted the data-background-rework branch September 2, 2016 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants