Skip to content

Commit

Permalink
Adapt component CardSelect to new design (#1312)
Browse files Browse the repository at this point in the history
* Adapt component CardSelect to new design

* Add changeset

* Fix bold for ghost and move active of ghost state out of ghost-utils

* Fix bold label case only for ghost variant

* Remove code preventing translation of arrow for changing of weight
  • Loading branch information
cibietici authored Nov 25, 2024
1 parent 95bed64 commit 7c1ab44
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-scissors-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vygruppen/spor-react": minor
---

CardSelect: adjust css values and component logic to adapt to new design
8 changes: 5 additions & 3 deletions packages/spor-react/src/input/CardSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export const CardSelect = forwardRef<CardSelectProps, "button">(
<chakra.button
type="button"
ref={triggerRef}
fontWeight="bold"
sx={styles.trigger}
aria-label={label}
{...buttonProps}
Expand All @@ -148,14 +147,17 @@ export const CardSelect = forwardRef<CardSelectProps, "button">(
offset={size === "sm" ? 6 : 12}
crossOffset={crossOffset}
placement={placement}
containerPadding={0}
>
<StaticCard
colorScheme="white"
size="lg"
size="md"
fontSize={"xs"}
border={"sm"}
borderColor={"grey"}
borderColor={"silver"}
sx={styles.card}
{...overlayProps}
maxWidth={(triggerRef.current?.clientWidth ?? 1) * 2}
>
<Dialog aria-label={label}>{children}</Dialog>
</StaticCard>
Expand Down
16 changes: 9 additions & 7 deletions packages/spor-react/src/theme/components/card-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { baseBackground, baseBorder, baseText } from "../utils/base-utils";
import { floatingBackground, floatingBorder } from "../utils/floating-utils";
import { focusVisibleStyles } from "../utils/focus-utils";
import { ghostBackground, ghostText } from "../utils/ghost-utils";
import { fontWeights } from "../foundations";

const parts = anatomy("card-select").parts("trigger", "card");

Expand All @@ -22,8 +23,8 @@ const config = helpers.defineMultiStyleConfig({
},
card: {
borderRadius: "sm",
boxShadow: "md",
padding: 3,
boxShadow: "xs",
padding: 2,
...baseText("default", props),
backgroundColor: mode(
"white",
Expand Down Expand Up @@ -56,7 +57,8 @@ const config = helpers.defineMultiStyleConfig({
...ghostBackground("active", props),
},
_expanded: {
...ghostBackground("selected", props),
...ghostBackground("active", props),
fontWeight: fontWeights.bold,
},
},
}),
Expand Down Expand Up @@ -88,16 +90,16 @@ const config = helpers.defineMultiStyleConfig({
paddingY: 1,
minHeight: "1.25rem",
fontSize: "xs",
borderRadius: "sm",
borderRadius: "lg",
},
},
md: {
trigger: {
paddingX: 2,
paddingY: 1.5,
minHeight: "2.625rem",
fontSize: "sm",
borderRadius: "sm",
fontSize: "xs",
borderRadius: "lg",
},
},
lg: {
Expand All @@ -106,7 +108,7 @@ const config = helpers.defineMultiStyleConfig({
paddingY: 2,
minHeight: "3.375rem",
fontSize: "sm",
borderRadius: "sm",
borderRadius: "lg",
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions packages/spor-react/src/theme/utils/ghost-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mode, StyleFunctionProps } from "@chakra-ui/theme-tools";
import { State, Subset } from "./types";
import { fontWeights } from "../foundations";

type GhostBackgroundState = Subset<
State,
Expand Down Expand Up @@ -30,8 +31,8 @@ export function ghostBackground(
case "selected": {
return {
backgroundColor: mode(
"ghost.surface.selected.light",
"ghost.surface.selected.dark",
"ghost.surface.hover.light",
"ghost.surface.hover.dark",
)(props),
};
}
Expand Down

0 comments on commit 7c1ab44

Please sign in to comment.