-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add styling hooks, or at least table ID for CSS targeting #9
Comments
Maybe even more ideal and customizable would be to take an option for each table element type that would be applied as attributes of the element. For example: const opts = {
table : {
style : "font-family: Helvetica, Arial, sans-serif; font-size: 11px; line-height: 20px;",
id: 'my-table'
},
tr : {
class : "some-class"
}
, td : {
style : "padding: 4px 2px; text-align: left; vertical-align: top; background-color: #eaeaea;"
}
}
tableify(data, opts); Would create something like <table style="font-family: Helvetica, Arial, sans-serif; font-size: 11px; line-height: 20px;" id="my-table">
<tr class="some-class">
<td style="padding: 4px 2px; text-align: left; vertical-align: top; background-color: #eaeaea;">
</td>
</tr>
</table> |
Your layout is cleaner and more elegant. I would add only that the id is really for people who want to use a CSS file. For example, I need the inline styles because I'm generating HTML emails that contain tables. So CSS file is not possible. If I was displaying table in the page, I might prefer to use the id and target with CSS. In the second case, I wouldn't want the the inline CSS because it would override the CSS in the file. So that is why it seems preferable that the table id be a separate parameter. That way, if I want to use CSS file, I can just pass an id with opts=null. Otherwise, I can pass both or even just opts. Case 1: inline CSS required: Case 2: CSS file: |
It can be done with just one opts parameter Case 1: inline CSS required: Case 2: CSS file This would work since we would just map the keys/attributes of I'd prefer not to change the function signature to handle one specific use case. We could also just add |
Sounds good. 👍 |
Hi, |
Love this package. I have a lot of tables that I need to display on the fly and would like this tool built out some more. In particular, styling. I'm thinking
tableify()
could take astyleOptions
object that looks something like this:These then get inserted into the tag with e.g.
style="'" + styleOptions.tableStyle + "'"
Alternatively, one could specify the table ID to target it with CSS by passing the id to
tableify()
. So you could writetableify("myTableID")
...and then you could have CSS that targets, like
The text was updated successfully, but these errors were encountered: