Skip to content

pass a class name to specific column headers#112

Merged
severo merged 8 commits intomasterfrom
add-config
Apr 9, 2025
Merged

pass a class name to specific column headers#112
severo merged 8 commits intomasterfrom
add-config

Conversation

@severo
Copy link
Copy Markdown
Contributor

@severo severo commented Apr 8, 2025

fixes #61

Screenshot From 2025-04-08 15-28-43

@severo severo requested review from bleakley and platypii April 8, 2025 13:32
@severo
Copy link
Copy Markdown
Contributor Author

severo commented Apr 8, 2025

I'm interested in your comments, @bleakley @platypii. I used the same logic to pass class names to inner components as I did in hyperparam (https://github.com/hyparam/hyperparam-cli/blob/master/src/hooks/useConfig.ts).

But if you know a better API or pattern, I would be happy to switch to it.


const ariaColCount = data.header.length + 1 // don't forget the selection column
const ariaRowCount = data.numRows + 1 // don't forget the header row
return <ColumnWidthProvider localStorageKey={`${cacheKey}:column-widths`}>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend setting "hide whitespace" for the review

Screenshot From 2025-04-08 22-26-36

@platypii
Copy link
Copy Markdown
Contributor

platypii commented Apr 8, 2025

I'm not sure I like the Config and ConfigProvider here.

How is the stuff in config different than any of the other HighTable "config" options like padding, overscan, etc? Config is so generic it's not clear what belongs to it or not.

Adding the provider seems like unnecessary complexity too.

I understand the desire to combine some of the options, there are a lot right now. Would a more logical grouping be a new style prop?

interface StyleProps {
  styled?: boolean
  customClass?: {
    hightable?: string
    columnHeaders?: (string|undefined)[] // array of custom classes for each column header, by "df.header" 0-based index
  }
}

Or maybe just plumb through a columnHeaderStyles prop and skip trying to nest things?

@severo
Copy link
Copy Markdown
Contributor Author

severo commented Apr 9, 2025

You're right; it's much clearer now. I also passed the column class name to the column cells. It's free, and it lets you apply styles to them if needed.

.custom-hightable thead th.delegated {
  background-color: #f3d373;
}
.custom-hightable tbody tr:not(:hover) td.delegated {
  background-color: #ffe9a9;
}
<HighTable
  data={data}
  className="custom-hightable"
  columnClassNames={[undefined, undefined, 'delegated']}
/>

Screenshot From 2025-04-09 09-39-37

Copy link
Copy Markdown
Contributor

@platypii platypii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opens up a whole bunch of cool style options! Love it

@severo severo merged commit d7fa9f7 into master Apr 9, 2025
8 checks passed
@severo severo deleted the add-config branch April 9, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply style to column header on a per-column basis

2 participants