Skip to content

Commit

Permalink
feat: Add Spinner component. Allow example to take preview style
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 3, 2020
1 parent b6a2824 commit 10df676
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/ComponentExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ const EXAMPLE_CSS = `
}
`;

const ComponentExample = ({ className, example, useToastManager }) => {
const ComponentExample = ({
className,
example,
useToastManager,
previewStyle,
}) => {
const [stylesLoaded, setStylesLoaded] = useState(false);
const ToastManager = window.__NR1_SDK__.ToastManager;
let formattedCode;
Expand Down Expand Up @@ -96,7 +101,10 @@ const ComponentExample = ({ className, example, useToastManager }) => {
</div>
)}
{stylesLoaded ? (
<LivePreview className="nr1-ComponentExample" />
<LivePreview
className="nr1-ComponentExample"
style={previewStyle}
/>
) : (
'Loading...'
)}
Expand All @@ -116,6 +124,8 @@ ComponentExample.propTypes = {
sourceCode: PropTypes.string.isRequired,
options: PropTypes.object.isRequired,
}).isRequired,
useToastManager: PropTypes.bool,
previewStyle: PropTypes.object,
};

export default ComponentExample;
4 changes: 4 additions & 0 deletions src/data/sidenav.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
"displayName": "Icon",
"url": "/components/icon"
},
{
"displayName": "Spinner",
"url": "/components/spinner"
},
{
"displayName": "Toast",
"url": "/components/toast"
Expand Down
7 changes: 7 additions & 0 deletions src/markdown-pages/components/spinner.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
path: '/components/spinner'
title: 'Spinner'
description: 'A Spinner component!'
component: 'Spinner'
template: 'ReferenceTemplate'
---
7 changes: 7 additions & 0 deletions src/templates/ReferenceTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import pages from '../data/sidenav.json';

import styles from './ReferenceTemplate.module.scss';

const previewStyles = {
Spinner: {
height: '16px',
},
};

const ReferenceTemplate = ({ data }) => {
const [isOpen, setIsOpen] = useState(false);
const { mdx } = data;
Expand Down Expand Up @@ -51,6 +57,7 @@ const ReferenceTemplate = ({ data }) => {
useToastManager={component === 'Toast'}
className={styles.componentExample}
example={example}
previewStyle={previewStyles[component]}
/>
))}
</div>
Expand Down

0 comments on commit 10df676

Please sign in to comment.