Skip to content

Commit 8ab77d1

Browse files
committed
feat(Popover): enhance background color handling
1 parent 7073558 commit 8ab77d1

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

packages/react-ui/src/components/popover/popover-content.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export const PopoverContent = (props: PrimitiveProps<"div">) => {
2828
<PopperFloating
2929
duration={duration}
3030
className={tx(
31-
"border-bd-normal relative border shadow-md transition-opacity",
31+
"relative border shadow-md transition-opacity",
3232
status == "open" ? "opacity-100" : "opacity-0",
33-
!hasBackgroundClass(className) && "bg-bg-normal",
33+
hasBackgroundClass(className) ? "border-transparent" : "bg-bg-normal border-bd-normal",
3434
className,
3535
)}
3636
aria-labelledby={labelId}

packages/react-ui/src/primitives/popper/popper-arrow.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { FloatingArrow, type FloatingArrowProps } from "@floating-ui/react";
2-
import { tx } from "../../utils";
32
import { usePopperArrow } from "./popper-arrow-context";
43

54
export type PopperArrowProps = Omit<FloatingArrowProps, "context" | "stroke" | "fill">;
@@ -12,7 +11,7 @@ export const PopperArrow = (props: PopperArrowProps) => {
1211
return (
1312
<FloatingArrow
1413
ref={setArrow}
15-
className={tx(arrowClassName, className)}
14+
className={className?.includes("fill-") ? className : arrowClassName}
1615
strokeWidth={strokeWidth}
1716
width={width}
1817
height={height}

website/src/routes/docs/_mdx/components/popover.mdx

+42
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,48 @@ export default function App() {
335335
}
336336
```
337337
338+
### 背景颜色
339+
340+
```jsx demo
341+
import {
342+
Button,
343+
Popover,
344+
PopoverArrow,
345+
PopoverClose,
346+
PopoverContent,
347+
PopoverDescription,
348+
PopoverTitle,
349+
PopoverTrigger,
350+
} from "@resolid/react-ui";
351+
352+
export default function App() {
353+
return (
354+
<div className={"flex flex-row gap-3"}>
355+
<Popover placement={"bottom"}>
356+
<PopoverTrigger render={(props) => <Button {...props} />}>打开弹出框</PopoverTrigger>
357+
<PopoverContent className="bg-bg-primary-hovered max-w-96">
358+
<PopoverArrow
359+
className={"fill-bg-primary-hovered [&>path:first-of-type]:stroke-bg-primary-hovered"}
360+
/>
361+
<PopoverTitle className={"p-4"}>弹出框标题</PopoverTitle>
362+
<PopoverDescription className={"p-4 pt-1"}>
363+
这是一个弹出框示例,你可以在这里放置相关的提示信息、确认内容或者操作说明。内容可以根据需求进行修改,以适应不同的业务场景。
364+
</PopoverDescription>
365+
<div className={"flex justify-end gap-4 p-4 pt-1"}>
366+
<PopoverClose
367+
render={(props) => <Button color={"neutral"} variant={"soft"} {...props} />}
368+
>
369+
取消
370+
</PopoverClose>
371+
<Button color={"neutral"}>确定</Button>
372+
</div>
373+
</PopoverContent>
374+
</Popover>
375+
</div>
376+
);
377+
}
378+
```
379+
338380
### 放置位置
339381
340382
通过传递 `placement` 属性来更改弹出框的放置位置。

0 commit comments

Comments
 (0)