Skip to content

Commit

Permalink
fix(menu): component name to match documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-fournier committed Sep 13, 2024
1 parent 05dfdf6 commit 66b8bfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* export default MyComponent;
* ```
*/
const CardComponent = (
const Card = (
{
elevation: cardElevation = 1,
delayLongPress,
Expand Down Expand Up @@ -330,24 +330,24 @@ const CardComponent = (
);
};

const Component = forwardRef(CardComponent);
const Component = forwardRef(Card);
Component.displayName = 'Card';

const Card = Component as typeof Component & {
const CardComponent = Component as typeof Component & {
Content: typeof CardContent;
Actions: typeof CardActions;
Cover: typeof CardCover;
Title: typeof CardTitle;
};

// @component ./CardContent.tsx
Card.Content = CardContent;
CardComponent.Content = CardContent;
// @component ./CardActions.tsx
Card.Actions = CardActions;
CardComponent.Actions = CardActions;
// @component ./CardCover.tsx
Card.Cover = CardCover;
CardComponent.Cover = CardCover;
// @component ./CardTitle.tsx
Card.Title = CardTitle;
CardComponent.Title = CardTitle;

const styles = StyleSheet.create({
innerContainer: {
Expand All @@ -365,4 +365,4 @@ const styles = StyleSheet.create({
},
});

export default Card;
export default CardComponent;
17 changes: 8 additions & 9 deletions src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ const DEFAULT_MODE = 'elevated';
* `Modal` contents within a `PaperProvider` in order for the menu to show. This
* wrapping is not necessary if you use Paper's `Modal` instead.
*/
class MenuComponent extends React.Component<Props, State> {
// @component ./MenuItem.tsx
static Item = MenuItem;

class Menu extends React.Component<Props, State> {
static defaultProps = {
overlayAccessibilityLabel: 'Close menu',
testID: 'menu',
Expand Down Expand Up @@ -709,13 +706,15 @@ const styles = StyleSheet.create({
},
});

const MenuWithHOC = withInternalTheme(withSafeAreaInsets(MenuComponent));
const Component = withInternalTheme(withSafeAreaInsets(Menu));
Component.displayName = 'Menu';

const Menu = MenuWithHOC as typeof MenuWithHOC & {
const MenuComponent = Component as typeof Component & {
Item: typeof MenuItem;
};

// we need to attach again MenuItem as it is lost after using withSafeAreaInsets
Menu.Item = MenuItem;
// we need to attach MenuItem here instead of a static property otherwise it will be lost after using withSafeAreaInsets
// @component ./MenuItem.tsx
MenuComponent.Item = MenuItem;

export default Menu;
export default MenuComponent;

0 comments on commit 66b8bfd

Please sign in to comment.