Skip to content

Commit

Permalink
fixed button styles without preflight, fixed select menu in popup whe…
Browse files Browse the repository at this point in the history
…n in portal
  • Loading branch information
marcus-wishes committed Nov 19, 2024
1 parent 214764d commit 40e2c37
Show file tree
Hide file tree
Showing 9 changed files with 532 additions and 433 deletions.
21 changes: 19 additions & 2 deletions library/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
Button.displayName = "LPButton"
export { Button }

const loadingSpinnerClassNames: { [appearance in ButtonAppearance]: string } = {
primary: "border-t-text-inverse",
default: "border-t-border-bold",
subtle: "border-t-border-bold",
link: "border-t-border-bold",
"subtle-link": "border-t-border-bold",
warning: "border-t-text-inverse",
danger: "border-t-text-inverse",
success: "border-t-text-inverse",
information: "border-t-text-inverse",
}

export const LoadingButton = ({
loading = false,
iconAfter,
Expand All @@ -200,7 +212,13 @@ export const LoadingButton = ({
<div className={loading ? "opacity-0" : undefined}>{children}</div>
{loading && (
<div className="absolute inset-0 flex items-center justify-center">
<LoadingSpinner />
<LoadingSpinner
className={
loadingSpinnerClassNames[
props.appearance ?? "default"
]
}
/>
</div>
)}
</Button>
Expand All @@ -218,7 +236,6 @@ export const ButtonGroup = ({
{...props}
className={twMerge("inline-flex flex-wrap gap-2 p-2", className)} //gap-2 and p-2 are because of the button outlines on focus
style={style}

>
{children}
</div>
Expand Down
2 changes: 1 addition & 1 deletion library/src/components/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function Root({
return (
<RPo.Close
className={twMerge(
"text-text-subtlest hover:text-text",
"text-text-subtlest hover:text-text bg-transparent border-none",
closerClassName,
)}
style={closerStyle}
Expand Down
7 changes: 5 additions & 2 deletions library/src/components/inputs/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ import { SlidingErrorMessage } from "./ErrorHelpWrapper"
import { IconSizeHelper } from "../IconSizeHelper"
import { inputBaseStyles } from "../styleHelper"

const menuStyles =
"bg-surface min-w-min z-10 shadow-overlay rounded overflow-hidden"
const menuStyles = "bg-surface min-w-min shadow-overlay rounded overflow-hidden" // some styles like zIndex are overwritten by react-select, use the custom-styles below for those

const optionStyles =
"py-2 px-3 border-l-2 border-l-transparent border-transparent border-solid"
Expand Down Expand Up @@ -212,6 +211,10 @@ const customStyles = {
minHeight: "2.25rem", // this is min-h-9 as set in the inputBaseStyle
flexWrap: "nowrap" as const,
}),
menuPortal: (provided: CSSObjectWithLabel) => ({
...provided,
zIndex: 51,
}),
}

//#endregion styles
Expand Down
7 changes: 7 additions & 0 deletions library/src/tailwind.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

/** Custom styles for running with preflight off */
@layer base {
button {
@apply cursor-pointer disabled:cursor-not-allowed bg-transparent border-none box-border;
}
}
Loading

0 comments on commit 40e2c37

Please sign in to comment.