Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codesandbox examples for charting demos #987

Merged
merged 37 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
dd68a29
initial effort
theiliad Mar 5, 2020
6ec0736
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Mar 5, 2020
7c5c499
Merge branch 'master' into codesandbox-dataviz
theiliad Mar 5, 2020
59dbe60
Merge branch 'master' into codesandbox-dataviz
theiliad Mar 6, 2020
59806b6
Merge branch 'master' into codesandbox-dataviz
theiliad Mar 9, 2020
5d0e2a7
add dynamic demos to basic charts
theiliad Apr 9, 2020
c4c8869
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Apr 9, 2020
0669dc5
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 5, 2020
a152988
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 5, 2020
f9eb9b1
update charting package version, optimize demo components
theiliad Jun 5, 2020
c10e8cf
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 5, 2020
18aa499
fix lint error
theiliad Jun 8, 2020
f513625
update @carbon/charts to 0.32.3
theiliad Jun 9, 2020
1defb65
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 9, 2020
31b1e59
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 9, 2020
076e799
Merge branch 'master' into codesandbox-dataviz
tw15egan Jun 9, 2020
ce03c2d
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 10, 2020
dab52f9
add image alt tags to dataviz chart types page
theiliad Jun 10, 2020
52a7a1e
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 11, 2020
e606862
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 11, 2020
483dde1
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 12, 2020
1ace04a
Merge branch 'master' of github.com:carbon-design-system/carbon-websi…
theiliad Jun 12, 2020
9bd44fb
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 12, 2020
1ed2c49
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 12, 2020
94b2702
update yarn.lock
theiliad Jun 12, 2020
5f3fb27
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 12, 2020
07990b3
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 15, 2020
82388ad
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 16, 2020
df93656
fix styling issues
theiliad Jun 16, 2020
d77fe25
styling fixes
theiliad Jun 22, 2020
a2c3aa8
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 22, 2020
15f2d99
undo overview-card tag height change
theiliad Jun 22, 2020
d34c8f7
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 22, 2020
2a31fac
move resources below anchor links for basic charts page
theiliad Jun 22, 2020
87f4d6b
Merge branch 'master' into codesandbox-dataviz
theiliad Jun 22, 2020
1145a1e
final touch on CodeBar
theiliad Jun 22, 2020
4b8bd93
Merge branch 'codesandbox-dataviz' of github.com:theiliad/carbon-webs…
theiliad Jun 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"/node_modules/*"
],
"dependencies": {
"@carbon/charts": "^0.28.1",
"@carbon/charts-react": "^0.28.1",
"@carbon/charts": "^0.32.3",
"@carbon/charts-react": "^0.32.3",
"@carbon/elements": "^10.13.0",
"@carbon/icons": "^10.12.0",
"@carbon/icons-react": "^10.12.0",
Expand Down
17 changes: 11 additions & 6 deletions src/components/ComponentDemo/Code/CodeBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ const StorybookLink = ({ framework, url }) => (
</a>
);

const CodeBar = ({ src, code, links }) => {
const CodeBar = ({ src, code, links, showSandboxURL }) => {
const sandboxUrl = useCodesandbox(code);
const storybookLinks = Object.entries(links);

Copy link
Contributor

@vpicone vpicone Jun 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subjective alert Do you mind moving this into a single, affirmative boolean. Just to clarify the intent a bit we can avoid chaining shortcuts. Not sure how you would have known this, it should be codified in an eslint rule.

return (
<div className={codeBar}>
<div className={linkList}>
<a target="_blank" rel="noopener noreferrer" href={sandboxUrl}>
CodeSandbox <Launch16 />
</a>
{showSandboxURL && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the re-use of the code bar. I'm confused how showSandboxURL is meant to be used though. As is, this check would mean we have to add showSandboxURL=true to all of our deployed ComponentDemos (they're currently missing the sandbox link in build preview).

What if instead, useCodesandbox returned null when no code is provided. We could use sandboxUrl && to determine whether to show the link or not.

Suggested change
{showSandboxURL && (
{sandboxUrl && (

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

<a target="_blank" rel="noopener noreferrer" href={sandboxUrl}>
CodeSandbox <Launch16 />
</a>
)}
{storybookLinks.map(([framework, url]) => (
<StorybookLink key={framework} framework={framework} url={url} />
))}
</div>
{src ? (

{src && (
<a
target="_blank"
rel="noopener noreferrer"
Expand All @@ -42,7 +45,9 @@ const CodeBar = ({ src, code, links }) => {
>
<Launch16 />
</a>
) : (
)}

{!src && code && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{!src && code && (
{shouldShowCopyButton (

<CopyButton
className={cx(button, copyButton)}
onClick={() => {
Expand Down
55 changes: 55 additions & 0 deletions src/components/data-visualization/AllDemos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';

import * as ChartComponents from '@carbon/charts-react';
import { demoGroups } from '@carbon/charts/demo/data';

import CodeBar from '../ComponentDemo/Code/CodeBar.js';

const generateHeadingID = (title) =>
title
.split(' ')
.map((t) => t.toLowerCase())
.join('-');

const AllDemos = () => (
<>
{demoGroups.map((demoGroup) => (
<>
<h2 id={generateHeadingID(demoGroup.title)}>{demoGroup.title}</h2>

{demoGroup.description && <p>{demoGroup.description}</p>}

{demoGroup.demos.map((demo) => {
const DemoComponent = ChartComponents[demo.chartType.vanilla];
return (
<>
{demo.description && <p>{demo.description}</p>}
<div
className="chart-demo-wrapper"
id={generateHeadingID(demo.title)}
>
<div className="chart-demo">
<DemoComponent
data={demo.data}
options={demo.options}
style={{ maxWidth: 400 }}
/>
</div>
<CodeBar
links={{
React: demo.codesandbox.react,
Angular: `https://carbon-design-system.github.io/carbon-charts/angular/?path=/story/${demo.id}`,
Vue: demo.codesandbox.vue,
Vanilla: demo.codesandbox.vanilla,
}}
/>
</div>
</>
);
})}
</>
))}
</>
);

export default AllDemos;
Loading