-
Notifications
You must be signed in to change notification settings - Fork 119
feat(data-viz): create intial pages for engineering #4312
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
fe7988b
feat(docs): data viz base structure
krisantrobus 4654b80
feat(data-viz): wokring base chart
krisantrobus 0cbd203
feat(data-viz): wip
krisantrobus 97f8ac2
feat(data-viz): wip
krisantrobus 1f696ac
feat(data-viz): wip
krisantrobus 427a1bd
feat(data-viz): wip
krisantrobus 3ba6789
feat(data-viz): sitemap
krisantrobus db40510
feat(data-viz): docs exmapleds
krisantrobus 1b60202
feat(data-viz): ci checks
krisantrobus b82ba11
feat(data-viz): docs refinement
krisantrobus 317220a
Merge branch 'main' of github.com:twilio-labs/paste into docs-data-vi…
krisantrobus 1b5bc22
chore(cleanup): remove redundant story
krisantrobus bb8c48b
chore(cleanup): changeset
krisantrobus 7d0d76b
fix(data-viz): fix urls
krisantrobus d828fb3
fix(data-viz): fix slugs
krisantrobus 8b7fcf4
feat(data-vix): chart-provider in project.json
krisantrobus 2297ca3
chore(data-vix): test chanpshots
krisantrobus 882cefc
chore(ci): fix supabase
krisantrobus 65f2844
chore(ci): fix supabase
krisantrobus 3f21680
chore(ci): ignore generated files for linting
krisantrobus e4b069a
chore(data-vix): typos
krisantrobus 856fa96
chore(data-vix): trigger rebuild
krisantrobus fa6c7b4
chore(data-vix): trigger rebuild
krisantrobus 34bcf1e
chore(data-vix): trigger rebuild
krisantrobus ff5cf14
Update packages/paste-website/src/components/site-wrapper/sidebar/Sid…
krisantrobus cb420bf
Merge branch 'main' of github.com:twilio-labs/paste into docs-data-vi…
krisantrobus 80bbe93
feat(data-visualization): vrt
krisantrobus 069f892
chore(tests): add support for same title sidebar disclousres
krisantrobus ab7de86
feat(data-viz): update docs urls and release versioning
krisantrobus 12a370d
Apply suggestions from code review
krisantrobus c9109cf
chore(data-viz): addressed PR comments
krisantrobus 7138cc9
Merge branch 'docs-data-viz-base-chart' of github.com:twilio-labs/pas…
krisantrobus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
29 changes: 29 additions & 0 deletions
29
packages/paste-libraries/data-visualization/stories/base-chart.stories.tsx
This file contains hidden or 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,29 @@ | ||
import type { Meta, StoryFn } from "@storybook/react"; | ||
import { ChartProvider } from "@twilio-paste/chart-provider"; | ||
import { Stack } from "@twilio-paste/stack"; | ||
import * as React from "react"; | ||
|
||
import { BaseChart } from "./components/BaseChart"; | ||
import { lineChartOptions } from "./options/lineChartOptions"; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default { | ||
title: "Libraries/data-visualization/base-chart", | ||
parameters: { | ||
chromatic: { disableSnapshot: true }, | ||
a11y: { | ||
// no need to a11y check composition of a11y checked components | ||
disable: true, | ||
}, | ||
}, | ||
} as Meta; | ||
|
||
export const HighchartsOptions: StoryFn = () => { | ||
return ( | ||
<Stack orientation="vertical" spacing="space100"> | ||
<ChartProvider highchartsOptions={{ chart: { type: "line" }, series: lineChartOptions.series }}> | ||
<BaseChart /> | ||
</ChartProvider> | ||
</Stack> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
packages/paste-libraries/data-visualization/stories/components/BaseChart.tsx
This file contains hidden or 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,48 @@ | ||
import { Box } from "@twilio-paste/box"; | ||
import { ChartContext } from "@twilio-paste/chart-provider"; | ||
import * as Highcharts from "highcharts"; | ||
import HighchartsReact from "highcharts-react-official"; | ||
import HighchartsAccessibilityModule from "highcharts/modules/accessibility"; | ||
import * as React from "react"; | ||
|
||
import { applyPasteHighchartsModules, usePasteHighchartsTheme } from "../../src"; | ||
|
||
const Chart: React.FC = () => { | ||
applyPasteHighchartsModules(Highcharts, HighchartsAccessibilityModule); | ||
const chartRef = React.useRef<HTMLElement | null>(null); | ||
const { options, setChart, setChartRef } = React.useContext(ChartContext); | ||
const [chartOptions, setChartOptions] = React.useState<Highcharts.Options>( | ||
// disabling animation for stories only. Not included in our docs examples | ||
usePasteHighchartsTheme({ ...options, plotOptions: { series: { animation: false } } }), | ||
); | ||
|
||
React.useLayoutEffect(() => { | ||
setChartOptions(Highcharts.merge(chartOptions, options)); | ||
}, [options]); | ||
|
||
React.useEffect(() => { | ||
if (chartRef.current) { | ||
setChartRef(chartRef.current); | ||
} | ||
}, [chartRef.current]); | ||
|
||
const callback = (chart: Highcharts.Chart): void => { | ||
if (chart?.series?.length > 0) { | ||
setChart(chart); | ||
} | ||
}; | ||
|
||
return ( | ||
<Box gridArea="base-chart" ref={chartRef} position="relative"> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
options={chartOptions} | ||
constructorType={chartOptions.chart?.map ? "mapChart" : undefined} | ||
updateArgs={[true, true, false]} | ||
callback={callback} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
export const BaseChart = React.memo(Chart); |
44 changes: 44 additions & 0 deletions
44
packages/paste-website/src/component-examples/data-visualization/BaseChart.tsx
This file contains hidden or 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,44 @@ | ||
import { Box } from "@twilio-paste/box"; | ||
import { ChartContext } from "@twilio-paste/chart-provider"; | ||
Check failure on line 2 in packages/paste-website/src/component-examples/data-visualization/BaseChart.tsx
|
||
import * as Highcharts from "highcharts"; | ||
import HighchartsReact from "highcharts-react-official"; | ||
import HighchartsAccessibilityModule from "highcharts/modules/accessibility"; | ||
import { applyPasteHighchartsModules, usePasteHighchartsTheme } from "@twilio-paste/data-visualization-library"; | ||
import * as React from "react"; | ||
|
||
const Chart: React.FC = () => { | ||
applyPasteHighchartsModules(Highcharts, HighchartsAccessibilityModule); | ||
const chartRef = React.useRef<HTMLElement | null>(null); | ||
const { options, setChart, setChartRef } = React.useContext(ChartContext); | ||
const [chartOptions, setChartOptions] = React.useState<Highcharts.Options>(usePasteHighchartsTheme(options)); | ||
|
||
React.useLayoutEffect(() => { | ||
setChartOptions(Highcharts.merge(chartOptions, options)); | ||
}, [options]); | ||
|
||
React.useEffect(() => { | ||
if (chartRef.current) { | ||
setChartRef(chartRef.current); | ||
} | ||
}, [chartRef.current]); | ||
|
||
const callback = (chart: Highcharts.Chart) => { | ||
if (chart?.series?.length > 0) { | ||
setChart(chart); | ||
} | ||
}; | ||
|
||
return ( | ||
<Box gridArea="base-chart" ref={chartRef} position="relative"> | ||
<HighchartsReact | ||
highcharts={Highcharts} | ||
options={chartOptions} | ||
constructorType={chartOptions.chart?.map ? "mapChart" : undefined} | ||
updateArgs={[true, true, false]} | ||
callback={callback} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
export const ExamplesDataVizBaseChart = React.memo(Chart); |
57 changes: 57 additions & 0 deletions
57
packages/paste-website/src/component-examples/data-visualization/ChartProviderExamples.ts
This file contains hidden or 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,57 @@ | ||
export const SimpleChartProviderExample = ` | ||
const ChartProviderExample = () => { | ||
const lineSeriesData = [ | ||
{ | ||
name: "Installation", | ||
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175], | ||
}, | ||
{ | ||
name: "Manufacturing", | ||
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434], | ||
}, | ||
] | ||
Comment on lines
+2
to
+12
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. decided to include the series so consumers can understand the formats required. Easier to onboard |
||
|
||
return ( | ||
<ChartProvider highchartsOptions={{ chart: { type: "line" }, series: lineSeriesData }}> | ||
<BaseChart /> | ||
</ChartProvider> | ||
); | ||
}; | ||
|
||
render(<ChartProviderExample />); | ||
`.trim(); | ||
|
||
export const CustomChartProviderExample = ` | ||
const ChartProviderExample = () => { | ||
const lineSeriesData = [ | ||
{ | ||
name: "Installation", | ||
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175], | ||
type: "line", | ||
}, | ||
{ | ||
name: "Manufacturing", | ||
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434], | ||
type: "line", | ||
}, | ||
{ | ||
name: "Sales & Distribution", | ||
data: [11744, 17722, 16005, 19771, 20185, 24377, 32147, 39387], | ||
type: "column", | ||
}, | ||
{ | ||
name: "Project Development", | ||
data: [null, null, 7988, 12169, 15112, 22452, 34400, 34227], | ||
type: "column", | ||
}, | ||
] | ||
|
||
return ( | ||
<ChartProvider highchartsOptions={{title: {floating: true, align: "right", text: "Custom charting title"}, series: lineSeriesData}}> | ||
<BaseChart /> | ||
</ChartProvider> | ||
); | ||
}; | ||
|
||
render(<ChartProviderExample />); | ||
`.trim(); |
This file contains hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
packages/paste-website/src/pages/components/chart-provider/api.mdx
This file contains hidden or 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,61 @@ | ||
import Changelog from '@twilio-paste/chart-provider/CHANGELOG.md'; // I don't know why this is needed but if you remove it the page fails to render | ||
import packageJson from '@twilio-paste/chart-provider/package.json'; | ||
|
||
import {SidebarCategoryRoutes} from '../../../constants'; | ||
import ComponentPageLayout from '../../../layouts/ComponentPageLayout'; | ||
import {getFeature, getNavigationData, getComponentApi} from '../../../utils/api'; | ||
|
||
export const meta = { | ||
title: 'ChartProvider', | ||
package: '@twilio-paste/chart-provider', | ||
description: packageJson.description, | ||
slug: '/components/chart-provider/api', | ||
}; | ||
|
||
export default ComponentPageLayout; | ||
|
||
export const getStaticProps = async () => { | ||
const navigationData = await getNavigationData(); | ||
const feature = await getFeature('Chart Provider'); | ||
const {componentApi, componentApiTocData} = getComponentApi('@twilio-paste/chart-provider'); | ||
return { | ||
props: { | ||
data: { | ||
...packageJson, | ||
...feature, | ||
}, | ||
componentApi, | ||
mdxHeadings: [...mdxHeadings, ...componentApiTocData], | ||
navigationData, | ||
pageHeaderData: { | ||
categoryRoute: SidebarCategoryRoutes.COMPONENTS, | ||
githubUrl: 'https://github.com/twilio-labs/paste/tree/main/packages/paste-core/components/chart-provider', | ||
storybookUrl: '/?path=/story/components-chartprovider', | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
## Installation | ||
|
||
```bash | ||
yarn add @twilio-paste/chart-provider - or - yarn add @twilio-paste/core | ||
``` | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { ChartProvider } from '@twilio-paste/core/chart-provider'; | ||
|
||
const ChartProviderExample = () => { | ||
return ( | ||
<ChartProvider {...config}> | ||
<BaseChart /> | ||
</ChartProvider> | ||
); | ||
}; | ||
``` | ||
|
||
## Props | ||
|
||
<PropsTable componentApi={props.componentApi} /> |
36 changes: 36 additions & 0 deletions
36
packages/paste-website/src/pages/components/chart-provider/changelog.mdx
This file contains hidden or 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,36 @@ | ||
import {SidebarCategoryRoutes} from '../../../constants'; | ||
import Changelog from '@twilio-paste/chart-provider/CHANGELOG.md'; | ||
import packageJson from '@twilio-paste/chart-provider/package.json'; | ||
import ComponentPageLayout from '../../../layouts/ComponentPageLayout'; | ||
import {getFeature, getNavigationData} from '../../../utils/api'; | ||
|
||
export const meta = { | ||
title: 'Chart Provider', | ||
package: '@twilio-paste/chart-provider', | ||
description: packageJson.description, | ||
slug: '/components/chart-provider/changelog', | ||
}; | ||
|
||
export default ComponentPageLayout; | ||
|
||
export const getStaticProps = async () => { | ||
const navigationData = await getNavigationData(); | ||
const feature = await getFeature('Chart Provider'); | ||
return { | ||
props: { | ||
data: { | ||
...packageJson, | ||
...feature, | ||
}, | ||
navigationData, | ||
mdxHeadings, | ||
pageHeaderData: { | ||
categoryRoute: SidebarCategoryRoutes.COMPONENTS, | ||
githubUrl: 'https://github.com/twilio-labs/paste/tree/main/packages/paste-core/components/chart-provider', | ||
storybookUrl: '/?path=/story/components-chartprovider', | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
<Changelog /> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Aligns more closely with our tooltip. The previous tooltip did not set the font from the theme