-
Notifications
You must be signed in to change notification settings - Fork 54
feat(Toolbar): add custom
kind of ToolbarItem
#1558
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1558 +/- ##
=========================================
- Coverage 71.56% 71.5% -0.06%
=========================================
Files 842 844 +2
Lines 6862 6890 +28
Branches 1947 1960 +13
=========================================
+ Hits 4911 4927 +16
- Misses 1945 1957 +12
Partials 6 6
Continue to review full report at Codecov.
|
import { defaultBehavior } from '../../lib/accessibility' | ||
|
||
export interface ToolbarCustomItemProps | ||
extends UIComponentProps, |
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 possible to restrict the prop types and remove onClick? onClick should be put on the content element instead as the custom item is not focusable.
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, I am missing something - but currently not sure how aforementioned statement can coexist with focusable
prop :)
/** A custom item can be focused. */
focusable?: boolean
@miroslavstastny, @jurokapsiar, could you, please, suggest which part I am missing?
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.
Per offline discussion: it should be focusable
conditionally, but it can't be actionable
(onClick: never
). We can consider to change this later based on provided use cases.
custom
kind of itemcustom
kind of ToolbarItem
> { | ||
static displayName = 'ToolbarCustomItem' | ||
|
||
static className = 'ui-toolbar__customitem' |
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.
ui-toolbar__custom-item
?
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 have a UT for this one:
test(`is a static equal to "${info.componentClassName}"`, () => {
It expects to have: ui-toolbar__customitem
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
...(p.fitted !== true && |
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.
just to be sure - which case we are protecting against with explicit p.fitted !== true && ..
, instead of !p.fitted && ..
?
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.
const hasPadding = (fitted) => fitted !== true && fitted !== 'horizontally'
const hasPaddingModified = (fitted) => !fitted && fitted !== 'horizontally'
console.log(hasPadding(true), hasPadding('horizontally'), hasPadding('vertically'))
false false true
console.log(hasPaddingModified(true), hasPaddingModified('horizontally'), hasPaddingModified('vertically'))
false false false
I believe it's the reason
<p> | ||
When <code>custom</code> kind is used it is the responsibility of the consumer to verify | ||
accessibility and styling aspects of the component and handle them correctly. This kind of | ||
items can't be actionable. |
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.
You can add:
This kind of items can't be actionable, but actionable components might be added to the content slot of the custom kind.
…hub.com/stardust-ui/react into feat/toolbar-custom-item
custom
Toolbar Item kind allows to insert any content into a toolbar item - either non-focusable (Text
) or focusable (Button
):fitted
propThis custom item adds padding by default. This can be customised by specifying
fitted
prop, which can be:false
(default)true
- removes all padding'horizontally'
- removes left and right padding'vertically'
- removes top and bottom paddingfocused
propA custom item can be focused.