GithubHelp home page GithubHelp logo

fixed column widths about elm-sortable-table HOT 4 OPEN

evancz avatar evancz commented on June 15, 2024
fixed column widths

from elm-sortable-table.

Comments (4)

MatthiasWinkelmann avatar MatthiasWinkelmann commented on June 15, 2024

Isn't that something that belongs in the CSS?

from elm-sortable-table.

ericgj avatar ericgj commented on June 15, 2024

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 .my-table thead > tr > th:nth-child(0){ } , .my-table thead > tr > th:nth-child(1){ }, etc., which is then of course very annoying when you want to insert or move columns around.

from elm-sortable-table.

ericgj avatar ericgj commented on June 15, 2024

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 customizations.thead function instead of just the onClick (i.e., the onClick plus the constant attributes supplied by config):

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 thead function, which is pretty low-level anyway.

from elm-sortable-table.

 avatar commented on June 15, 2024

Having the same problem.
Setting attributes to header cells is a very, very common use case.

Every function that returns a column should take a list f attributes to apply to its th.

from elm-sortable-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.