Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

Commit 8df3944

Browse files
committed
Use MarginTopSnippet
1 parent 5463e0e commit 8df3944

36 files changed

Lines changed: 65 additions & 49 deletions

packages/visual-stack-docs/src/components/Demo/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ export const Snippet = ({ tag, src }) => {
2323
);
2424
};
2525

26+
export const MarginTopSnippet = ({ tag, src }) => {
27+
const srcTag = R.view(R.lensPath([tag]))(src);
28+
if (!srcTag) return null;
29+
return (
30+
<div className="snippet margin-top-snippet">
31+
<pre>{trimLeadingWhiteSpace(src[tag]).join('\n')}</pre>
32+
</div>
33+
);
34+
};
35+
2636
export class Demo extends React.Component {
2737
constructor(props) {
2838
super(props);

packages/visual-stack-docs/src/components/Demo/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.snippet {
1+
.margin-top-snippet {
22
margin-top: 10px;
33
}
44

packages/visual-stack-docs/src/containers/Components/Docs/alert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Body, Header, Panel } from '@cjdev/visual-stack/lib/components/Panel';
3-
import { Demo, Snippet } from '../../../components/Demo';
3+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
44
import { Button } from '@cjdev/visual-stack/lib/components/Button';
55
/* s1:start */
66
import { openAlert, closeAlert } from '@cjdev/visual-stack-redux';

packages/visual-stack-docs/src/containers/Components/Docs/blankslate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Panel, Body, Header } from '@cjdev/visual-stack/lib/components/Panel';
3-
import { Demo, Snippet } from '../../../components/Demo';
3+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
44
import IconExample from 'mdi-react/BlurIcon';
55

66
import {

packages/visual-stack-docs/src/containers/Components/Docs/button-with-dropdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as R from 'ramda';
22
import React from 'react';
33
import { Panel, Body, Header } from '@cjdev/visual-stack/lib/components/Panel';
4-
import { Demo, Snippet } from '../../../components/Demo';
4+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
55
import { Button } from '@cjdev/visual-stack/lib/components/Button';
66

77
/* s1:start */

packages/visual-stack-docs/src/containers/Components/Docs/button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import './button.css';
33
import { Body, Header, Panel } from '@cjdev/visual-stack/lib/components/Panel';
4-
import { Demo, Snippet } from '../../../components/Demo';
4+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
55
import { Button } from '@cjdev/visual-stack/lib/components/Button';
66
import {
77
AccountIcon,

packages/visual-stack-docs/src/containers/Components/Docs/card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Panel, Body, Header } from '@cjdev/visual-stack/lib/components/Panel';
3-
import { Demo, Snippet } from '../../../components/Demo';
3+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
44
/* s2:start */
55
import Card from '@cjdev/visual-stack/lib/components/Card';
66
/* s2:end */

packages/visual-stack-docs/src/containers/Components/Docs/chip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Box } from '@cjdev/visual-stack';
44
import { Chip } from '@cjdev/visual-stack';
55
/* s2:end */
66
import { Panel, Body } from '@cjdev/visual-stack/lib/components/Panel';
7-
import { Demo, Snippet } from '../../../components/Demo';
7+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
88

99
export default () => (
1010
<Demo srcFile="/samples/src/containers/Components/Docs/chip.js">

packages/visual-stack-docs/src/containers/Components/Docs/collapsiblepanel.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import * as React from 'react';
22
import { Body, Panel, Header } from '@cjdev/visual-stack/lib/components/Panel';
3-
import { CollapsiblePanel, PureCollapsiblePanel } from '@cjdev/visual-stack/lib/components/CollapsiblePanel';
3+
import {
4+
CollapsiblePanel,
5+
PureCollapsiblePanel,
6+
} from '@cjdev/visual-stack/lib/components/CollapsiblePanel';
47
import './collapsiblepanel.css';
58
import {
69
FieldContent,
@@ -9,7 +12,7 @@ import {
912
ChoiceInput,
1013
Field,
1114
} from '@cjdev/visual-stack/lib/components/Form';
12-
import { Demo, Snippet } from '../../../components/Demo';
15+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
1316
import SVG from 'react-inlinesvg';
1417
import sampleIconPath from './reporting.svg';
1518
import { useState } from 'react';
@@ -19,27 +22,30 @@ const SampleIcon = () => {
1922
};
2023

2124
export default () => {
22-
23-
const [ collapsed, setCollapsed ] = useState(false);
25+
const [collapsed, setCollapsed] = useState(false);
2426

2527
return (
2628
<Demo srcFile="/samples/src/containers/Components/Docs/collapsiblepanel.js">
2729
{snippets => (
2830
<Panel>
2931
<Header>Collapsible Panels</Header>
3032
<Body paddingSize="none">
31-
3233
{/* s1:start */}
33-
<PureCollapsiblePanel onChange={setCollapsed} collapsed={collapsed} title="Pure Collapsible Panel">
34-
<div>Use the PureCollapsiblePanel if you want to manage the 'collapsed' state yourself. Unlike CollapsiblePanel, it
35-
does not keep track of the state itself and merely calls you back with the state via 'onChange' when a
36-
user clicks on it.
34+
<PureCollapsiblePanel
35+
onChange={setCollapsed}
36+
collapsed={collapsed}
37+
title="Pure Collapsible Panel"
38+
>
39+
<div>
40+
Use the PureCollapsiblePanel if you want to manage the
41+
'collapsed' state yourself. Unlike CollapsiblePanel, it does not
42+
keep track of the state itself and merely calls you back with
43+
the state via 'onChange' when a user clicks on it.
3744
</div>
3845
</PureCollapsiblePanel>
3946
{/* s1:end */}
4047
<Snippet tag="s1" src={snippets} />
4148

42-
4349
{/* s2:start */}
4450
<CollapsiblePanel
4551
title={
@@ -159,7 +165,6 @@ export default () => {
159165
</CollapsiblePanel>
160166
{/* s5:end */}
161167
<Snippet tag="s5" src={snippets} />
162-
163168
</Body>
164169
</Panel>
165170
)}

packages/visual-stack-docs/src/containers/Components/Docs/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22

33
import { Panel, Body, Header } from '@cjdev/visual-stack/lib/components/Panel';
4-
import { Demo, Snippet } from '../../../components/Demo';
4+
import { Demo, MarginTopSnippet as Snippet } from '../../../components/Demo';
55

66
import { DateTime } from 'luxon';
77

0 commit comments

Comments
 (0)