-
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 component from presentation to shared-ux #137224
Conversation
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.
An awesome addition! Just a few changes and thoughts.
); | ||
|
||
return ( | ||
<EuiFlexGroup id={`kbnPresentationToolbar__solutionToolbar`} gutterSize="s"> |
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 ID is probably not necessary.
extraButtons?: Array<ReactElement<typeof PrimaryButton | typeof ToolbarPopover> | undefined>; | ||
} | ||
|
||
export interface Props { |
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.
needs docs
children: NamedSlots; | ||
} | ||
|
||
export const Toolbar = ({ children }: Props) => { |
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.
needs docs
import { IconButtonGroup, PrimaryButton } from '../buttons'; | ||
import { ToolbarPopover } from '../popover'; | ||
|
||
interface NamedSlots { |
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 ends up getting exported as part of the Props interface, so it probably needs docs and inline docs per parameter:
/** Some description **/
primaryButton: ...
import { ToolbarPopover } from '../popover'; | ||
|
||
interface NamedSlots { | ||
primaryButton: ReactElement<typeof PrimaryButton | typeof ToolbarPopover>; |
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: we repeat typeof PrimaryButton | typeof ToolbarPopover
in a number of places... let's introduce a type:
type Button = typeof PrimaryButton | typeof ToolbarPopover`
export const Toolbar = ({ children }: Props) => { | ||
const { primaryButton, iconButtonGroup, extraButtons = [] } = children; | ||
|
||
const extra = extraButtons.map((button, index) => |
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: we don't currently restrict this array to any particular length, but it stands to reason there's a maximum. We might want to consider logging a warning-- or throwing an error-- if the number of extra buttons exceeds a certain design limit. Thoughts @cchaos ?
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 added an error in fa629f2 for over 120 buttons. I'm open to lowering that number to...50? Would logging a warning be better? 😅
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 log a warning, yes... and I was thinking more like 5, maybe as many as 7. Maybe @ryankeairns can weigh in, but we don't need to block this PR from going in.
|
||
export { Toolbar } from './toolbar'; | ||
export type { ToolbarProps } from './toolbar'; | ||
export type { Button } from './toolbar'; |
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 this would better be called ToolbarButton
or something.
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 can get behind that thanks! 3247796
|
||
describe('<Toolbar />', () => { | ||
test('is rendered', () => { | ||
const primaryButton = <PrimaryButton label="Create chart" onClick={() => 'click'} />; |
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: onClick
be just empty function if we're not testing if it can be clicked. but can we add a test that click actually calls the function?
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.
Good call - 379590c I got a little goofed up trying to get only the button clicked and I think this test nails it thanks!
|
||
if (extraButtons.length > 120) { | ||
throw new Error( | ||
'There are over 120 extra buttons. Please consider limiting the number of buttons.' |
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 the error be localized?
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.
Probably, yes! Thank you! 3247796 I think I did it right? 🤞🏻
…-ref HEAD~1..HEAD --fix'
@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.
I don't have any additional comments, so on my end this is approved. Tested this by running storybook in Chrome on Mac OSX.
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.
Great work!
export const Toolbar = ({ children }: Props) => { | ||
const { primaryButton, iconButtonGroup, extraButtons = [] } = children; | ||
|
||
const extra = extraButtons.map((button, index) => |
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 log a warning, yes... and I was thinking more like 5, maybe as many as 7. Maybe @ryankeairns can weigh in, but we don't need to block this PR from going in.
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
History
To update your PR or re-run it, just comment with: cc @rshen91 |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
Summary
The
Toolbar component
was previously namedSolutionToolbar component
. It is currently only used inx-pack/plugins/canvas/public/components/workpad_header/workpad_header.component.tsx
.Checklist
Delete any items that are not applicable to this PR.
For maintainers