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

How can I alternate row styles? #173

Open
flippedcracker opened this issue May 13, 2024 · 9 comments
Open

How can I alternate row styles? #173

flippedcracker opened this issue May 13, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@flippedcracker
Copy link

I've been using the lipgloss table module, but I like some of the options this one provides. But I don't see how to easily style every other row. Before, I was using the StyleFunc. Can you give any guidance?

@Evertras
Copy link
Owner

Hey there, this feels like a bit of an obvious oversight... let me take a look at this over the weekend when I get some time, apologies for the late response!

@Evertras Evertras added the enhancement New feature or request label May 17, 2024
@Evertras
Copy link
Owner

I've added a way to provide a row styling function which is demonstrated in the updates example, which includes both alternating row styles as well as some dynamic styling for the row data. This has been released as v0.16.0, let me know if this does what you wanted or if this needs to be resolved in some other way.

@Evertras
Copy link
Owner

Hi @flippedcracker just checking if you were able to take a look at this to see if there was anything missing? If I don't hear back in a few days I'll close this issue for now, but obviously please feel free to reopen if there's still something missing.

@flippedcracker
Copy link
Author

Sorry for the late response. And thank you for the quick fix. The fix works great for a static table. Can I still highlight selected rows with this?

@flippedcracker
Copy link
Author

flippedcracker commented May 28, 2024

I figured out to use the WithRows().HighlightStyle()

Thanks!

Edit: looks like that doesn't change the background, just the foreground.

@flippedcracker
Copy link
Author

Just to be more complete; If you use the HighlightStyle with the WithRowsStyleFunc, it appears that only the foreground color of the currently highlighted row will change the to the Highlight Style specified. The background color stays the same as what is defined in the WithRowStyleFunc.

@Evertras
Copy link
Owner

Apologies for the late response on this as life has been busy lately, I'll take another look at this when I get some time hopefully in the near future!

@Evertras
Copy link
Owner

Released a fix that should hopefully solve this in v0.16.1. The idea is that the highlighted row style is actually a poor fit for a custom style func anyway, because a single highlighted style may not apply properly. So the better way to approach this is to give the user control over what a highlighted row looks like with their custom style function, just passing it in as input.

Let me know if this solves things more fully. Apologies again for the wait!

@rflandau
Copy link

rflandau commented Jul 17, 2024

Not OP, but this solution works. It is not quite as granular as the coordinates provided by lipgloss's table, but the struct should well facilitate that if it becomes necessary in the future.
Ignore me; I hadn't noticed the existence of StyledCell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants