-
Notifications
You must be signed in to change notification settings - Fork 185
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
Toolbar #791
Merged
theiliad
merged 31 commits into
carbon-design-system:master
from
hlyang397:create-toolbar
Oct 27, 2020
Merged
Toolbar #791
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
ebc79e2
feat: create toolbar components
hlyang397 e611cbf
refactor: use constants in configuration
hlyang397 4febc82
feat: create toolbar storybook demo group
hlyang397 fc89ba2
refactor: toolbar button
hlyang397 3294ec2
feat: disable toolbar button if it won't work
hlyang397 ac8c1f7
fix: title should use parent node to get max title width
hlyang397 a3ed332
feat: provide minZoomRatio option
hlyang397 65ade54
Merge branch 'master' into create-toolbar
b5e355f
Merge branch 'master' into create-toolbar
hlyang397 9014561
feat allow overflow menu item to be disabled
hlyang397 4080fb6
Merge branch 'master' into create-toolbar
hlyang397 840c452
feat: combine toolbar icon and overflow menu item to controls
hlyang397 71f66f1
Merge branch 'master' into create-toolbar
hlyang397 1ca8e64
Merge branch 'master' into create-toolbar
hlyang397 fe574fd
fix: not import src/ in demo folder to avoid build failure
hlyang397 081a301
feat: support keyboard event for toolbar button
hlyang397 56b3c20
refactor: fix scss style
hlyang397 f6a4a59
refactor: change configuration name
hlyang397 ad3c9b0
refactor: remove default ToolbarControls in configuration
hlyang397 f18b3a9
Merge branch 'master' of github.com:carbon-design-system/carbon-chart…
hlyang397 bf47a52
feat: allow to use keyboard to control overflow menu
hlyang397 c21edba
Merge branch 'master' into create-toolbar
hlyang397 4e3be68
fix: align toolbar to title component
hlyang397 4ca109d
Merge branch 'master' into create-toolbar
hlyang397 4c136d2
refactor: refactor statements and fix typos
hlyang397 1c7e6ca
refactor: change ToolbarControl.text field to optional
hlyang397 bcee77b
refactor: use getControlConfigByType() to reduce methods count
hlyang397 d9ccac3
Merge branch 'master' into create-toolbar
hlyang397 ffb41bc
refactor: minor changes per comments
hlyang397 0f1889d
refactor: remove toolbar control text in demo
hlyang397 70f7497
refactor: use d3.select to replace document.getElementById
hlyang397 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 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,70 @@ | ||
import * as barChart from "./bar"; | ||
import * as lineChart from "./line"; | ||
|
||
// utility function to enable toolbar option | ||
const addToolbarOptions = (options, configs?) => { | ||
options.experimental = true; | ||
|
||
options.toolbar = { | ||
enabled: true | ||
}; | ||
options.zoomBar = { | ||
top: { | ||
enabled: true | ||
} | ||
}; | ||
options.toolbar.controls = [ | ||
{ | ||
type: "Zoom in", | ||
text: "Zoom in" | ||
}, | ||
{ | ||
type: "Zoom out", | ||
text: "Zoom out" | ||
}, | ||
{ | ||
type: "Reset zoom", | ||
text: "Reset zoom" | ||
} | ||
]; | ||
|
||
if (configs) { | ||
if (configs.titlePostfix) { | ||
hlyang397 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
options.title += configs.titlePostfix; | ||
} | ||
if (configs.numberOfIcons) { | ||
options.toolbar.numberOfIcons = configs.numberOfIcons; | ||
} | ||
if (configs.controls) { | ||
options.toolbar.controls = configs.controls; | ||
} | ||
} | ||
|
||
return options; | ||
}; | ||
|
||
export const toolbarStackedBarTimeSeriesData = | ||
barChart.stackedBarTimeSeriesData; | ||
export const toolbarStackedBarTimeSeriesOptions = addToolbarOptions( | ||
Object.assign({}, barChart.stackedBarTimeSeriesOptions) | ||
); | ||
|
||
export const toolbarLineTimeSeriesData = lineChart.lineTimeSeriesData; | ||
export const toolbarLineTimeSeriesOptions = addToolbarOptions( | ||
Object.assign({}, lineChart.lineTimeSeriesOptions), | ||
{ | ||
titlePostfix: " - two icons", | ||
numberOfIcons: 2, | ||
controls: [ | ||
{ | ||
type: "Reset zoom" | ||
}, | ||
{ | ||
type: "Zoom in" | ||
}, | ||
{ | ||
type: "Zoom out" | ||
} | ||
] | ||
} | ||
); |
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
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.
do we need to provide the
text
field every time? are they not defaulted to the correct term?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.
No,
text
field is not required and it's defaulted totype
.This is to demo how to change the toolbar control text.
The other story shows that it also works without
text
field.Let me know if you like to remove the
text
field in demo data as well.Update interface in 1c7e6ca.
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.
Maybe it'd better to just include a small tutorial story for the toolbar and describe this there. I wouldn't want the text in the demo code, that'll result in users copying that code over to their projects, and it'll show up in codesandbox