typst-bytefield icon indicating copy to clipboard operation
typst-bytefield copied to clipboard

Passthrough length & color arguments to text and box

Open nopeslide opened this issue 1 year ago • 3 comments

Small usage improvement. Every field represents some text at the end and afaik fields do not use length or color arguments. instead of

bytes(3)[
  #box(width:100%,height:100%,fill:green)[
    #text(8pt)[
      my bytes
    ]
  ]
]

passthrough length arguments to text and color arguments as box fill

bytes(3,8pt,green)[my bytes]

nopeslide avatar Feb 21 '24 07:02 nopeslide

There is already a named argument fill for the background color.

Example: bytes(3, fill: green)[Text] produces a field with green background.

I not sure if there is a benefit of removing the named argument instead of just a passthrough color.

Actually with the size i think it is not obvious where it belongs to. If we think about for example having a option to specify the desired rowhigh for a field, this could be confusing. But adding a argument text-size like in the header is probably a good idea.

Beside that you can very easily create a wrapper like let my_bytes(size, fontsize, color, body) = bytes(size, fill: color)[#text(textsize, body)]. This would keep the default implementation slim.

But i would like to add a global option for the default font size inside a field, through the bytefield function for just that bytefield or the bf-config for all bytefields.

jomaway avatar Feb 21 '24 10:02 jomaway

Beside that you can very easily create a wrapper like let my_bytes(size, fontsize, color, body) = bytes(size, fill: color)[#text(textsize, body)]. This would keep the default implementation slim.

I already wrote so many wrappers :D this was just something I did often, so I thought it could be a default feature

Actually with the size i think it is not obvious where it belongs to. If we think about for example having a option to specify the desired rowhigh for a field, this could be confusing. But adding a argument text-size like in the header is probably a good idea.

I always think the unnamed args should reflect common options. manipulating the row height should be rare use case, but manipulating the text size so the text fits inside the cell is a common one, isn't it?

There is already a named argument fill for the background color.

must have overlooked this one

nopeslide avatar Feb 21 '24 12:02 nopeslide

Just to give a short update on the current status on this one. Now it is possible to set a global font size for all data fields as part of the global setup (See #31). This might be helpful if you want to set a different font size as the default font size in your document. If none is specified this will fallback to the font size set on the document itself.

jomaway avatar Mar 09 '24 11:03 jomaway