diff --git a/packages/react-core/src/components/Card/CardHeader.tsx b/packages/react-core/src/components/Card/CardHeader.tsx index 1ee98dbee92..5ccdfb29e4a 100644 --- a/packages/react-core/src/components/Card/CardHeader.tsx +++ b/packages/react-core/src/components/Card/CardHeader.tsx @@ -54,6 +54,8 @@ export interface CardHeaderSelectableActionsObject { * the isSelected prop on the card component instead. */ isChecked?: boolean; + /** Flag indicating the action is hidden */ + isHidden?: boolean; } export interface CardHeaderProps extends React.HTMLProps { @@ -133,7 +135,8 @@ export const CardHeader: React.FunctionComponent = ({ const SelectableCardInput = selectableActions?.variant === 'single' ? Radio : Checkbox; const getSelectableProps = () => ({ - className: 'pf-m-standalone', + className: css('pf-m-standalone'), + inputClassName: css(selectableActions?.isHidden && 'pf-v6-screen-reader'), label: <>, 'aria-label': selectableActions.selectableActionAriaLabel, 'aria-labelledby': selectableActions.selectableActionAriaLabelledby, @@ -150,7 +153,11 @@ export const CardHeader: React.FunctionComponent = ({ const getClickableProps = () => { const isDisabledLinkCard = isCardDisabled && isClickableLinkCard; const baseProps = { - className: css('pf-v6-c-card__clickable-action', isDisabledLinkCard && styles.modifiers.disabled), + className: css( + 'pf-v6-c-card__clickable-action', + isDisabledLinkCard && styles.modifiers.disabled, + selectableActions?.isHidden && 'pf-v6-screen-reader' + ), id: selectableActions.selectableActionId, 'aria-label': selectableActions.selectableActionAriaLabel, 'aria-labelledby': selectableActions.selectableActionAriaLabelledby, diff --git a/packages/react-core/src/components/Card/examples/Card.md b/packages/react-core/src/components/Card/examples/Card.md index b819eecc855..ef2946b0a30 100644 --- a/packages/react-core/src/components/Card/examples/Card.md +++ b/packages/react-core/src/components/Card/examples/Card.md @@ -19,6 +19,7 @@ ouia: true import pfLogo from '../../assets/PF-HorizontalLogo-Color.svg'; import pfLogoSmall from '../../assets/PF-IconLogo.svg'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; +import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; ## Examples @@ -178,3 +179,25 @@ Dividers can be placed between sections of the card. ```ts file='./CardWithDividers.tsx' ``` + +## Cards as tiles + +Sets of selectable cards can be used as tiles, which are static options that users can select. + +They can be either single selectable or multi selectable, by passing the `variant` property to the `selectableActions` object. You can also toggle the visibility of the radio or checkbox by passing the `isHidden` property to the `selectableActions` object. + +### Single selectable tiles + +To prevent users from selecting more than 1 tile in a set, set `variant` to "single" within the `selectableActions` object of ``. + +```ts file='./CardTile.tsx' + +``` + +### Multi selectable tiles + +To allow users to select more than 1 tile in a set, do not set `variant` within the `selectableActions` object of ``. + +```ts file='./CardTileMulti.tsx' + +``` diff --git a/packages/react-core/src/components/Card/examples/CardTile.tsx b/packages/react-core/src/components/Card/examples/CardTile.tsx new file mode 100644 index 00000000000..9fdbadaacea --- /dev/null +++ b/packages/react-core/src/components/Card/examples/CardTile.tsx @@ -0,0 +1,73 @@ +import React from 'react'; +import { Card, CardHeader, CardBody, Gallery, Flex } from '@patternfly/react-core'; +import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; + +export const CardTile: React.FunctionComponent = () => { + const [isChecked, setIsChecked] = React.useState(''); + const id1 = 'tile-1'; + const id2 = 'tile-2'; + const id3 = 'tile-3'; + + const onChange = (event: React.FormEvent) => { + setIsChecked(event.currentTarget.id); + }; + + return ( + + + + + + Tile header + + + Tile content and description + + + + + + Tile header + + + Tile content and description + + + + + + Tile header (disabled) + + + Tile content and description + + + ); +}; diff --git a/packages/react-core/src/components/Card/examples/CardTileMulti.tsx b/packages/react-core/src/components/Card/examples/CardTileMulti.tsx new file mode 100644 index 00000000000..87a453ad1d5 --- /dev/null +++ b/packages/react-core/src/components/Card/examples/CardTileMulti.tsx @@ -0,0 +1,84 @@ +import React from 'react'; +import { Card, CardHeader, CardBody, Gallery, Flex } from '@patternfly/react-core'; +import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; + +export const CardTileMulti: React.FunctionComponent = () => { + const [isChecked1, setIsChecked1] = React.useState(false); + const [isChecked2, setIsChecked2] = React.useState(false); + const [isChecked3, setIsChecked3] = React.useState(false); + const id1 = 'multi-tile-1'; + const id2 = 'multi-tile-2'; + const id3 = 'multi-tile-3'; + + const onChange = (event: React.FormEvent, checked: boolean) => { + const name = event.currentTarget.name; + + switch (name) { + case id1: + setIsChecked1(checked); + break; + case id2: + setIsChecked2(checked); + break; + case id3: + setIsChecked3(checked); + break; + } + }; + + return ( + + + + + + Tile header + + + Tile content and description + + + + + + Tile header + + + Tile content and description + + + + + + Tile header (disabled) + + + Tile content and description + + + ); +}; diff --git a/packages/react-core/src/components/Tile/examples/Tile.md b/packages/react-core/src/components/Tile/examples/Tile.md deleted file mode 100644 index d5b77885080..00000000000 --- a/packages/react-core/src/components/Tile/examples/Tile.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -id: Tile -section: components -cssPrefix: pf-v6-c-tile -propComponents: ['Tile'] ---- - -import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; -import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; -import './Tile.css'; - -## Examples - -Keyboard interaction patterns and a11y is implemented in the Tile demos, located in the [Demo section](/components/tile/react-demos). - -### Basic tile -Basic tiles can appear in one of three states: a default state, selected state, and a disabled state. To change the state of a tile, use the properties `isSelected` and `isDisabled`. -```ts file="./TileBasic.tsx" -``` - -### With subtext -Tile subtext can provide users with additional context. To add subtext, pass a short description to the `` component. -```ts file="./TileWithSubtext.tsx" -``` - -### With icon -Icons can provide a visual cue that helps users understand what the tile is being used for. To add an icon, use the `icon` property. -```ts file="./TileWithIcon.tsx" -``` - -### With stacked icon -You can further customize a tile’s appearance by placing an icon above the title. To stack your icon on top of a tile’s title, use the `isStacked` property. -```ts file="./TileStacked.tsx" -``` - -### With large icons -You can make your icons larger to help catch a user’s attention. To increase the size of an icon, use the `isDisplayLarge` property. - -Be aware that `isDisplayLarge` can only be used when `isStacked` is also applied. -```ts file="./TileStackedWithLargeIcons.tsx" -``` - -### With long subtext -To provide users with a large amount of context, subtext can be elongated to wrap around to the next line. To format a long subtext, you can pass the component `Flex` into ``. - -You can also change the type of `Flex` you can use so that the line breaks in the subtext fits your needs. You can do this by changing the default flex. The standard is `default: “flex_1”`, and changing the number in the default will also change where the sentence breaks. -```ts file="./TileWithExtraContent.tsx" -``` diff --git a/packages/react-core/src/components/index.ts b/packages/react-core/src/components/index.ts index 681a6834e64..5c9f602ca73 100644 --- a/packages/react-core/src/components/index.ts +++ b/packages/react-core/src/components/index.ts @@ -65,7 +65,6 @@ export * from './Switch'; export * from './Tabs'; export * from './TextArea'; export * from './TextInput'; -export * from './Tile'; export * from './TimePicker'; export * from './Timestamp'; export * from './Title'; diff --git a/packages/react-core/src/components/Tile/Tile.tsx b/packages/react-core/src/deprecated/components/Tile/Tile.tsx similarity index 100% rename from packages/react-core/src/components/Tile/Tile.tsx rename to packages/react-core/src/deprecated/components/Tile/Tile.tsx diff --git a/packages/react-core/src/components/Tile/__tests__/Tile.test.tsx b/packages/react-core/src/deprecated/components/Tile/__tests__/Tile.test.tsx similarity index 100% rename from packages/react-core/src/components/Tile/__tests__/Tile.test.tsx rename to packages/react-core/src/deprecated/components/Tile/__tests__/Tile.test.tsx diff --git a/packages/react-core/src/components/Tile/__tests__/__snapshots__/Tile.test.tsx.snap b/packages/react-core/src/deprecated/components/Tile/__tests__/__snapshots__/Tile.test.tsx.snap similarity index 100% rename from packages/react-core/src/components/Tile/__tests__/__snapshots__/Tile.test.tsx.snap rename to packages/react-core/src/deprecated/components/Tile/__tests__/__snapshots__/Tile.test.tsx.snap diff --git a/packages/react-core/src/components/Tile/examples/Tile.css b/packages/react-core/src/deprecated/components/Tile/examples/Tile.css similarity index 100% rename from packages/react-core/src/components/Tile/examples/Tile.css rename to packages/react-core/src/deprecated/components/Tile/examples/Tile.css diff --git a/packages/react-core/src/demos/TileDemo.md b/packages/react-core/src/deprecated/components/Tile/examples/Tile.md similarity index 55% rename from packages/react-core/src/demos/TileDemo.md rename to packages/react-core/src/deprecated/components/Tile/examples/Tile.md index e65369c1383..aa989ab5f1c 100644 --- a/packages/react-core/src/demos/TileDemo.md +++ b/packages/react-core/src/deprecated/components/Tile/examples/Tile.md @@ -1,15 +1,80 @@ --- id: Tile section: components +cssPrefix: pf-v6-c-tile +propComponents: ['Tile'] +deprecated: true --- +import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; +import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; +import './Tile.css'; + +**Note:** Tile has been deprecated. Use the [card](/components/card#cards-as-tiles) component instead. + +## Examples + +Keyboard interaction patterns and a11y is implemented in the Tile demos, located in the [Demo section](/components/tile/react-demos). + +### Basic tile + +Basic tiles can appear in one of three states: a default state, selected state, and a disabled state. To change the state of a tile, use the properties `isSelected` and `isDisabled`. + +```ts file="./TileBasic.tsx" + +``` + +### With subtext + +Tile subtext can provide users with additional context. To add subtext, pass a short description to the `` component. + +```ts file="./TileWithSubtext.tsx" + +``` + +### With icon + +Icons can provide a visual cue that helps users understand what the tile is being used for. To add an icon, use the `icon` property. + +```ts file="./TileWithIcon.tsx" + +``` + +### With stacked icon + +You can further customize a tile’s appearance by placing an icon above the title. To stack your icon on top of a tile’s title, use the `isStacked` property. + +```ts file="./TileStacked.tsx" + +``` + +### With large icons + +You can make your icons larger to help catch a user’s attention. To increase the size of an icon, use the `isDisplayLarge` property. + +Be aware that `isDisplayLarge` can only be used when `isStacked` is also applied. + +```ts file="./TileStackedWithLargeIcons.tsx" + +``` + +### With long subtext + +To provide users with a large amount of context, subtext can be elongated to wrap around to the next line. To format a long subtext, you can pass the component `Flex` into ``. + +You can also change the type of `Flex` you can use so that the line breaks in the subtext fits your needs. You can do this by changing the default flex. The standard is `default: “flex_1”`, and changing the number in the default will also change where the sentence breaks. + +```ts file="./TileWithExtraContent.tsx" + +``` + ## Demos ### Tiles with single selection ```ts import React from 'react'; -import { Tile } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; const TileSingleSelect: React.FunctionComponent = () => { const [selectedId, setSelectedId] = React.useState(''); @@ -40,7 +105,7 @@ const TileSingleSelect: React.FunctionComponent = () => { ```ts import React from 'react'; -import { Tile } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; const TileMultiSelect: React.FunctionComponent = () => { const [selectedIds, setSelectedIds] = React.useState([]); diff --git a/packages/react-core/src/components/Tile/examples/TileBasic.tsx b/packages/react-core/src/deprecated/components/Tile/examples/TileBasic.tsx similarity index 83% rename from packages/react-core/src/components/Tile/examples/TileBasic.tsx rename to packages/react-core/src/deprecated/components/Tile/examples/TileBasic.tsx index 40549eb85e0..72a0bc535eb 100644 --- a/packages/react-core/src/components/Tile/examples/TileBasic.tsx +++ b/packages/react-core/src/deprecated/components/Tile/examples/TileBasic.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Tile } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; export const TileBasic: React.FunctionComponent = () => (
diff --git a/packages/react-core/src/components/Tile/examples/TileStacked.tsx b/packages/react-core/src/deprecated/components/Tile/examples/TileStacked.tsx similarity index 90% rename from packages/react-core/src/components/Tile/examples/TileStacked.tsx rename to packages/react-core/src/deprecated/components/Tile/examples/TileStacked.tsx index 82728f9cda8..f3ede9249a8 100644 --- a/packages/react-core/src/components/Tile/examples/TileStacked.tsx +++ b/packages/react-core/src/deprecated/components/Tile/examples/TileStacked.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Tile } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; export const TileStacked: React.FunctionComponent = () => ( diff --git a/packages/react-core/src/components/Tile/examples/TileStackedWithLargeIcons.tsx b/packages/react-core/src/deprecated/components/Tile/examples/TileStackedWithLargeIcons.tsx similarity index 91% rename from packages/react-core/src/components/Tile/examples/TileStackedWithLargeIcons.tsx rename to packages/react-core/src/deprecated/components/Tile/examples/TileStackedWithLargeIcons.tsx index ccaf2ce1c56..bf498a81ce5 100644 --- a/packages/react-core/src/components/Tile/examples/TileStackedWithLargeIcons.tsx +++ b/packages/react-core/src/deprecated/components/Tile/examples/TileStackedWithLargeIcons.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Tile } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; export const TileStackedWithLargeIcons: React.FunctionComponent = () => ( diff --git a/packages/react-core/src/components/Tile/examples/TileWithExtraContent.tsx b/packages/react-core/src/deprecated/components/Tile/examples/TileWithExtraContent.tsx similarity index 91% rename from packages/react-core/src/components/Tile/examples/TileWithExtraContent.tsx rename to packages/react-core/src/deprecated/components/Tile/examples/TileWithExtraContent.tsx index b71e4094ac6..5a7982a3553 100644 --- a/packages/react-core/src/components/Tile/examples/TileWithExtraContent.tsx +++ b/packages/react-core/src/deprecated/components/Tile/examples/TileWithExtraContent.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { Tile, Flex } from '@patternfly/react-core'; +import { Flex } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; export const TileWithExtraContent: React.FunctionComponent = () => ( diff --git a/packages/react-core/src/components/Tile/examples/TileWithIcon.tsx b/packages/react-core/src/deprecated/components/Tile/examples/TileWithIcon.tsx similarity index 90% rename from packages/react-core/src/components/Tile/examples/TileWithIcon.tsx rename to packages/react-core/src/deprecated/components/Tile/examples/TileWithIcon.tsx index 8d6110b0ab1..2c320ff2a23 100644 --- a/packages/react-core/src/components/Tile/examples/TileWithIcon.tsx +++ b/packages/react-core/src/deprecated/components/Tile/examples/TileWithIcon.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Tile } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon'; export const TileWithIcon: React.FunctionComponent = () => ( diff --git a/packages/react-core/src/components/Tile/examples/TileWithSubtext.tsx b/packages/react-core/src/deprecated/components/Tile/examples/TileWithSubtext.tsx similarity index 87% rename from packages/react-core/src/components/Tile/examples/TileWithSubtext.tsx rename to packages/react-core/src/deprecated/components/Tile/examples/TileWithSubtext.tsx index 73e39747999..c04d2f2a2b0 100644 --- a/packages/react-core/src/components/Tile/examples/TileWithSubtext.tsx +++ b/packages/react-core/src/deprecated/components/Tile/examples/TileWithSubtext.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Tile } from '@patternfly/react-core'; +import { Tile } from '@patternfly/react-core/deprecated'; export const TileWithSubtext: React.FunctionComponent = () => (
diff --git a/packages/react-core/src/components/Tile/index.ts b/packages/react-core/src/deprecated/components/Tile/index.ts similarity index 100% rename from packages/react-core/src/components/Tile/index.ts rename to packages/react-core/src/deprecated/components/Tile/index.ts diff --git a/packages/react-core/src/deprecated/components/index.ts b/packages/react-core/src/deprecated/components/index.ts index 9d36fef85c2..39cc31d69fb 100644 --- a/packages/react-core/src/deprecated/components/index.ts +++ b/packages/react-core/src/deprecated/components/index.ts @@ -2,4 +2,5 @@ export * from './Chip'; export * from './DragDrop'; export * from './Modal'; export * from './DualListSelector'; +export * from './Tile'; export * from './Wizard';