-
Notifications
You must be signed in to change notification settings - Fork 793
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
Changes from 16 commits
dd68a29
6ec0736
7c5c499
59dbe60
59806b6
5d0e2a7
c4c8869
0669dc5
a152988
f9eb9b1
c10e8cf
18aa499
f513625
1defb65
31b1e59
076e799
ce03c2d
dab52f9
52a7a1e
e606862
483dde1
1ace04a
9bd44fb
1ed2c49
94b2702
5f3fb27
07990b3
82388ad
df93656
d77fe25
a2c3aa8
15f2d99
d34c8f7
2a31fac
87f4d6b
1145a1e
4b8bd93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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); | ||||||
|
||||||
return ( | ||||||
<div className={codeBar}> | ||||||
<div className={linkList}> | ||||||
<a target="_blank" rel="noopener noreferrer" href={sandboxUrl}> | ||||||
CodeSandbox <Launch16 /> | ||||||
</a> | ||||||
{showSandboxURL && ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love the re-use of the code bar. I'm confused how What if instead,
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||||||
|
@@ -42,7 +45,9 @@ const CodeBar = ({ src, code, links }) => { | |||||
> | ||||||
<Launch16 /> | ||||||
</a> | ||||||
) : ( | ||||||
)} | ||||||
|
||||||
{!src && code && ( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<CopyButton | ||||||
className={cx(button, copyButton)} | ||||||
onClick={() => { | ||||||
|
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; |
There was a problem hiding this comment.
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.