@patternfly/quickstarts 5.2.0-prerelease.2 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import { QuickStart, QuickStartStatus } from '../utils/quick-start-types';
3
+ import { QuickstartAction } from './QuickStartTileHeader';
3
4
  import './QuickStartTile.scss';
4
5
  interface QuickStartTileProps {
5
6
  quickStart: QuickStart;
6
7
  status: QuickStartStatus;
7
8
  isActive: boolean;
8
9
  onClick?: () => void;
10
+ /** Action config for button rendered next to title */
11
+ action?: QuickstartAction;
9
12
  }
10
13
  declare const QuickStartTile: React.FC<QuickStartTileProps>;
11
14
  export default QuickStartTile;
@@ -1,12 +1,24 @@
1
1
  import './QuickStartTileHeader.scss';
2
2
  import * as React from 'react';
3
+ import { ButtonProps } from '@patternfly/react-core';
3
4
  import { QuickStartType } from '../utils/quick-start-types';
5
+ export interface QuickstartAction {
6
+ /** Screen reader aria label. */
7
+ 'aria-label': string;
8
+ /** Icon to be rendered as a plain button, by default Bookmark outlined will be used. */
9
+ icon?: React.ComponentType<unknown>;
10
+ /** Callback with synthetic event parameter. */
11
+ onClick?: (e: React.SyntheticEvent) => void;
12
+ /** Additional button props to be rendered as extra props. */
13
+ buttonProps?: ButtonProps;
14
+ }
4
15
  interface QuickStartTileHeaderProps {
5
16
  status: string;
6
17
  duration: number;
7
18
  name: string;
8
19
  type?: QuickStartType;
9
20
  quickStartId?: string;
21
+ action?: QuickstartAction;
10
22
  }
11
23
  declare const QuickStartTileHeader: React.FC<QuickStartTileHeaderProps>;
12
24
  export default QuickStartTileHeader;
@@ -4,6 +4,6 @@ export { default as QuickStartTile } from './QuickStartTile';
4
4
  export { default as QuickStartTileDescription } from './QuickStartTileDescription';
5
5
  export { default as QuickStartTileFooter } from './QuickStartTileFooter';
6
6
  export { default as QuickStartTileFooterExternal } from './QuickStartTileFooterExternal';
7
- export { default as QuickStartTileHeader } from './QuickStartTileHeader';
7
+ export { default as QuickStartTileHeader, QuickstartAction } from './QuickStartTileHeader';
8
8
  export * from './Toolbar/QuickStartCatalogFilterItems';
9
9
  export * from './Catalog';
package/dist/index.es.js CHANGED
@@ -21,6 +21,7 @@ import '@patternfly/react-tokens/dist/esm/global_palette_blue_300';
21
21
  import okColor from '@patternfly/react-tokens/dist/esm/global_palette_green_500';
22
22
  import ExternalLinkAltIcon from '@patternfly/react-icons/dist/js/icons/external-link-alt-icon';
23
23
  import OutlinedClockIcon from '@patternfly/react-icons/dist/js/icons/outlined-clock-icon';
24
+ import OutlinedBookmarkIcon from '@patternfly/react-icons/dist/js/icons/outlined-bookmark-icon';
24
25
  import ArrowRightIcon from '@patternfly/react-icons/dist/js/icons/arrow-right-icon';
25
26
  import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
26
27
 
@@ -1667,23 +1668,26 @@ const statusColorMap = {
1667
1668
  [QuickStartStatus.IN_PROGRESS]: 'purple',
1668
1669
  [QuickStartStatus.NOT_STARTED]: 'grey',
1669
1670
  };
1670
- const QuickStartTileHeader = ({ status, duration, name, type, quickStartId, }) => {
1671
+ const QuickStartTileHeader = ({ status, duration, name, type, quickStartId, action, }) => {
1671
1672
  const { getResource } = React.useContext(QuickStartContext);
1672
1673
  const statusLocaleMap = {
1673
1674
  [QuickStartStatus.COMPLETE]: getResource('Complete'),
1674
1675
  [QuickStartStatus.IN_PROGRESS]: getResource('In progress'),
1675
1676
  [QuickStartStatus.NOT_STARTED]: getResource('Not started'),
1676
1677
  };
1678
+ const ActionIcon = (action === null || action === void 0 ? void 0 : action.icon) || OutlinedBookmarkIcon;
1677
1679
  return (React.createElement("div", { className: "pfext-quick-start-tile-header" },
1678
- React.createElement(Title, { headingLevel: "h3", "data-test": "title", id: quickStartId },
1679
- React.createElement(QuickStartMarkdownView, { content: name })),
1680
+ React.createElement(Flex, { flexWrap: { default: 'nowrap' } },
1681
+ React.createElement(Title, { headingLevel: "h3", "data-test": "title", id: quickStartId },
1682
+ React.createElement(QuickStartMarkdownView, { content: name })),
1683
+ action && (React.createElement(Button, Object.assign({ "aria-label": action['aria-label'], icon: React.createElement(ActionIcon, null), variant: "plain", onClick: action.onClick }, action.buttonProps)))),
1680
1684
  React.createElement("div", { className: "pfext-quick-start-tile-header__status" },
1681
1685
  type && (React.createElement(Label, { className: "pfext-quick-start-tile-header--margin", color: type.color }, type.text)),
1682
1686
  duration && (React.createElement(Label, { variant: "outline", "data-test": "duration", icon: React.createElement(OutlinedClockIcon, null), className: "pfext-quick-start-tile-header--margin" }, getResource('{{duration, number}} minutes', duration).replace('{{duration, number}}', duration))),
1683
1687
  status !== QuickStartStatus.NOT_STARTED && (React.createElement(Label, { variant: "outline", color: statusColorMap[status], icon: React.createElement(StatusIcon, { status: status }), "data-test": "status" }, statusLocaleMap[status])))));
1684
1688
  };
1685
1689
 
1686
- const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, }) => {
1690
+ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, action, }) => {
1687
1691
  const { metadata: { name: id }, spec: { icon, tasks, displayName, description, durationMinutes, prerequisites, link, type }, } = quickStart;
1688
1692
  const { setActiveQuickStart, footer } = React.useContext(QuickStartContext);
1689
1693
  const ref = React.useRef(null);
@@ -1706,26 +1710,31 @@ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, })
1706
1710
  const handleClick = (e) => {
1707
1711
  var _a;
1708
1712
  if ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) {
1709
- if (link) {
1710
- window.open(link.href);
1711
- }
1712
- else {
1713
+ if (!link) {
1713
1714
  setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
1714
1715
  }
1715
1716
  onClick();
1716
1717
  }
1717
1718
  };
1718
- return (React.createElement("div", { ref: ref },
1719
- React.createElement(CatalogTile, { id: id + '-catalog-tile', style: {
1719
+ const linkProps = link
1720
+ ? {
1721
+ href: link.href,
1722
+ target: '_blank',
1723
+ rel: 'noreferrer',
1724
+ }
1725
+ : {};
1726
+ return (React.createElement("div", { ref: ref, onClick: handleClick },
1727
+ React.createElement(CatalogTile, Object.assign({ id: id + '-catalog-tile', style: {
1720
1728
  cursor: 'pointer',
1721
- }, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id }), onClick: handleClick, onKeyDown: (event) => {
1729
+ }, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id, action: action }), onKeyDown: (event) => {
1722
1730
  if (event.key === 'Enter' || event.key === ' ') {
1723
1731
  setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
1724
1732
  onClick();
1725
1733
  }
1726
- },
1727
- // https://github.com/patternfly/patternfly-react/issues/7039
1728
- href: link === null || link === void 0 ? void 0 : link.href, "data-test": `tile ${id}`, description: React.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent, tabIndex: 0 })));
1734
+ } }, linkProps, { "data-test": `tile ${id}`, description: React.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent, tabIndex: 0,
1735
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1736
+ // @ts-ignore-next-line
1737
+ isSelectableRaised: true }))));
1729
1738
  };
1730
1739
 
1731
1740
  const QuickStartCatalog = ({ quickStarts }) => {