Skip to content

Commit 3f3cee1

Browse files
committed
add monochrome color tooltip, clarified tooltip behavior in docs
1 parent 0396655 commit 3f3cee1

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

docs/src/content/docs/docs/components/tooltip.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { Tooltip } from "studiocms:ui/components";
1313

1414
A tooltip component that will show on hover (desktop) or tap (mobile). It's used to provide additional information about an element.
1515

16+
:::note[Note]
17+
Only one tooltip can be open at a time. If you open another tooltip, the previous one will close.
18+
:::
19+
1620
## Usage
1721

1822
<Tabs>
@@ -109,6 +113,8 @@ The values for the position prop are:
109113

110114
The tooltip can be set to be open by default. This is useful for debugging or when you want the tooltip to be visible without user interaction.
111115

116+
Keep in mind, if a user interacts with another tooltip, the `defaultOpen` tooltip will close, even if it was not in view.
117+
112118
:::note[Note]
113119
The `defaultOpen` prop can only be used on one tooltip at a time per page. If you set it on multiple tooltips, only the last one will be open by default.
114120
:::
@@ -174,6 +180,10 @@ The tooltip can be styled with different colors. The default is `default`. The a
174180
<button>Info</button>
175181
<Fragment slot="tooltip">This is an info tooltip.</Fragment>
176182
</Tooltip>
183+
<Tooltip color="mono">
184+
<button>Monochrome</button>
185+
<Fragment slot="tooltip">This is an monochrome tooltip.</Fragment>
186+
</Tooltip>
177187
</PreviewCard>
178188
</TabItem>
179189
<TabItem label="Code">
@@ -206,6 +216,10 @@ The tooltip can be styled with different colors. The default is `default`. The a
206216
<button>Info</button>
207217
<Fragment slot="tooltip">This is an info tooltip.</Fragment>
208218
</Tooltip>
219+
<Tooltip color="mono">
220+
<button>Monochrome</button>
221+
<Fragment slot="tooltip">This is an monochrome tooltip.</Fragment>
222+
</Tooltip>
209223
```
210224
</TabItem>
211225
</Tabs>

packages/studiocms_ui/src/components/Tooltip/Tooltip.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface Props extends Omit<HTMLAttributes<"div">, "class:list"> {
3232
/**
3333
* The color of the tooltip. Defaults to 'default'.
3434
*/
35-
color?: "default" | "primary" | "secondary" | "success" | "warning" | "error";
35+
color?: "default" | "primary" | "secondary" | "success" | "warning" | "error" | "mono";
3636
3737
/**
3838
* The gap between the tooltip and the anchor element in pixels. Defaults to 8.

packages/studiocms_ui/src/components/Tooltip/tooltip.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
color: var(--text-light);
5858
border-color: var(--info-hover);
5959
}
60+
.sui-tooltip-popup.color-mono {
61+
background-color: var(--mono-base);
62+
color: var(--text-inverted);
63+
border-color: var(--mono-hover);
64+
}
6065
.sui-tooltip-popup.color-default.variant-outlined {
6166
border-color: var(--text-muted);
6267
background-color: var(--default-base);
@@ -81,6 +86,10 @@
8186
border-color: var(--info-hover);
8287
background-color: var(--default-base);
8388
}
89+
.sui-tooltip-popup.color-mono.variant-outlined {
90+
border-color: var(--mono-hover);
91+
background-color: var(--default-base);
92+
}
8493
.sui-tooltip-popup.animate {
8594
transition: opacity 0.2s ease-out, visibility 0.2s;
8695
}
@@ -122,6 +131,10 @@
122131
background-color: var(--info-base);
123132
border-color: var(--info-hover);
124133
}
134+
.sui-tooltip-popup.color-mono .sui-tooltip-pointer {
135+
background-color: var(--mono-base);
136+
border-color: var(--mono-hover);
137+
}
125138
.sui-tooltip-popup.color-default.variant-outlined .sui-tooltip-pointer {
126139
border-color: var(--text-muted);
127140
background-color: var(--default-base);
@@ -145,6 +158,10 @@
145158
border-color: var(--info-hover);
146159
background-color: var(--default-base);
147160
}
161+
.sui-tooltip-popup.color-mono.variant-outlined .sui-tooltip-pointer {
162+
border-color: var(--mono-hover);
163+
background-color: var(--default-base);
164+
}
148165
.sui-tooltip-popup.top .sui-tooltip-pointer {
149166
bottom: -9px;
150167
transform: rotateZ(45deg);

0 commit comments

Comments
 (0)