Skip to content

Commit

Permalink
fix(table): differentiate selected bg color from striped bg color (#3221
Browse files Browse the repository at this point in the history
)

* fix: override bg color when selecting striped row

* chore(style): differentiate selected bg color from striped row

* chore: changeset

* chore(changeset): add issue number

---------

Co-authored-by: WK Wong <[email protected]>
  • Loading branch information
sjoerdvanBommel and wingkwong authored Jul 6, 2024
1 parent 57f7c95 commit b4c046f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-ears-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/theme": patch
---

Differentiate selected bg color from striped bg color (#1602)
48 changes: 46 additions & 2 deletions packages/core/theme/src/components/table.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {VariantProps} from "tailwind-variants";

import {tv} from "../utils/tv";
import {dataFocusVisibleClasses} from "../utils";
import {tv} from "../utils/tv";

/**
* Table **Tailwind Variants** component
Expand Down Expand Up @@ -120,7 +120,7 @@ const table = tv({
variants: {
color: {
default: {
td: "before:bg-default/40 data-[selected=true]:text-default-foreground",
td: "before:bg-default/60 data-[selected=true]:text-default-foreground",
},
primary: {
td: "before:bg-primary/20 data-[selected=true]:text-primary",
Expand Down Expand Up @@ -273,6 +273,50 @@ const table = tv({
fullWidth: true,
align: "start",
},
compoundVariants: [
{
isStriped: true,
color: "default",
class: {
td: "group-data-[odd=true]:data-[selected=true]:before:bg-default/60",
},
},
{
isStriped: true,
color: "primary",
class: {
td: "group-data-[odd=true]:data-[selected=true]:before:bg-primary/20",
},
},
{
isStriped: true,
color: "secondary",
class: {
td: "group-data-[odd=true]:data-[selected=true]:before:bg-secondary/20",
},
},
{
isStriped: true,
color: "success",
class: {
td: "group-data-[odd=true]:data-[selected=true]:before:bg-success/20",
},
},
{
isStriped: true,
color: "warning",
class: {
td: "group-data-[odd=true]:data-[selected=true]:before:bg-warning/20",
},
},
{
isStriped: true,
color: "danger",
class: {
td: "group-data-[odd=true]:data-[selected=true]:before:bg-danger/20",
},
},
],
});

export type TableVariantProps = VariantProps<typeof table>;
Expand Down

0 comments on commit b4c046f

Please sign in to comment.