-
Notifications
You must be signed in to change notification settings - Fork 31
add ServiceCard component #200
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
Changes from 11 commits
6f60bd3
4ce6b3a
a941a0d
8e545e2
c9d1e10
d183eb0
5f42d55
2b74087
e8d285f
afac096
b8723cc
9541df0
6899a73
8b0207c
241e44f
948231b
eb895bb
a6c3ae1
c119f00
92ec3db
49d6e4a
d972e5e
6062897
c4bcc8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| section: extensions | ||
| subsection: Component groups | ||
| id: Service card | ||
| source: react | ||
| propComponents: ['ServiceCard'] | ||
| sourceLink: https://github.com/patternfly/react-component-groups/blob/main/packages/module/patternfly-docs/content/extensions/component-groups/examples/ServiceCard/ServiceCard.md | ||
| --- | ||
|
|
||
| import ServiceCard from "@patternfly/react-component-groups/dist/dynamic/ServiceCard"; | ||
| import { EllipsisVIcon } from '@patternfly/react-icons'; | ||
| import contentHeaderIcon from '../../assets/icons/content-header-icon.svg' | ||
|
|
||
| A **Service Card** component allows | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Service Card | ||
|
|
||
| ```js file="./ServiceCardExample.tsx" | ||
|
|
||
| ``` | ||
|
|
||
| ### Service Card with Gallery example | ||
|
|
||
| ```js file="./ServiceCardGalleryExample.tsx" | ||
|
|
||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React from 'react'; | ||
| import ServiceCard from "@patternfly/react-component-groups/dist/dynamic/ServiceCard"; | ||
| import contentHeaderIcon from '../../assets/icons/content-header-icon.svg'; | ||
|
|
||
| export const BasicExample: React.FunctionComponent = () => ( | ||
| <ServiceCard | ||
| title='Example' | ||
| subtitle='A basic example' | ||
| description='This is a basic ServiceCard Example' | ||
| icon={<img src={contentHeaderIcon} alt="content-header-icon" />} | ||
| showDisabledButton={false} | ||
| helperText='' | ||
|
||
| learnMoreUrl='/' | ||
| launchUrl='/' | ||
| /> | ||
| ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please add icons to these cards and show a helper text in one of the cards? Just to show the features. For the footers we could hardcode the default one in the example and another with something like this (another already known use case of this component) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import React from 'react'; | ||
| import ServiceCard from "@patternfly/react-component-groups/dist/dynamic/ServiceCard"; | ||
| import { Gallery } from '@patternfly/react-core/dist/dynamic/layouts/Gallery'; | ||
| import { GalleryItem } from '@patternfly/react-core/dist/dynamic/layouts/Gallery'; | ||
|
|
||
|
|
||
| export const ServiceCardGalleryExample: React.FunctionComponent = () => ( | ||
| <Gallery hasGutter minWidths={{ default: '330px' }}> | ||
| <GalleryItem> | ||
| <ServiceCard | ||
| title='Example2' | ||
| subtitle='A basic example' | ||
| description='This is a basic ServiceCard Example' | ||
| iconUrl='/' | ||
| showDisabledButton={false} | ||
| helperText='' | ||
| learnMoreUrl='/' | ||
| launchUrl='/' | ||
| /> | ||
| </GalleryItem> | ||
| <GalleryItem> | ||
| <ServiceCard | ||
| title='Example2' | ||
| subtitle='A second example' | ||
| description='This is another basic ServiceCard Example' | ||
| iconUrl='/' | ||
| showDisabledButton={false} | ||
| helperText='' | ||
| learnMoreUrl='/' | ||
| launchUrl='/' | ||
| /> | ||
| </GalleryItem> | ||
| </Gallery> | ||
| ) |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should preferably use cypress |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import React from 'react'; | ||
| import { render } from '@testing-library/react'; | ||
| import ServiceCard from './ServiceCard'; | ||
|
|
||
| describe('LogSnippet component', () => { | ||
| it('should render LogSnippet component', () => { | ||
| expect(render(<ServiceCard | ||
| title='Example' | ||
| subtitle='A basic example' | ||
| description='This is a basic ServiceCard Example' | ||
| icon='/' | ||
| showDisabledButton={false} | ||
| helperText='' | ||
| learnMoreUrl='/' | ||
| launchUrl='/' | ||
| />)).toMatchSnapshot(); | ||
| }); | ||
| }); |
fhlavac marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,102 @@ | ||||||
| import React from 'react'; | ||||||
| import { Button, ButtonVariant, Card, CardBody, CardFooter, CardHeader, Text, TextContent, TextVariants } from '@patternfly/react-core'; | ||||||
| import { HelperText } from '@patternfly/react-core/dist/dynamic/components/HelperText'; | ||||||
| import { HelperTextItem } from '@patternfly/react-core/dist/dynamic/components/HelperText'; | ||||||
| import { createUseStyles } from 'react-jss'; | ||||||
|
|
||||||
| export interface ServiceCardProps { | ||||||
| /** Title for card */ | ||||||
| title: string; | ||||||
| /** Subtitle for card */ | ||||||
| subtitle: string; | ||||||
| /** Custom description */ | ||||||
| description: string; | ||||||
| /** icon for service card */ | ||||||
| icon: React.ReactNode; | ||||||
| /** Whether to show if button is disabled */ | ||||||
| showDisabledButton?: boolean; | ||||||
fhlavac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| /** Helper text for card */ | ||||||
| helperText?: string; | ||||||
| /** learn more button url*/ | ||||||
| learnMoreUrl: string; | ||||||
| /** Optional launch button url*/ | ||||||
| launchUrl?: string; | ||||||
| /** Optional foot to override default Learn More and Launch buttons */ | ||||||
| footer?: React.ReactElement | ||||||
fhlavac marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| /** Optional custom OUIA ID */ | ||||||
| ouiaId?: string | number; | ||||||
| } | ||||||
fhlavac marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| const useStyles = createUseStyles({ | ||||||
| card: { | ||||||
| height: ('var(--pf-v5-u-h-100)') | ||||||
|
||||||
| height: ('var(--pf-v5-u-h-100)') | |
| height: 'var(--pf-v5-u-h-100)' |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| marginRight: ('var(--pf-v5-global--spacer--md)'), | |
| marginRight: 'var(--pf-v5-global--spacer--md)', |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| marginRight: ('var(--pf-v5-global--spacer--sm)') | |
| marginRight: 'var(--pf-v5-global--spacer--md)' |
I think this one should be md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@InsaneZein can you please add some texts to the docs? It would also be nice to create an example with the custom footer. Let me know if you need help with the texts.