-
Notifications
You must be signed in to change notification settings - Fork 355
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(toolbar): adds color variant #10284
Changes from 1 commit
cac5f6b
aee554f
4e887c9
c507409
ac359ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||||
import React from 'react'; | ||||||
import { Toolbar, ToolbarItem, ToolbarContent, Button, SearchInput, Checkbox } from '@patternfly/react-core'; | ||||||
|
||||||
export const ToolbarColorVariant: React.FunctionComponent = () => { | ||||||
const [isSecondary, setisSecondary] = React.useState(true); | ||||||
|
||||||
return ( | ||||||
<React.Fragment> | ||||||
<Toolbar id="toolbar-" colorVariant={isSecondary ? 'secondary' : 'primary'}> | ||||||
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.
Suggested change
|
||||||
<ToolbarContent> | ||||||
<ToolbarItem> | ||||||
<SearchInput aria-label="Items example search input" /> | ||||||
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. Just to give this a unique name:
Suggested change
|
||||||
</ToolbarItem> | ||||||
<ToolbarItem> | ||||||
<Button variant="secondary">Action</Button> | ||||||
</ToolbarItem> | ||||||
<ToolbarItem variant="separator" /> | ||||||
<ToolbarItem> | ||||||
<Button variant="primary">Action</Button> | ||||||
</ToolbarItem> | ||||||
</ToolbarContent> | ||||||
</Toolbar> | ||||||
<Checkbox | ||||||
label="Secondary" | ||||||
isChecked={isSecondary} | ||||||
onChange={(_event, checked) => setisSecondary(checked)} | ||||||
id="isSecondaryCheckbox" | ||||||
/> | ||||||
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. Should we add the ability to see all of the variants? Looks like the way it is now toggles between secondary and primary, which we should at least call out that it's secondary when checked, and primary when unchecked, which is different from the default (no value for 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. I thought of that but followed the drawer model, which has a no-background modifier but only showed an example for secondary - and also I didn't know how to make a dropdown work lol. Maybe I can pair program with someone to do that? 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. I would say it may be nice to see all the color variants. We could lay them out individually instead of with a dropdown since there's only 3 (similar to how we show Alert or Label), but if we want to go the dropdown route feel free to ping me and I can help out. @srambach 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. @sarah, we should probably update the Drawer example as well. I agree that we should show all variants. |
||||||
</React.Fragment> | ||||||
); | ||||||
}; |
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.
Question for react-dev - should we have a
default
which will unsetcolorVariant
? Without acolorVariant
set, the toolbar background can be dynamic depending on how it's used. By default, a toolbar's background is transparent (same ascolorVariant="no-background"
) except when it's sticky, then it's the primary background (same ascolorVariant="primary"
)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 usually lean towards having the "default" case be where a user would leave out the
colorVariant
prop entirely, and only apply the colors if the prop is present. But we've done both ways in different areas, so either works.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 did a quick search to see what we do with other color variant props. It looks like the Drawer has a color variant that has a
default
option. So I would lean towards adding one here as well for consistency.