+
{deprecation && (
-
+
Due {format(new Date(deprecation.date), 'MMMM do, yyyy')}
)}
-
-
+ {description && (
+
+ )}
+
{examples.map((example, idx) => (
-
+
))}
diff --git a/src/components/PropList.module.scss b/src/components/PropList.module.scss
index f49307611..0948a0cb3 100644
--- a/src/components/PropList.module.scss
+++ b/src/components/PropList.module.scss
@@ -1,40 +1,36 @@
.container {
- display: flex;
- border-bottom: solid var(--color-neutrals-200) 1px;
- padding-bottom: 2rem;
- margin-top: 1rem;
-}
-
-.info {
- width: 30%;
- word-break: break-all;
+ display: grid;
+ grid-template-columns: 30% minmax(0, 1fr);
+ grid-gap: 1rem;
- code {
- font-weight: bold;
+ &:not(:last-child) {
+ margin-bottom: 2rem;
+ padding-bottom: 2rem;
+ border-bottom: solid var(--color-neutrals-200) 1px;
}
+}
- h3 {
- margin-top: 0;
- }
+.propName {
+ font-weight: bold;
+}
+
+.info {
+ overflow-wrap: break-all;
}
.default {
margin-top: 2rem;
- color: var(--color-neutrals-700);
- p:first-of-type {
+ .label {
+ color: var(--color-neutrals-600);
font-size: 0.75rem;
+ font-weight: bold;
}
}
-.type {
- color: var(--color-neutrals-600);
-}
-
.deprecation {
- padding: 0.25rem;
+ padding: 0.5rem;
background: var(--color-red-100);
- margin-bottom: 1rem;
}
.deprecationDate {
@@ -43,17 +39,13 @@
margin-bottom: 1rem;
}
-.propInfo {
- width: 70%;
-}
-
-.markdownContainer > *:first-child {
- margin-top: 0;
-}
+.deprecationMarkdownContainer {
+ p:last-child {
+ margin-bottom: 0;
+ }
-.details {
- &:not(:last-child):not(:empty) {
- margin-bottom: 1rem;
+ code {
+ background: var(--color-red-200);
}
}
@@ -65,21 +57,15 @@
font-weight: bold;
}
-.arg {
- padding-left: 1rem;
-}
-
-.listLike {
- font-family: var(--code-font);
+.codeDef {
font-size: 0.875rem;
- color: var(--color-neutrals-600);
max-height: 320px;
overflow-y: auto;
}
.shape {
&:not(:last-child) {
- margin-bottom: 2rem;
+ margin-bottom: 4rem;
}
h4 {
@@ -92,3 +78,7 @@
padding-bottom: 0;
}
}
+
+.section:not(:last-child) {
+ margin-bottom: 2rem;
+}
diff --git a/src/components/ReferenceExample.js b/src/components/ReferenceExample.js
index 6801289e2..d89f38ec4 100644
--- a/src/components/ReferenceExample.js
+++ b/src/components/ReferenceExample.js
@@ -66,7 +66,13 @@ const ReferenceExample = ({
useToastManager={useToastManager}
/>
)}
-
+
{live &&
}
diff --git a/src/components/ReferenceExample.module.scss b/src/components/ReferenceExample.module.scss
index bd97e7e85..7d3a880af 100644
--- a/src/components/ReferenceExample.module.scss
+++ b/src/components/ReferenceExample.module.scss
@@ -10,5 +10,7 @@
}
.title {
+ font-weight: bold;
+ font-size: 1.25rem;
margin-bottom: 1rem;
}
diff --git a/src/components/ReferencePreview.js b/src/components/ReferencePreview.js
index f027d712e..c2348b1a6 100644
--- a/src/components/ReferencePreview.js
+++ b/src/components/ReferencePreview.js
@@ -8,7 +8,6 @@ const EXAMPLE_CSS = `
.nr1-ReferenceExample {
line-height: 1.36;
font-weight: 400;
- background-color: #fff;
color: #000e0e;
font-size: 12px;
font-family: Open Sans,Segoe UI,Tahoma,sans-serif;
diff --git a/src/components/TypeDefReference.js b/src/components/TypeDefReference.js
index bbcbb989d..d041eb69d 100644
--- a/src/components/TypeDefReference.js
+++ b/src/components/TypeDefReference.js
@@ -1,60 +1,33 @@
import React from 'react';
-import Markdown from 'react-markdown';
import PropTypes from 'prop-types';
import styles from './TypeDefReference.module.scss';
-
-const RenderDescription = ({ children }) => (
-
-);
-
-const RenderProperty = ({ property }) => {
- const { type, name, description } = property;
-
- return (
-
- );
-};
+import CodeDef from './CodeDef';
const TypeDefReference = ({ typeDef }) => {
const { properties, name } = typeDef;
return (
-
-
{name}
-
-
{`{`}
- {properties.map((property, i) => (
-
- ))}
-
{`}`}
-
+
+
+ {name}
+
+
+ {'{'}
+
+ {properties.map((property) => (
+
+ {property.name}:
+ {property.type},{' '}
+
+
+ ))}
+
+ {'}'}
+
);
};
-RenderProperty.propTypes = {
- property: PropTypes.shape({
- type: PropTypes.string,
- name: PropTypes.string,
- description: PropTypes.string,
- }),
-};
-
-RenderDescription.propTypes = {
- children: PropTypes.node.isRequired,
-};
-
TypeDefReference.propTypes = {
typeDef: PropTypes.shape({
properties: PropTypes.array,
diff --git a/src/components/TypeDefReference.module.scss b/src/components/TypeDefReference.module.scss
index ae862b4b5..b8f17b3b5 100644
--- a/src/components/TypeDefReference.module.scss
+++ b/src/components/TypeDefReference.module.scss
@@ -1,42 +1,13 @@
-.container {
- color: var(--color-neutrals-500);
- font-family: var(--code-font);
- font-size: 0.875rem;
- line-height: 1.5;
- margin-top: 2rem;
+.container:not(:last-child) {
+ margin-bottom: 2rem;
}
.name {
font-size: 1rem;
- font-family: var(--primary-font-family);
- color: var(--color-neutrals-800);
+ font-weight: normal;
margin-bottom: 0.5rem;
}
-.block {
- margin-left: 0.5rem;
-}
-
-.topBracket {
- margin-bottom: 1rem;
-}
-
-.type {
- color: var(--color-green-500);
- background: var(--color-green-050);
-}
-
-.description {
- > p {
- display: inline;
- }
-}
-
-.propertyContainer {
- margin: 0 0 1rem 1.5rem;
-}
-
-.propertyName {
- color: var(--color-neutrals-700);
- margin-right: 0.5rem;
+.typeDef {
+ font-size: 0.875rem;
}
diff --git a/src/components/styles.scss b/src/components/styles.scss
index 554ff7533..63f100d15 100644
--- a/src/components/styles.scss
+++ b/src/components/styles.scss
@@ -88,7 +88,7 @@ body {
font-family: var(--primary-font-family);
color: var(--color-neutrals-700);
background-color: var(--color-white);
- line-height: 1.2;
+ line-height: 1.5;
}
main {
@@ -106,8 +106,8 @@ img {
}
p {
- margin: 0;
- margin-top: 8px;
+ margin-top: 0;
+ margin-bottom: 1em;
}
h1,
@@ -116,7 +116,7 @@ h3,
h4,
h5,
h6 {
- margin-top: revert;
+ margin-top: 0;
margin-bottom: 8px;
font-weight: 600;
color: var(--color-neutrals-800);
@@ -166,12 +166,8 @@ button,
}
ul {
- padding-left: 30px;
- line-height: 1.6;
-}
-
-li {
- margin-bottom: 1rem;
+ margin: 0;
+ padding-left: 2rem;
}
code {
diff --git a/src/hooks/useApiDoc.js b/src/hooks/useApiDoc.js
index 0e05d843f..74f9b8ef1 100644
--- a/src/hooks/useApiDoc.js
+++ b/src/hooks/useApiDoc.js
@@ -1,5 +1,5 @@
import { useMemo } from 'react';
-import { pullTypeDefNames } from '../utils/typeDefs';
+import { getTypeDefs } from '../utils/typeDefs';
import navigationApi from '../data/navigationApi';
const IGNORED_METHODS = [
@@ -38,28 +38,6 @@ const useApiDoc = (name) => {
const apiDocs = api?.__docs__;
- const getTypeDefs = (api) => {
- const apiTypeDefNames = Object.getOwnPropertyNames(api)
- .filter((key) => !IGNORED_METHODS.includes(key))
- .map((key) => api[key]?.__docs__?.tags)
- .filter(Boolean)
- .flatMap(pullTypeDefNames);
-
- const allTypeDefs = window.__NR1_SDK__.default.__typeDefs__;
-
- const typeDefs = apiTypeDefNames
- .map((name) => allTypeDefs[name])
- .filter((typeDef) => typeDef !== undefined);
-
- const structuredTypeDefs = typeDefs.map((typeDef) => ({
- properties: typeDef.tags.property,
- name: typeDef.tags.typedef.find((tag) => tag.identifier).identifier
- .name,
- }));
-
- return structuredTypeDefs;
- };
-
const getConstants = (api) => {
return Object.getOwnPropertyNames(api)
.filter(
@@ -70,21 +48,20 @@ const useApiDoc = (name) => {
.map((member) => {
return {
name: `${name}.${member}`,
- type: api[member] instanceof Array ? 'array' : typeof api[member],
- values:
- api[member] instanceof Array
- ? api[member].map((el) => JSON.stringify(el))
- : Object.getOwnPropertyNames(api[member]).map(
- (key) => `${key}: ${JSON.stringify(api[member][key])}`
- ),
+ value: api[member],
};
});
};
+ const properties = Object.getOwnPropertyNames(api)
+ .filter((key) => !IGNORED_METHODS.includes(key))
+ .map((key) => api[key]?.__docs__?.tags)
+ .filter(Boolean);
+
return {
description: apiDocs?.text,
usage: `import { ${name} } from 'nr1'`,
- typeDefs: getTypeDefs(api),
+ typeDefs: getTypeDefs(properties),
constants: getConstants(api),
methods: Object.getOwnPropertyNames(api)
.filter(
diff --git a/src/hooks/useComponentDoc.js b/src/hooks/useComponentDoc.js
index a8076b037..926d964bf 100644
--- a/src/hooks/useComponentDoc.js
+++ b/src/hooks/useComponentDoc.js
@@ -1,8 +1,8 @@
import { useMemo } from 'react';
import { getPropTypeDefinition } from '../utils/propTypeInfo';
-import { pullTypeDefNames } from '../utils/typeDefs';
+import { getTypeDefs } from '../utils/typeDefs';
-const IGNORED_LIVE_EXAMPLES = ['Dropdown', 'Modal', 'Tooltip'];
+const IGNORED_LIVE_EXAMPLES = ['Dropdown', 'Modal', 'Tooltip', 'Select'];
const IGNORED_METHODS = [
'prototype',
@@ -32,36 +32,6 @@ const getPropTypes = (component) => {
);
};
-const getTypeDefs = (component) => {
- const tagsFromComponentProperties = Object.getOwnPropertyNames(component)
- .filter((key) => !IGNORED_METHODS.includes(key))
- .map((key) => component[key]?.__docs__?.tags)
- .filter(Boolean);
-
- const tagsFromPropTypes = component.propTypes
- ? Object.getOwnPropertyNames(component.propTypes).map(
- (key) => component.propTypes[key]?.__docs__?.tags
- )
- : [];
-
- const componentTypeDefNames = tagsFromComponentProperties
- .concat(tagsFromPropTypes)
- .flatMap(pullTypeDefNames);
-
- const allTypeDefs = window.__NR1_SDK__.default.__typeDefs__;
-
- const typeDefs = componentTypeDefNames
- .map((name) => allTypeDefs[name])
- .filter((typeDef) => typeDef !== undefined);
-
- const structuredTypeDefs = typeDefs.map((typeDef) => ({
- properties: typeDef.tags.property,
- name: typeDef.tags.typedef.find((tag) => tag.identifier).identifier.name,
- }));
-
- return structuredTypeDefs;
-};
-
const useComponentDoc = (componentName) => {
if (typeof window === 'undefined') global.window = {};
@@ -73,6 +43,17 @@ const useComponentDoc = (componentName) => {
return null;
}
+ const tagsFromComponentProperties = Object.getOwnPropertyNames(component)
+ .filter((key) => !IGNORED_METHODS.includes(key))
+ .map((key) => component[key]?.__docs__?.tags)
+ .filter(Boolean);
+
+ const tagsFromPropTypes = component.propTypes
+ ? Object.getOwnPropertyNames(component.propTypes).map(
+ (key) => component.propTypes[key]?.__docs__?.tags
+ )
+ : [];
+
return {
description: component?.__docs__?.text,
examples: getExamples(component),
@@ -95,7 +76,9 @@ const useComponentDoc = (componentName) => {
examples: methodDocs?.tags.examples ?? [],
};
}),
- typeDefs: getTypeDefs(component),
+ typeDefs: getTypeDefs(
+ tagsFromComponentProperties.concat(tagsFromPropTypes)
+ ),
};
}, [componentName, window?.__NR1_SDK__]);
};
diff --git a/src/templates/ApiReferenceTemplate.js b/src/templates/ApiReferenceTemplate.js
index f20e74fb4..242aeabbb 100644
--- a/src/templates/ApiReferenceTemplate.js
+++ b/src/templates/ApiReferenceTemplate.js
@@ -3,8 +3,9 @@ import cx from 'classnames';
import { graphql } from 'gatsby';
import PropTypes from 'prop-types';
import InlineCodeSnippet from '../components/InlineCodeSnippet';
-import ReactMarkdown from 'react-markdown';
import Layout from '../components/Layout';
+import PageTitle from '../components/PageTitle';
+import Markdown from '../components/Markdown';
import MethodReference from '../components/MethodReference';
import TypeDefReference from '../components/TypeDefReference';
import ConstantReference from '../components/ConstantReference';
@@ -28,31 +29,41 @@ const ApiReferenceTemplate = ({ data }) => {
return (
- {api}
+ {api}
-
+ {apiDescription && (
+
+ )}
{methods.length > 0 && (
- API methods
+ API methods
{methods.map((method, i) => (
-
+
))}
)}
{typeDefs.length > 0 && (
- Type definitions
+ Type definitions
{typeDefs.map((typeDef, i) => (
))}
@@ -61,7 +72,7 @@ const ApiReferenceTemplate = ({ data }) => {
{constants.length > 0 && (
- Constants
+ Constants
{constants.map((constant, i) => (
))}
diff --git a/src/templates/ComponentReferenceTemplate.js b/src/templates/ComponentReferenceTemplate.js
index a5ef245f4..77492f6ac 100644
--- a/src/templates/ComponentReferenceTemplate.js
+++ b/src/templates/ComponentReferenceTemplate.js
@@ -3,9 +3,10 @@ import cx from 'classnames';
import { graphql } from 'gatsby';
import PropTypes from 'prop-types';
import InlineCodeSnippet from '../components/InlineCodeSnippet';
-import ReactMarkdown from 'react-markdown';
import ReferenceExample from '../components/ReferenceExample';
import Layout from '../components/Layout';
+import PageTitle from '../components/PageTitle';
+import Markdown from '../components/Markdown';
import MethodReference from '../components/MethodReference';
import SEO from '../components/Seo';
import PropList from '../components/PropList';
@@ -15,14 +16,30 @@ import useComponentDoc from '../hooks/useComponentDoc';
import IconGallery from '../components/IconGallery';
import TypeDefReference from '../components/TypeDefReference';
+const chartStyles = {
+ height: '200px',
+};
+
const previewStyles = {
+ AreaChart: chartStyles,
+ BarChart: chartStyles,
+ BillboardChart: chartStyles,
+ FunnelChart: chartStyles,
+ HeatmapChart: chartStyles,
+ HistogramChart: chartStyles,
+ JsonChart: chartStyles,
+ LineChart: chartStyles,
+ PieChart: chartStyles,
+ ScatterChart: chartStyles,
+ SparklineChart: chartStyles,
+ StackedBarChart: chartStyles,
+ TableChart: chartStyles,
Spinner: {
height: '16px',
},
};
const ComponentReferenceTemplate = ({ data }) => {
- // const [isOpen, setIsOpen] = useState(false);
const { mdx } = data;
const { frontmatter } = mdx;
const { title, description, component } = frontmatter;
@@ -38,26 +55,20 @@ const ComponentReferenceTemplate = ({ data }) => {
return (
- {component}
-
-
+ {component}
+
{examples.length > 0 && (
- Examples
+
Examples
{examples.map((example, i) => (
{
)}
{methods.length > 0 && (
- Methods
+ Methods
{methods.map((method, i) => (
-
+
))}
)}
{typeDefs.length > 0 && (
- Type definitions
+ Type definitions
{typeDefs.map((typeDef, i) => (
))}
diff --git a/src/templates/ReferenceTemplate.module.scss b/src/templates/ReferenceTemplate.module.scss
index c679a6a06..f2cc250d0 100644
--- a/src/templates/ReferenceTemplate.module.scss
+++ b/src/templates/ReferenceTemplate.module.scss
@@ -1,16 +1,9 @@
-.description {
- margin-top: 0.5rem;
- padding-top: 0.5rem;
-
- ul {
- padding-top: 0.5rem;
- }
-
- li {
- margin: 0;
- }
-}
-
.section:not(:last-child) {
margin-bottom: 2rem;
}
+
+.sectionTitle {
+ margin-bottom: 1rem;
+ font-size: 1.75rem;
+ font-weight: bold;
+}
diff --git a/src/utils/typeDefs.js b/src/utils/typeDefs.js
index cbc2a80cd..e3c6bef00 100644
--- a/src/utils/typeDefs.js
+++ b/src/utils/typeDefs.js
@@ -7,7 +7,7 @@ const IGNORED_TYPE_DEFS = [
'boolean',
];
-export const pullTypeDefNames = (tags) => {
+const pullTypeDefNames = (tags) => {
return Object.values(tags)
.reduce((acc, tag) => acc.concat(tag), [])
.flatMap((tag) => [tag.type, tag.promiseType])
@@ -15,3 +15,20 @@ export const pullTypeDefNames = (tags) => {
.filter((tag) => !IGNORED_TYPE_DEFS.includes(tag))
.map((tag) => tag.replace(/\[\]$/, '')); // TimePickerRange[] => TimePickerRange
};
+
+export const getTypeDefs = (tags) => {
+ const allTypeDefs = window.__NR1_SDK__.default.__typeDefs__;
+
+ return tags
+ .flatMap(pullTypeDefNames)
+ .map((name) => allTypeDefs[name])
+ .filter((typeDef) => typeDef !== undefined)
+ .map((typeDef) => ({
+ properties: typeDef.tags.property.map((property) => ({
+ name: property.identifier.name,
+ description: property.description,
+ type: property.type,
+ })),
+ name: typeDef.tags.typedef.find((tag) => tag.identifier).identifier.name,
+ }));
+};