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

inputGroup - add InputGroupItem #9074

Merged
merged 4 commits into from
May 17, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AlertActionCloseButton,
AlertVariant,
InputGroup,
InputGroupItem,
useInterval
} from '@patternfly/react-core';

Expand Down Expand Up @@ -45,12 +46,16 @@ export const AlertGroupAsync: React.FunctionComponent = () => {
return (
<React.Fragment>
<InputGroup style={{ marginBottom: '16px' }}>
<button onClick={startAsyncAlerts} type="button" className={btnClasses}>
Start async alerts
</button>
<button onClick={stopAsyncAlerts} type="button" className={btnClasses}>
Stop async alerts
</button>
<InputGroupItem>
<button onClick={startAsyncAlerts} type="button" className={btnClasses}>
Start async alerts
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={stopAsyncAlerts} type="button" className={btnClasses}>
Stop async alerts
</button>
</InputGroupItem>
</InputGroup>
<AlertGroup isToast isLiveRegion aria-live="assertive">
{alerts.map(({ title, variant, key }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
AlertGroup,
AlertActionCloseButton,
AlertVariant,
InputGroup
InputGroup,
InputGroupItem
} from '@patternfly/react-core';

export const AlertGroupMultipleDynamic: React.FunctionComponent = () => {
Expand Down Expand Up @@ -34,9 +35,11 @@ export const AlertGroupMultipleDynamic: React.FunctionComponent = () => {
return (
<React.Fragment>
<InputGroup style={{ marginBottom: '16px' }}>
<button onClick={addAlertCollection} type="button" className={btnClasses}>
Add alert collection
</button>
<InputGroupItem>
<button onClick={addAlertCollection} type="button" className={btnClasses}>
Add alert collection
</button>
</InputGroupItem>
</InputGroup>
<AlertGroup isToast isLiveRegion>
{alerts.map(({ title, variant, key }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
AlertGroup,
AlertActionCloseButton,
AlertVariant,
InputGroup
InputGroup,
InputGroupItem
} from '@patternfly/react-core';

export const AlertGroupSingularDynamic: React.FunctionComponent = () => {
Expand Down Expand Up @@ -38,15 +39,21 @@ export const AlertGroupSingularDynamic: React.FunctionComponent = () => {
return (
<React.Fragment>
<InputGroup style={{ marginBottom: '16px' }}>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add single success alert
</button>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add single danger alert
</button>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add single info alert
</button>
<InputGroupItem>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add single success alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add single danger alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add single info alert
</button>
</InputGroupItem>
</InputGroup>
<AlertGroup isLiveRegion>
{alerts.map(({ title, variant, key }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
AlertGroup,
AlertActionCloseButton,
AlertVariant,
InputGroup
InputGroup,
InputGroupItem
} from '@patternfly/react-core';

export const AlertGroupSingularDynamicOverflow: React.FunctionComponent = () => {
Expand Down Expand Up @@ -57,15 +58,21 @@ export const AlertGroupSingularDynamicOverflow: React.FunctionComponent = () =>
return (
<React.Fragment>
<InputGroup style={{ marginBottom: '16px' }}>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add single success alert
</button>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add single danger alert
</button>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add single info alert
</button>
<InputGroupItem>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add single success alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add single danger alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add single info alert
</button>
</InputGroupItem>
</InputGroup>
<AlertGroup isLiveRegion onOverflowClick={onOverflowClick} overflowMessage={overflowMessage}>
{alerts.slice(0, maxDisplayed).map(({ key, variant, title }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
AlertGroup,
AlertActionCloseButton,
AlertVariant,
InputGroup
InputGroup,
InputGroupItem
} from '@patternfly/react-core';

export const AlertGroupToast: React.FunctionComponent = () => {
Expand Down Expand Up @@ -38,15 +39,21 @@ export const AlertGroupToast: React.FunctionComponent = () => {
return (
<React.Fragment>
<InputGroup style={{ marginBottom: '16px' }}>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add toast success alert
</button>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add toast danger alert
</button>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add toast info alert
</button>
<InputGroupItem>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add toast success alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add toast danger alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add toast info alert
</button>
</InputGroupItem>
</InputGroup>
<AlertGroup isToast isLiveRegion>
{alerts.map(({ key, variant, title }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
AlertGroup,
AlertActionCloseButton,
AlertVariant,
InputGroup
InputGroup,
InputGroupItem
} from '@patternfly/react-core';

export const AlertGroupToastOverflowCapture: React.FunctionComponent = () => {
Expand Down Expand Up @@ -57,15 +58,21 @@ export const AlertGroupToastOverflowCapture: React.FunctionComponent = () => {
return (
<React.Fragment>
<InputGroup style={{ marginBottom: '16px' }}>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add toast success alert
</button>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add toast danger alert
</button>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add toast info alert
</button>
<InputGroupItem>
<button onClick={addSuccessAlert} type="button" className={btnClasses}>
Add toast success alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addDangerAlert} type="button" className={btnClasses}>
Add toast danger alert
</button>
</InputGroupItem>
<InputGroupItem>
<button onClick={addInfoAlert} type="button" className={btnClasses}>
Add toast info alert
</button>
</InputGroupItem>
</InputGroup>
<AlertGroup isToast isLiveRegion onOverflowClick={onOverflowClick} overflowMessage={overflowMessage}>
{alerts.slice(0, maxDisplayed).map(({ key, variant, title }) => (
Expand Down
118 changes: 61 additions & 57 deletions packages/react-core/src/components/CalendarMonth/CalendarMonth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TextInput } from '../TextInput';
import { Button } from '../Button';
import { Select, SelectList, SelectOption } from '../Select';
import { MenuToggle, MenuToggleElement } from '../MenuToggle';
import { InputGroup } from '../InputGroup';
import { InputGroup, InputGroupItem } from '../InputGroup';
import AngleLeftIcon from '@patternfly/react-icons/dist/esm/icons/angle-left-icon';
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
import { css } from '@patternfly/react-styles';
Expand Down Expand Up @@ -259,67 +259,71 @@ export const CalendarMonth = ({
</Button>
</div>
<InputGroup>
<div className={styles.calendarMonthHeaderMonth}>
<span id={hiddenMonthId} hidden>
Month
</span>
<Select
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle
ref={toggleRef}
onClick={()=>setIsSelectOpen(!isSelectOpen)}
isExpanded={isSelectOpen}
style={{width: "140px"} as React.CSSProperties }
>
{monthFormatted}
</MenuToggle>
)}
aria-labelledby={hiddenMonthId}
isOpen={isSelectOpen}
onOpenChange={(isOpen) => {
setIsSelectOpen(isOpen);
onSelectToggle(isOpen);
}}
onSelect={(ev, monthNum) => {
// When we put CalendarMonth in a Popover we want the Popover's onDocumentClick
// to see the SelectOption as a child so it doesn't close the Popover.
setTimeout(() => {
setIsSelectOpen(false);
onSelectToggle(false);
<InputGroupItem isFill>
<div className={styles.calendarMonthHeaderMonth}>
<span id={hiddenMonthId} hidden>
Month
</span>
<Select
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
<MenuToggle
ref={toggleRef}
onClick={() => setIsSelectOpen(!isSelectOpen)}
isExpanded={isSelectOpen}
style={{ width: '140px' } as React.CSSProperties}
>
{monthFormatted}
</MenuToggle>
)}
aria-labelledby={hiddenMonthId}
isOpen={isSelectOpen}
onOpenChange={(isOpen) => {
setIsSelectOpen(isOpen);
onSelectToggle(isOpen);
}}
onSelect={(ev, monthNum) => {
// When we put CalendarMonth in a Popover we want the Popover's onDocumentClick
// to see the SelectOption as a child so it doesn't close the Popover.
setTimeout(() => {
setIsSelectOpen(false);
onSelectToggle(false);
const newDate = new Date(focusedDate);
newDate.setMonth(Number(monthNum as string));
setFocusedDate(newDate);
setHoveredDate(newDate);
setShouldFocus(false);
onMonthChange(ev, newDate);
}, 0);
}}
selected={monthFormatted}
>
<SelectList>
{longMonths.map((longMonth, index) => (
<SelectOption key={index} itemId={index} isSelected={longMonth === monthFormatted}>
{longMonth}
</SelectOption>
))}
</SelectList>
</Select>
</div>
</InputGroupItem>
<InputGroupItem>
<div className={styles.calendarMonthHeaderYear}>
<TextInput
aria-label={yearInputAriaLabel}
type="number"
value={yearFormatted}
onChange={(ev: React.FormEvent<HTMLInputElement>, year: string) => {
const newDate = new Date(focusedDate);
newDate.setMonth(Number(monthNum as string));
newDate.setFullYear(+year);
setFocusedDate(newDate);
setHoveredDate(newDate);
setShouldFocus(false);
onMonthChange(ev, newDate);
}, 0);
}}
selected={monthFormatted}
>
<SelectList>
{longMonths.map((longMonth, index) => (
<SelectOption key={index} itemId={index} isSelected={longMonth === monthFormatted}>
{longMonth}
</SelectOption>
))}
</SelectList>
</Select>
</div>
<div className={styles.calendarMonthHeaderYear}>
<TextInput
aria-label={yearInputAriaLabel}
type="number"
value={yearFormatted}
onChange={(ev: React.FormEvent<HTMLInputElement>, year: string) => {
const newDate = new Date(focusedDate);
newDate.setFullYear(+year);
setFocusedDate(newDate);
setHoveredDate(newDate);
setShouldFocus(false);
onMonthChange(ev, newDate);
}}
/>
</div>
}}
/>
</div>
</InputGroupItem>
</InputGroup>
<div className={css(styles.calendarMonthHeaderNavControl, styles.modifiers.nextMonth)}>
<Button
Expand Down
Loading