Skip to content

Commit

Permalink
Clean Battery
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac committed Sep 12, 2023
1 parent 1937ec3 commit 32e9fda
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 102 deletions.
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,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 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

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 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
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();
});
});
17 changes: 6 additions & 11 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 @@ -80,7 +75,7 @@ export interface BatteryProps extends React.DetailedHTMLProps<React.HTMLAttribut
className?: string;
}

export const Battery: React.FunctionComponent<BatteryProps> = ({ severity, label, labelHidden, className, ...props }: BatteryProps) => {
const Battery: React.FunctionComponent<BatteryProps> = ({ severity, label, labelHidden, className, ...props }: BatteryProps) => {
const classes = useStyles();
const batteryClasses = classNames(classes.battery, classes[`battery-${severity}`], className);

Expand All @@ -93,23 +88,23 @@ export const Battery: React.FunctionComponent<BatteryProps> = ({ severity, 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.

5 changes: 0 additions & 5 deletions packages/module/src/Battery/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
export * from './Battery';
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';

0 comments on commit 32e9fda

Please sign in to comment.