Skip to content
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

Feature Request: Cell/Header Attributes #204

Open
huntabyte opened this issue Mar 16, 2024 · 3 comments
Open

Feature Request: Cell/Header Attributes #204

huntabyte opened this issue Mar 16, 2024 · 3 comments

Comments

@huntabyte
Copy link

huntabyte commented Mar 16, 2024

The createRender function is nice for rendering full-blown components, sometimes all you need is a data-* attribute or class to get the cell where you want it. These attributes could be merged with the ones already provided by the library to spread onto the various elements.

Something along the lines of this:

table.column({
	header: 'Type',
	accessor: 'type',
+ 	cellAttrs: ({ value }) => ({
+		'data-value': value,
+		'data-button': true,
+	}),
+	headerAttrs: () => ({
+		'data-whatever': 'whatever'
+	})
}),

Where the Attrs takes the same params as the respective render properties, but expects a Record<string, unknown> or similar.

If this is something you'd be willing to accept into the library, I'm more than happy to submit a PR - just want your blessing before spending the time @bryanmylee!

@lolcabanon
Copy link
Contributor

@huntabyte he seems to be pretty busy lately, but he answered and merged some of my PRs not long ago.

For the record, I've been using simple components like <Faded/> or <Strong/> for basic styling, and I would benefit from this update!

@huntabyte
Copy link
Author

I'm just curious on his insights if this should be a plugin or part of the column definition!

@lolcabanon
Copy link
Contributor

I personally think a plugin would make sense as it would be tree shakable and the design of the plugin system is well adapted for this kind of functionality.

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

No branches or pull requests

2 participants