Skip to content

Commit 3f51858

Browse files
gitstart-calcomgitstartUdit Takkar
authored
chore: add Popover in storybook (#11021)
Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: Udit Takkar <[email protected]>
1 parent 2c498ac commit 3f51858

File tree

2 files changed

+143
-2
lines changed

2 files changed

+143
-2
lines changed

packages/ui/components/popover/AnimatedPopover.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ export const AnimatedPopover = ({
5959
) : (
6060
<div className="max-w-36 flex items-center">
6161
<Tooltip content={text}>
62-
<div className="select-none truncate font-medium">
62+
<div className="flex select-none truncate font-medium">
6363
{text}
6464
{count && count > 0 && (
65-
<div className="flex h-4 w-4 items-center justify-center rounded-full">{count}</div>
65+
<div className="text-emphasis flex items-center justify-center rounded-full font-semibold">
66+
<span>&nbsp;</span>
67+
{count}
68+
</div>
6669
)}
6770
</div>
6871
</Tooltip>
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import { TooltipProvider } from "@radix-ui/react-tooltip";
2+
import { Canvas, Meta, Story } from "@storybook/addon-docs";
3+
import { Fragment } from "react";
4+
5+
import { FilterCheckboxFieldsContainer } from "@calcom/features/filters/components/TeamsFilter";
6+
import {
7+
CustomArgsTable,
8+
Examples,
9+
Example,
10+
Title,
11+
VariantsTable,
12+
VariantRow,
13+
} from "@calcom/storybook/components";
14+
import { Button, CheckboxField } from "@calcom/ui";
15+
16+
import { List, ListItem } from "../list";
17+
import { AnimatedPopover } from "./AnimatedPopover";
18+
19+
<Meta title="UI/Popover" component={AnimatedPopover} />
20+
21+
<Title title="Popover" suffix="Brief" subtitle="Version 1.0 — Last Update: 29 Aug 2023" />
22+
23+
## Definition
24+
25+
The `Popover` component is used to display rich content in a portal.
26+
27+
## Structure
28+
29+
The `Popover` component can be used to display a rich content in a portal.
30+
31+
<CustomArgsTable of={AnimatedPopover} />
32+
33+
## Examples
34+
35+
<Examples>
36+
<Example title="Default">
37+
<TooltipProvider>
38+
<AnimatedPopover text="Go">
39+
<FilterCheckboxFieldsContainer>
40+
{["First", "Second", "Third"]?.map((eventType) => (
41+
<div key={eventType.value} className="items-center hover:bg-muted flex cursor-pointer px-4 py-2">
42+
<CheckboxField
43+
checked={false}
44+
onChange={(e) => {
45+
console.log("changed ", e);
46+
}}
47+
description={eventType}
48+
/>
49+
</div>
50+
))}
51+
</FilterCheckboxFieldsContainer>
52+
</AnimatedPopover>
53+
</TooltipProvider>
54+
</Example>
55+
<Example title="With Trigger">
56+
<TooltipProvider>
57+
<AnimatedPopover text="Go" Trigger={<button>click here</button>}>
58+
<FilterCheckboxFieldsContainer>
59+
{["First", "Second", "Third"]?.map((eventType) => (
60+
<div key={eventType.value} className="items-center hover:bg-muted flex cursor-pointer px-4 py-2">
61+
<CheckboxField
62+
checked={false}
63+
onChange={(e) => {
64+
console.log("changed ", e);
65+
}}
66+
description={eventType}
67+
/>
68+
</div>
69+
))}
70+
</FilterCheckboxFieldsContainer>
71+
</AnimatedPopover>
72+
</TooltipProvider>
73+
</Example>
74+
<Example title="With count">
75+
<TooltipProvider>
76+
<AnimatedPopover text="Go here" count={1}>
77+
<FilterCheckboxFieldsContainer>
78+
{["First", "Second", "Third"]?.map((eventType) => (
79+
<div key={eventType.value} className="items-center hover:bg-muted flex cursor-pointer px-4 py-2">
80+
<CheckboxField
81+
checked={false}
82+
onChange={(e) => {
83+
console.log("changed ", e);
84+
}}
85+
description={eventType}
86+
/>
87+
</div>
88+
))}
89+
</FilterCheckboxFieldsContainer>
90+
</AnimatedPopover>
91+
</TooltipProvider>
92+
</Example>
93+
</Examples>
94+
95+
## Popover Story
96+
97+
<Canvas>
98+
<Story
99+
name="Popover"
100+
args={{
101+
text: "Go",
102+
childrenText: "Here is it",
103+
defaultOpen: false,
104+
}}
105+
argTypes={{
106+
count: {
107+
control: {
108+
type: "number",
109+
},
110+
},
111+
}}>
112+
{({ text, childrenText, count, defaultOpen }) => (
113+
<VariantsTable titles={["Default"]} columnMinWidth={50}>
114+
<VariantRow>
115+
<TooltipProvider>
116+
<AnimatedPopover text={text} count={count} defaultOpen={defaultOpen}>
117+
<FilterCheckboxFieldsContainer>
118+
{["First", "Second", "Third"]?.map((eventType) => (
119+
<div
120+
key={eventType.value}
121+
className="items-center hover:bg-muted flex cursor-pointer px-4 py-2">
122+
<CheckboxField
123+
checked={false}
124+
onChange={(e) => {
125+
console.log("changed ", e);
126+
}}
127+
description={eventType}
128+
/>
129+
</div>
130+
))}
131+
</FilterCheckboxFieldsContainer>
132+
</AnimatedPopover>
133+
</TooltipProvider>
134+
</VariantRow>
135+
</VariantsTable>
136+
)}
137+
</Story>
138+
</Canvas>

0 commit comments

Comments
 (0)