diff --git a/packages/react-core/src/components/Card/CardHeadMain.test.tsx b/packages/react-core/src/components/Card/CardHeadMain.test.tsx new file mode 100644 index 00000000000..1d1070b1bb7 --- /dev/null +++ b/packages/react-core/src/components/Card/CardHeadMain.test.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { CardHeadMain } from './CardHeadMain'; +import { shallow } from 'enzyme'; + +test('renders with PatternFly Core styles', () => { + const view = shallow(text); + expect(view).toMatchSnapshot(); +}); + +test('className is added to the root element', () => { + const view = shallow(text); + expect(view.prop('className')).toMatchSnapshot(); +}); + +test('extra props are spread to the root element', () => { + const testId = 'card-head-main'; + const view = shallow(); + expect(view.prop('data-testid')).toBe(testId); +}); diff --git a/packages/react-core/src/components/Card/CardHeadMain.tsx b/packages/react-core/src/components/Card/CardHeadMain.tsx new file mode 100644 index 00000000000..af7268e658f --- /dev/null +++ b/packages/react-core/src/components/Card/CardHeadMain.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +import { css } from '@patternfly/react-styles'; + +export interface CardHeadMainProps extends React.HTMLProps { + /** Content rendered inside the Card Head Main */ + children?: React.ReactNode; + /** Additional classes added to the Card Head Main */ + className?: string; +} + +export const CardHeadMain: React.FunctionComponent = ({ + children = null, + className = '', + ...props +}: CardHeadMainProps) => ( +
+ {children} +
+); diff --git a/packages/react-core/src/components/Card/__snapshots__/CardHeadMain.test.tsx.snap b/packages/react-core/src/components/Card/__snapshots__/CardHeadMain.test.tsx.snap new file mode 100644 index 00000000000..c03990dedc3 --- /dev/null +++ b/packages/react-core/src/components/Card/__snapshots__/CardHeadMain.test.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`className is added to the root element 1`] = `"pf-c-card__head-main extra-class"`; + +exports[`renders with PatternFly Core styles 1`] = ` +
+ text +
+`; diff --git a/packages/react-core/src/components/Card/examples/Card.md b/packages/react-core/src/components/Card/examples/Card.md index 49bf749e5a9..ee5fdfe369f 100644 --- a/packages/react-core/src/components/Card/examples/Card.md +++ b/packages/react-core/src/components/Card/examples/Card.md @@ -3,10 +3,10 @@ title: 'Card' section: components cssPrefix: 'pf-c-card' typescript: true -propComponents: ['Card', 'CardHeader', 'CardBody', 'CardFooter'] +propComponents: ['Card', 'CardHeadMain', 'CardHeader', 'CardBody', 'CardFooter'] --- -import { Card, CardActions, CardHead, CardHeader, CardBody, CardFooter, Checkbox, DropdownActions } from '@patternfly/react-core'; +import { Brand, Card, CardActions, CardHead, CardHeadMain, CardHeader, CardBody, CardFooter, Checkbox, DropdownActions } from '@patternfly/react-core'; import pfLogo from './pfLogo.svg'; ## Examples @@ -25,7 +25,7 @@ SimpleCard = () => ( ```js title=With-image-and-actions import React from 'react'; -import { Card, CardHead, CardActions, CardHeader, CardBody, CardFooter, Dropdown, DropdownToggle, DropdownItem, DropdownSeparator, DropdownPosition, DropdownDirection, KebabToggle, } from '@patternfly/react-core'; +import { Brand, Card, CardHead, CardHeadMain, CardActions, CardHeader, CardBody, CardFooter, Dropdown, DropdownToggle, DropdownItem, DropdownSeparator, DropdownPosition, DropdownDirection, KebabToggle, } from '@patternfly/react-core'; import pfLogo from './pfLogo.svg'; class KebabDropdown extends React.Component { @@ -75,7 +75,9 @@ class KebabDropdown extends React.Component { return ( - PatternFly logo + + + ( - PatternFly Logo + + + Header Body diff --git a/packages/react-core/src/components/Card/index.ts b/packages/react-core/src/components/Card/index.ts index de136f47d58..504e3ac5cf9 100644 --- a/packages/react-core/src/components/Card/index.ts +++ b/packages/react-core/src/components/Card/index.ts @@ -4,3 +4,4 @@ export * from './CardBody'; export * from './CardFooter'; export * from './CardHeader'; export * from './CardHead'; +export * from './CardHeadMain';