@roadlittledawn/docs-design-system-react 0.2.0 → 0.2.1
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.
|
@@ -7,13 +7,12 @@ var defaultTitles = {
|
|
|
7
7
|
};
|
|
8
8
|
export function Callout(_a) {
|
|
9
9
|
var variant = _a.variant, title = _a.title, children = _a.children, _b = _a.className, className = _b === void 0 ? "" : _b;
|
|
10
|
-
var calloutClasses = [
|
|
11
|
-
"dds-callout",
|
|
12
|
-
"dds-callout-".concat(variant),
|
|
13
|
-
className,
|
|
14
|
-
]
|
|
10
|
+
var calloutClasses = ["dds-callout", "dds-callout-".concat(variant), className]
|
|
15
11
|
.filter(Boolean)
|
|
16
12
|
.join(" ");
|
|
17
|
-
var titleClasses = [
|
|
18
|
-
|
|
13
|
+
var titleClasses = [
|
|
14
|
+
"dds-callout-title",
|
|
15
|
+
"dds-callout-title-".concat(variant),
|
|
16
|
+
].join(" ");
|
|
17
|
+
return (_jsxs("div", { className: calloutClasses, children: [title !== null && (_jsx("p", { className: titleClasses, children: title || defaultTitles[variant] })), children] }));
|
|
19
18
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
interface HeadingProps {
|
|
3
|
+
/** Optionally override auto-generation of `id` attribute */
|
|
4
|
+
id?: string;
|
|
3
5
|
/** Heading level (h1, h2, h3, or h4) */
|
|
4
6
|
level: 1 | 2 | 3 | 4;
|
|
5
7
|
/** Heading content */
|
|
@@ -7,5 +9,5 @@ interface HeadingProps {
|
|
|
7
9
|
/** Additional CSS classes */
|
|
8
10
|
className?: string;
|
|
9
11
|
}
|
|
10
|
-
export declare function Heading({ level, children, className }: HeadingProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function Heading({ level, children, id, className }: HeadingProps): import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import slugify from "../utils/slugify";
|
|
2
3
|
export function Heading(_a) {
|
|
3
|
-
var
|
|
4
|
+
var _b;
|
|
5
|
+
var level = _a.level, children = _a.children, id = _a.id, _c = _a.className, className = _c === void 0 ? "" : _c;
|
|
4
6
|
var Tag = "h".concat(level);
|
|
5
7
|
var classNames = "dds-heading dds-heading-".concat(level, " ").concat(className).trim();
|
|
6
|
-
|
|
8
|
+
var generatedId = typeof children === "string" ? (_b = slugify({ value: children })) !== null && _b !== void 0 ? _b : undefined : undefined;
|
|
9
|
+
var idAttr = id !== null && id !== void 0 ? id : generatedId;
|
|
10
|
+
return (_jsx(Tag, { id: idAttr, className: classNames, children: children }));
|
|
7
11
|
}
|
package/dist/styles.css
CHANGED
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
/* Callout Colors and Styles */
|
|
109
109
|
--dds-callout-text: #374151; /* gray-700 */
|
|
110
110
|
--dds-callout-padding: 1.25rem; /* p-5 */
|
|
111
|
+
--dds-callout-margin: 1rem 0;
|
|
111
112
|
--dds-callout-radius: 0.25rem; /* rounded */
|
|
112
113
|
--dds-callout-title-size: 0.75rem; /* text-xs */
|
|
113
114
|
--dds-callout-title-margin-bottom: 0.5rem; /* mb-2 */
|
|
@@ -197,7 +198,8 @@
|
|
|
197
198
|
/* Collapser Colors and Styles */
|
|
198
199
|
--dds-collapser-radius: 0.375rem; /* rounded-md */
|
|
199
200
|
--dds-collapser-border: #e5e7eb; /* gray-200 */
|
|
200
|
-
--dds-collapser-shadow:
|
|
201
|
+
--dds-collapser-shadow:
|
|
202
|
+
0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
|
|
201
203
|
--dds-collapser-button-padding: 0.75rem; /* p-3 */
|
|
202
204
|
--dds-collapser-button-hover-bg: #f9fafb; /* gray-50 */
|
|
203
205
|
--dds-collapser-icon-color: #6b7280; /* gray-500 */
|
|
@@ -658,6 +660,7 @@ pre[class*="language-"] {
|
|
|
658
660
|
}
|
|
659
661
|
.dds-callout {
|
|
660
662
|
padding: var(--dds-callout-padding);
|
|
663
|
+
margin: var(--dds-callout-margin);
|
|
661
664
|
border-radius: var(--dds-callout-radius);
|
|
662
665
|
border: 1px solid;
|
|
663
666
|
border-left-width: 6px;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import slug from "slug";
|
|
2
|
+
slug.extend({
|
|
3
|
+
"/": "-",
|
|
4
|
+
"\\": "-",
|
|
5
|
+
_: "-",
|
|
6
|
+
"-": "-",
|
|
7
|
+
"&": "and",
|
|
8
|
+
});
|
|
9
|
+
export default function slugify(_a) {
|
|
10
|
+
var value = _a.value, options = _a.options;
|
|
11
|
+
if (!value || value.match(/^\s+$/))
|
|
12
|
+
return null;
|
|
13
|
+
var slugified = typeof options === "string" ? slug(value, options) : slug(value, options);
|
|
14
|
+
// remove repetitive dashes
|
|
15
|
+
var repetitiveRemoved = slugified.replace(/-{2,}/g, "-");
|
|
16
|
+
// strip leading and trailing dashes
|
|
17
|
+
var dashesTrimmed = repetitiveRemoved.replace(/^-+/, "").replace(/-+$/, "");
|
|
18
|
+
// return null when empty
|
|
19
|
+
return dashesTrimmed || null;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roadlittledawn/docs-design-system-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React components for documentation design system",
|
|
6
6
|
"repository": {
|
|
@@ -25,11 +25,13 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"prismjs": "^1.29.0",
|
|
27
27
|
"react": "^18.0.0",
|
|
28
|
-
"react-dom": "^18.0.0"
|
|
28
|
+
"react-dom": "^18.0.0",
|
|
29
|
+
"slug": "^9.0.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/react": "^18.0.0",
|
|
32
33
|
"@types/react-dom": "^18.0.0",
|
|
34
|
+
"@types/slug": "^5.0.9",
|
|
33
35
|
"postcss": "^8.4.0",
|
|
34
36
|
"postcss-cli": "^11.0.0",
|
|
35
37
|
"postcss-import": "^16.0.0",
|