-
Notifications
You must be signed in to change notification settings - Fork 114
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
feat(data-visualization): add package #2200
Conversation
🦋 Changeset detectedLatest commit: 04fc775 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✔️ Deploy Preview for paste-theme-designer ready! 🔨 Explore the source changes: 04fc775 🔍 Inspect the deploy log: https://app.netlify.com/sites/paste-theme-designer/deploys/620d866194e82f000882f68e 😎 Browse the preview: https://deploy-preview-2200--paste-theme-designer.netlify.app |
"highcharts": "^9.3.3", | ||
"highcharts-react-official": "^3.1.0", |
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.
I mark these two as devDeps because I want to use them in the story file. Highcharts alone is a peerDep because we expect consumers to only need Highcharts to use the hook.
} | ||
|
||
return merge(options, { | ||
colors: Object.values(context.dataVisualization), |
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.
We originally only designed for these sequential color values, but I took the liberty of applying our text and font styles elsewhere to make the charts look more branded. The nice thing about this package is we can update the styles as needed and ship it as a patch, which folks can get for free.
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.
Yeah, I was wondering about that actually when I looked at the story. Very worthwhile.
We will need one of the PD crew to review the text styles once we get the docs up. That design pass can happen at that time though
* @param {Highcharts.Options} options - options to be provided into Highcharts for rendering. | ||
* @returns {Highcharts.Options} optionsWithPasteTheme - Passed options with deepmerged Paste Theme | ||
*/ | ||
export const usePasteHighchartsTheme = (options: Highcharts.Options): Highcharts.Options => { |
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.
I needed to take an options
object as argument here because the theme in Highcharts is applied over the same object that configures chart data. I was running into issues where my styles weren't applying because the options object defined different values for certain keys. So we need to take the options object, deepmerge our styles over them, and return a new object which is passed into Highcharts. This works pretty well, as can be seen in the stories.
* @param {Highcharts.Options} options - options to be provided into Highcharts for rendering. | ||
* @returns {Highcharts.Options} optionsWithPasteTheme - Passed options with deepmerged Paste Theme | ||
*/ | ||
export const usePasteHighchartsTheme = (options: Highcharts.Options): Highcharts.Options => { |
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.
We need this to be a React hook so that the styles update upon toggling between light and dark theme. Can't just export a static object, unless we instruct developers to swap it themselves which is much less ergonomic and more error prone.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e984ef1:
|
Size Change: +222 B (0%) Total Size: 466 kB
ℹ️ View Unchanged
|
packages/paste-libraries/data-visualization/stories/index.stories.tsx
Outdated
Show resolved
Hide resolved
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
ac421f0
to
86fe68e
Compare
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.
Is it worth adding tests for the hook? Even snap shotting the returned data? Just to preserve the expected outcome, given a certain highcharts config doesn't accidently regress over time.
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.
Overall, a pretty decent place to call this v1. Some tests would be nice and an open question on chart type coverage
packages/paste-libraries/data-visualization/stories/index.stories.tsx
Outdated
Show resolved
Hide resolved
86fe68e
to
857e51d
Compare
✔️ Deploy Preview for paste-docs ready! 🔨 Explore the source changes: 04fc775 🔍 Inspect the deploy log: https://app.netlify.com/sites/paste-docs/deploys/620d8661e7dd580008d1a5e4 😎 Browse the preview: https://deploy-preview-2200--paste-docs.netlify.app |
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.
Code looks fine. I'm more than fine with copy pasta examples from highcharts too with ts-ignores.
One final thing, which I didn't spot, we will need to add highcharts as a root dependency because Storybook is a root application. Right now it works when import highcharts into a story because yarn is hoisting the dep from the data visualisation package to the root of the repo.
9403ec1
to
793863d
Compare
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.
this makes sense, looks really, really awesome and the stories are fantastic. I'm glad you included what it looks like w/o the hook as well for easy comparison. People are going to be happyyyyyyy 🎉
A few things:
@katieporter I chatted with Shadi, and since this PR is really just to add the tokens, with a few fixes to fix really obvious things, he's going to create a ticket for followup work to polish up the theme with more design-eng pairing. We can address these comments ^ when that polish work happens. |
dd050a4
to
d01b2d2
Compare
d01b2d2
to
e984ef1
Compare
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.
Praise: Thank you for the PR notes and the tests! This looks good to me.
📊 📈 👍🏼 🎉
This PR adds a new package called
@twilio-paste/data-visualization-library
. This package will serve as a container for future data viz utilities. In its current form, we export a helpful React hook which exports a Highcharts option object with Paste theme values applied. This will help developers build themed and accessible charts in Highcharts more easily. I've added a couple stories showing how it works.