Skip to content

Commit 816fc76

Browse files
Merge pull request #14968 from logonoff/OCPBUGS-54963-card
OCPBUGS-54963: Fix visual regression with knative getting started card
2 parents 5847a05 + 8e1d26f commit 816fc76

File tree

3 files changed

+63
-88
lines changed

3 files changed

+63
-88
lines changed

frontend/packages/console-shared/src/components/getting-started/GettingStartedExpandableGrid.tsx

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,44 @@ interface GettingStartedExpandableGridProps {
2020
isOpen?: boolean;
2121
setIsOpen?: (isOpen: boolean) => void;
2222
setShowState?: (showState: GettingStartedShowState) => void;
23+
/** Optional title content. Defaults to "Getting started" */
24+
title?: React.ReactNode;
25+
/** Optional tooltip content placed after the title. Has default content. */
26+
titleTooltip?: React.ReactNode | false;
27+
/** Optional header content */
28+
headerContent?: React.ReactNode;
29+
/** Optional footer content */
30+
footerContent?: React.ReactNode;
2331
}
2432

25-
export const GettingStartedExpandableGrid: React.FC<GettingStartedExpandableGridProps> = ({
26-
children,
27-
isOpen,
28-
setIsOpen,
29-
setShowState,
30-
}) => {
33+
const TitleContent = () => {
3134
const { t } = useTranslation();
35+
return <>{t('console-shared~Getting started resources')}</>;
36+
};
3237

33-
const title = t('console-shared~Getting started resources');
34-
const titleTooltip = (
38+
const TitlePopoverContent = () => {
39+
const { t } = useTranslation();
40+
41+
return (
3542
<span className="ocs-getting-started-expandable-grid__tooltip">
3643
{t(
3744
'console-shared~Use our collection of resources to help you get started with the Console.',
3845
)}
3946
</span>
4047
);
48+
};
49+
50+
export const GettingStartedExpandableGrid: React.FC<GettingStartedExpandableGridProps> = ({
51+
children,
52+
isOpen,
53+
setIsOpen,
54+
setShowState,
55+
title = <TitleContent />,
56+
titleTooltip = <TitlePopoverContent />,
57+
headerContent,
58+
footerContent,
59+
}) => {
60+
const { t } = useTranslation();
4161

4262
const handleClose = () => {
4363
setShowState(GettingStartedShowState.HIDE);
@@ -75,15 +95,19 @@ export const GettingStartedExpandableGrid: React.FC<GettingStartedExpandableGrid
7595
>
7696
<CardTitle data-test="title" id="expandable-card-title">
7797
{title}{' '}
78-
<Popover bodyContent={titleTooltip} triggerAction="hover">
79-
<span role="button" aria-label={t('console-shared~More info')}>
80-
<OutlinedQuestionCircleIcon />
81-
</span>
82-
</Popover>
98+
{titleTooltip && (
99+
<Popover bodyContent={titleTooltip} triggerAction="hover">
100+
<span role="button" aria-label={t('console-shared~More info')}>
101+
<OutlinedQuestionCircleIcon />
102+
</span>
103+
</Popover>
104+
)}
83105
</CardTitle>
84106
</CardHeader>
85107
<CardExpandableContent>
108+
{headerContent && headerContent}
86109
<CardBody className="ocs-getting-started-expandable-grid__content">{children}</CardBody>
110+
{footerContent && footerContent}
87111
</CardExpandableContent>
88112
</Card>
89113
);

frontend/packages/knative-plugin/src/components/functions/GettingStartedSection.scss

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import * as React from 'react';
2-
import { Card, CardBody, ExpandableSection } from '@patternfly/react-core';
2+
import { CardHeader, Content, ContentVariants, PageSection } from '@patternfly/react-core';
33
import { useTranslation } from 'react-i18next';
4-
import { useUserSettings } from '@console/shared';
4+
import { GettingStartedExpandableGrid, useUserSettings } from '@console/shared';
55
import { FUNCTIONS_GETTING_STARTED_SECTION_USER_SETTING_KEY } from '../../const';
66
import { FunctionsDocsGettingStartedCard } from './FunctionsDocsGettingStartedCard';
77
import { QuickStartGettingStartedCard } from './QuickStartGettingStartedCard';
88
import { SampleGettingStartedCard } from './SamplesGettingStartedCard';
99

10-
import './GettingStartedSection.scss';
11-
1210
export const GettingStartedSection: React.FC = () => {
1311
const { t } = useTranslation();
1412

@@ -18,30 +16,30 @@ export const GettingStartedSection: React.FC = () => {
1816
);
1917

2018
return (
21-
<div className="odc-functions-getting-started-section">
22-
<ExpandableSection
23-
toggleText={t('knative-plugin~Get started with functions')}
24-
onToggle={() => setIsGettingStartedSectionOpen(!isGettingStartedSectionOpen)}
25-
isExpanded={isGettingStartedSectionOpen}
26-
displaySize="lg"
19+
<PageSection className="pf-v6-u-pt-0">
20+
<GettingStartedExpandableGrid
21+
setIsOpen={setIsGettingStartedSectionOpen}
22+
isOpen={isGettingStartedSectionOpen}
23+
title={<>{t('knative-plugin~Get started with functions')}</>}
24+
headerContent={
25+
<CardHeader>
26+
<Content component={ContentVariants.h4}>
27+
{t('knative-plugin~Choose how to create a function from below methods')}
28+
</Content>
29+
</CardHeader>
30+
}
31+
titleTooltip={false}
2732
>
28-
<Card className="odc-functions-getting-started-grid" data-test="getting-started">
29-
<span className="odc-functions-getting-started-grid__title">
30-
{t('knative-plugin~Choose how to create a function from below methods')}
31-
</span>
32-
<CardBody className="odc-functions-getting-started-grid__content">
33-
<SampleGettingStartedCard />
34-
<QuickStartGettingStartedCard
35-
featured={['serverless-functions-using-cli', 'serverless-functions-using-ide']}
36-
title={t('knative-plugin~Create function with guided documentation')}
37-
description={t(
38-
'knative-plugin~Follow guided documentation to create serverless functions.',
39-
)}
40-
/>
41-
<FunctionsDocsGettingStartedCard />
42-
</CardBody>
43-
</Card>
44-
</ExpandableSection>
45-
</div>
33+
<SampleGettingStartedCard />
34+
<QuickStartGettingStartedCard
35+
featured={['serverless-functions-using-cli', 'serverless-functions-using-ide']}
36+
title={t('knative-plugin~Create function with guided documentation')}
37+
description={t(
38+
'knative-plugin~Follow guided documentation to create serverless functions.',
39+
)}
40+
/>
41+
<FunctionsDocsGettingStartedCard />
42+
</GettingStartedExpandableGrid>
43+
</PageSection>
4644
);
4745
};

0 commit comments

Comments
 (0)