Skip to content

Commit

Permalink
fix(noble): use sprinkles to reset styles to avoid specificity issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyaaa committed Apr 25, 2024
1 parent 37fd535 commit 76f8bcb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/ui/noble/noble-button.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import clx from "clsx";
import Box from "../box";
import Icon from "../icon";
import { store } from "../../models/store";
import { baseButton } from "../button/button.css";
import type { Sprinkles } from "../../styles/rainbow-sprinkles.css";
import type {
NobleButtonProps,
NobleButtonVariant,
Expand Down Expand Up @@ -46,6 +46,25 @@ export default function NobleButton(props: NobleButtonProps) {

return otherProps;
},
get baseButtonStyles(): Sprinkles {
return {
fontFamily: "$body",
cursor: "pointer",
appearance: "none",
border: "none",
position: "relative",
userSelect: "none",
whiteSpace: "nowrap",
verticalAlign: "middle",
lineHeight: 1.2,
transitionProperty:
"background-color,border-color,color,fill,stroke,opacity,box-shadow,transform,filter",
transitionDuration: "200ms",
display: "flex",
justifyContent: "center",
alignItems: "center",
};
},
get variantStyles() {
const variantStylesMap: Record<NobleButtonVariant, BoxProps> = {
solid: {
Expand Down Expand Up @@ -101,7 +120,10 @@ export default function NobleButton(props: NobleButtonProps) {
},
};

return variantStylesMap[props.variant];
return {
...state.baseButtonStyles,
...variantStylesMap[props.variant],
};
},
getDisabledStyles() {
const isLightTheme = state.theme === "light";
Expand Down Expand Up @@ -198,7 +220,7 @@ export default function NobleButton(props: NobleButtonProps) {
{...state.variantStyles}
{...state.buttonProps}
{...props.attributes}
className={clx(baseButton, props.className)}
className={props.className}
attributes={{
...props.domAttributes,
onClick: props.disabled ? undefined : (event) => props.onClick?.(event),
Expand Down

0 comments on commit 76f8bcb

Please sign in to comment.