Skip to content
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(MenuToggle): add placeholder support #10882

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/react-core/src/components/MenuToggle/MenuToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export interface MenuToggleProps
isFullHeight?: boolean;
/** Flag indicating the toggle takes up the full width of its parent */
isFullWidth?: boolean;
/** Flag indicating the toggle contains placeholder text */
isPlaceholder?: boolean;
/** Object used to configure a split button menu toggle */
splitButtonOptions?: SplitButtonOptions;
/** Variant styles of the menu toggle */
Expand Down Expand Up @@ -85,6 +87,7 @@ class MenuToggleBase extends React.Component<MenuToggleProps, MenuToggleState> {
isDisabled: false,
isFullWidth: false,
isFullHeight: false,
isPlaceholder: false,
size: 'default',
ouiaSafe: true
};
Expand All @@ -103,6 +106,7 @@ class MenuToggleBase extends React.Component<MenuToggleProps, MenuToggleState> {
isDisabled,
isFullHeight,
isFullWidth,
isPlaceholder,
splitButtonOptions,
variant,
status,
Expand Down Expand Up @@ -179,6 +183,7 @@ class MenuToggleBase extends React.Component<MenuToggleProps, MenuToggleState> {
isFullHeight && styles.modifiers.fullHeight,
isFullWidth && styles.modifiers.fullWidth,
isDisabled && styles.modifiers.disabled,
isPlaceholder && styles.modifiers.placeholder,
size === MenuToggleSize.sm && styles.modifiers.small,
className
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,9 @@ describe('menu toggle', () => {
await user.click(screen.getByRole(`button`) as Element);
expect(mockClick).toHaveBeenCalled();
});

test(`Renders with class ${styles.modifiers.placeholder} when isPlaceholder is passed`, () => {
render(<MenuToggle isPlaceholder>Toggle</MenuToggle>);
expect(screen.getByRole('button')).toHaveClass(styles.modifiers.placeholder);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,11 @@ When the status value is "warning" or "danger", you must include helper text tha
```ts file='MenuToggleStatus.tsx'

```

### Placeholder text in toggle

To indicate the toggle contains placeholder text, pass the `isPlaceholder` property to the `MenuToggle`.

```ts file='MenuTogglePlaceholder.tsx'

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import { MenuToggle } from '@patternfly/react-core';

export const MenuTogglePlaceholder: React.FunctionComponent = () => (
<MenuToggle isPlaceholder>Placeholder text</MenuToggle>
);
Loading