-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[shared-ux] Migrate toolbar button component #124372
Conversation
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
e6742ef
to
f6154e6
Compare
<SolutionToolbarButton | ||
{...rest} | ||
iconType="folderOpen" | ||
onClick={onClick} |
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.
Why is onClick
destructured explicitly and not with the rest
?
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 think what's happening is that the solution toolbar allows consumers to pass their own onClick handler. I'm looking at button.tsx with the props extending EUIButtonPropsForButton and seeing the following:
export interface Props
extends Pick<EuiButtonPropsForButton, 'onClick' | 'iconType' | 'iconSide' | 'className'>
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.
@majagrubic has a point: there's no need to destructure props on line 17 to extract onClick
, because we're not doing anything with it. You could actually do:
<SolutionToolbarButton iconType="folderOpen" {...props} />
extends Pick<EuiButtonPropsForButton, 'onClick' | 'iconType' | 'iconSide' | 'className'> { | ||
label: string; | ||
primary?: boolean; | ||
isDarkModeEnabled?: boolean; |
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 this being used anywhere?
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.
Some of it is being used in the solution_toolbar.tsx
file in the props. In the solution toolbar implementation, the primary styling is used consistently in how the toolbar is set up.
I'm tempted to keep this as is since the items directory comes directly from the presentation team. I'm thinking as I migrate more components over, more and more references will occur with parts of the items folder.
|
||
return ( | ||
<EuiPopover | ||
anchorPosition="downLeft" |
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.
should this be customizable or are we ok with it always being down & left?
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'm open to making this customizable - thoughts @clintandrewhall?
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 would expose and default it.
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.
It's already exposed on line 18... just need to use it here. Pretty sure downLeft
is the EUI default, as well.
className={`solutionToolbar ${ | ||
isDarkModeEnabled ? 'solutionToolbar--dark' : 'solutionToolbar--light' | ||
}`} | ||
id={`kbnPresentationToolbar__solutionToolbar`} |
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 want to be adding ids here? I would say it needs to be passed as a prop then
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.
17c81e7 for changes, let me know if I'm understanding correctly, thanks
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 is a great start...! Keep up the good work. You might find that splitting this into smaller PRs allows you to focus on the individual components... but that's up to you.
*/ | ||
|
||
export { SolutionToolbar } from './solution_toolbar'; | ||
export * from './items'; |
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.
nit: best practice is to explicitly name the exports.
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.
Ok! Fixed in e27b041 thank you!
<SolutionToolbarButton | ||
{...rest} | ||
iconType="folderOpen" | ||
onClick={onClick} |
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.
@majagrubic has a point: there's no need to destructure props on line 17 to extract onClick
, because we're not doing anything with it. You could actually do:
<SolutionToolbarButton iconType="folderOpen" {...props} />
@@ -0,0 +1,12 @@ | |||
.solutionToolbarButton { |
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 should not be introducing any SASS to SharedUX, and it we must, we must document it here: #122594
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 removed it in e27b041 thank you!
|
||
return ( | ||
<EuiPopover | ||
anchorPosition="downLeft" |
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.
It's already exposed on line 18... just need to use it here. Pretty sure downLeft
is the EUI default, as well.
primary={true} | ||
className={`solutionToolbar__primaryButton ${ | ||
isDarkModeEnabled | ||
? 'solutionToolbar__primaryButton--dark' |
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 really want to see all of this SASS gone. :-/
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.
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const ComponentStrings = { |
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 is a deprecated approach from my time on Presentation Team. See: #103013
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.
Let me know if my changes in 7fa17de make sense thanks!
* Side Public License, v 1. | ||
*/ | ||
|
||
export * from './labs'; |
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.
copy-pasta error?
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.
Removed in e27b041 thanks!
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { EuiCode } from '@elastic/eui'; | ||
|
||
export const LabsStrings = { |
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 shouldn't be bringing labs
strings in...?
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.
Removed in e27b041 thanks!
@elasticmachine merge upstream |
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.
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.
Codewise looks good, waiting for the design to approve
I'm working on an in-depth review. Please don't merge yet. |
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 have some comments in the works. Bear with me for a few minutes.
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled in files
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Closing in favor of splitting this PR into smaller PRs that are more targeted in scope thanks! |
Summary
This PR migrates the toolbar button component from the
kibana-react
folder to theshared-ux
directoryWhere toolbars similarly are used in the codebase:
Lens has a
ToolbarPopover
component that seems similarx-pack/plugins/lens/public/shared_components/toolbar_popover.tsx
lens/public/shared_components/legend_settings_popover.tsx
ToolbarPopover
used in datatable_visualization inx-pack/plugins/lens/public/datatable_visualization/components/toolbar.tsx
heatmap_visualization/toolbar_component.tsx
pie_visualization/toolbar.tsx
visualizations/gauge/toolbar_component/index.tsx
xy_visualization/xy_config_panel/axis_settings_popover.tsx
xy_visualization/xy_config_panel/visual_options_popover/index.tsx
SolutionToolbarPopover PresentationToolbar
insrc/plugins/presentation_util/public/components/solution_toolbar/solution_toolbar.tsx
EditorMenu
in dashboard hasSolutionToolbarPopover
insrc/plugins/dashboard/public/application/top_nav/editor_menu.tsx
Checklist
Delete any items that are not applicable to this PR.
For maintainers