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

Allow table striping to be controlled by role or attribute #1365

Closed
mojavelinux opened this issue Jun 9, 2015 · 9 comments
Closed

Allow table striping to be controlled by role or attribute #1365

mojavelinux opened this issue Jun 9, 2015 · 9 comments
Assignees
Milestone

Comments

@mojavelinux
Copy link
Member

Allow the striping of table rows (alternating colors) to be controlled by either a role or attribute.

To be consistent with how the borders are handled, the attribute might make the most sense.

[stripes="none"]
|===
|first row
|second row
|third row
|===

Though, we could disable it by default and allow it to be enabled using a role:

[.striped]
|===
|first row
|second row
|third row
|===

This would be similar to how Bootstrap works. See http://getbootstrap.com/css/#tables-striped.

As a side note, hovered rows might be interesting too. This may tip the scale towards using roles.

[striped.spotlight]
|===
...
|===
@mojavelinux mojavelinux added this to the v1.5.4 milestone Jun 9, 2015
@mojavelinux mojavelinux self-assigned this Jul 26, 2015
@mojavelinux
Copy link
Member Author

You can add the following CSS to a docinfo file to get this behavior today:

<style>
/* disable the default striping of rows */
table tr.even, table tr.alt, table tr:nth-of-type(even) {
  background: none
}
/* stripe even rows only when the "striped" CSS class is used */
table.striped tr.even, table.striped tr.alt, table.striped tr:nth-of-type(even) {
  background: #f8f8f7;
}
</style>

You could also invert the shading so that it colors the odd rows instead of the even rows:

<style>
/* disable the default striping of rows */
table tr.even, table tr.alt, table tr:nth-of-type(even) {
  background: none
}
/* stripe odd rows only when the "striped" CSS class is used */
table.striped tr.odd, table.striped tr.alt, table.striped tr:nth-of-type(odd) {
  background: #f8f8f7;
}
</style>

Note that Asciidoctor doesn't actually use the "even", "odd" or "alt" CSS classes. Those are just present for completeness (in case you use them in other regions of your web page).

@mojavelinux mojavelinux modified the milestones: v1.5.4, v1.6.0 Dec 21, 2015
@dsisnero
Copy link

Would like this somehow in asciidoctor-pdf also

@antoyo
Copy link

antoyo commented Oct 4, 2016

@dsisnero It is already possible to do so in the whole document (but not on a specific table) by modifying the theme.
You just have to comment the line:

  even_row_background_color: f9f9f9

under the section table:.

@mojavelinux
Copy link
Member Author

miltador pushed a commit to miltador-forks/asciidoctor that referenced this issue Apr 13, 2017
It is already present in asciidoctor-pdf.
I repetead the logic to match that.
Changed default stripes background color
to match asciidoctor default styles.
Also added posiblity to define own color
through 'stripesbgcolor' document attribute.

Fixes asciidoctor#1365
miltador pushed a commit to miltador-forks/asciidoctor that referenced this issue Apr 13, 2017
It is already present in asciidoctor-pdf.
I repetead the logic to match that.
Changed default stripes background color
to match asciidoctor default styles.
Also added posiblity to define own color
through 'stripesbgcolor' document attribute.

Fixes asciidoctor#1365
miltador pushed a commit to miltador-forks/asciidoctor that referenced this issue Apr 13, 2017
It is already present in asciidoctor-pdf.
I repetead the logic to match that.
Changed default stripes background color
to match asciidoctor default styles.
Also added posiblity to define own color
through 'stripesbgcolor' document attribute.

Fixes asciidoctor#1365
miltador added a commit to miltador-forks/asciidoctor that referenced this issue Apr 13, 2017
It is already present in asciidoctor-pdf.
I repetead the logic to match that.
Changed default stripes background color
to match asciidoctor default styles.
Also added posiblity to define own color
through 'stripesbgcolor' document attribute.

Fixes asciidoctor#1365
miltador added a commit to miltador-forks/asciidoctor that referenced this issue Apr 13, 2017
It is already present in asciidoctor-pdf.
I repetead the logic to match that.
Changed default stripes background color
to match asciidoctor default styles.
Also added posiblity to define own color
through 'stripesbgcolor' document attribute.

Fixes asciidoctor#1365
miltador added a commit to miltador-forks/asciidoctor that referenced this issue Apr 13, 2017
It is already present in asciidoctor-pdf.
I repetead the logic to match that.
Changed default stripes background color
to match asciidoctor default styles.
Also added posiblity to define own color
through 'stripesbgcolor' document attribute.

Fixes asciidoctor#1365
miltador added a commit to miltador-forks/asciidoctor that referenced this issue Apr 13, 2017
It is already present in asciidoctor-pdf.
I repetead the logic to match that.
Changed default stripes background color
to match asciidoctor default styles.
Also added posiblity to define own color
through 'stripesbgcolor' document attribute.

Fixes asciidoctor#1365
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Mar 3, 2018
…stripe option on table

- valid values are even, odd, all, and none
- not set by default; implies stripes on even rows
- requires support from stylesheet
@mojavelinux
Copy link
Member Author

I think the option should be named "stripe" to be congruent with the frame and grid options. The CSS classes should also follow suite.

It's possible to control this behavior either using the option or the role directly. After all, the option just sets the role.

  • stripe=even|odd|all|none
  • .stripe-even, .stripe-odd, .stripe-all, .stripe-none

I don't add the role by default to reduce bloat. If we decide it should be added by default (like with frame and grid), I can update the PR.

@mojavelinux
Copy link
Member Author

In the end, I decided to go back to the plural form, "stripes", as I think this is more parallel and natural.

  • stripes=even|odd|all|none
  • .stripes-even, .stripes-odd, .stripes-all, .stripes-none

@fdellwing
Copy link

Good decision because asciidoctor-pdf is using stripes as well!

@earshinov
Copy link

earshinov commented Jun 12, 2018

Hello. Shouldn't the stripes attribute be documented in the official documentation like Writer's Guide or User Manual?

@mojavelinux
Copy link
Member Author

This feature is now documented in the User Manual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants