Skip to content

Commit

Permalink
feat: Add support for imported content
Browse files Browse the repository at this point in the history
  • Loading branch information
Sporiff committed Oct 24, 2023
1 parent d050111 commit a7c28ff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/markdown.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"Tooltip": {
"prefix": "@tooltip",
"description": "Insert content accompanied by a tooltip",
"body": "<Tooltip>[${1:${TM_SELECTED_TEXT}}](${0:The content in the tooltip})</Tooltip>"
"body": "<Tooltip>${1:${TM_SELECTED_TEXT}} || ${0:The content in the tooltip}</Tooltip>"
},
"Abbreviation": {
"prefix": "@abbreviation",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tooltip.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let toolTipContent = "";
let body = "";
// Matchs the pattern "text || text"
const tooltipRegex = /(.*)\s\|\|\s(.*)/m;
const tooltipRegex = /(.*)\n?\s\|\|\s\n?((.|\n)*)/m;
if (Astro.slots.has("default")) {
content = await Astro.slots.render("default");
Expand Down
2 changes: 1 addition & 1 deletion src/components/atlas/BuildTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const BuildTooltip: FC<{
<>
<Tooltip
position={props.position ? props.position : "top"}
content={props.content}
zIndex={100}
content={<div style={{ maxWidth: "fit-content" }}>{props.content}</div>}
>
<span className="underline decoration-dashed">{props.children}</span>
</Tooltip>
Expand Down
20 changes: 14 additions & 6 deletions src/content/docs/en/kitchen-sink/typography.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ Abbreviations can be written using the `<Abbr>` component. This component transf

</Table>

<Callout type="important">

Tooltips only support single line content.

</Callout>

Tooltips can be written using the `<Tooltip>` component. This component transforms content written as `${Article content} || %${Tooltip content}%` into an [Atlas `Tooltip` component](https://atlas.adeven.com/docs/components/Tooltip).

```mdx
Expand Down Expand Up @@ -165,3 +159,17 @@ Tooltips are shown above the content by default. You can customize the position
```

<Tooltip position="right">This is content that needs a tooltip || Here it is!</Tooltip>

### Imported content

You can use MDX imports to add multi-line or reusable content to your tooltip. This is especially useful for content such as method signatures or concept definitions.

```mdx
import ResolveLinkWithUrl from "@ios-signatures/ADJLinkResolution/resolveLinkWithUrl.mdx"

<Tooltip>`resolveLinkWithUrl` method || <ResolveLinkWithUrl /></Tooltip>
```

import ResolveLinkWithUrl from "@ios-signatures/ADJLinkResolution/resolveLinkWithUrl.mdx"

<Tooltip>`resolveLinkWithUrl` method || <ResolveLinkWithUrl /></Tooltip>

0 comments on commit a7c28ff

Please sign in to comment.