-
Notifications
You must be signed in to change notification settings - Fork 65
fixed column widths #12
Comments
Isn't that something that belongs in the CSS? |
In my opinion, no. But even if you do want to put it there, you run into the problem that it's hard to write CSS rules to apply to particular header cells, since they aren't classed or otherwise distinguished. You end up with rules like |
In other words the underlying issue is how to set attributes on the header cells without having to override the default thead function? This is just a motivating case for that. A generic solution might be to change the Config type to type Config data msg :
Config
{ toId : data -> String
, toMsg : State -> msg
, columns : List (Column data msg, List (Attribute msg))
, customizations : Customizations data msg
} and passing a list of attributes down to the type alias Customizations data msg =
{ tableAttrs : List (Attribute msg)
, caption : Maybe (HtmlDetails msg)
, thead : List (String, Status, List (Attribute msg)) -> HtmlDetails msg
, tfoot : Maybe (HtmlDetails msg)
, tbodyAttrs : List (Attribute msg)
, rowAttrs : data -> List (Attribute msg)
} Then the public API wouldn't have to change, besides the signature of the |
Having the same problem. Every function that returns a column should take a list f attributes to apply to its |
HTML table columns are a pain, as we all know. The default is they expand to fill the content, regardless of width styling. This is often not what we want. The recommendations for fixing column widths that I could find (and here and there) recommend setting
table-layout: fixed
, and thatEmphasis mine. Here is the dilemma: the first row of cells is
thead > tr > th
, and customizing those cells is difficult in this library. (It's easy enough to set widths of thetbody
row cells, but the browser ignores these.) Essentially, it is impossible to set fixed column widths using this library without overriding yourconfig.customizations.thead
function. And yet, it does seem like this is a basic feature that should be supported without quite so much pain.My thought for an interface is
where:
and then threading that through a
customizations.thead
function that sets the width on theth
elements. (Or instead of untyped widths, have unit types forpx
,%
,em
, etc. similar to elm-css.)What do you think?
EDIT: I'd be happy to open a PR. I have it working externally.
The text was updated successfully, but these errors were encountered: