-
Notifications
You must be signed in to change notification settings - Fork 793
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Codesandbox examples for charting demos (#987)
* initial effort * add dynamic demos to basic charts * update charting package version, optimize demo components * fix lint error * update @carbon/charts to 0.32.3 * add image alt tags to dataviz chart types page * update yarn.lock * fix styling issues * styling fixes * undo overview-card tag height change * move resources below anchor links for basic charts page * final touch on CodeBar Co-authored-by: TJ Egan <[email protected]>
- Loading branch information
Showing
14 changed files
with
225 additions
and
935 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
|
||
import * as ChartComponents from '@carbon/charts-react'; | ||
|
||
import H2 from 'gatsby-theme-carbon/src/components/markdown/H2'; | ||
import CodeBar from '../ComponentDemo/Code/CodeBar.js'; | ||
|
||
import demoGroups from '../../data/data-visualization'; | ||
|
||
const generateHeadingID = (title) => | ||
title | ||
.split(' ') | ||
.map((t) => t.toLowerCase()) | ||
.join('-'); | ||
|
||
const AllDemos = () => ( | ||
<> | ||
{demoGroups.map((demoGroup) => ( | ||
<> | ||
<H2>{demoGroup.title}</H2> | ||
|
||
{demoGroup.description && ( | ||
<div className="bx--row"> | ||
<div className="bx--col-sm-4 bx--col-md-8 bx--col-lg-8"> | ||
<p className="dataviz-copy">{demoGroup.description}</p> | ||
</div> | ||
</div> | ||
)} | ||
|
||
{demoGroup.demos.map((demo) => { | ||
const DemoComponent = ChartComponents[demo.chartType.vanilla]; | ||
return ( | ||
<> | ||
{demo.description && ( | ||
<div className="bx--row"> | ||
<div className="bx--col-sm-4 bx--col-md-8 bx--col-lg-8"> | ||
<p className="dataviz-copy">{demo.description}</p> | ||
</div> | ||
</div> | ||
)} | ||
<div className="bx--row"> | ||
<div className="bx--col-sm-4 bx--col-md-8 bx--col-lg-8"> | ||
<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> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
})} | ||
</> | ||
))} | ||
</> | ||
); | ||
|
||
export default AllDemos; |
Oops, something went wrong.
5cb04e0
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.
Successfully deployed to following URLs: