@roadlittledawn/docs-design-system-react 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -91
- package/dist/components/Button.stories.js +63 -0
- package/dist/components/Callout.stories.js +49 -0
- package/dist/components/Card.stories.js +42 -0
- package/dist/components/CardGrid.stories.js +28 -0
- package/dist/components/CodeBlock.stories.js +91 -0
- package/dist/components/Collapser.stories.js +35 -0
- package/dist/components/CollapserGroup.stories.js +35 -0
- package/dist/components/Heading.stories.js +42 -0
- package/dist/components/Link.stories.js +42 -0
- package/dist/components/List.d.ts +26 -0
- package/dist/components/List.js +36 -0
- package/dist/components/List.stories.d.ts +28 -0
- package/dist/components/List.stories.js +88 -0
- package/dist/components/Popover.d.ts +64 -0
- package/dist/components/Popover.js +202 -0
- package/dist/components/Popover.stories.d.ts +35 -0
- package/dist/components/Popover.stories.js +183 -0
- package/dist/components/Typography.stories.js +49 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.css +391 -0
- package/package.json +1 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useRef, useId, useCallback, useEffect, useState, } from "react";
|
|
14
|
+
function GlossaryTemplate(_a) {
|
|
15
|
+
var data = _a.data;
|
|
16
|
+
return (_jsxs("div", { className: "dds-popover-glossary", children: [_jsx("span", { className: "dds-popover-eyebrow", children: "Glossary" }), _jsx("p", { className: "dds-popover-title", children: _jsx("dfn", { title: data.term, children: data.title }) }), _jsx("div", { className: "dds-popover-body", children: data.definition })] }));
|
|
17
|
+
}
|
|
18
|
+
function PreviewTemplate(_a) {
|
|
19
|
+
var _b;
|
|
20
|
+
var data = _a.data;
|
|
21
|
+
var _c = useState(false), imageError = _c[0], setImageError = _c[1];
|
|
22
|
+
return (_jsxs("div", { className: "dds-popover-preview", children: [data.imageUrl && !imageError && (_jsx("div", { className: "dds-popover-preview-image-wrap", children: _jsx("img", { className: "dds-popover-preview-image", src: data.imageUrl, alt: "", "aria-hidden": "true", onError: function () { return setImageError(true); } }) })), _jsxs("div", { className: "dds-popover-preview-body", children: [_jsx("p", { className: "dds-popover-title", children: data.title }), data.excerpt && (_jsx("div", { className: "dds-popover-body", children: data.excerpt })), data.href && (_jsxs("a", { className: "dds-popover-preview-link", href: data.href, target: "_blank", rel: "noopener noreferrer", children: [(_b = data.linkText) !== null && _b !== void 0 ? _b : "Read more", " \u2192"] }))] })] }));
|
|
23
|
+
}
|
|
24
|
+
/** Resolve the actual placement given preferred placement and available space */
|
|
25
|
+
function resolvePlacement(triggerRect, preferred) {
|
|
26
|
+
if (preferred !== "auto")
|
|
27
|
+
return preferred;
|
|
28
|
+
var spaceAbove = triggerRect.top;
|
|
29
|
+
var spaceBelow = window.innerHeight - triggerRect.bottom;
|
|
30
|
+
// Prefer top if there's more space above (and at least 180px)
|
|
31
|
+
if (spaceAbove > spaceBelow && spaceAbove >= 180)
|
|
32
|
+
return "top";
|
|
33
|
+
return "bottom";
|
|
34
|
+
}
|
|
35
|
+
/** Compute pixel coordinates for the popover given trigger rect and placement */
|
|
36
|
+
function computePosition(triggerRect, popoverEl, placement) {
|
|
37
|
+
var popoverWidth = popoverEl.offsetWidth;
|
|
38
|
+
var popoverHeight = popoverEl.offsetHeight;
|
|
39
|
+
var gap = 8; // px gap between trigger and popover
|
|
40
|
+
var viewportPad = 8; // min distance from viewport edges
|
|
41
|
+
var top = 0;
|
|
42
|
+
var left = 0;
|
|
43
|
+
var triggerCenterX = triggerRect.left + triggerRect.width / 2;
|
|
44
|
+
// Vertical
|
|
45
|
+
var isTop = placement.startsWith("top");
|
|
46
|
+
if (isTop) {
|
|
47
|
+
top = triggerRect.top - popoverHeight - gap;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
top = triggerRect.bottom + gap;
|
|
51
|
+
}
|
|
52
|
+
// Horizontal
|
|
53
|
+
if (placement.endsWith("-start")) {
|
|
54
|
+
left = triggerRect.left;
|
|
55
|
+
}
|
|
56
|
+
else if (placement.endsWith("-end")) {
|
|
57
|
+
left = triggerRect.right - popoverWidth;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// center-aligned
|
|
61
|
+
left = triggerCenterX - popoverWidth / 2;
|
|
62
|
+
}
|
|
63
|
+
// Clamp to viewport horizontally
|
|
64
|
+
left = Math.max(viewportPad, Math.min(left, window.innerWidth - popoverWidth - viewportPad));
|
|
65
|
+
// Flip vertically if overflowing
|
|
66
|
+
if (isTop && top < viewportPad) {
|
|
67
|
+
top = triggerRect.bottom + gap;
|
|
68
|
+
}
|
|
69
|
+
else if (!isTop && top + popoverHeight > window.innerHeight - viewportPad) {
|
|
70
|
+
top = triggerRect.top - popoverHeight - gap;
|
|
71
|
+
}
|
|
72
|
+
return { top: top, left: left };
|
|
73
|
+
}
|
|
74
|
+
export function Popover(_a) {
|
|
75
|
+
var content = _a.content, glossary = _a.glossary, preview = _a.preview, _b = _a.placement, placement = _b === void 0 ? "auto" : _b, _c = _a.size, size = _c === void 0 ? "md" : _c, _d = _a.showDelay, showDelay = _d === void 0 ? 200 : _d, _e = _a.hideDelay, hideDelay = _e === void 0 ? 150 : _e, children = _a.children, _f = _a.className, className = _f === void 0 ? "" : _f;
|
|
76
|
+
var id = useId();
|
|
77
|
+
var popoverId = "dds-popover-".concat(id.replace(/:/g, ""));
|
|
78
|
+
var triggerRef = useRef(null);
|
|
79
|
+
var popoverRef = useRef(null);
|
|
80
|
+
var showTimerRef = useRef(null);
|
|
81
|
+
var hideTimerRef = useRef(null);
|
|
82
|
+
var clearTimers = useCallback(function () {
|
|
83
|
+
if (showTimerRef.current)
|
|
84
|
+
clearTimeout(showTimerRef.current);
|
|
85
|
+
if (hideTimerRef.current)
|
|
86
|
+
clearTimeout(hideTimerRef.current);
|
|
87
|
+
}, []);
|
|
88
|
+
var positionPopover = useCallback(function () {
|
|
89
|
+
var trigger = triggerRef.current;
|
|
90
|
+
var popover = popoverRef.current;
|
|
91
|
+
if (!trigger || !popover)
|
|
92
|
+
return;
|
|
93
|
+
// The Popover API renders in the top layer, outside the normal DOM tree,
|
|
94
|
+
// so it doesn't inherit class-based dark mode from ancestor elements.
|
|
95
|
+
// Mirror the theme onto the popover element itself.
|
|
96
|
+
var isDark = document.documentElement.classList.contains("dds-dark") ||
|
|
97
|
+
document.documentElement.dataset.ddsTheme === "dark" ||
|
|
98
|
+
document.body.classList.contains("dds-dark") ||
|
|
99
|
+
document.body.dataset.ddsTheme === "dark" ||
|
|
100
|
+
!!trigger.closest(".dds-dark, [data-dds-theme='dark']");
|
|
101
|
+
if (isDark) {
|
|
102
|
+
popover.setAttribute("data-dds-theme", "dark");
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
popover.removeAttribute("data-dds-theme");
|
|
106
|
+
}
|
|
107
|
+
var triggerRect = trigger.getBoundingClientRect();
|
|
108
|
+
var resolved = resolvePlacement(triggerRect, placement);
|
|
109
|
+
var _a = computePosition(triggerRect, popover, resolved), top = _a.top, left = _a.left;
|
|
110
|
+
popover.style.top = "".concat(top, "px");
|
|
111
|
+
popover.style.left = "".concat(left, "px");
|
|
112
|
+
// Set placement data attribute for CSS arrow/animation direction
|
|
113
|
+
var baseDir = resolved.startsWith("top") ? "top" : "bottom";
|
|
114
|
+
popover.setAttribute("data-placement", baseDir);
|
|
115
|
+
}, [placement]);
|
|
116
|
+
var showPopover = useCallback(function () {
|
|
117
|
+
clearTimers();
|
|
118
|
+
showTimerRef.current = setTimeout(function () {
|
|
119
|
+
var popover = popoverRef.current;
|
|
120
|
+
if (!popover)
|
|
121
|
+
return;
|
|
122
|
+
// Position before showing so it doesn't flash in the wrong spot
|
|
123
|
+
popover.style.visibility = "hidden";
|
|
124
|
+
try {
|
|
125
|
+
popover.showPopover();
|
|
126
|
+
}
|
|
127
|
+
catch (_a) {
|
|
128
|
+
// Popover API not supported — fall back to display toggle
|
|
129
|
+
popover.style.display = "block";
|
|
130
|
+
}
|
|
131
|
+
positionPopover();
|
|
132
|
+
popover.style.visibility = "";
|
|
133
|
+
}, showDelay);
|
|
134
|
+
}, [clearTimers, showDelay, positionPopover]);
|
|
135
|
+
var hidePopover = useCallback(function () {
|
|
136
|
+
clearTimers();
|
|
137
|
+
hideTimerRef.current = setTimeout(function () {
|
|
138
|
+
var popover = popoverRef.current;
|
|
139
|
+
if (!popover)
|
|
140
|
+
return;
|
|
141
|
+
try {
|
|
142
|
+
popover.hidePopover();
|
|
143
|
+
}
|
|
144
|
+
catch (_a) {
|
|
145
|
+
popover.style.display = "none";
|
|
146
|
+
}
|
|
147
|
+
}, hideDelay);
|
|
148
|
+
}, [clearTimers, hideDelay]);
|
|
149
|
+
// Reposition on scroll/resize while open
|
|
150
|
+
useEffect(function () {
|
|
151
|
+
var handleReposition = function () {
|
|
152
|
+
var popover = popoverRef.current;
|
|
153
|
+
if (!popover)
|
|
154
|
+
return;
|
|
155
|
+
// Only reposition if visible (Popover API or display fallback)
|
|
156
|
+
if (popover.matches(":popover-open") ||
|
|
157
|
+
popover.style.display === "block") {
|
|
158
|
+
positionPopover();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
window.addEventListener("scroll", handleReposition, { passive: true });
|
|
162
|
+
window.addEventListener("resize", handleReposition, { passive: true });
|
|
163
|
+
return function () {
|
|
164
|
+
window.removeEventListener("scroll", handleReposition);
|
|
165
|
+
window.removeEventListener("resize", handleReposition);
|
|
166
|
+
};
|
|
167
|
+
}, [positionPopover]);
|
|
168
|
+
// Cleanup timers on unmount
|
|
169
|
+
useEffect(function () { return function () { return clearTimers(); }; }, [clearTimers]);
|
|
170
|
+
var triggerClasses = ["dds-popover-trigger", className]
|
|
171
|
+
.filter(Boolean)
|
|
172
|
+
.join(" ");
|
|
173
|
+
var popoverClasses = [
|
|
174
|
+
"dds-popover",
|
|
175
|
+
"dds-popover-".concat(size),
|
|
176
|
+
]
|
|
177
|
+
.filter(Boolean)
|
|
178
|
+
.join(" ");
|
|
179
|
+
// Resolve which content to render
|
|
180
|
+
var popoverContent = content !== null && content !== void 0 ? content : (glossary ? (_jsx(GlossaryTemplate, { data: glossary })) : preview ? (_jsx(PreviewTemplate, { data: preview })) : null);
|
|
181
|
+
if (!popoverContent)
|
|
182
|
+
return _jsx(_Fragment, { children: children });
|
|
183
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: triggerRef, className: triggerClasses, onMouseEnter: showPopover, onMouseLeave: hidePopover, onFocus: showPopover, onBlur: hidePopover,
|
|
184
|
+
// Touch: toggle on tap (clear any pending hover timers first)
|
|
185
|
+
onClick: function () {
|
|
186
|
+
clearTimers();
|
|
187
|
+
var popover = popoverRef.current;
|
|
188
|
+
if (!popover)
|
|
189
|
+
return;
|
|
190
|
+
try {
|
|
191
|
+
popover.togglePopover();
|
|
192
|
+
if (popover.matches(":popover-open"))
|
|
193
|
+
positionPopover();
|
|
194
|
+
}
|
|
195
|
+
catch (_a) {
|
|
196
|
+
var isVisible = popover.style.display === "block";
|
|
197
|
+
popover.style.display = isVisible ? "none" : "block";
|
|
198
|
+
if (!isVisible)
|
|
199
|
+
positionPopover();
|
|
200
|
+
}
|
|
201
|
+
}, "aria-describedby": popoverId, tabIndex: 0, children: children }), _jsx("div", __assign({ ref: popoverRef, id: popoverId }, { popover: "auto" }, { className: popoverClasses, onMouseEnter: clearTimers, onMouseLeave: hidePopover, children: popoverContent }))] }));
|
|
202
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Popover } from "./Popover";
|
|
3
|
+
declare const meta: Meta<typeof Popover>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Popover>;
|
|
6
|
+
/**
|
|
7
|
+
* The glossary template renders a structured definition popover.
|
|
8
|
+
* The `definition` field accepts `ReactNode` — pre-render any markdown
|
|
9
|
+
* using your preferred renderer before passing it in.
|
|
10
|
+
*/
|
|
11
|
+
export declare const GlossaryDefinition: Story;
|
|
12
|
+
/**
|
|
13
|
+
* The preview template renders a Wikipedia-style content preview with an
|
|
14
|
+
* optional featured image, excerpt, and "Read more" link.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ContentPreview: Story;
|
|
17
|
+
/**
|
|
18
|
+
* Pass any React element as the `content` prop when the built-in templates
|
|
19
|
+
* don't fit your use case.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CustomContent: Story;
|
|
22
|
+
/**
|
|
23
|
+
* Size variants — sm (240px), md (320px), lg (480px).
|
|
24
|
+
*/
|
|
25
|
+
export declare const Sizes: Story;
|
|
26
|
+
/**
|
|
27
|
+
* Placement variants control which side of the trigger the popover appears on.
|
|
28
|
+
* "auto" (default) detects available viewport space.
|
|
29
|
+
*/
|
|
30
|
+
export declare const Placement: Story;
|
|
31
|
+
/**
|
|
32
|
+
* Multiple popovers in a paragraph — only one can be open at a time
|
|
33
|
+
* (native Popover API `popover="auto"` behaviour).
|
|
34
|
+
*/
|
|
35
|
+
export declare const InlineParagraph: Story;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Popover } from "./Popover";
|
|
14
|
+
var meta = {
|
|
15
|
+
title: "Components/Popover",
|
|
16
|
+
component: Popover,
|
|
17
|
+
tags: ["autodocs"],
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: "centered",
|
|
20
|
+
docs: {
|
|
21
|
+
description: {
|
|
22
|
+
component: "\nA hover/tap-activated popover for enriching inline content in documentation.\nBuilt on the native [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) for reliable top-layer rendering \u2014 no z-index wars, no overflow clipping.\n\nCommon use cases include glossary term definitions and Wikipedia-style content previews.\n\n## Content modes\n\nThe `Popover` supports three mutually exclusive content modes, checked in this order:\n\n1. **`content`** \u2014 arbitrary `ReactNode`; you control everything\n2. **`glossary`** \u2014 structured `{ term, title, definition }` template\n3. **`preview`** \u2014 structured `{ title, excerpt, imageUrl, href }` template\n\n## When to Use\n\n- Inline term definitions that would interrupt reading flow if expanded in-place\n- Link previews that let users get context without navigating away\n- Any contextual content that benefits from being on-demand rather than always visible\n\n## When Not to Use\n\n- For critical information users must read \u2014 use a `Callout` instead\n- As a primary navigation mechanism\n- For content that needs persistent visibility\n\n## Mobile behavior\n\nOn screens \u2264 640 px the popover renders as a bottom sheet instead of a floating panel.\nHover events don't apply; the popover toggles on tap.\n\n## Accessibility\n\n- Trigger has `tabIndex={0}` and shows the popover on focus (keyboard accessible)\n- Popover panel has `role=\"tooltip\"` and is linked via `aria-describedby`\n- The native Popover API handles Escape-key dismissal automatically\n- Light-dismiss (click outside) is provided by `popover=\"auto\"`\n ",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default meta;
|
|
28
|
+
/**
|
|
29
|
+
* The glossary template renders a structured definition popover.
|
|
30
|
+
* The `definition` field accepts `ReactNode` — pre-render any markdown
|
|
31
|
+
* using your preferred renderer before passing it in.
|
|
32
|
+
*/
|
|
33
|
+
export var GlossaryDefinition = {
|
|
34
|
+
args: {
|
|
35
|
+
glossary: {
|
|
36
|
+
term: "observability",
|
|
37
|
+
title: "Observability",
|
|
38
|
+
definition: (_jsxs(_Fragment, { children: ["The ability to understand the internal state of a system by examining its external outputs \u2014 primarily", " ", _jsx("a", { href: "https://example.com/metrics", children: "metrics" }), ", logs, and traces."] })),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
parameters: {
|
|
42
|
+
docs: {
|
|
43
|
+
source: {
|
|
44
|
+
code: "<Popover\n glossary={{\n term: \"observability\",\n title: \"Observability\",\n definition: (\n <>\n The ability to understand the internal state of a system by examining\n its external outputs \u2014 primarily{\" \"}\n <a href=\"https://example.com/metrics\">metrics</a>, logs, and traces.\n </>\n ),\n }}\n>\n observability\n</Popover>",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
render: function (args) { return (_jsxs("p", { style: { fontFamily: "sans-serif", fontSize: "1rem", color: "var(--dds-tabs-panel-text)" }, children: ["Modern software reliability depends on", " ", _jsx(Popover, __assign({}, args, { children: "observability" })), " to diagnose production issues quickly."] })); },
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The preview template renders a Wikipedia-style content preview with an
|
|
52
|
+
* optional featured image, excerpt, and "Read more" link.
|
|
53
|
+
*/
|
|
54
|
+
export var ContentPreview = {
|
|
55
|
+
args: {
|
|
56
|
+
preview: {
|
|
57
|
+
title: "New Relic",
|
|
58
|
+
excerpt: "New Relic is an observability platform that helps engineers plan, build, deploy, and run software. Over 17,000 customers use New Relic to improve uptime, performance, and operational efficiency.",
|
|
59
|
+
imageUrl: "https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=640&q=80",
|
|
60
|
+
href: "https://newrelic.com",
|
|
61
|
+
linkText: "Read more",
|
|
62
|
+
},
|
|
63
|
+
size: "lg",
|
|
64
|
+
},
|
|
65
|
+
parameters: {
|
|
66
|
+
docs: {
|
|
67
|
+
source: {
|
|
68
|
+
code: "<Popover\n size=\"lg\"\n preview={{\n title: \"New Relic\",\n excerpt: \"New Relic is an observability platform that helps engineers plan, build, deploy, and run software.\",\n imageUrl: \"/images/newrelic.jpg\",\n href: \"https://newrelic.com\",\n linkText: \"Read more\",\n }}\n>\n New Relic\n</Popover>",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
render: function (args) { return (_jsxs("p", { style: { fontFamily: "sans-serif", fontSize: "1rem", color: "var(--dds-tabs-panel-text)" }, children: ["The monitoring data is sent to ", _jsx(Popover, __assign({}, args, { children: "New Relic" })), " ", "where you can build dashboards and alerts."] })); },
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Pass any React element as the `content` prop when the built-in templates
|
|
76
|
+
* don't fit your use case.
|
|
77
|
+
*/
|
|
78
|
+
export var CustomContent = {
|
|
79
|
+
args: {
|
|
80
|
+
content: (_jsxs("div", { style: { padding: "1rem" }, children: [_jsx("strong", { style: { display: "block", marginBottom: "0.5rem" }, children: "API Rate Limits" }), _jsxs("table", { style: { fontSize: "0.8125rem", borderCollapse: "collapse", width: "100%" }, children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { style: { textAlign: "left", paddingBottom: "0.25rem", borderBottom: "1px solid #e5e7eb" }, children: "Plan" }), _jsx("th", { style: { textAlign: "right", paddingBottom: "0.25rem", borderBottom: "1px solid #e5e7eb" }, children: "Req/min" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { children: "Free" }), _jsx("td", { style: { textAlign: "right" }, children: "60" })] }), _jsxs("tr", { children: [_jsx("td", { children: "Pro" }), _jsx("td", { style: { textAlign: "right" }, children: "1,000" })] }), _jsxs("tr", { children: [_jsx("td", { children: "Enterprise" }), _jsx("td", { style: { textAlign: "right" }, children: "Unlimited" })] })] })] })] })),
|
|
81
|
+
size: "md",
|
|
82
|
+
},
|
|
83
|
+
parameters: {
|
|
84
|
+
docs: {
|
|
85
|
+
source: {
|
|
86
|
+
code: "<Popover\n content={\n <div style={{ padding: \"1rem\" }}>\n <strong>API Rate Limits</strong>\n {/* custom table or any JSX */}\n </div>\n }\n>\n rate limits\n</Popover>",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
render: function (args) { return (_jsxs("p", { style: { fontFamily: "sans-serif", fontSize: "1rem", color: "var(--dds-tabs-panel-text)" }, children: ["Each API key is subject to ", _jsx(Popover, __assign({}, args, { children: "rate limits" })), " based on your subscription plan."] })); },
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Size variants — sm (240px), md (320px), lg (480px).
|
|
94
|
+
*/
|
|
95
|
+
export var Sizes = {
|
|
96
|
+
parameters: {
|
|
97
|
+
docs: {
|
|
98
|
+
source: {
|
|
99
|
+
code: "<Popover size=\"sm\" glossary={{ term: \"sm\", title: \"Small (240px)\", definition: \"A compact popover for brief definitions.\" }}>\n small\n</Popover>\n\n<Popover size=\"md\" glossary={{ term: \"md\", title: \"Medium (320px)\", definition: \"The default size, suitable for most glossary and preview use cases.\" }}>\n medium\n</Popover>\n\n<Popover size=\"lg\" glossary={{ term: \"lg\", title: \"Large (480px)\", definition: \"A wider panel for rich content previews with images or tables.\" }}>\n large\n</Popover>",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
render: function () { return (_jsxs("div", { style: {
|
|
104
|
+
fontFamily: "sans-serif",
|
|
105
|
+
fontSize: "1rem",
|
|
106
|
+
display: "flex",
|
|
107
|
+
gap: "2rem",
|
|
108
|
+
alignItems: "center",
|
|
109
|
+
color: "var(--dds-tabs-panel-text)",
|
|
110
|
+
}, children: [_jsx(Popover, { size: "sm", glossary: {
|
|
111
|
+
term: "sm",
|
|
112
|
+
title: "Small (240px)",
|
|
113
|
+
definition: "A compact popover for brief definitions.",
|
|
114
|
+
}, children: "small" }), _jsx(Popover, { size: "md", glossary: {
|
|
115
|
+
term: "md",
|
|
116
|
+
title: "Medium (320px)",
|
|
117
|
+
definition: "The default size, suitable for most glossary and preview use cases.",
|
|
118
|
+
}, children: "medium" }), _jsx(Popover, { size: "lg", glossary: {
|
|
119
|
+
term: "lg",
|
|
120
|
+
title: "Large (480px)",
|
|
121
|
+
definition: "A wider panel for rich content previews with images or tables.",
|
|
122
|
+
}, children: "large" })] })); },
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Placement variants control which side of the trigger the popover appears on.
|
|
126
|
+
* "auto" (default) detects available viewport space.
|
|
127
|
+
*/
|
|
128
|
+
export var Placement = {
|
|
129
|
+
parameters: {
|
|
130
|
+
docs: {
|
|
131
|
+
source: {
|
|
132
|
+
code: "<Popover placement=\"top\" glossary={...}>shows above</Popover>\n<Popover placement=\"bottom\" glossary={...}>shows below</Popover>\n<Popover placement=\"top-start\" glossary={...}>top-start</Popover>\n<Popover placement=\"bottom-end\" glossary={...}>bottom-end</Popover>",
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
render: function () { return (_jsx("div", { style: {
|
|
137
|
+
fontFamily: "sans-serif",
|
|
138
|
+
fontSize: "1rem",
|
|
139
|
+
display: "flex",
|
|
140
|
+
flexWrap: "wrap",
|
|
141
|
+
gap: "2rem",
|
|
142
|
+
justifyContent: "center",
|
|
143
|
+
padding: "6rem 2rem",
|
|
144
|
+
color: "var(--dds-tabs-panel-text)",
|
|
145
|
+
}, children: [
|
|
146
|
+
"top",
|
|
147
|
+
"top-start",
|
|
148
|
+
"top-end",
|
|
149
|
+
"bottom",
|
|
150
|
+
"bottom-start",
|
|
151
|
+
"bottom-end",
|
|
152
|
+
].map(function (p) { return (_jsx(Popover, { placement: p, glossary: {
|
|
153
|
+
term: p,
|
|
154
|
+
title: "placement=\"".concat(p, "\""),
|
|
155
|
+
definition: "The popover opens ".concat(p.replace("-", " "), " relative to its trigger."),
|
|
156
|
+
}, children: p }, p)); }) })); },
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Multiple popovers in a paragraph — only one can be open at a time
|
|
160
|
+
* (native Popover API `popover="auto"` behaviour).
|
|
161
|
+
*/
|
|
162
|
+
export var InlineParagraph = {
|
|
163
|
+
parameters: {
|
|
164
|
+
docs: {
|
|
165
|
+
source: {
|
|
166
|
+
code: "<p>\n <Popover glossary={{ term: \"apm\", title: \"APM\", definition: \"Application Performance Monitoring...\" }}>APM</Popover>\n {\" \"}data flows into{\" \"}\n <Popover preview={{ title: \"New Relic\", excerpt: \"...\", href: \"https://newrelic.com\" }}>New Relic</Popover>\n {\" \"}where you can configure{\" \"}\n <Popover glossary={{ term: \"alert\", title: \"Alert\", definition: \"A notification triggered when a signal crosses a threshold.\" }}>alerts</Popover>.\n</p>",
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
render: function () { return (_jsxs("p", { style: { fontFamily: "sans-serif", fontSize: "1rem", maxWidth: "480px", lineHeight: 1.7, color: "var(--dds-tabs-panel-text)", margin: 0 }, children: [_jsx(Popover, { glossary: {
|
|
171
|
+
term: "apm",
|
|
172
|
+
title: "APM",
|
|
173
|
+
definition: "Application Performance Monitoring — tracks the performance of software applications and their underlying infrastructure.",
|
|
174
|
+
}, children: "APM" }), " ", "data flows into", " ", _jsx(Popover, { preview: {
|
|
175
|
+
title: "New Relic",
|
|
176
|
+
excerpt: "New Relic is an observability platform used by over 17,000 customers.",
|
|
177
|
+
href: "https://newrelic.com",
|
|
178
|
+
}, children: "New Relic" }), " ", "where you can configure", " ", _jsx(Popover, { glossary: {
|
|
179
|
+
term: "alert",
|
|
180
|
+
title: "Alert",
|
|
181
|
+
definition: "A notification triggered when a metric or signal crosses a defined threshold.",
|
|
182
|
+
}, children: "alerts" }), " ", "to notify your on-call team."] })); },
|
|
183
|
+
};
|
|
@@ -24,6 +24,13 @@ export var H1 = {
|
|
|
24
24
|
variant: 'h1',
|
|
25
25
|
children: 'Heading 1 Style',
|
|
26
26
|
},
|
|
27
|
+
parameters: {
|
|
28
|
+
docs: {
|
|
29
|
+
source: {
|
|
30
|
+
code: "<Typography variant=\"h1\">Heading 1 Style</Typography>",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
27
34
|
};
|
|
28
35
|
/**
|
|
29
36
|
* H2 heading style.
|
|
@@ -33,6 +40,13 @@ export var H2 = {
|
|
|
33
40
|
variant: 'h2',
|
|
34
41
|
children: 'Heading 2 Style',
|
|
35
42
|
},
|
|
43
|
+
parameters: {
|
|
44
|
+
docs: {
|
|
45
|
+
source: {
|
|
46
|
+
code: "<Typography variant=\"h2\">Heading 2 Style</Typography>",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
36
50
|
};
|
|
37
51
|
/**
|
|
38
52
|
* H3 heading style.
|
|
@@ -42,6 +56,13 @@ export var H3 = {
|
|
|
42
56
|
variant: 'h3',
|
|
43
57
|
children: 'Heading 3 Style',
|
|
44
58
|
},
|
|
59
|
+
parameters: {
|
|
60
|
+
docs: {
|
|
61
|
+
source: {
|
|
62
|
+
code: "<Typography variant=\"h3\">Heading 3 Style</Typography>",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
45
66
|
};
|
|
46
67
|
/**
|
|
47
68
|
* H4 heading style.
|
|
@@ -51,6 +72,13 @@ export var H4 = {
|
|
|
51
72
|
variant: 'h4',
|
|
52
73
|
children: 'Heading 4 Style',
|
|
53
74
|
},
|
|
75
|
+
parameters: {
|
|
76
|
+
docs: {
|
|
77
|
+
source: {
|
|
78
|
+
code: "<Typography variant=\"h4\">Heading 4 Style</Typography>",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
54
82
|
};
|
|
55
83
|
/**
|
|
56
84
|
* Paragraph style (default).
|
|
@@ -60,6 +88,13 @@ export var Paragraph = {
|
|
|
60
88
|
variant: 'p',
|
|
61
89
|
children: 'This is a paragraph with the default typography style. It provides readable text for body content.',
|
|
62
90
|
},
|
|
91
|
+
parameters: {
|
|
92
|
+
docs: {
|
|
93
|
+
source: {
|
|
94
|
+
code: "<Typography variant=\"p\">\n This is a paragraph with the default typography style. It provides readable text for body content.\n</Typography>",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
63
98
|
};
|
|
64
99
|
/**
|
|
65
100
|
* Caption style for small text.
|
|
@@ -69,10 +104,24 @@ export var Caption = {
|
|
|
69
104
|
variant: 'caption',
|
|
70
105
|
children: 'This is caption text, typically used for figure captions or footnotes.',
|
|
71
106
|
},
|
|
107
|
+
parameters: {
|
|
108
|
+
docs: {
|
|
109
|
+
source: {
|
|
110
|
+
code: "<Typography variant=\"caption\">\n This is caption text, typically used for figure captions or footnotes.\n</Typography>",
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
72
114
|
};
|
|
73
115
|
/**
|
|
74
116
|
* All typography variants displayed together.
|
|
75
117
|
*/
|
|
76
118
|
export var AllVariants = {
|
|
119
|
+
parameters: {
|
|
120
|
+
docs: {
|
|
121
|
+
source: {
|
|
122
|
+
code: "<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>\n <Typography variant=\"h1\">Heading 1 Style</Typography>\n <Typography variant=\"h2\">Heading 2 Style</Typography>\n <Typography variant=\"h3\">Heading 3 Style</Typography>\n <Typography variant=\"h4\">Heading 4 Style</Typography>\n <Typography variant=\"p\">\n This is paragraph text. It's the default variant and is suitable for\n body content and general text throughout your documentation.\n </Typography>\n <Typography variant=\"caption\">\n This is caption text, used for smaller annotations or supplementary information.\n </Typography>\n</div>",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
77
126
|
render: function () { return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '1rem' }, children: [_jsx(Typography, { variant: "h1", children: "Heading 1 Style" }), _jsx(Typography, { variant: "h2", children: "Heading 2 Style" }), _jsx(Typography, { variant: "h3", children: "Heading 3 Style" }), _jsx(Typography, { variant: "h4", children: "Heading 4 Style" }), _jsx(Typography, { variant: "p", children: "This is paragraph text. It's the default variant and is suitable for body content and general text throughout your documentation." }), _jsx(Typography, { variant: "caption", children: "This is caption text, used for smaller annotations or supplementary information." })] })); },
|
|
78
127
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export * from './components/Collapser';
|
|
|
6
6
|
export * from './components/CollapserGroup';
|
|
7
7
|
export * from './components/CodeBlock';
|
|
8
8
|
export * from './components/Tabs';
|
|
9
|
+
export * from './components/Popover';
|
|
9
10
|
export * from './components/Typography';
|
|
10
11
|
export * from './components/Heading';
|
|
11
12
|
export * from './components/Link';
|
|
13
|
+
export * from './components/List';
|
|
12
14
|
export * from './hooks/useKeyPress';
|
package/dist/index.js
CHANGED
|
@@ -7,8 +7,10 @@ export * from './components/Collapser';
|
|
|
7
7
|
export * from './components/CollapserGroup';
|
|
8
8
|
export * from './components/CodeBlock';
|
|
9
9
|
export * from './components/Tabs';
|
|
10
|
+
export * from './components/Popover';
|
|
10
11
|
export * from './components/Typography';
|
|
11
12
|
export * from './components/Heading';
|
|
12
13
|
export * from './components/Link';
|
|
14
|
+
export * from './components/List';
|
|
13
15
|
// Export hooks
|
|
14
16
|
export * from './hooks/useKeyPress';
|