Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
807 additions
and
88 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@twilio-paste/menu': patch | ||
'@twilio-paste/core': patch | ||
--- | ||
|
||
[Menu]: Enable Component to respect element customizations set on the customization provider. Component now enables setting an element name on the underlying HTML element and checks the emotion theme object to determine whether it should merge in custom styles to the ones set by the component author. |
464 changes: 464 additions & 0 deletions
464
packages/paste-core/components/menu/__tests__/customization.spec.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
35 changes: 21 additions & 14 deletions
35
packages/paste-core/components/menu/src/SubMenuButton.tsx
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 |
---|---|---|
@@ -1,24 +1,31 @@ | ||
import * as React from 'react'; | ||
import type {BoxElementProps} from '@twilio-paste/box'; | ||
import type {MenuPrimitiveButtonProps} from '@twilio-paste/menu-primitive'; | ||
import {MenuPrimitiveButton} from '@twilio-paste/menu-primitive'; | ||
import {MediaObject, MediaBody, MediaFigure} from '@twilio-paste/media-object'; | ||
import {ChevronRightIcon} from '@twilio-paste/icons/esm/ChevronRightIcon'; | ||
import {StyledMenuItem} from './MenuItem'; | ||
|
||
export type SubMenuButtonProps = MenuPrimitiveButtonProps; | ||
export type SubMenuButtonProps = MenuPrimitiveButtonProps & {element?: BoxElementProps['element']}; | ||
|
||
const SubMenuButton = React.forwardRef<HTMLButtonElement, SubMenuButtonProps>((props, ref) => { | ||
// MenuPrimitiveButton from reakit types `as` as HTML element names, but accepts components. any prevents type errors | ||
return ( | ||
<MenuPrimitiveButton {...props} as={StyledMenuItem as any} ref={ref}> | ||
<MediaObject as="span" verticalAlign="center"> | ||
{props.children && <MediaBody as="span">{props.children}</MediaBody>} | ||
<MediaFigure as="span" align="end" spacing="space20"> | ||
<ChevronRightIcon decorative size="sizeIcon30" /> | ||
</MediaFigure> | ||
</MediaObject> | ||
</MenuPrimitiveButton> | ||
); | ||
}); | ||
const SubMenuButton = React.forwardRef<HTMLButtonElement, SubMenuButtonProps>( | ||
({element = 'SUBMENU_BUTTON', ...props}, ref) => { | ||
// MenuPrimitiveButton from reakit types `as` as HTML element names, but accepts components. any prevents type errors | ||
return ( | ||
<MenuPrimitiveButton {...props} as={StyledMenuItem as any} element={element} ref={ref}> | ||
<MediaObject as="span" verticalAlign="center" element={`${element}_MEDIA_OBJECT`}> | ||
{props.children && ( | ||
<MediaBody as="span" element={`${element}_MEDIA_BODY`}> | ||
{props.children} | ||
</MediaBody> | ||
)} | ||
<MediaFigure as="span" align="end" spacing="space20" element={`${element}_MEDIA_FIGURE`}> | ||
<ChevronRightIcon decorative size="sizeIcon30" element={`${element}_ICON`} /> | ||
</MediaFigure> | ||
</MediaObject> | ||
</MenuPrimitiveButton> | ||
); | ||
} | ||
); | ||
SubMenuButton.displayName = 'SubMenuButton'; | ||
export {SubMenuButton}; |
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
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,3 @@ | ||
import {useMenuPrimitiveState} from '@twilio-paste/menu-primitive'; | ||
|
||
export {useMenuPrimitiveState as useMenuState}; |
Oops, something went wrong.