Skip to content
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

Export types for all available components #37

Merged
merged 10 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source: react
propComponents: ['Battery']
---

import { Battery } from "@patternfly/react-component-groups";
import Battery from '@patternfly/react-component-groups/dist/dynamic/Battery';


This is the battery component that generates a 'battery' which corresponds to a level 1-4.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Battery } from '@patternfly/react-component-groups';
import Battery from '@patternfly/react-component-groups/dist/dynamic/Battery';

const BatteryCriticalExample: React.FunctionComponent = () => (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Battery } from '@patternfly/react-component-groups';
import Battery from '@patternfly/react-component-groups/dist/dynamic/Battery';

const BatteryDefaultExample: React.FunctionComponent = () => <Battery label="Default" severity={'an unknown value' as any}/>

Check warning on line 4 in packages/module/patternfly-docs/content/extensions/component-groups/examples/Battery/BatteryDefaultExample.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Unexpected any. Specify a different type

export default BatteryDefaultExample;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Battery } from '@patternfly/react-component-groups';
import Battery from '@patternfly/react-component-groups/dist/dynamic/Battery';

const BatteryHighExample: React.FunctionComponent = () => (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Battery } from '@patternfly/react-component-groups';
import Battery from '@patternfly/react-component-groups/dist/dynamic/Battery';

const BatteryLowExample: React.FunctionComponent = () => (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Battery } from '@patternfly/react-component-groups';
import Battery from '@patternfly/react-component-groups/dist/dynamic/Battery';

const BatteryMediumExample: React.FunctionComponent = () => (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import { ActionMenu } from '@patternfly/react-component-groups';
import { Breadcrumbs } from '@patternfly/react-component-groups';
import { BrowserRouter as Router } from 'react-router-dom';
import { CheckCircleIcon } from '@patternfly/react-icons';
import { DetailsPage } from'@patternfly/react-component-groups';
import { DetailsPageHeader } from'@patternfly/react-component-groups';
import { HorizontalNav } from '@patternfly/react-component-groups';
import HorizontalNav from '@patternfly/react-component-groups/dist/dynamic/HorizontalNav';
import DetailsPage from '@patternfly/react-component-groups/dist/dynamic/DetailsPage';
import DetailsPageHeader from'@patternfly/react-component-groups/dist/dynamic/DetailsPageHeader';

## Components Usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { DetailsPage } from '@patternfly/react-component-groups';
import { CheckCircleIcon } from '@patternfly/react-icons';
import DetailsPage from '@patternfly/react-component-groups/dist/dynamic/DetailsPage';

export const BasicExample: React.FunctionComponent = () => (
<Router>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { DetailsPageHeader } from '@patternfly/react-component-groups';
import { CheckCircleIcon } from '@patternfly/react-icons';
import DetailsPageHeader from '@patternfly/react-component-groups/dist/dynamic/DetailsPageHeader';

export const BasicExample: React.FunctionComponent = () => (
<Router>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { HorizontalNav } from '@patternfly/react-component-groups';
import HorizontalNav from '@patternfly/react-component-groups/dist/dynamic/HorizontalNav';

export const BasicExample: React.FunctionComponent = () => (
<HorizontalNav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source: react
propComponents: ['ErrorBoundary']
---

import { ErrorBoundary } from "@patternfly/react-component-groups";
import ErrorBoundary from "@patternfly/react-component-groups/dist/dynamic/ErrorBoundary";

## Component usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ErrorBoundary } from '@patternfly/react-component-groups';
import ErrorBoundary from '@patternfly/react-component-groups/dist/dynamic/ErrorBoundary';

export const BasicExample: React.FunctionComponent = () => {
const Surprise = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ErrorBoundary } from '@patternfly/react-component-groups';
import ErrorBoundary from '@patternfly/react-component-groups/dist/dynamic/ErrorBoundary';

export const BasicExample: React.FunctionComponent = () => (<ErrorBoundary headerTitle={'My app header'}>
<div>My app content</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source: react
propComponents: ['ErrorState']
---

import { ErrorState } from "@patternfly/react-component-groups";
import ErrorState from "@patternfly/react-component-groups/dist/dynamic/ErrorState";

## Component usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import { ErrorState } from '@patternfly/react-component-groups';
import ErrorState from "@patternfly/react-component-groups/dist/dynamic/ErrorState";

export const BasicExample: React.FunctionComponent = () => <ErrorState errorTitle='A Basic Error' errorDescription='The following is an example of a basic error' />;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source: react
propComponents: ['NotAuthorized']
---

import { NotAuthorized } from "@patternfly/react-component-groups";
import NotAuthorized from "@patternfly/react-component-groups/dist/dynamic/NotAuthorized";

## Component usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { NotAuthorized } from '@patternfly/react-component-groups';
import { Button } from '@patternfly/react-core';
import NotAuthorized from "@patternfly/react-component-groups/dist/dynamic/NotAuthorized";

export const BasicExample: React.FunctionComponent = () => {
const actions = [
Expand Down
30 changes: 0 additions & 30 deletions packages/module/src/Battery/Batery.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import React from 'react';
import { render } from '@testing-library/react';
import Battery, { BatterySeverity } from './Battery';
import CriticalBattery from './CriticalBattery';
import HighBattery from './HighBattery';
import MediumBattery from './MediumBattery';
import LowBattery from './LowBattery';
import NullBattery from './NullBattery';

describe('Battery component', () => {
jest.spyOn(global.console, 'error');
Expand Down Expand Up @@ -52,29 +47,4 @@ describe('Battery component', () => {
expect(container).toMatchSnapshot();
});
});

test(`CriticalBattery`, () => {
const { container } = render(<CriticalBattery />);
expect(container).toMatchSnapshot();
});

test(`HighBattery`, () => {
const { container } = render(<HighBattery />);
expect(container).toMatchSnapshot();
});

test(`MediumBattery`, () => {
const { container } = render(<MediumBattery />);
expect(container).toMatchSnapshot();
});

test(`LowBattery`, () => {
const { container } = render(<LowBattery />);
expect(container).toMatchSnapshot();
});

test(`NullBattery`, () => {
const { container } = render(<NullBattery />);
expect(container).toMatchSnapshot();
});
});
15 changes: 5 additions & 10 deletions packages/module/src/Battery/Battery.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React from 'react';
import classNames from 'classnames';
import CriticalBattery from './CriticalBattery';
import HighBattery from './HighBattery';
import MediumBattery from './MediumBattery';
import LowBattery from './LowBattery';
import NullBattery from './NullBattery';
import { createUseStyles } from 'react-jss'

const batteryDefault = {
Expand Down Expand Up @@ -93,23 +88,23 @@ const Battery: React.FunctionComponent<BatteryProps> = ({ severity, label, label
switch (severity) {
case 'critical':
case 4:
return <CriticalBattery />;
return <path d="M 99.168858,143.38516 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698858,11.2 z M 99.168857,235.25069 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z" />;
case 'high':
case 'error':
case 3:
return <HighBattery />;
return <path d="M 99.168857,235.25069 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z" />;
case 'medium':
case 'warn':
case 2:
return <MediumBattery />;
return <path d="M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z" />;
case 'low':
case 'info':
case 1:
return <LowBattery />;
return <path d="M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z" />;
default:
// eslint-disable-next-line
console.error('Warning: Unsupported value presented to battery component');
return <NullBattery />;
return <path d="M 99.168858,143.38516 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698858,11.2 z M 99.168857,235.25069 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z" />;
}
};

Expand Down
10 changes: 0 additions & 10 deletions packages/module/src/Battery/CriticalBattery.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions packages/module/src/Battery/HighBattery.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions packages/module/src/Battery/LowBattery.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions packages/module/src/Battery/MediumBattery.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions packages/module/src/Battery/NullBattery.tsx

This file was deleted.

40 changes: 0 additions & 40 deletions packages/module/src/Battery/__snapshots__/Batery.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,6 @@ exports[`Battery component API should hide label 1`] = `
</div>
`;

exports[`Battery component CriticalBattery 1`] = `
<div>
<path
d="M 99.168858,143.38516 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698858,11.2 z M 99.168857,235.25069 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z"
/>
</div>
`;

exports[`Battery component HighBattery 1`] = `
<div>
<path
d="M 99.168857,235.25069 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z"
/>
</div>
`;

exports[`Battery component LowBattery 1`] = `
<div>
<path
d="M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z"
/>
</div>
`;

exports[`Battery component MediumBattery 1`] = `
<div>
<path
d="M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z"
/>
</div>
`;

exports[`Battery component NullBattery 1`] = `
<div>
<path
d="M 99.168858,143.38516 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698858,11.2 z M 99.168857,235.25069 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z M 99.168857,327.14542 H 351.33914 c 5.33437,0 9.69886,-5.04 9.69886,-11.19999 v -28 c 0,-6.16001 -4.36449,-11.2 -9.69886,-11.2 H 99.168857 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.19999 9.698857,11.19999 z M 99.168993,419.0375 H 351.33927 c 5.33437,0 9.69886,-5.04 9.69886,-11.2 v -28 c 0,-6.16 -4.36449,-11.2 -9.69886,-11.2 H 99.168993 c -5.334371,0 -9.698857,5.04 -9.698857,11.2 v 28 c 0,6.16 4.364486,11.2 9.698857,11.2 z"
/>
</div>
`;

exports[`Battery component should render correctly CriticalBattery - 4 1`] = `
<div>
<i
Expand Down
7 changes: 1 addition & 6 deletions packages/module/src/Battery/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
export { default } from './Battery';
export { default as Battery } from './Battery';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to test the imports in a test environment. We don't want to loose any of these references. We are only looking for the extra types reference.

Copy link
Collaborator Author

@fhlavac fhlavac Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hyperkid123 do you think it is safer not to remove these explicit exports? I can add them back, maybe it's better to keep them explicitly listed. When testing that, haven't found any issues

export { default as CriticalBattery } from './CriticalBattery';
export { default as HighBattery } from './HighBattery';
export { default as MediumBattery } from './MediumBattery';
export { default as LowBattery } from './LowBattery';
export { default as NullBattery } from './NullBattery';
export * from './Battery';
Loading
Loading