diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..7bd591e7bce --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +package.json +packages/**/dist/**/*.js +packages/**/.cache/**/*.js +scripts/generators/**/templates/**/*.js \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000000..02654395168 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "none", + "useTabs": false, + "printWidth": 120 +} diff --git a/package.json b/package.json index 5f3209d80e7..faabc32aad2 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "minimist": "^1.2.0", "mutation-observer": "^1.0.3", "plop": "^2.0.0", + "prettier": "^1.18.2", "react": "^16.4.0", "react-dom": "^16.4.0", "sass-loader": "^6.0.6", @@ -71,6 +72,8 @@ "stylelint-config-standard": "^18.2.0", "ts-jest": "24.1.0", "tslint": "^5.12.0", + "tslint-config-prettier": "^1.18.0", + "tslint-plugin-prettier": "^2.0.1", "tslint-react": "^3.6.0" }, "scripts": { @@ -88,6 +91,7 @@ "lint:style": "stylelint \"**/sass/**/*.scss\" \"!**/dist/**/*.scss\"", "lint:ts": "node --max-old-space-size=4096 node_modules/.bin/tslint --project ./tslint.config.json --config tslint.json", "lint:versions": "node ./packages/patternfly-4/verifyCoreVersions.js", + "prettier": "node node_modules/.bin/prettier --write \"storybook/**/*.{js,ts,tsx}\" \"packages/**/*.{js,ts,tsx}\" \"scripts/**/*.{js,ts,tsx}\"", "start": "yarn start:pf3", "start:cypress": "lerna run cypress:open", "start:demo-app": "lerna run start:demo-app --stream", diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTile/CatalogTile.js b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTile/CatalogTile.js index dd9c49f90f5..b432c60edfd 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTile/CatalogTile.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTile/CatalogTile.js @@ -42,7 +42,7 @@ class CatalogTile extends React.Component { } this.descFullHeight = ref.clientHeight; - } + }; handleDescriptionSpanRef = ref => { if (!ref) { @@ -50,7 +50,7 @@ class CatalogTile extends React.Component { } this.descLineHeight = parseInt(window.getComputedStyle(ref).getPropertyValue('line-height'), 10); - } + }; handleClick = e => { const { onClick, href } = this.props; @@ -61,7 +61,7 @@ class CatalogTile extends React.Component { if (onClick) { onClick(e); } - } + }; renderBadges = badges => { if (!badges || !badges.length) { @@ -75,7 +75,7 @@ class CatalogTile extends React.Component { ))} ); - } + }; render() { const { diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js index 4fdc4776a43..d47f4536712 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/CatalogTileViewCategory.js @@ -55,14 +55,14 @@ class CatalogTileViewCategory extends React.Component { const rightSpacerWidth = this.categoryContainer.clientWidth % 235; this.setState({ numShown, rightSpacerWidth }); } - } + }; handleRef = ref => { if (!ref) { return; } this.categoryContainer = ref; - } + }; render() { const { children, className, title, totalItems, viewAllText, viewAll, onViewAll, ...props } = this.props; diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/__mocks__/mockCatalogTileViewExample.js b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/__mocks__/mockCatalogTileViewExample.js index b6302002d32..bfae10ba65f 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/__mocks__/mockCatalogTileViewExample.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/CatalogTileView/__mocks__/mockCatalogTileViewExample.js @@ -17,7 +17,7 @@ class MockCatalogTileViewExample extends React.Component { onViewAll = id => { this.setState({ showAll: id }); - } + }; getBadges = item => { const badges = []; @@ -39,13 +39,13 @@ class MockCatalogTileViewExample extends React.Component { } return badges; - } + }; renderEmptyState = category => ( There are no items in this category. - ) + ); renderCategory = category => { const { showAll } = this.state; @@ -80,7 +80,7 @@ class MockCatalogTileViewExample extends React.Component { } return null; - } + }; render() { const { showAll } = this.state; diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/DiffView/DiffView.js b/packages/patternfly-3/patternfly-react-extensions/src/components/DiffView/DiffView.js index 22c63712200..e0c8e75b53d 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/DiffView/DiffView.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/DiffView/DiffView.js @@ -34,7 +34,9 @@ const DiffView = ({ const files = parseDiff(gitDiff); const hunk = files[0].hunks; - if (hunk.length === 0) { return emptyState; } + if (hunk.length === 0) { + return emptyState; + } return hunk && ; } @@ -53,7 +55,9 @@ const DiffView = ({ /> ); - if (patch === '') { return emptyState; } + if (patch === '') { + return emptyState; + } return
{files.map(renderFile)}
; }; diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/FilterSidePanel/_mocks_/mockFilterSidePanelExample.js b/packages/patternfly-3/patternfly-react-extensions/src/components/FilterSidePanel/_mocks_/mockFilterSidePanelExample.js index e5bf5830f3a..c65f96ecaba 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/FilterSidePanel/_mocks_/mockFilterSidePanelExample.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/FilterSidePanel/_mocks_/mockFilterSidePanelExample.js @@ -52,13 +52,13 @@ class MockFilterSidePanelExample extends React.Component { const showAllCategories = { ...this.state.showAllCategories }; showAllCategories[id] = !showAllCategories[id]; this.setState({ showAllCategories }); - } + }; onFilterChange = (id, value) => { const activeFilters = { ...this.state.activeFilters }; activeFilters[id] = value; this.setState({ activeFilters }); - } + }; getStars = count => { const stars = []; @@ -73,7 +73,7 @@ class MockFilterSidePanelExample extends React.Component { {stars} ); - } + }; render() { const { activeFilters, showAllCategories } = this.state; @@ -259,7 +259,7 @@ class MockFilterSidePanelExample extends React.Component { checked={activeFilters.paymentDinersClub} onChange={e => this.onFilterChange('paymentDinersClub', e.target.checked)} > - {'Diner\'s Club'} + {"Diner's Club"} this.onFilterChange('mileage10', e.target.checked)} - >{'< 20'} + > + {'< 20'} + { active: selectedItem.id === item.id }; - if (item.disabled) { return { ...itemProps, disabled: true }; } + if (item.disabled) { + return { ...itemProps, disabled: true }; + } return { ...itemProps, onClick: e => onItemClick({ e, id: item.id, name: item.name }) }; }; diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/Select/SelectInput.js b/packages/patternfly-3/patternfly-react-extensions/src/components/Select/SelectInput.js index 31583d79100..de769f4bd4e 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/Select/SelectInput.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/Select/SelectInput.js @@ -11,7 +11,9 @@ class SelectInput extends React.Component { } componentDidMount() { - if (this.props.focus) { this.searchInput.current.focus(); } + if (this.props.focus) { + this.searchInput.current.focus(); + } } render() { diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/Select/StatefulWrapperSelect.js b/packages/patternfly-3/patternfly-react-extensions/src/components/Select/StatefulWrapperSelect.js index c805da85a36..b33652b69e4 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/Select/StatefulWrapperSelect.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/Select/StatefulWrapperSelect.js @@ -20,10 +20,12 @@ class StatefulWrapperSelect extends Component { const { options } = this.state; const results = []; options.forEach(opt => { - if (opt.name.includes(search)) { results.push(opt); } + if (opt.name.includes(search)) { + results.push(opt); + } }); return results; - } + }; onSearch = e => { e.persist(); @@ -43,17 +45,21 @@ class StatefulWrapperSelect extends Component { }, 700); } ); - } else { this.setState({ isSearching: false, searchValue: '' }); } - } + } else { + this.setState({ isSearching: false, searchValue: '' }); + } + }; onClear = () => this.setState({ searchValue: '', isSearching: false }); onItemClick = host => - this.setState({ selected: { id: host.id, name: host.name }, open: false, isSearching: false, searchValue: '' }) + this.setState({ selected: { id: host.id, name: host.name }, open: false, isSearching: false, searchValue: '' }); handleClickOutside = () => { - if (this.state.open === true) { this.onToggle(); } - } + if (this.state.open === true) { + this.onToggle(); + } + }; render() { const { open, isSearching, searchValue, selected, isLoading, options, matched } = this.state; diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockTableGridExample.js b/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockTableGridExample.js index 9def985b028..4ebe2ff94d0 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockTableGridExample.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockTableGridExample.js @@ -56,11 +56,11 @@ class MockTableGridExample extends React.Component { }); this.setState({ items, sortField: id, isAscending: updateAscending }); - } + }; onSelect = (item, field) => { this.setState({ selectedItem: item, selectedField: field }); - } + }; toggleSelection = item => { const { selectedItems } = this.state; @@ -73,12 +73,12 @@ class MockTableGridExample extends React.Component { newSelections = [...selectedItems, item]; } this.setState({ selectedItems: newSelections }); - } + }; toggleAllSelections = () => { const { items, selectedItems } = this.state; this.setState({ selectedItems: selectedItems.length > 0 ? [] : [...items] }); - } + }; renderItemRow = (item, index) => { const { selectType } = this.props; @@ -121,7 +121,7 @@ class MockTableGridExample extends React.Component { ); - } + }; render() { const { items, selectedItems, sortField, isAscending } = this.state; diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockVirtualTableGridExample.js b/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockVirtualTableGridExample.js index 00356b34547..260bdaca77c 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockVirtualTableGridExample.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/TableGrid/_mocks_/mockVirtualTableGridExample.js @@ -56,11 +56,11 @@ class MockVirtualTableGridExample extends React.Component { }); this.setState({ items, sortField: id, isAscending: updateAscending }); - } + }; onSelect = (item, field) => { this.setState({ selectedItem: item, selectedField: field }); - } + }; toggleSelection = item => { const { selectedItems } = this.state; @@ -73,12 +73,12 @@ class MockVirtualTableGridExample extends React.Component { newSelections = [...selectedItems, item]; } this.setState({ selectedItems: newSelections }); - } + }; toggleAllSelections = () => { const { items, selectedItems } = this.state; this.setState({ selectedItems: selectedItems.length > 0 ? [] : [...items] }); - } + }; ItemHeader = tableData => { const { numItems, selectType, selectedItems, sortField, isAscending } = tableData; @@ -134,7 +134,7 @@ class MockVirtualTableGridExample extends React.Component { ); - } + }; ItemRow = rowProps => { const { obj, tableData, index } = rowProps; @@ -177,7 +177,7 @@ class MockVirtualTableGridExample extends React.Component { ); - } + }; render() { const { items, selectedItem, selectedItems, selectedField, sortField, isAscending } = this.state; diff --git a/packages/patternfly-3/patternfly-react-extensions/src/components/VerticalTabs/_mocks_/mockVerticalTabsExample.js b/packages/patternfly-3/patternfly-react-extensions/src/components/VerticalTabs/_mocks_/mockVerticalTabsExample.js index 48793ef91ba..83caaaec106 100644 --- a/packages/patternfly-3/patternfly-react-extensions/src/components/VerticalTabs/_mocks_/mockVerticalTabsExample.js +++ b/packages/patternfly-3/patternfly-react-extensions/src/components/VerticalTabs/_mocks_/mockVerticalTabsExample.js @@ -9,7 +9,7 @@ class MockVerticalTabsExample extends React.Component { onActivateTab = id => { this.setState({ activeTabId: id }); - } + }; render() { const { restrictTabs, wrapStyle } = this.props; diff --git a/packages/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/TreeViewExample.js b/packages/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/TreeViewExample.js index a14b7ef46ca..e0c1a82d041 100644 --- a/packages/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/TreeViewExample.js +++ b/packages/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/TreeViewExample.js @@ -69,7 +69,7 @@ class TreeViewExample extends React.Component { } } this.setState({ tree }); - } + }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/common/Timer.js b/packages/patternfly-3/patternfly-react/src/common/Timer.js index 5deb14093de..68cd85b6dab 100644 --- a/packages/patternfly-3/patternfly-react/src/common/Timer.js +++ b/packages/patternfly-3/patternfly-react/src/common/Timer.js @@ -11,8 +11,12 @@ class Timer { // startTimer optionally takes a new func and delay so the timer instance can be reused. startTimer(func, delay = -1) { this.clearTimer(); - if (func) { this.execute = func; } - if (delay >= 0) { this.delay = delay; } + if (func) { + this.execute = func; + } + if (delay >= 0) { + this.delay = delay; + } this.timer = setTimeout(this.execute, this.delay); } clearTimer() { diff --git a/packages/patternfly-3/patternfly-react/src/common/closestPolyfill.js b/packages/patternfly-3/patternfly-react/src/common/closestPolyfill.js index b9ed199757f..eb71838acf0 100644 --- a/packages/patternfly-3/patternfly-react/src/common/closestPolyfill.js +++ b/packages/patternfly-3/patternfly-react/src/common/closestPolyfill.js @@ -9,7 +9,9 @@ export function closest(selector) { let el = this; if (document.documentElement.contains(el)) { while (el && el.nodeType === 1) { - if (el.matches(selector)) { return el; } + if (el.matches(selector)) { + return el; + } el = el.parentElement || el.parentNode; } } diff --git a/packages/patternfly-3/patternfly-react/src/common/controlled.js b/packages/patternfly-3/patternfly-react/src/common/controlled.js index cd860573c02..ea2a8e94879 100644 --- a/packages/patternfly-3/patternfly-react/src/common/controlled.js +++ b/packages/patternfly-3/patternfly-react/src/common/controlled.js @@ -49,21 +49,21 @@ const controlled = ({ types, defaults = {}, persist }) => WrappedComponent => { setControlledState = updater => { this.setState(updater); - } + }; loadPersistent = () => { if (persist && persist.length > 0) { const fromPersisted = window && window.sessionStorage && window.sessionStorage.getItem(this.sessionKey()); fromPersisted && this.setState(JSON.parse(fromPersisted)); } - } + }; savePersistent = () => { if (persist && persist.length > 0) { const toPersist = selectKeys(this.state, persist); window && window.sessionStorage && window.sessionStorage.setItem(this.sessionKey(), JSON.stringify(toPersist)); } - } + }; sessionKey = () => this.props.sessionKey || JSON.stringify(persist); diff --git a/packages/patternfly-3/patternfly-react/src/components/ApplicationLauncher/Wrappers/StatefulApplicationLauncherWrapper.js b/packages/patternfly-3/patternfly-react/src/components/ApplicationLauncher/Wrappers/StatefulApplicationLauncherWrapper.js index 8cf7fefa1c4..6264ec956ca 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ApplicationLauncher/Wrappers/StatefulApplicationLauncherWrapper.js +++ b/packages/patternfly-3/patternfly-react/src/components/ApplicationLauncher/Wrappers/StatefulApplicationLauncherWrapper.js @@ -14,11 +14,13 @@ class StatefulApplicationLauncherWrapper extends React.Component { toggleLauncher = () => { this.setState({ open: !this.state.open }); - } + }; handleClickOutside = () => { - if (this.state.open === true) { this.toggleLauncher(); } - } + if (this.state.open === true) { + this.toggleLauncher(); + } + }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/BreadcrumbSwitcher/BreadcrumbSwitcherHelper.js b/packages/patternfly-3/patternfly-react/src/components/BreadcrumbSwitcher/BreadcrumbSwitcherHelper.js index cbd64cdd0ec..ad13a45e5e3 100644 --- a/packages/patternfly-3/patternfly-react/src/components/BreadcrumbSwitcher/BreadcrumbSwitcherHelper.js +++ b/packages/patternfly-3/patternfly-react/src/components/BreadcrumbSwitcher/BreadcrumbSwitcherHelper.js @@ -3,7 +3,9 @@ * @param {String} path - the path that should be removed of slashes */ export const removeLastSlashFromPath = path => { - if (!path || path.length < 2) { return path; } + if (!path || path.length < 2) { + return path; + } const lastCharIndex = path.length - 1; return path[lastCharIndex] === '/' ? path.slice(0, -1) : path; }; diff --git a/packages/patternfly-3/patternfly-react/src/components/Button/Button.stories.js b/packages/patternfly-3/patternfly-react/src/components/Button/Button.stories.js index fbed945aa4c..7cd28286017 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Button/Button.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/Button/Button.stories.js @@ -217,7 +217,9 @@ stories.add( const bsStyle = select('Style', BUTTON_BS_STYLES, 'default'); const bsSize = select('Size', [undefined, 'xsmall', 'small', 'large']); const props = { bsStyle, title: bsStyle, id: 'dropdown-example' }; - if (bsSize) { props.bsSize = bsSize; } + if (bsSize) { + props.bsSize = bsSize; + } const story = ( @@ -245,7 +247,9 @@ stories.add( const bsSize = select('Size', [undefined, 'xsmall', 'small', 'large']); const props = { bsStyle, title: bsStyle, id: 'dropdown-example' }; - if (bsSize) { props.bsSize = bsSize; } + if (bsSize) { + props.bsSize = bsSize; + } const story = ( diff --git a/packages/patternfly-3/patternfly-react/src/components/Chart/DonutChart.js b/packages/patternfly-3/patternfly-react/src/components/Chart/DonutChart.js index 175f75acb83..bb58239c296 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Chart/DonutChart.js +++ b/packages/patternfly-3/patternfly-react/src/components/Chart/DonutChart.js @@ -11,7 +11,9 @@ const colIndexOfMaxValue = columns => columns.reduce((iMax, x, i, arr) => (x[1] const truncateNum = (num, precision) => { const pointNotation = num.toString().split('.'); - if (pointNotation.length === 1) { return pointNotation[0]; } + if (pointNotation.length === 1) { + return pointNotation[0]; + } return `${pointNotation[0]}.${pointNotation[1].slice(0, precision)}`; }; diff --git a/packages/patternfly-3/patternfly-react/src/components/ClassificationBanner/ClassificationBanner.stories.js b/packages/patternfly-3/patternfly-react/src/components/ClassificationBanner/ClassificationBanner.stories.js index 4d95d0c5932..24d1c8c3e70 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ClassificationBanner/ClassificationBanner.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/ClassificationBanner/ClassificationBanner.stories.js @@ -41,7 +41,7 @@ class ClassificationBannerStoryWrapper extends React.Component { this.setState({ closed: false }); - } + }; render() { const bottomBanner = boolean('Show Bottom Banner', true); diff --git a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateComponents/TodayButton.js b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateComponents/TodayButton.js index 324e2ec3832..274464966ca 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateComponents/TodayButton.js +++ b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateComponents/TodayButton.js @@ -4,7 +4,9 @@ import PropTypes from 'prop-types'; class TodayButton extends React.Component { setToday = () => { const { setSelected } = this.props; - if (setSelected) setSelected(new Date()); + if (setSelected) { + setSelected(new Date()); + } }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateTimePicker.js b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateTimePicker.js index 9e3db6604df..ffa1ed2bbe6 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateTimePicker.js +++ b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/DateTimePicker.js @@ -19,19 +19,13 @@ class DateTimePicker extends React.Component { formatDate = date => { const { locale } = this.props; - const options = [ - { year: 'numeric', month: 'numeric', day: 'numeric' }, - { hour: '2-digit', minute: '2-digit' } - ]; + const options = [{ year: 'numeric', month: 'numeric', day: 'numeric' }, { hour: '2-digit', minute: '2-digit' }]; if (Date.parse(date)) { const parsedValue = new Date(date); - return `${parsedValue.toLocaleString( - locale, - options[0] - )} ${parsedValue.toLocaleString(locale, options[1])}`; + return `${parsedValue.toLocaleString(locale, options[0])} ${parsedValue.toLocaleString(locale, options[1])}`; } return date; - } + }; setSelected = date => { let newDate = new Date(this.state.value); @@ -44,16 +38,13 @@ class DateTimePicker extends React.Component { typeOfDateInput: 'M', isTimeTableOpen: false }); - } + }; render() { const { locale, weekStartsOn, id, placement } = this.props; const { value, typeOfDateInput, isTimeTableOpen, hiddenValue } = this.state; const popover = ( - +
this.setState({ tmpValue: e.target.value })} onBlur={e => this.setSelected(e.target.value)} /> - + - this.setState({ tmpValue: formatTime(value, locale) }) - } + onClick={() => this.setState({ tmpValue: formatTime(value, locale) })} > diff --git a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeClock.js b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeClock.js index a76ee5a31c9..628f670e50c 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeClock.js +++ b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeClock.js @@ -20,7 +20,7 @@ class PickTimeClock extends React.Component { time.setMinutes(time.getMinutes() + amount); } setSelected(time); - } + }; toggleAMPM = () => { const { time, setSelected } = this.props; if (this.state.ampm === AM) { @@ -31,7 +31,7 @@ class PickTimeClock extends React.Component { this.setState({ ampm: AM }); } setSelected(time); - } + }; render() { const { time, toggleTimeTable } = this.props; const minutes = time.getMinutes(); diff --git a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeTable.js b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeTable.js index dbbe87af7d8..ac7960eb89a 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeTable.js +++ b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/PickTimeTable.js @@ -8,13 +8,14 @@ class PickTimeTable extends React.Component { const { time, setSelected, toggleTimeTable } = this.props; const hours = time.getHours(); newTime = parseInt(newTime, 10); - if (type === MINUTE) { time.setMinutes(newTime); } - else if (type === HOUR) { + if (type === MINUTE) { + time.setMinutes(newTime); + } else if (type === HOUR) { time.setHours(hours < 12 ? newTime % 12 : (newTime % 12) + 12); } setSelected(time); toggleTimeTable(); - } + }; render() { const hoursArray = [['12', '01', '02', '03'], ['04', '05', '06', '07'], ['08', '09', '10', '11']]; const minutesArray = [['00', '05', '10', '15'], ['20', '25', '30', '35'], ['40', '45', '50', '55']]; diff --git a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/TimeInput.js b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/TimeInput.js index 457c17c6972..3c2f482acac 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/TimeInput.js +++ b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeComponents/TimeInput.js @@ -28,7 +28,7 @@ class TimeInput extends React.Component { typeOfTimeInput: type, isTimeTableOpen: !this.state.isTimeTableOpen }); - } + }; render() { const { time, setSelected, className } = this.props; const { typeOfTimeInput, isTimeTableOpen } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeHelpers.js b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeHelpers.js index 9ea09d899e5..a6f3a001585 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeHelpers.js +++ b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimeHelpers.js @@ -1,5 +1,7 @@ export const getDateFromTime = time => { - if (time === '') { return time; } + if (time === '') { + return time; + } if (Date.parse(time)) { return new Date(time); } else if (Date.parse(`1/1/1 ${time}`)) { diff --git a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimePicker.js b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimePicker.js index 808524eddf6..2976ec32543 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimePicker.js +++ b/packages/patternfly-3/patternfly-react/src/components/DateTimePicker/TimePicker.js @@ -12,9 +12,12 @@ class TimePicker extends React.Component { setSelected = time => { const newTime = getDateFromTime(time); - if (newTime) { this.setState({ value: newTime, tmpValue: formatTime(newTime, this.props.locale) }); } - else { this.setState({ tmpValue: formatTime(newTime, this.props.locale) }); } - } + if (newTime) { + this.setState({ value: newTime, tmpValue: formatTime(newTime, this.props.locale) }); + } else { + this.setState({ tmpValue: formatTime(newTime, this.props.locale) }); + } + }; render() { const { value } = this.state; const { locale, placement, id } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualList.js b/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualList.js index 20837676392..a8573833701 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualList.js +++ b/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualList.js @@ -67,7 +67,7 @@ class DualList extends React.Component { selectCount, isMainChecked }); - } + }; onMainCheckboxChange = ({ target: { @@ -94,7 +94,7 @@ class DualList extends React.Component { items, selectCount }); - } + }; onSortClick = ({ target: { @@ -110,13 +110,13 @@ class DualList extends React.Component { items: itemsReversed, isSortAsc: !isSortAsc }); - } + }; onFilterChange = event => { /** https://reactjs.org/docs/events.html#event-pooling */ event.persist(); this.onFilterChangeDebounced(event); - } + }; emitFilterChange = ({ target: { @@ -138,7 +138,7 @@ class DualList extends React.Component { const filteredItemsLength = getFilterredItemsLength(items); const isMainChecked = filteredItemsLength > 0 && getSelectedFilterredItemsLength(items) === filteredItemsLength; this.props.onFilterChange({ side, filterTerm, items, isMainChecked }); - } + }; moveTo = otherSide => { const side = otherSide === 'right' ? 'left' : 'right'; @@ -211,7 +211,7 @@ class DualList extends React.Component { items: otherSideItems } }); - } + }; leftArrowClick = () => { const { @@ -219,7 +219,7 @@ class DualList extends React.Component { } = this.props; left.onClick(); this.moveTo('left'); - } + }; rightArrowClick = () => { const { @@ -227,7 +227,7 @@ class DualList extends React.Component { } = this.props; right.onClick(); this.moveTo('right'); - } + }; render() { const { left, right, arrows, allowHiddenInputs } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualListControlled.js b/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualListControlled.js index 13749ac2fcb..7057f26dd77 100644 --- a/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualListControlled.js +++ b/packages/patternfly-3/patternfly-react/src/components/DualListSelector/DualListControlled.js @@ -41,7 +41,7 @@ class DualListControlled extends React.Component { }, () => onItemChange(this.state) ); - } + }; onMainCheckboxChange = ({ side, checked, items, selectCount }) => { const { onMainCheckboxChange } = this.props; @@ -56,7 +56,7 @@ class DualListControlled extends React.Component { }, () => onMainCheckboxChange(this.state) ); - } + }; onSortClick = ({ side, items, isSortAsc }) => { const { onSortClick } = this.props; @@ -70,7 +70,7 @@ class DualListControlled extends React.Component { }, () => onSortClick(this.state) ); - } + }; onFilterChange = ({ side, filterTerm, items, isMainChecked }) => { const { onFilterChange } = this.props; @@ -85,12 +85,12 @@ class DualListControlled extends React.Component { }, () => onFilterChange(this.state) ); - } + }; onChange = ({ left, right }) => { const { onChange } = this.props; this.setState({ left, right }, () => onChange(this.state)); - } + }; render() { const { left, right, allowHiddenInputs } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js index 509a27a3de0..ad684f442dd 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js +++ b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js @@ -29,7 +29,7 @@ class ExpandCollapse extends React.Component { } else { this.setState(prevState => ({ expanded: !prevState.expanded })); } - } + }; render() { const { children, textCollapsed, textExpanded, align, className, bordered } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js b/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js index 93a9d30608b..e33e8215394 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Filter/__mocks__/mockFilterExample.js @@ -87,7 +87,7 @@ export class MockFilterExample extends React.Component { keyEvent.stopPropagation(); keyEvent.preventDefault(); } - } + }; categoryValueSelected = value => { const { currentValue, currentFilterType, filterCategory } = this.state; @@ -102,11 +102,11 @@ export class MockFilterExample extends React.Component { this.filterAdded(currentFilterType, filterValue); } } - } + }; clearFilters = () => { this.setState({ activeFilters: [] }); - } + }; filterAdded = (field, value) => { let filterText = ''; @@ -132,14 +132,14 @@ export class MockFilterExample extends React.Component { const activeFilters = [...this.state.activeFilters, { label: filterText }]; this.setState({ activeFilters }); - } + }; filterCategorySelected = category => { const { filterCategory } = this.state; if (filterCategory !== category) { this.setState({ filterCategory: category, currentValue: '' }); } - } + }; filterValueSelected = filterValue => { const { currentFilterType, currentValue } = this.state; @@ -150,24 +150,24 @@ export class MockFilterExample extends React.Component { this.filterAdded(currentFilterType, filterValue); } } - } + }; filterExists = fieldTitle => { const { activeFilters } = this.state; const index = findIndex(activeFilters, filter => filter.label.startsWith(fieldTitle)); return index !== -1; - } + }; getFilterValue = fieldTitle => { const { activeFilters } = this.state; const existingFilter = find(activeFilters, filter => filter.label.startsWith(fieldTitle)); return existingFilter.label.substring(existingFilter.label.indexOf(': ') + 2); - } + }; enforceSingleSelect = fieldTitle => { const { activeFilters } = this.state; remove(activeFilters, filter => filter.label.startsWith(fieldTitle)); - } + }; removeFilter = filter => { const { activeFilters } = this.state; @@ -177,7 +177,7 @@ export class MockFilterExample extends React.Component { const updated = [...activeFilters.slice(0, index), ...activeFilters.slice(index + 1)]; this.setState({ activeFilters: updated }); } - } + }; selectFilterType = filterType => { const { currentFilterType } = this.state; @@ -203,11 +203,11 @@ export class MockFilterExample extends React.Component { filterCategory: newFilterCategory }); } - } + }; updateCurrentValue = event => { this.setState({ currentValue: event.target.value }); - } + }; renderInput() { const { currentFilterType, currentValue, filterCategory } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/Form/Form.stories.js b/packages/patternfly-3/patternfly-react/src/components/Form/Form.stories.js index 9e150938a4b..2a1fe1a9442 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Form/Form.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/Form/Form.stories.js @@ -84,8 +84,12 @@ exampleStories.add( const { bsSize, disabled } = formFieldsKnobs; const buttonsProps = {}; - if (bsSize) { buttonsProps.bsSize = bsSize; } - if (disabled) { buttonsProps.disabled = disabled; } + if (bsSize) { + buttonsProps.bsSize = bsSize; + } + if (disabled) { + buttonsProps.disabled = disabled; + } const formFields = InlineFormFields.map(formField => InlineFormField({ ...formField, ...formFieldsKnobs })).reduce( (result = [], element) => [...result, element, ' '], // create spacing betwwen elements @@ -120,8 +124,12 @@ exampleStories.add( const { bsSize, disabled } = formFieldsKnobs; const buttonsProps = {}; - if (bsSize) { buttonsProps.bsSize = bsSize; } - if (disabled) { buttonsProps.disabled = disabled; } + if (bsSize) { + buttonsProps.bsSize = bsSize; + } + if (disabled) { + buttonsProps.disabled = disabled; + } const showLoading = boolean('Show Loading', false); const formFields = BasicFormFields.map(formField => HorizontalFormField({ ...formField, ...formFieldsKnobs })); @@ -168,8 +176,12 @@ exampleStories.add( const { bsSize, disabled } = formFieldsKnobs; const buttonsProps = {}; - if (bsSize) { buttonsProps.bsSize = bsSize; } - if (disabled) { buttonsProps.disabled = disabled; } + if (bsSize) { + buttonsProps.bsSize = bsSize; + } + if (disabled) { + buttonsProps.disabled = disabled; + } const showLoading = boolean('Show Loading', false); const formFields = BasicFormFields.map(formField => VerticalFormField({ ...formField, ...formFieldsKnobs })); @@ -214,8 +226,12 @@ exampleStories.add( const { bsSize, disabled } = formFieldsKnobs; const buttonsProps = {}; - if (bsSize) { buttonsProps.bsSize = bsSize; } - if (disabled) { buttonsProps.disabled = disabled; } + if (bsSize) { + buttonsProps.bsSize = bsSize; + } + if (disabled) { + buttonsProps.disabled = disabled; + } const showLoading = boolean('Show Loading', false); const formFields = BasicFormFields.map(formField => HorizontalFormField({ ...formField, ...formFieldsKnobs })); diff --git a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/BasicForm.js b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/BasicForm.js index 9b7d5dac347..56e9081e40f 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/BasicForm.js +++ b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/BasicForm.js @@ -37,7 +37,7 @@ export const BasicFormFields = [ label: 'Phone', useFieldLevelHelp: true, content: - 'Please specify Country code
Click here for a list of Country codes', + "Please specify Country code
Click here for a list of Country codes", close: 'true', help: 'Enter a valid phone number', formControl: ({ validationState, ...props }) => @@ -88,7 +88,7 @@ export const getBasicFormKnobs = () => ({ disabled: boolean('Disabled', false), content: text( 'Field Level Help Content', - 'Please specify Country code
Click here for a list of Country codes' + "Please specify Country code
Click here for a list of Country codes" ), close: select('Close Popover', ['true', 'false'], 'true') }); diff --git a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/FormExample.js b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/FormExample.js index 2b8d7a13312..f1fe8ffd3fe 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/FormExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/FormExample.js @@ -15,9 +15,13 @@ export class FormExample extends React.Component { getValidationState() { const { length } = this.state.value; - if (length > 10) { return 'success'; } - else if (length > 5) { return 'warning'; } - else if (length > 0) { return 'error'; } + if (length > 10) { + return 'success'; + } else if (length > 5) { + return 'warning'; + } else if (length > 0) { + return 'error'; + } return null; } diff --git a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/HorizontalFormField.js b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/HorizontalFormField.js index 299c7403e72..0f839df0316 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/HorizontalFormField.js +++ b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/HorizontalFormField.js @@ -20,8 +20,12 @@ export const HorizontalFormField = ({ }) => { const controlProps = { ...props }; - if (bsSize) { controlProps.bsSize = bsSize; } - if (validationState) { controlProps.validationState = validationState; } + if (bsSize) { + controlProps.bsSize = bsSize; + } + if (validationState) { + controlProps.validationState = validationState; + } const formGroupProps = { key: controlId, controlId, ...controlProps }; diff --git a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/InlineFormField.js b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/InlineFormField.js index 968b5512916..788e7fcb782 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/InlineFormField.js +++ b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/InlineFormField.js @@ -6,8 +6,12 @@ import { Form } from '../index'; export const InlineFormField = ({ controlId, label, formControl, validationState, bsSize, showLabel, ...props }) => { const controlProps = { ...props }; - if (bsSize) { controlProps.bsSize = bsSize; } - if (validationState) { controlProps.validationState = validationState; } + if (bsSize) { + controlProps.bsSize = bsSize; + } + if (validationState) { + controlProps.validationState = validationState; + } const formGroupProps = { key: controlId, controlId, ...controlProps }; diff --git a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/VerticalFormField.js b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/VerticalFormField.js index 63625b02af7..fac2edbdb28 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Form/Stories/VerticalFormField.js +++ b/packages/patternfly-3/patternfly-react/src/components/Form/Stories/VerticalFormField.js @@ -19,8 +19,12 @@ export const VerticalFormField = ({ }) => { const controlProps = { ...props }; - if (bsSize) { controlProps.bsSize = bsSize; } - if (validationState) { controlProps.validationState = validationState; } + if (bsSize) { + controlProps.bsSize = bsSize; + } + if (validationState) { + controlProps.validationState = validationState; + } const formGroupProps = { key: controlId, controlId, ...controlProps }; diff --git a/packages/patternfly-3/patternfly-react/src/components/InfoTip/InfoTip.js b/packages/patternfly-3/patternfly-react/src/components/InfoTip/InfoTip.js index 391c4a66b74..d1d0084348c 100644 --- a/packages/patternfly-3/patternfly-react/src/components/InfoTip/InfoTip.js +++ b/packages/patternfly-3/patternfly-react/src/components/InfoTip/InfoTip.js @@ -13,7 +13,7 @@ class InfoTip extends React.Component { handleEnterKeyDown = event => { this.setState({ open: !this.state.open }); event.preventDefault(); - } + }; handleTabKeyDown = event => { if (this.state.footerFocused) { @@ -23,7 +23,7 @@ class InfoTip extends React.Component { } event.stopPropagation(); event.nativeEvent.stopImmediatePropagation(); - } + }; handleKeyDown = event => { if (event.shiftKey && event.keyCode) { @@ -39,24 +39,24 @@ class InfoTip extends React.Component { default: return null; } - } + }; handleBackFocus = () => { if (this.state.open) { this.setState({ open: false }); } - } + }; handleClick = event => { event.preventDefault(); this.setState({ open: !this.state.open }); - } + }; handleBlur = event => { if (event && event.relatedTarget) { event.relatedTarget.click(); } this.setState({ open: false }); - } + }; render() { const { children, onToggle, ...props } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/Label/CompoundLabel.js b/packages/patternfly-3/patternfly-react/src/components/Label/CompoundLabel.js index 617752e88d5..7487a14c23b 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Label/CompoundLabel.js +++ b/packages/patternfly-3/patternfly-react/src/components/Label/CompoundLabel.js @@ -16,11 +16,13 @@ class CompoundLabel extends React.Component { className={this.props.innerClassName} overlayPlacement={this.props.overlayPlacement} /> - ) + ); render() { const values = [...this.props.values]; - if (values.length === 0) { return null; } + if (values.length === 0) { + return null; + } const categoryTooltip = {this.props.category.label}; return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockCompoundLabel.js b/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockCompoundLabel.js index d729c4dae41..bff957cb70c 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockCompoundLabel.js +++ b/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockCompoundLabel.js @@ -22,7 +22,7 @@ export class MockCompoundLabel extends React.Component { const values = this.state.tag.values.filter(val => val.id !== value.id); const state = { tag: { ...this.state.tag, values } }; this.setState(state); - } + }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockLabelExamples.js b/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockLabelExamples.js index d924fd3b9f2..6252deb9397 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockLabelExamples.js +++ b/packages/patternfly-3/patternfly-react/src/components/Label/__mocks__/mockLabelExamples.js @@ -16,7 +16,7 @@ export class MockLabelRemove extends React.Component { } removeMe = index => { this.setState(this.state.types.splice(index, 1)); - } + }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/ListView/ListViewItem.js b/packages/patternfly-3/patternfly-react/src/components/ListView/ListViewItem.js index 852f82f6bac..14689ae3b3f 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ListView/ListViewItem.js +++ b/packages/patternfly-3/patternfly-react/src/components/ListView/ListViewItem.js @@ -24,7 +24,7 @@ class ListViewItem extends React.Component { onExpand(); } this.setState(prevState => ({ expanded: !prevState.expanded })); - } + }; render() { const { diff --git a/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockCompoundExpansionExample.js b/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockCompoundExpansionExample.js index 2c5102846a6..1feab51eaa0 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockCompoundExpansionExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockCompoundExpansionExample.js @@ -30,7 +30,7 @@ export class MockCompoundExpansion extends React.Component { item.expandType = expandProp; } this.setState({ listItems: mockListItems }); - } + }; renderAdditionalInfoExpandItems(item) { return ( @@ -80,7 +80,7 @@ export class MockCompoundExpansion extends React.Component { ); - } + }; render() { const { listItems } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockListItems.js b/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockListItems.js index 746d2bb0b39..030eb7375a1 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockListItems.js +++ b/packages/patternfly-3/patternfly-react/src/components/ListView/__mocks__/mockListItems.js @@ -11,10 +11,10 @@ export const mockListItems = [ properties: { hosts: 3, clusters: 1, nodes: 7, images: 4 }, expandedContentText: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', compoundExpandText: { - hosts: 'Text describing Item 1\'s hosts', - clusters: 'Text describing Item 1\'s clusters', - nodes: 'Text describing Item 1\'s nodes', - images: 'Text describing Item 1\'s images' + hosts: "Text describing Item 1's hosts", + clusters: "Text describing Item 1's clusters", + nodes: "Text describing Item 1's nodes", + images: "Text describing Item 1's images" } }, { @@ -23,10 +23,10 @@ export const mockListItems = [ properties: { hosts: 2, clusters: 1, nodes: 11, images: 8 }, expandedContentText: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', compoundExpandText: { - hosts: 'Text describing Item 2\'s hosts', - clusters: 'Text describing Item 2\'s clusters', - nodes: 'Text describing Item 2\'s nodes', - images: 'Text describing Item 2\'s images' + hosts: "Text describing Item 2's hosts", + clusters: "Text describing Item 2's clusters", + nodes: "Text describing Item 2's nodes", + images: "Text describing Item 2's images" } }, { @@ -35,30 +35,30 @@ export const mockListItems = [ properties: { hosts: 4, clusters: 2, nodes: 9, images: 8 }, expandedContentText: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', compoundExpandText: { - hosts: 'Text describing Item 3\'s hosts', - clusters: 'Text describing Item 3\'s clusters', - nodes: 'Text describing Item 3\'s nodes', - images: 'Text describing Item 3\'s images' + hosts: "Text describing Item 3's hosts", + clusters: "Text describing Item 3's clusters", + nodes: "Text describing Item 3's nodes", + images: "Text describing Item 3's images" } }, { description: 'This is Item without heading', expandedContentText: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', compoundExpandText: { - hosts: 'Text describing Item 4\'s hosts', - clusters: 'Text describing Item 4\'s clusters', - nodes: 'Text describing Item 4\'s nodes', - images: 'Text describing Item 4\'s images' + hosts: "Text describing Item 4's hosts", + clusters: "Text describing Item 4's clusters", + nodes: "Text describing Item 4's nodes", + images: "Text describing Item 4's images" } }, { properties: { hosts: 4, clusters: 2, nodes: 9, images: 8 }, expandedContentText: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', compoundExpandText: { - hosts: 'Text describing Item 5\'s hosts', - clusters: 'Text describing Item 5\'s clusters', - nodes: 'Text describing Item 5\'s nodes', - images: 'Text describing Item 5\'s images' + hosts: "Text describing Item 5's hosts", + clusters: "Text describing Item 5's clusters", + nodes: "Text describing Item 5's nodes", + images: "Text describing Item 5's images" } }, { @@ -66,10 +66,10 @@ export const mockListItems = [ expandedContentText: 'There is no close `x` on the right of this box.', hideCloseIcon: true, compoundExpandText: { - hosts: 'Text describing Item 6\'s hosts', - clusters: 'Text describing Item 6\'s clusters', - nodes: 'Text describing Item 6\'s nodes', - images: 'Text describing Item 6\'s images' + hosts: "Text describing Item 6's hosts", + clusters: "Text describing Item 6's clusters", + nodes: "Text describing Item 6's nodes", + images: "Text describing Item 6's images" } } ]; diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.stories.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.stories.js index 555c1ebafb3..8a9b709b9fd 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.stories.js @@ -32,9 +32,7 @@ stories.add('Managed Login Page with errors display on top of the form', () => ( )); -stories.add('Managed Login Page with errors display under form inputs', () => ( - -)); +stories.add('Managed Login Page with errors display under form inputs', () => ); stories.add('Build Your own Basic Login Page', () => LoginPage.Pattern(getBuildYourOwnPageProps())); diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.test.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.test.js index 1383f87c59c..706e8eb3470 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.test.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/LoginPage.test.js @@ -379,7 +379,7 @@ test('Translation works', () => { }); test('submitButtonAttributes are added to the DOM', () => { - const id = 'submit-button-unique-test-id' + const id = 'submit-button-unique-test-id'; const props = createProps(); props.card.form.submitButtonAttributes = { id }; const component = mount(); diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/SocialLoginPage.test.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/SocialLoginPage.test.js index 5995b34d85c..aab48846153 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/SocialLoginPage.test.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/SocialLoginPage.test.js @@ -181,7 +181,7 @@ test('Click on the "More" button will expend the list and the button will change expect(component.find('.ReactCollapse--collapse > ul > li')).toBeTruthy(); }); -test('While the social list has 4 or less links, it won\'t have the \'double-col\' class and the expend button won\'t exist', () => { +test("While the social list has 4 or less links, it won't have the 'double-col' class and the expend button won't exist", () => { const props = { ...createProps() }; props.card.social.links = [...logoList].splice(0, 4); const component = mount(); diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js index d46b7a54217..bbe1af21522 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardSocialColumns.js @@ -22,7 +22,7 @@ class LoginCardSocialColumns extends React.Component { this.setState({ width: window.innerWidth }); - } + }; getListItems = () => { this.hiddenLinks = []; @@ -38,7 +38,7 @@ class LoginCardSocialColumns extends React.Component { return ; }) ); - } + }; getHiddenListItems = () => { const { numberOfButtonsToShow } = this.props; @@ -48,11 +48,11 @@ class LoginCardSocialColumns extends React.Component { )) ); - } + }; toggleExpend = () => { this.setState({ expend: !this.state.expend }); - } + }; render() { const { links, numberOfButtonsToShow } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardWithValidation.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardWithValidation.js index 4f3b8ae6a31..cd8aa8c6e22 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardWithValidation.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginCardWithValidation.js @@ -41,7 +41,9 @@ class LoginCardWithValidation extends React.Component { static getDerivedStateFromProps(props, state) { // disableSubmit prop will only be used in a not validated login card const { validate, disableSubmit } = props; - if (validate) { return null; } + if (validate) { + return null; + } if (disableSubmit !== state.form.disableSubmit) { return { form: { disableSubmit } @@ -57,7 +59,7 @@ class LoginCardWithValidation extends React.Component { const otherInputType = inputType === 'usernameField' ? 'passwordField' : 'usernameField'; const otherInputValue = this.state[otherInputType].value; return otherInputValue.length < 1; - } + }; onInputChange = (e, inputType) => { const { @@ -75,7 +77,7 @@ class LoginCardWithValidation extends React.Component { disableSubmit: this.shouldDisableSubmit(inputType, value) } })); - } + }; onInputFocus = (e, inputType) => { this.props[inputType].onFocus && this.props[inputType].onFocus(e); @@ -86,7 +88,7 @@ class LoginCardWithValidation extends React.Component { showError: false } }); - } + }; onInputBlur = (e, inputType) => { this.props[inputType].onBlur && this.props[inputType].onBlur(e); @@ -98,12 +100,12 @@ class LoginCardWithValidation extends React.Component { }, isCapsLock: false }); - } + }; onKeyPress = (e, inputType) => { this.props[inputType].onMouseEnter && this.props[inputType].onMouseEnter(e); this.handleCapsLock(e); - } + }; onSubmit = e => { e.preventDefault(); @@ -113,7 +115,7 @@ class LoginCardWithValidation extends React.Component { } else { this.handleOnInputErrors(); } - } + }; onSubmitStart = () => { this.setState(({ form }) => ({ @@ -125,7 +127,7 @@ class LoginCardWithValidation extends React.Component { showError: false } })); - } + }; onSubmitError = submitError => { this.setState(({ form }) => ({ @@ -138,7 +140,7 @@ class LoginCardWithValidation extends React.Component { isSubmitting: false } })); - } + }; getFormError = () => { const { @@ -151,7 +153,7 @@ class LoginCardWithValidation extends React.Component {
)) : submitError; - } + }; getModifiedProps = () => { const { usernameField, passwordField, isCapsLock, form } = this.state; @@ -186,7 +188,7 @@ class LoginCardWithValidation extends React.Component { isSubmitting: form.isSubmitting, submitError: this.getFormError() }; - } + }; handleOnInputErrors = () => { const { usernameField, passwordField } = this.state; @@ -207,13 +209,13 @@ class LoginCardWithValidation extends React.Component { } !topErrorOnly && this.hideSubmitError(); - } + }; isFormValid = () => !!this.state.usernameField.value && !!this.state.passwordField.value && !this.isPasswordShort() && - this.isUserNameValid() + this.isUserNameValid(); isPasswordShort = () => { const { @@ -225,7 +227,7 @@ class LoginCardWithValidation extends React.Component { } } = this.state; return passwordMinLength > 0 && currentPasswordLength < passwordMinLength; - } + }; hideSubmitError = () => { this.setState({ @@ -234,7 +236,7 @@ class LoginCardWithValidation extends React.Component { showError: false } }); - } + }; clearFormErrors = () => { this.setState(({ form }) => ({ @@ -243,7 +245,7 @@ class LoginCardWithValidation extends React.Component { errors: [] } })); - } + }; handleOnPasswordTooShort = () => { const { @@ -268,7 +270,7 @@ class LoginCardWithValidation extends React.Component { } } ); - } + }; handleOnInvalidUsername = () => { const { @@ -293,7 +295,7 @@ class LoginCardWithValidation extends React.Component { } } ); - } + }; handleOnEmptyInput = inputType => { const { @@ -318,7 +320,7 @@ class LoginCardWithValidation extends React.Component { } } ); - } + }; toggleCapsLock = e => { if (!this.state.passwordField.value) { @@ -328,7 +330,7 @@ class LoginCardWithValidation extends React.Component { this.setState({ isCapsLock: !this.state.isCapsLock }); - } + }; handleCapsLock = e => { const keyCode = e.keyCode ? e.keyCode : e.which; @@ -339,7 +341,7 @@ class LoginCardWithValidation extends React.Component { this.setState({ isCapsLock }); - } + }; isUserNameValid = () => { const { @@ -352,7 +354,7 @@ class LoginCardWithValidation extends React.Component { return atPos > 1 && dotPos - atPos > 2 && atPos < dotPos; } return true; - } + }; render() { const { validate, children } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginLanguagePicker.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginLanguagePicker.js index fe8efb5c55b..1b9677470de 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginLanguagePicker.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginCardComponents/LoginLanguagePicker.js @@ -24,7 +24,7 @@ class LoginLanguagePicker extends React.Component { const { onLanguageChange } = this.props; onLanguageChange(e); this.setState({ title: e.target.text }); - } + }; render() { const { availableLanguages, className, id } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageAlert.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageAlert.js index b386ba82cdb..2e4ac1f7b00 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageAlert.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageAlert.js @@ -12,7 +12,7 @@ class LoginPageAlert extends React.Component { return; } this.setState({ show: false }); - } + }; render() { const { type, message } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageWithTranslation.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageWithTranslation.js index 04ced43e1f0..dbd9e44c735 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageWithTranslation.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/components/LoginPageComponents/LoginPageWithTranslation.js @@ -24,19 +24,19 @@ class LoginPageWithTranslation extends React.Component { return; } this.switchToLanguage(newLanguage); - } + }; onPasswordChange = e => { const { card } = this.props; card.form.passwordField.onChange && card.form.passwordField.onChange(e); this.setState({ passwordValue: e.target.value }); - } + }; onUsernameChange = e => { const { card } = this.props; card.form.usernameField.onChange && card.form.usernameField.onChange(e); this.setState({ usernameValue: e.target.value }); - } + }; getDefaultPropsToPass = () => { const { card } = this.props; @@ -59,7 +59,7 @@ class LoginPageWithTranslation extends React.Component { } } }; - } + }; switchToLanguage = language => { const { container, card, header } = this.props; @@ -124,7 +124,7 @@ class LoginPageWithTranslation extends React.Component { }; this.setState({ translatedProps, language }); - } + }; render() { const newProps = { diff --git a/packages/patternfly-3/patternfly-react/src/components/LoginPage/mocks/messages.fr.js b/packages/patternfly-3/patternfly-react/src/components/LoginPage/mocks/messages.fr.js index acd5cfed128..8ad73f105d3 100644 --- a/packages/patternfly-3/patternfly-react/src/components/LoginPage/mocks/messages.fr.js +++ b/packages/patternfly-3/patternfly-react/src/components/LoginPage/mocks/messages.fr.js @@ -1,11 +1,13 @@ const pageHeader = { - alert: 'Patternfly sera mis à jour à 2.13.5 à 00:00, 23 Sep 2018 (UTC). Cette mise à jour durera de 8 à 12 heures, veuillez planifier à l\'avance pour cette panne.', + alert: + "Patternfly sera mis à jour à 2.13.5 à 00:00, 23 Sep 2018 (UTC). Cette mise à jour durera de 8 à 12 heures, veuillez planifier à l'avance pour cette panne.", logo: 'Patternfly', - caption: 'Utilisez cette zone pour placer des informations ou un message d\'introduction sur votre application qui peut être pertinent pour utilisateurs.' + caption: + "Utilisez cette zone pour placer des informations ou un message d'introduction sur votre application qui peut être pertinent pour utilisateurs." }; const footerLinks = [ - { children: 'Conditions d\'utilisation', href: '#' }, + { children: "Conditions d'utilisation", href: '#' }, { children: 'Aidez-moi', href: '#' }, { children: 'Politique de confidentialité', href: '#' } ]; @@ -17,9 +19,9 @@ const cardHeader = { }; const signUp = { - label: 'Besoin d\'un compte?', + label: "Besoin d'un compte?", link: { - label: 'S\'inscrire' + label: "S'inscrire" } }; @@ -29,7 +31,7 @@ const forgotPassword = 'mot de passe oublié?'; const form = { error: 'Votre compte a été bloqué Contactez votre administrateur pour le débloquer.', - submitText: 'S\'identifier' + submitText: "S'identifier" }; const passwordField = { @@ -46,7 +48,7 @@ const passwordField = { const usernameField = { placeholder: 'Adresse e-mail', errors: { - empty: 'S\'il vous plaît entrer votre email.', + empty: "S'il vous plaît entrer votre email.", invalid: 'Votre email est invalide' } }; diff --git a/packages/patternfly-3/patternfly-react/src/components/Masthead/__mocks__/mockHorizontalMasthead.js b/packages/patternfly-3/patternfly-react/src/components/Masthead/__mocks__/mockHorizontalMasthead.js index a216caecf8e..9306f086c96 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Masthead/__mocks__/mockHorizontalMasthead.js +++ b/packages/patternfly-3/patternfly-react/src/components/Masthead/__mocks__/mockHorizontalMasthead.js @@ -18,7 +18,7 @@ export class MockHorizontalMasthead extends React.Component { this.setState({ menuCollapsed: !this.state.menuCollapsed }); - } + }; render() { const { menuCollapsed } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogDeleteConfirmation.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogDeleteConfirmation.js index a497dd97a84..e36a8e17500 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogDeleteConfirmation.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogDeleteConfirmation.js @@ -11,15 +11,15 @@ class MessageDialogDeleteConfirmation extends Component { primaryAction = () => { this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { const primaryContent =

Main Dialog Text

; diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogError.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogError.js index 4a700308700..36efdca9a8b 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogError.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogError.js @@ -11,15 +11,15 @@ class MessageDialogError extends Component { primaryAction = () => { this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { const primaryContent =

Main Dialog Text

; diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogInfo.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogInfo.js index d6a0b3c64fa..67bdce38ef5 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogInfo.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogInfo.js @@ -11,15 +11,15 @@ class MessageDialogInfo extends Component { primaryAction = () => { this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { const primaryContent =

Main Dialog Text

; diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogNondestructiveAction.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogNondestructiveAction.js index d5163838a13..6e73e63028b 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogNondestructiveAction.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogNondestructiveAction.js @@ -11,15 +11,15 @@ class MessageDialogNondestructiveAction extends Component { primaryAction = () => { this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { const primaryContent =

Main Dialog Text

; diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogQuestion.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogQuestion.js index 74756134cac..25b11073123 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogQuestion.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogQuestion.js @@ -11,15 +11,15 @@ class MessageDialogQuestion extends Component { primaryAction = () => { this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { const primaryContent =

Main Dialog Text. Are you sure you want to xxxxx?

; diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogSuccess.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogSuccess.js index 96ecf0d473b..8700ea9416e 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogSuccess.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogSuccess.js @@ -11,15 +11,15 @@ class MessageDialogSuccess extends Component { primaryAction = () => { this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { const primaryContent =

Main Dialog Text

; diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogToggleableOptions.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogToggleableOptions.js index 4a08c7027bd..da308db9c36 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogToggleableOptions.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogToggleableOptions.js @@ -13,15 +13,15 @@ class MessageDialogToggleableOptions extends Component { primaryAction = () => { // Do some stuff this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { // StoryBook Knobs Config diff --git a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogWarning.js b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogWarning.js index 654d9b6061a..b7fed11b37c 100644 --- a/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogWarning.js +++ b/packages/patternfly-3/patternfly-react/src/components/MessageDialog/Stories/MessageDialogWarning.js @@ -11,15 +11,15 @@ class MessageDialogWarning extends Component { primaryAction = () => { this.setState(() => ({ show: false })); - } + }; secondaryAction = () => { this.setState(() => ({ show: false })); - } + }; showModal = () => { this.setState(() => ({ show: true })); - } + }; render() { const primaryContent =

Main Dialog Text

; diff --git a/packages/patternfly-3/patternfly-react/src/components/Modal/Patterns/StatefulModalPattern.js b/packages/patternfly-3/patternfly-react/src/components/Modal/Patterns/StatefulModalPattern.js index 7d83d9d2383..92ebf495615 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Modal/Patterns/StatefulModalPattern.js +++ b/packages/patternfly-3/patternfly-react/src/components/Modal/Patterns/StatefulModalPattern.js @@ -19,11 +19,11 @@ class StatefulModalPattern extends React.Component { open = () => { this.setState({ show: true }); - } + }; close = () => { this.setState({ show: false }); - } + }; getModalPatternProps = () => this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/Modal/Stories/ModalPatternExample.js b/packages/patternfly-3/patternfly-react/src/components/Modal/Stories/ModalPatternExample.js index 1567c3556ba..c0bfa7f7638 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Modal/Stories/ModalPatternExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Modal/Stories/ModalPatternExample.js @@ -14,11 +14,11 @@ export class ModalPatternExample extends React.Component { setTimeout(() => { this.setState({ loading: false }); }, 1000); - } + }; close = () => { this.setState({ showModal: false, loading: false }); - } + }; renderStateless = () => { // We need knobs on the stateless example, because we must drive its state ourselves. @@ -44,7 +44,7 @@ export class ModalPatternExample extends React.Component { ); - } + }; renderStateful = () => ( // No knobs for the stateful example, we want to let it control its own state. @@ -66,7 +66,7 @@ export class ModalPatternExample extends React.Component { (Modal Contents Here) - ) + ); render() { return this.props.stateful ? this.renderStateful() : this.renderStateless(); diff --git a/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/ModelessOverlay.js b/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/ModelessOverlay.js index 000af7500ad..109bb8f7cee 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/ModelessOverlay.js +++ b/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/ModelessOverlay.js @@ -17,7 +17,7 @@ class ModelessOverlay extends React.Component { updateForTransitions = () => { this.setState({ isIn: this.props.show }); - } + }; render() { const { children, className, bsSize, show, ...otherProps } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/__mocks__/mockModelessManager.js b/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/__mocks__/mockModelessManager.js index 75229920900..21e274f05e3 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/__mocks__/mockModelessManager.js +++ b/packages/patternfly-3/patternfly-react/src/components/ModelessOverlay/__mocks__/mockModelessManager.js @@ -11,10 +11,10 @@ export class MockModelessManager extends React.Component { } close = () => { this.setState({ showOverlay: false }); - } + }; toggleOpen = () => { this.setState({ showOverlay: !this.state.showOverlay }); - } + }; render() { const { children, size } = this.props; const defaultBody = ( diff --git a/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/NotificationDrawerPanelWrapper.js b/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/NotificationDrawerPanelWrapper.js index 0849a0b6dc4..c852a6353dd 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/NotificationDrawerPanelWrapper.js +++ b/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/NotificationDrawerPanelWrapper.js @@ -28,7 +28,9 @@ const NotificationDrawerPanelWrapper = ({ const unreadCount = notifications.filter(notification => !notification.seen).length; const getUnread = () => { - if (unreadCount !== 1) { return `${unreadCount} ${translations.unreadEvents}`; } + if (unreadCount !== 1) { + return `${unreadCount} ${translations.unreadEvents}`; + } return `1 ${translations.unreadEvent}`; }; diff --git a/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulNotificationDrawerWrapper.js b/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulNotificationDrawerWrapper.js index bc003ff756e..7e2c6de9efd 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulNotificationDrawerWrapper.js +++ b/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulNotificationDrawerWrapper.js @@ -15,7 +15,7 @@ class StatefulNotificationDrawerWrapper extends React.Component { onClickLink = url => { window.open(url.href); - } + }; onMarkPanelAsRead = panelkey => { const panels = this.state.panels.map(panel => { @@ -29,22 +29,26 @@ class StatefulNotificationDrawerWrapper extends React.Component { }); this.setState({ panels }); this.updateUnreadCount(); - } + }; onMarkPanelAsClear = key => { const panels = this.state.panels.map(panel => { - if (panel.panelkey === key) { panel.notifications = []; } + if (panel.panelkey === key) { + panel.notifications = []; + } return panel; }); this.setState({ panels }); this.updateUnreadCount(); - } + }; onNotificationAsRead = (panelkey, nkey) => { const panels = this.state.panels.map(panel => { if (panel.panelkey === panelkey) { panel.notifications.map(notification => { - if (notification.id === nkey) { notification.seen = true; } + if (notification.id === nkey) { + notification.seen = true; + } return notification; }); } @@ -52,11 +56,11 @@ class StatefulNotificationDrawerWrapper extends React.Component { }); this.setState({ panels }); this.updateUnreadCount(); - } + }; onNotificationClick = () => { // On Click - } + }; onNotificationHide = (panelkey, nkey) => { const panels = this.state.panels.map(panel => { @@ -71,17 +75,21 @@ class StatefulNotificationDrawerWrapper extends React.Component { }); this.setState({ panels }); this.updateUnreadCount(); - } + }; togglePanel = key => { - if (this.state.expandedPanel === key) { this.setState({ expandedPanel: '-1' }); } else { this.setState({ expandedPanel: key }); } - } + if (this.state.expandedPanel === key) { + this.setState({ expandedPanel: '-1' }); + } else { + this.setState({ expandedPanel: key }); + } + }; toggleDrawerExpand = () => { this.setState(prevState => ({ isExpanded: !prevState.isExpanded })); - } + }; updateUnreadCount = () => { let hasunread = false; @@ -93,7 +101,7 @@ class StatefulNotificationDrawerWrapper extends React.Component { } } this.props.updateUnreadCount(hasunread); - } + }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulToggleNotificationDrawerWrapper.js b/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulToggleNotificationDrawerWrapper.js index 91f86578e71..f5163e0a80e 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulToggleNotificationDrawerWrapper.js +++ b/packages/patternfly-3/patternfly-react/src/components/Notification/Wrappers/StatefulToggleNotificationDrawerWrapper.js @@ -18,11 +18,15 @@ class StatefulToggleNotificationDrawerWrapper extends React.Component { this.setState(prevState => ({ isDrawerOpen: !prevState.isDrawerOpen })); - } + }; updateUnreadCount = bool => { - if (bool) { this.setState({ hasUnreadMessages: true }); } else { this.setState({ hasUnreadMessages: false }); } - } + if (bool) { + this.setState({ hasUnreadMessages: true }); + } else { + this.setState({ hasUnreadMessages: false }); + } + }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/Overlay/__mocks__/mockOverlayManager.js b/packages/patternfly-3/patternfly-react/src/components/Overlay/__mocks__/mockOverlayManager.js index 53fa36c35db..8955808ed65 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Overlay/__mocks__/mockOverlayManager.js +++ b/packages/patternfly-3/patternfly-react/src/components/Overlay/__mocks__/mockOverlayManager.js @@ -15,7 +15,7 @@ export class MockOverlayManager extends React.Component { toggleOverlay = () => { const { showOverlay } = this.state; this.setState({ showOverlay: !showOverlay }); - } + }; render() { const { placement } = this.props; const { showOverlay } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/Pagination/Paginator.js b/packages/patternfly-3/patternfly-react/src/components/Pagination/Paginator.js index efecaefbcec..c21b1819e95 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Pagination/Paginator.js +++ b/packages/patternfly-3/patternfly-react/src/components/Pagination/Paginator.js @@ -41,7 +41,7 @@ class Paginator extends React.Component { handleFormSubmit = e => { this.setPage(this.state.pageChangeValue); - } + }; handlePageChange(e) { this.setState({ pageChangeValue: e.target.value }); diff --git a/packages/patternfly-3/patternfly-react/src/components/Pagination/__mocks__/mockPaginationRow.js b/packages/patternfly-3/patternfly-react/src/components/Pagination/__mocks__/mockPaginationRow.js index 0b85e622cbc..43f9926653b 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Pagination/__mocks__/mockPaginationRow.js +++ b/packages/patternfly-3/patternfly-react/src/components/Pagination/__mocks__/mockPaginationRow.js @@ -16,12 +16,12 @@ export class MockPaginationRow extends React.Component { const newPaginationState = Object.assign({}, this.state.pagination); newPaginationState.page = e.target.value; this.setState({ pagination: newPaginationState }); - } + }; onPerPageSelect = (eventKey, e) => { const newPaginationState = Object.assign({}, this.state.pagination); newPaginationState.perPage = eventKey; this.setState({ pagination: newPaginationState }); - } + }; render() { const { viewType, diff --git a/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.js b/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.js index 0472b8b404a..38efa2cbe43 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.js +++ b/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.js @@ -25,16 +25,16 @@ class Slider extends React.Component { onSlide = value => { this.setState({ value }, () => this.props.onSlide(value)); - } + }; onInputChange = event => { const newValue = parseInt(event.target.value || 0, 10); this.setState({ value: newValue }, () => this.props.onSlide(newValue)); - } + }; onFormatChange = format => { this.setState({ tooltipFormat: format }); - } + }; formatter = value => `${value} ${this.state.tooltipFormat}`; diff --git a/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.stories.js b/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.stories.js index 48163956e8b..6f5859115ff 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/Slider/Slider.stories.js @@ -115,6 +115,4 @@ SliderStories.add('Slider', () => ( -)).add('onSlide function', () => ( - -)); +)).add('onSlide function', () => ); diff --git a/packages/patternfly-3/patternfly-react/src/components/Sort/__mocks__/mockSortExample.js b/packages/patternfly-3/patternfly-react/src/components/Sort/__mocks__/mockSortExample.js index 9e332bb5403..1aec26648d1 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Sort/__mocks__/mockSortExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Sort/__mocks__/mockSortExample.js @@ -51,13 +51,13 @@ export class MockSortExample extends React.Component { const activeFilters = [...this.state.activeFilters, { label: filterText }]; this.setState({ activeFilters }); - } + }; toggleCurrentSortDirection = () => { this.setState(prevState => ({ isSortAscending: !prevState.isSortAscending })); - } + }; updateCurrentSortType = sortType => { const { currentSortType } = this.state; @@ -68,7 +68,7 @@ export class MockSortExample extends React.Component { isSortAscending: true }); } - } + }; render() { const { currentSortType, isSortNumeric, isSortAscending } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/Switch/Switch.stories.js b/packages/patternfly-3/patternfly-react/src/components/Switch/Switch.stories.js index 1fbc4bddf76..3a493a43e7a 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Switch/Switch.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/Switch/Switch.stories.js @@ -20,8 +20,12 @@ stories.add( const offColor = select('Off Color', Switch.SWITCH_COLORS, 'default'); const props = { bsSize, title: bsSize, id: 'bsSize-example' }; - if (onColor) { props.onColor = onColor; } - if (offColor) { props.offColor = offColor; } + if (onColor) { + props.onColor = onColor; + } + if (offColor) { + props.offColor = offColor; + } const story = (
diff --git a/packages/patternfly-3/patternfly-react/src/components/Table/TableConfirmButtonsRow.js b/packages/patternfly-3/patternfly-react/src/components/Table/TableConfirmButtonsRow.js index 590bde30cc7..fe1f008abd6 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Table/TableConfirmButtonsRow.js +++ b/packages/patternfly-3/patternfly-react/src/components/Table/TableConfirmButtonsRow.js @@ -34,16 +34,16 @@ class TableConfirmButtonsRow extends React.Component { rowDimensions: this.element.getBoundingClientRect() }); } - } + }; handleScroll = event => { this.saveRowDimensions(); - } + }; handleResize = event => { this.fetchClientDimensions(); this.saveRowDimensions(); - } + }; fetchClientDimensions() { this.setState({ diff --git a/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js b/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js index f617b3fc87d..ad836bea4ab 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js +++ b/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockClientPaginationTable.js @@ -251,34 +251,34 @@ export class MockClientPaginationTable extends React.Component { } onFirstPage = () => { this.setPage(1); - } + }; onLastPage = () => { const { page } = this.state.pagination; const totalPages = this.totalPages(); if (page < totalPages) { this.setPage(totalPages); } - } + }; onNextPage = () => { const { page } = this.state.pagination; if (page < this.totalPages()) { this.setPage(this.state.pagination.page + 1); } - } + }; onPageInput = e => { this.setState({ pageChangeValue: e.target.value }); - } + }; onPerPageSelect = (eventKey, e) => { const newPaginationState = Object.assign({}, this.state.pagination); newPaginationState.perPage = eventKey; newPaginationState.page = 1; this.setState({ pagination: newPaginationState }); - } + }; onPreviousPage = () => { if (this.state.pagination.page > 1) { this.setPage(this.state.pagination.page - 1); } - } + }; onRow = (row, { rowIndex }) => { const { selectedRows } = this.state; const selected = selectedRows.indexOf(row.id) > -1; @@ -286,7 +286,7 @@ export class MockClientPaginationTable extends React.Component { className: classNames({ selected }), role: 'row' }; - } + }; onSelectAllRows = event => { const { onRowsLogger } = this.props; const { rows, selectedRows } = this.state; @@ -316,7 +316,7 @@ export class MockClientPaginationTable extends React.Component { }); onRowsLogger(updatedRows.filter(r => r.selected)); } - } + }; onSelectRow = (event, row) => { const { onRowsLogger } = this.props; const { rows, selectedRows } = this.state; @@ -339,10 +339,10 @@ export class MockClientPaginationTable extends React.Component { }); onRowsLogger(rows.filter(r => r.selected)); } - } + }; onSubmit = () => { this.setPage(this.state.pageChangeValue); - } + }; setPage = value => { const page = Number(value); if (!Number.isNaN(value) && value !== '' && page > 0 && page <= this.totalPages()) { @@ -350,7 +350,7 @@ export class MockClientPaginationTable extends React.Component { newPaginationState.page = page; this.setState({ pagination: newPaginationState, pageChangeValue: page }); } - } + }; currentRows() { const { rows, sortingColumns, columns, pagination } = this.state; return compose( @@ -366,7 +366,7 @@ export class MockClientPaginationTable extends React.Component { totalPages = () => { const { perPage } = this.state.pagination; return Math.ceil(mockRows.length / perPage); - } + }; render() { const { columns, pagination, sortingColumns, pageChangeValue } = this.state; const sortedPaginatedRows = this.currentRows(); diff --git a/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockServerPaginationTable.js b/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockServerPaginationTable.js index 7189dd5ea8a..80eb02ce349 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockServerPaginationTable.js +++ b/packages/patternfly-3/patternfly-react/src/components/Table/__mocks__/mockServerPaginationTable.js @@ -211,14 +211,14 @@ export class MockServerPaginationTable extends React.Component { const newPaginationState = Object.assign({}, this.state.pagination); newPaginationState.page = page; this.getPage(this.state.sortingColumns, newPaginationState); - } + }; onPerPageSelect = (eventKey, e) => { const newPaginationState = Object.assign({}, this.state.pagination); newPaginationState.perPage = eventKey; newPaginationState.page = 1; this.getPage(this.state.sortingColumns, newPaginationState); - } + }; onSelectAllRows = event => { const { sortingColumns, pagination, rows } = this.state; @@ -227,7 +227,7 @@ export class MockServerPaginationTable extends React.Component { // refresh rows after all rows selected this.getPage(sortingColumns, pagination); }); - } + }; onSelectRow = (event, row) => { const { sortingColumns, pagination } = this.state; @@ -235,7 +235,7 @@ export class MockServerPaginationTable extends React.Component { // refresh rows after row is selected this.getPage(sortingColumns, pagination); }); - } + }; onSort = (e, column, sortDirection) => { // Clearing existing sortingColumns does simple single column sort. To do multisort, // set each column based on existing sorts specified and set sort position. @@ -249,7 +249,7 @@ export class MockServerPaginationTable extends React.Component { alert(`Server API called with: sort by ${column.property} ${updatedSortingColumns[column.property].direction}`); this.getPage(updatedSortingColumns, this.state.pagination); - } + }; getPage(sortingColumns, pagination) { const { onServerPageLogger } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/ToastNotification/TimedToastNotification.js b/packages/patternfly-3/patternfly-react/src/components/ToastNotification/TimedToastNotification.js index d664e68238b..c6fce04bd4d 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ToastNotification/TimedToastNotification.js +++ b/packages/patternfly-3/patternfly-react/src/components/ToastNotification/TimedToastNotification.js @@ -43,12 +43,12 @@ class TimedToastNotification extends React.Component { onMouseEnter = () => { const { onMouseEnter } = this.props; onMouseEnter && onMouseEnter(); - } + }; onMouseLeave = () => { const { onMouseLeave } = this.props; onMouseLeave && onMouseLeave(); - } + }; render() { const { children, className, type, onDismiss } = this.props; const { onMouseEnter, onMouseLeave } = this; diff --git a/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotification.stories.js b/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotification.stories.js index 818c17254d8..b6ff9e27b33 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotification.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotification.stories.js @@ -70,7 +70,7 @@ class ToastNotificationStoryWrapper extends React.Component { type: 'info', persistent: false, timerdelay: 8000, - message: 'By default, a toast notification\'s timer expires after eight seconds.' + message: "By default, a toast notification's timer expires after eight seconds." }, { key: 2, diff --git a/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotificationList.js b/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotificationList.js index d9a615781d5..fe5bbadf510 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotificationList.js +++ b/packages/patternfly-3/patternfly-react/src/components/ToastNotification/ToastNotificationList.js @@ -18,19 +18,19 @@ class ToastNotificationList extends React.Component { this.setState({ paused: true }); const { onMouseEnter } = this.props; onMouseEnter(); - } + }; onMouseLeave = () => { this.setState({ paused: false }); const { onMouseLeave } = this.props; onMouseLeave(); - } + }; onMouseOver = () => { this.setState({ paused: true }); const { onMouseOver } = this.props; onMouseOver(); - } + }; renderChildren() { const { paused } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/Toolbar/ToolbarFind.js b/packages/patternfly-3/patternfly-react/src/components/Toolbar/ToolbarFind.js index 7a81ea1b44e..72f9e606cf5 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Toolbar/ToolbarFind.js +++ b/packages/patternfly-3/patternfly-react/src/components/Toolbar/ToolbarFind.js @@ -19,7 +19,7 @@ class ToolbarFind extends React.Component { if (keyEvent.key === 'Enter' && onEnter) { onEnter(currentValue); } - } + }; handleFindNext = () => { const { currentValue } = this.state; @@ -28,7 +28,7 @@ class ToolbarFind extends React.Component { if (onFindNext) { onFindNext(currentValue); } - } + }; handleFindPrevious = () => { const { currentValue } = this.state; @@ -37,7 +37,7 @@ class ToolbarFind extends React.Component { if (onFindPrevious) { onFindPrevious(currentValue); } - } + }; handleValueChange = event => { const { onChange } = this.props; @@ -47,15 +47,15 @@ class ToolbarFind extends React.Component { if (onChange) { onChange(event.target.value); } - } + }; hideDropdown = () => { this.setState({ dropdownShown: false }); - } + }; toggleDropdownShown = () => { this.setState(prevState => ({ dropdownShown: !prevState.dropdownShown })); - } + }; renderCounts() { const { currentValue } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js b/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js index 0e5585ad349..8fb4f02a42f 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Toolbar/__mocks__/mockToolbarExample.js @@ -26,7 +26,7 @@ export class MockToolbarExample extends React.Component { keyEvent.stopPropagation(); keyEvent.preventDefault(); } - } + }; setViewType(viewType) { const { onViewChanged } = this.props; @@ -47,13 +47,13 @@ export class MockToolbarExample extends React.Component { this.filterAdded(currentFilterType, filterValue); } } - } + }; clearFilters = () => { const { onFiltersChanged } = this.props; this.setState({ activeFilters: [] }); onFiltersChanged && onFiltersChanged('Filters cleared.'); - } + }; filterAdded = (field, value) => { const { onFiltersChanged } = this.props; @@ -77,14 +77,14 @@ export class MockToolbarExample extends React.Component { const activeFilters = [...this.state.activeFilters, { label: filterText }]; this.setState({ activeFilters }); onFiltersChanged && onFiltersChanged(`Filter Added: ${filterText}`); - } + }; filterCategorySelected = category => { const { filterCategory } = this.state; if (filterCategory !== category) { this.setState({ filterCategory: category }); } - } + }; filterValueSelected = filterValue => { const { currentFilterType, currentValue } = this.state; @@ -95,7 +95,7 @@ export class MockToolbarExample extends React.Component { this.filterAdded(currentFilterType, filterValue); } } - } + }; removeFilter = filter => { const { onFiltersChanged } = this.props; @@ -107,7 +107,7 @@ export class MockToolbarExample extends React.Component { this.setState({ activeFilters: updated }); } onFiltersChanged && onFiltersChanged(`Filter Removed: ${filter.label}`); - } + }; selectFilterType = filterType => { const { currentFilterType } = this.state; @@ -118,7 +118,7 @@ export class MockToolbarExample extends React.Component { this.setState({ filterCategory: undefined }); } } - } + }; toggleCurrentSortDirection = () => { const { isSortAscending } = this.state; @@ -126,7 +126,7 @@ export class MockToolbarExample extends React.Component { this.setState({ isSortAscending: !isSortAscending }); onSortChanged && onSortChanged(`sort ascending: ${!isSortAscending}`); - } + }; updateCurrentSortType = sortType => { const { currentSortType } = this.state; @@ -140,11 +140,11 @@ export class MockToolbarExample extends React.Component { }); } onSortChanged && onSortChanged(`sort type: ${sortType.title}`); - } + }; updateCurrentValue = event => { this.setState({ currentValue: event.target.value }); - } + }; renderInput() { const { currentFilterType, currentValue, filterCategory } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeView.js b/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeView.js index 74b50133226..0abb5006c21 100644 --- a/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeView.js +++ b/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeView.js @@ -16,7 +16,7 @@ class TreeView extends React.Component { onFocus = node => { this.setState(() => ({ focusedNodeId: node.dataset.id })); - } + }; onKeyDown = event => { const nodes = this.getVisibleNodes([...this.treeRef.current.getElementsByTagName('li')]); @@ -33,7 +33,7 @@ class TreeView extends React.Component { const [lastVisibleNode] = nodes.slice(-1); lastVisibleNode.focus(); } - } + }; onKeyPress = event => { const nodes = this.getVisibleNodes([...this.treeRef.current.getElementsByTagName('li')]); @@ -58,13 +58,13 @@ class TreeView extends React.Component { if (key === '*') { this.setState(prevState => ({ expandSiblings: prevState.focusedNodeId })); } - } + }; getVisibleNodes = nodes => nodes.filter(node => !node.className.match(/node-hidden/)); clearExpandSiblings = () => { this.setState(() => ({ expandSiblings: '' })); - } + }; treeRef = React.createRef(); diff --git a/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeViewNode.js b/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeViewNode.js index b513f8c7f2d..c4562eb9d50 100644 --- a/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeViewNode.js +++ b/packages/patternfly-3/patternfly-react/src/components/TreeView/TreeViewNode.js @@ -64,17 +64,17 @@ class TreeViewNode extends Component { e.stopPropagation(); this.handleSelect(e); } - } + }; onFocus = e => { e.stopPropagation(); this.props.onFocus(this.nodeRef.current); this.setState(() => ({ focused: true })); - } + }; onBlur = () => { this.setState(() => ({ focused: false })); - } + }; handleSelect = e => { const { node, selectNode } = this.props; @@ -85,16 +85,16 @@ class TreeViewNode extends Component { this.nodeRef.current.focus(); selectNode(node); } - } + }; toggleExpand = e => { e.stopPropagation(); this.toggleExpandedState(); - } + }; toggleExpandedState = () => { this.setState(prevState => ({ expanded: !prevState.expanded })); - } + }; nodeRef = React.createRef(); diff --git a/packages/patternfly-3/patternfly-react/src/components/TreeView/__mocks__/MockTreeView.js b/packages/patternfly-3/patternfly-react/src/components/TreeView/__mocks__/MockTreeView.js index 677aa85ef5f..8c9400277d7 100644 --- a/packages/patternfly-3/patternfly-react/src/components/TreeView/__mocks__/MockTreeView.js +++ b/packages/patternfly-3/patternfly-react/src/components/TreeView/__mocks__/MockTreeView.js @@ -27,13 +27,13 @@ export class MockTreeView extends React.Component { return { ...node, selected: false }; } return node; - }) + }); selectNode = selectedNode => { this.setState(prevState => ({ nodes: this.nodeSelector(prevState.nodes, selectedNode) })); - } + }; render() { const { nodes } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/AsyncTypeAheadSelect.js b/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/AsyncTypeAheadSelect.js index 53d17c9505c..766f4124607 100644 --- a/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/AsyncTypeAheadSelect.js +++ b/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/AsyncTypeAheadSelect.js @@ -16,7 +16,7 @@ class AsyncTypeAheadSelect extends React.Component { handleSearch = query => { this.onSearchStart(); Promise.resolve(this.props.onSearch(query)).then(options => this.onSearchEnd(options)); - } + }; render() { const { innerRef, ...props } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/mock.js b/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/mock.js index 14dcfbf6514..63fd6ee93d8 100644 --- a/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/mock.js +++ b/packages/patternfly-3/patternfly-react/src/components/TypeAheadSelect/mock.js @@ -185,7 +185,7 @@ const mockData = { 'Tajikistan', 'Tanzania', 'Thailand', - 'Timor L\'Este', + "Timor L'Este", 'Togo', 'Tonga', 'Trinidad & Tobago', diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.js index 393fd9626b6..a85a3477277 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.js @@ -63,29 +63,29 @@ class BaseVerticalNav extends React.Component { const { onLayoutChange, setControlledState } = this.props; setControlledState({ isMobile: newLayout === 'mobile' }); onLayoutChange && onLayoutChange(newLayout); - } + }; setActivePath = activePath => { if (!this.state.controlledActivePath) { this.props.setControlledState({ activePath }); } - } + }; setControlledActivePath = controlledActivePath => { this.setState({ controlledActivePath }); - } + }; setControlledHoverPath = controlledHoverPath => { this.setState({ controlledHoverPath }); - } + }; setControlledMobilePath = controlledMobilePath => { this.setState({ controlledMobilePath }); - } + }; setControlledPinnedPath = controlledPinnedPath => { this.setState({ controlledPinnedPath }); - } + }; setHoverPath = hoverPath => { if (!this.state.controlledHoverPath) { @@ -94,56 +94,56 @@ class BaseVerticalNav extends React.Component { ...(hoverPath === null ? { showMobileNav: false } : {}) }); } - } + }; setMobilePath = mobilePath => { if (!this.state.controlledMobilePath) { this.props.setControlledState({ mobilePath }); } - } + }; setPinnedPath = pinnedPath => { if (!this.state.controlledPinnedPath) { this.props.setControlledState({ pinnedPath }); } - } + }; hoverTimer = new Timer(); clearBodyClasses = () => { if (this.props.dynamicBodyClasses) { setBodyClassIf(false, 'collapsed-nav'); setBodyClassIf(false, 'hidden-nav'); } - } + }; collapseMenu = () => { const { onCollapse, setControlledState } = this.props; setControlledState({ navCollapsed: true }); onCollapse && onCollapse(); - } + }; expandMenu = () => { const { onExpand, setControlledState } = this.props; setControlledState({ navCollapsed: false }); onExpand && onExpand(); - } + }; forceHideSecondaryMenu = () => { this.setState({ forceHidden: true }); // eslint-disable-line react/no-unused-state setTimeout(() => { this.setState({ forceHidden: false }); // eslint-disable-line react/no-unused-state }, 500); - } + }; handleBodyClick = () => { // Clear hover state on body click. Helps especially when using blurDisabled prop. this.setHoverPath(null); - } + }; navigateToItem = item => { const { onNavigate } = this.props; onNavigate(item); // Note: This should become router-aware later on. - } + }; updateBodyClasses = () => { // Note: Updating the body element classes from here like this is a hacky, non-react-y pattern. @@ -154,7 +154,7 @@ class BaseVerticalNav extends React.Component { setBodyClassIf(!isMobile && collapsed, 'collapsed-nav'); setBodyClassIf(isMobile, 'hidden-nav'); } - } + }; updateNavOnItemBlur = (primary, secondary, tertiary, idPath, parentPath, noDelay, callback) => { const { hoverPath, blurDelay, blurDisabled, setControlledState } = this.props; @@ -181,7 +181,7 @@ class BaseVerticalNav extends React.Component { } } } - } + }; updateNavOnItemClick = (primary, secondary, tertiary, idPath, parentPath) => { const { onItemClick, hoverPath, hoverDisabled, isMobile } = this.props; @@ -201,7 +201,7 @@ class BaseVerticalNav extends React.Component { this.navigateToItem(item); } onItemClick && onItemClick(primary, secondary, tertiary); - } + }; updateNavOnItemHover = (primary, secondary, tertiary, idPath, parentPath, callback) => { const { onItemHover, hoverPath, hoverDelay, hoverDisabled, isMobile } = this.props; @@ -221,7 +221,7 @@ class BaseVerticalNav extends React.Component { }, hoverDelay); } } - } + }; updateNavOnMenuToggleClick = () => { const { onMenuToggleClick, isMobile, showMobileNav, navCollapsed, setControlledState } = this.props; @@ -238,21 +238,21 @@ class BaseVerticalNav extends React.Component { this.collapseMenu(); } onMenuToggleClick && onMenuToggleClick(); - } + }; updateNavOnMobileSelection = (primary, secondary, tertiary) => { const { onMobileSelection } = this.props; // All the behavior here is handled by mobilePath and setMobilePath, // but we still make a callback available here. onMobileSelection && onMobileSelection(primary, secondary, tertiary); - } + }; updateNavOnPin = (item, depth, pinned) => { const { onItemPin, isMobile } = this.props; if (!isMobile) { onItemPin && onItemPin(item, depth, pinned); } - } + }; render() { const { items, children } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.stories.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.stories.js index 9f8447198fe..9ef30c6c463 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNav.stories.js @@ -215,7 +215,8 @@ stories.add( 'Custom Masthead', withInfo({ propTablesExclude: [MockFixedLayout, MockIconBarChildren, Icon, MenuItem, Dropdown, Dropdown.Menu, Dropdown.Toggle], - text: 'Example using the **Masthead**, **Brand** and **IconBar** components with images. (items from \'Items as Objects\').' + text: + "Example using the **Masthead**, **Brand** and **IconBar** components with images. (items from 'Items as Objects')." })(() => (
diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavConstants.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavConstants.js index 4772ceda46d..a84168296ee 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavConstants.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavConstants.js @@ -118,9 +118,15 @@ const getNextDepth = depth => const deepestOf = (pri, sec, ter) => (pri && sec && ter) || (pri && sec) || pri; const componentForDepth = depth => { - if (depth === 'primary') { return VerticalNavItem; } - if (depth === 'secondary') { return VerticalNavSecondaryItem; } - if (depth === 'tertiary') { return VerticalNavTertiaryItem; } + if (depth === 'primary') { + return VerticalNavItem; + } + if (depth === 'secondary') { + return VerticalNavSecondaryItem; + } + if (depth === 'tertiary') { + return VerticalNavTertiaryItem; + } return null; }; diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItem.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItem.js index bb63db12a77..927054ce0f1 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItem.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItem.js @@ -9,7 +9,9 @@ import VerticalNavItemHelper from './VerticalNavItemHelper'; * In the future, we could lift some of the primary-specific code from Helper into this file. */ const BaseVerticalNavItem = props => { - if (wrongDepth(props, 'primary')) { return correctDepth(props); } + if (wrongDepth(props, 'primary')) { + return correctDepth(props); + } return ; }; diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js index 74a41d4e261..292e0da4762 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavItemHelper.js @@ -78,7 +78,7 @@ class BaseVerticalNavItemHelper extends React.Component { const { primary, secondary, tertiary } = this.getContextNavItems(); const { updateNavOnItemBlur, idPath, onBlur } = this.props; updateNavOnItemBlur(primary, secondary, tertiary, this.idPath(), idPath, noDelay, onBlur); - } + }; onItemClick = event => { const { primary, secondary, tertiary } = this.getContextNavItems(); @@ -95,19 +95,19 @@ class BaseVerticalNavItemHelper extends React.Component { } this.setActive(); onClick && onClick(primary, secondary, tertiary); - } + }; onItemHover = () => { const { primary, secondary, tertiary } = this.getContextNavItems(); const { updateNavOnItemHover, idPath, onHover } = this.props; updateNavOnItemHover(primary, secondary, tertiary, this.idPath(), idPath, onHover); - } + }; onMobileSelection = (primary, secondary, tertiary) => { const { setMobilePath, updateNavOnMobileSelection } = this.props; setMobilePath(this.idPath()); updateNavOnMobileSelection(primary, secondary, tertiary); - } + }; getContextNavItems = () => { // We have primary, secondary, and tertiary items as props if they are part of the parent context, @@ -119,11 +119,11 @@ class BaseVerticalNavItemHelper extends React.Component { secondary: depth === 'secondary' ? navItem : secondaryItem, tertiary: depth === 'tertiary' ? navItem : tertiaryItem }; - } + }; setActive = () => { this.props.setActivePath(this.idPath()); - } + }; setHovered() { this.props.setHoverPath(this.idPath()); @@ -132,7 +132,7 @@ class BaseVerticalNavItemHelper extends React.Component { id = () => { const { id, title } = this.navItem(null, true); // Need to ignorePath here so we don't get an infinite call stack... return id || title || this.props.index; - } + }; idPath = () => `${this.props.idPath}${this.id()}/`; @@ -150,7 +150,7 @@ class BaseVerticalNavItemHelper extends React.Component { selectedOnMobile: valOrOnPath(item.selectedOnMobile, props.mobilePath), pinned: valOrOnPath(item.pinned, props.pinnedPath) }; - } + }; pinNextDepth = () => { const { @@ -181,7 +181,7 @@ class BaseVerticalNavItemHelper extends React.Component { } } updateNavOnPin(this.navItem(), nextDepth, !pinnedPath); - } + }; render() { const { diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavSecondaryItem.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavSecondaryItem.js index 847044a2f64..abb29759b92 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavSecondaryItem.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavSecondaryItem.js @@ -9,7 +9,9 @@ import VerticalNavItemHelper from './VerticalNavItemHelper'; * In the future, we could lift some of the secondary-specific code from Helper into this file. */ const BaseVerticalNavSecondaryItem = props => { - if (wrongDepth(props, 'secondary')) { return correctDepth(props); } + if (wrongDepth(props, 'secondary')) { + return correctDepth(props); + } return ; }; diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavTertiaryItem.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavTertiaryItem.js index a7d4443b516..48e91daa135 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavTertiaryItem.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/VerticalNavTertiaryItem.js @@ -9,7 +9,9 @@ import VerticalNavItemHelper from './VerticalNavItemHelper'; * In the future, we could lift some of the tertiary-specific code from Helper into this file. */ const BaseVerticalNavTertiaryItem = props => { - if (wrongDepth(props, 'tertiary')) { return correctDepth(props); } + if (wrongDepth(props, 'tertiary')) { + return correctDepth(props); + } return ; }; diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockNavItems.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockNavItems.js index 852539a301c..715259be74c 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockNavItems.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockNavItems.js @@ -96,7 +96,7 @@ export const mockNavItems = [ badges: [ { count: 9999, - tooltip: 'Whoa, that\'s a lot' + tooltip: "Whoa, that's a lot" } ] }, diff --git a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockWithMastHeadComponent.js b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockWithMastHeadComponent.js index 169a1367a72..759d803214d 100644 --- a/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockWithMastHeadComponent.js +++ b/packages/patternfly-3/patternfly-react/src/components/VerticalNav/__mocks__/mockWithMastHeadComponent.js @@ -9,7 +9,7 @@ export class MockWithMastHeadComponent extends React.Component { onCollapse = () => { this.setState({ collapse: !this.state.collapse }); - } + }; render() { return ( diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/StatefulWizardPattern.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/StatefulWizardPattern.js index d105aae944d..f6ba81a9d2b 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/StatefulWizardPattern.js +++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/StatefulWizardPattern.js @@ -33,7 +33,7 @@ class StatefulWizardPattern extends React.Component { return; } this.setState({ activeStepIndex: newStepIndex }); - } + }; render() { const { shouldDisableNextStep, shouldDisablePreviousStep, shouldDisableCancelButton, ...otherProps } = this.props; diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js index 26510ffeee7..ef4c3a03981 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js +++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Patterns/WizardPattern.js @@ -58,18 +58,26 @@ const WizardPattern = ({ const activeStep = getStep(); const goToStep = newStepIndex => { - if (shouldPreventGoToStep(newStepIndex)) { return; } + if (shouldPreventGoToStep(newStepIndex)) { + return; + } if (newStepIndex === activeStepIndex + 1) { const stepOnNextResult = activeStep.onNext && activeStep.onNext(); const propOnNextResult = onNext(newStepIndex); const stepFailed = stepOnNextResult === false || propOnNextResult === false; - if (stepFailed) { return; } + if (stepFailed) { + return; + } } if (newStepIndex === activeStepIndex - 1) { const stepFailed = onBack(newStepIndex) === false; - if (stepFailed) { return; } + if (stepFailed) { + return; + } + } + if (onStepChanged) { + onStepChanged(newStepIndex); } - if (onStepChanged) { onStepChanged(newStepIndex); } }; const shouldPreventGoToStep = newStepIndex => { diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/LoadingWizardExample.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/LoadingWizardExample.js index 4c741e6ae10..59dcf2e6b2a 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/LoadingWizardExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/LoadingWizardExample.js @@ -12,10 +12,10 @@ export class LoadingWizardExample extends React.Component { } close = () => { this.setState({ showModal: false }); - } + }; open = () => { this.setState({ showModal: true }); - } + }; render() { const { showModal } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js index 42b17eb44f4..cde44b59d2f 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardExample.js @@ -11,10 +11,10 @@ import { renderWizardSteps, renderSidebarItems, renderWizardContents } from './m export class WizardExample extends MockWizardBase { open = () => { this.setState({ showModal: true }); - } + }; close = () => { this.setState({ showModal: false }); - } + }; render() { const { showModal, activeStepIndex, activeSubStepIndex } = this.state; diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardPatternExample.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardPatternExample.js index 6a65b88de5f..9f3244ceeaa 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardPatternExample.js +++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/WizardPatternExample.js @@ -28,13 +28,13 @@ export class WizardPatternExample extends React.Component { close = () => { this.setState({ showModal: false, loading: false }); - } + }; open = () => { this.setState({ showModal: true, loading: true }); setTimeout(() => { this.setState({ loading: false }); }, 1000); - } + }; renderStateless = () => { // We need knobs on the stateless example, because we must drive its state ourselves. const { loading, activeStepIndex } = this.state; @@ -64,7 +64,7 @@ export class WizardPatternExample extends React.Component { />
); - } + }; renderStateful = () => ( // No knobs for the stateful example, we want to let it control its own state.
@@ -84,7 +84,7 @@ export class WizardPatternExample extends React.Component { loading={this.state.loading} />
- ) + ); render() { return this.props.stateful ? this.renderStateful() : this.renderStateless(); } diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardBase.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardBase.js index 148086e03a4..ba024559f88 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardBase.js +++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardBase.js @@ -23,7 +23,7 @@ class MockWizardBase extends React.Component { activeSubStepIndex: steps[prevState.activeStepIndex - 1].subSteps.length - 1 })); } - } + }; onNextButtonClick = () => { const { steps } = this.props; const { activeStepIndex, activeSubStepIndex } = this.state; @@ -39,13 +39,13 @@ class MockWizardBase extends React.Component { activeSubStepIndex: 0 })); } - } + }; onSidebarItemClick = (stepIndex, subStepIndex) => { this.setState({ activeStepIndex: stepIndex, activeSubStepIndex: subStepIndex }); - } + }; onStepClick = stepIndex => { if (stepIndex === this.state.activeStepIndex) { return; @@ -54,7 +54,7 @@ class MockWizardBase extends React.Component { activeStepIndex: stepIndex, activeSubStepIndex: 0 }); - } + }; render() { return false; } diff --git a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardReviewStepsManager.js b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardReviewStepsManager.js index 8c7d78ae614..0f9bba1d4f5 100644 --- a/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardReviewStepsManager.js +++ b/packages/patternfly-3/patternfly-react/src/components/Wizard/Stories/mockWizardReviewStepsManager.js @@ -16,7 +16,7 @@ class MockWizardReviewStepsManager extends React.Component { this.setState({ steps: updated }); - } + }; subStepClicked = (e, stepIndex, subStepIndex) => { e.preventDefault(); const updated = [...this.state.steps]; @@ -24,7 +24,7 @@ class MockWizardReviewStepsManager extends React.Component { this.setState({ steps: updated }); - } + }; render() { const { steps } = this.state; return ( diff --git a/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.js b/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.js index 6ea69fc2623..41364823820 100644 --- a/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.js +++ b/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.js @@ -24,21 +24,25 @@ class SerialConsole extends React.Component { } onResetClick = event => { - if (event.button !== 0) { return; } + if (event.button !== 0) { + return; + } this.props.onDisconnect(); this.props.onConnect(); event.target.blur(); this.focusTerminal(); - } + }; onDisconnectClick = event => { - if (event.button !== 0) { return; } + if (event.button !== 0) { + return; + } this.props.onDisconnect(); event.target.blur(); this.focusTerminal(); - } + }; /** * Backend sent data. @@ -60,7 +64,7 @@ class SerialConsole extends React.Component { focusTerminal = () => { this.childTerminal && this.childTerminal.focus(); - } + }; render() { const { id, status, topClassName } = this.props; diff --git a/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.stories.js b/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.stories.js index 6ccb51a59df..acffffacdf8 100644 --- a/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.stories.js +++ b/packages/patternfly-3/react-console/src/SerialConsole/SerialConsole.stories.js @@ -44,13 +44,13 @@ export class SerialConsoleConnector extends React.Component { passKeys: false, status: DISCONNECTED // will close the terminal window }); - } + }; onConnect = () => { log('SerialConsoleConnector.onConnect(), ', this.state); this.setConnected(); this.tellFairyTale(); - } + }; onData = data => { log('UI terminal component produced data, i.e. a key was pressed, pass it to backend. [', data, ']'); @@ -60,32 +60,32 @@ export class SerialConsoleConnector extends React.Component { if (this.state.passKeys) { this.onDataFromBackend(data); } - } + }; onDataFromBackend = data => { log('Backend sent data, pass them to the UI component. [', data, ']'); if (this.childSerialconsole) { this.childSerialconsole.onDataReceived(data); } - } + }; onDisconnect = () => { this.setState({ status: DISCONNECTED }); timeoutIds.forEach(id => clearTimeout(id)); - } + }; onResize = (rows, cols) => { log('UI has been resized, pass this info to backend. [', rows, ', ', cols, ']'); - } + }; setConnected = () => { this.setState({ status: CONNECTED, passKeys: true }); - } + }; tellFairyTale = () => { let time = 1000; @@ -102,7 +102,7 @@ export class SerialConsoleConnector extends React.Component { time += 5000; timeoutIds.push(setTimeout(this.onBackendDisconnected, time)); - } + }; render() { return ( diff --git a/packages/patternfly-3/react-console/src/SerialConsole/XTerm.js b/packages/patternfly-3/react-console/src/SerialConsole/XTerm.js index 9d122ae8506..6a005a02047 100644 --- a/packages/patternfly-3/react-console/src/SerialConsole/XTerm.js +++ b/packages/patternfly-3/react-console/src/SerialConsole/XTerm.js @@ -100,7 +100,7 @@ class XTerm extends React.Component { // https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload event.returnValue = ''; return ''; - } + }; /** * Backend closed connection. @@ -125,11 +125,11 @@ class XTerm extends React.Component { onFocus = () => { window.addEventListener('beforeunload', this.onBeforeUnload); - } + }; onBlur = () => { window.removeEventListener('beforeunload', this.onBeforeUnload); - } + }; /** * If autoFit is enabled, compute the size and set it @@ -174,8 +174,10 @@ class XTerm extends React.Component { } focus = () => { - if (this.state.terminal) { this.state.terminal.focus(); } - } + if (this.state.terminal) { + this.state.terminal.focus(); + } + }; render() { // ensure react never reuses this div by keying it with the terminal widget diff --git a/packages/patternfly-3/react-console/src/SpiceConsole/SpiceConsole.js b/packages/patternfly-3/react-console/src/SpiceConsole/SpiceConsole.js index 82092c82b07..908ac2bca15 100644 --- a/packages/patternfly-3/react-console/src/SpiceConsole/SpiceConsole.js +++ b/packages/patternfly-3/react-console/src/SpiceConsole/SpiceConsole.js @@ -45,7 +45,7 @@ class SpiceConsole extends React.Component { } onConnected = () => { this.setState({ status: CONNECTED }); - } + }; onCtrlAltDel = e => { if (this.sc) { @@ -54,23 +54,23 @@ class SpiceConsole extends React.Component { sendCtrlAltDel(); window.sc = undefined; } - } + }; onSpiceError = e => { this.disconnect(); this.onDisconnected(e); // if (e !== undefined && e.message === "Permission denied.") { - } + }; onDisconnected = e => { this.setState({ status: DISCONNECTED }); this.props.onDisconnected(e); - } + }; onSecurityFailure = e => { this.setState({ status: DISCONNECTED }); this.props.onSecurityFailure(e); - } + }; render() { const { textDisconnected, textConnecting, textSendShortcut, textCtrlAltDel } = this.props; diff --git a/packages/patternfly-3/react-console/src/VncConsole/VncConsole.js b/packages/patternfly-3/react-console/src/VncConsole/VncConsole.js index 91d8af39448..a6df6a15508 100644 --- a/packages/patternfly-3/react-console/src/VncConsole/VncConsole.js +++ b/packages/patternfly-3/react-console/src/VncConsole/VncConsole.js @@ -73,45 +73,45 @@ class VncConsole extends React.Component { return; } this.rfb.disconnect(); - } + }; onConnected = () => { this.setState({ status: CONNECTED }); - } + }; onCtrlAltDel = e => { if (this.rfb) { this.rfb.sendCtrlAltDel(); this.focusVnc(e); } - } + }; onDisconnected = e => { this.setState({ status: DISCONNECTED }); this.props.onDisconnected(e); - } + }; onSecurityFailure = e => { this.setState({ status: DISCONNECTED }); this.props.onSecurityFailure(e); - } + }; removeEventListeners = () => { this.rfb.removeEventListener('connect', this.onConnected); this.rfb.removeEventListener('disconnect', this.onDisconnected); this.rfb.removeEventListener('securityfailure', this.onSecurityFailure); - } + }; setNovncElem = e => { this.novncElem = e; - } + }; focusVnc = e => { if (e && e.target && e.target.blur) { e.target.blur(); } this.novncElem && this.novncElem.focus(); - } + }; render() { const { diff --git a/packages/patternfly-4/react-charts/src/components/Chart/Chart.test.tsx b/packages/patternfly-4/react-charts/src/components/Chart/Chart.test.tsx index 94041f55506..a1535f42455 100644 --- a/packages/patternfly-4/react-charts/src/components/Chart/Chart.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/Chart/Chart.test.tsx @@ -4,7 +4,7 @@ import { Chart } from './Chart'; import { ChartGroup } from '../ChartGroup'; import { ChartLine } from '../ChartLine'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('Chart', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/Chart/Chart.tsx b/packages/patternfly-4/react-charts/src/components/Chart/Chart.tsx index a56b71b40c7..e5021ca5d8d 100644 --- a/packages/patternfly-4/react-charts/src/components/Chart/Chart.tsx +++ b/packages/patternfly-4/react-charts/src/components/Chart/Chart.tsx @@ -13,19 +13,13 @@ import { VictoryChart, VictoryChartProps, VictoryStyleInterface, - VictoryZoomContainer, + VictoryZoomContainer } from 'victory'; import { ChartContainer } from '../ChartContainer'; -import { - ChartLegend, - ChartLegendOrientation, - ChartLegendPosition, - ChartLegendWrapper -} from '../ChartLegend'; +import { ChartLegend, ChartLegendOrientation, ChartLegendPosition, ChartLegendWrapper } from '../ChartLegend'; import { ChartCommonStyles, ChartThemeDefinition } from '../ChartTheme'; import { getClassName, getLabelTextSize, getPaddingForSide, getTheme } from '../ChartUtils'; - /** * See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/victory/index.d.ts */ @@ -229,7 +223,7 @@ export interface ChartProps extends VictoryChartProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -244,7 +238,7 @@ export interface ChartProps extends VictoryChartProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -270,17 +264,20 @@ export interface ChartProps extends VictoryChartProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The scale prop determines which scales your chart should use. This prop can be * given as a string specifying a supported scale ("linear", "time", "log", "sqrt"), * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -302,7 +299,7 @@ export interface ChartProps extends VictoryChartProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * The standalone prop determines whether the component will render a standalone svg * or a tag that will be included in an external svg. Set standalone to false to @@ -360,7 +357,7 @@ export const Chart: React.FunctionComponent = ({ ariaDesc, ariaTitle, children, - legendComponent = , + legendComponent = , legendData, legendPosition = ChartCommonStyles.legend.position as ChartLegendPosition, padding, @@ -377,10 +374,10 @@ export const Chart: React.FunctionComponent = ({ ...rest }: ChartProps) => { const defaultPadding = { - bottom: getPaddingForSide('bottom', padding, theme.chart.padding), + bottom: getPaddingForSide('bottom', padding, theme.chart.padding), left: getPaddingForSide('left', padding, theme.chart.padding), right: getPaddingForSide('right', padding, theme.chart.padding), - top: getPaddingForSide('top', padding, theme.chart.padding), + top: getPaddingForSide('top', padding, theme.chart.padding) }; // Clone so users can override container props @@ -389,7 +386,7 @@ export const Chart: React.FunctionComponent = ({ title: ariaTitle, theme, ...containerComponent.props, - className: getClassName({className: containerComponent.props.className}) // Override VictoryContainer class name + className: getClassName({ className: containerComponent.props.className }) // Override VictoryContainer class name }); const legend = React.cloneElement(legendComponent, { @@ -412,7 +409,7 @@ export const Chart: React.FunctionComponent = ({ // Adjust for axis label React.Children.toArray(children).map((child: any) => { if (child.type.role === 'axis' && child.props.label && !child.props.dependentAxis) { - xAxisLabelHeight = getLabelTextSize({text: child.props.label, theme}).height + 10; + xAxisLabelHeight = getLabelTextSize({ text: child.props.label, theme }).height + 10; legendTitleHeight = 0; } }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.test.tsx index 1fb3b2b5cec..864a3e8bccf 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartArea } from '../ChartArea'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartArea', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.tsx b/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.tsx index cfa704e996b..03b4012aad7 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartArea/ChartArea.tsx @@ -201,7 +201,7 @@ export interface ChartAreaProps extends VictoryAreaProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -216,7 +216,7 @@ export interface ChartAreaProps extends VictoryAreaProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The name prop is used to reference a component instance when defining shared events. */ @@ -225,7 +225,7 @@ export interface ChartAreaProps extends VictoryAreaProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -251,7 +251,7 @@ export interface ChartAreaProps extends VictoryAreaProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The samples prop specifies how many individual points to plot when plotting * y as a function of x. Samples is ignored if x props are provided instead. @@ -263,10 +263,13 @@ export interface ChartAreaProps extends VictoryAreaProps { * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -288,7 +291,7 @@ export interface ChartAreaProps extends VictoryAreaProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * Use the sortKey prop to indicate how data should be sorted. This prop * is given directly to the lodash sortBy function to be executed on the @@ -389,7 +392,7 @@ export const ChartArea: React.FunctionComponent = ({ ...containerComponent.props }); return ; -} +}; // Note: VictoryArea.role must be hoisted hoistNonReactStatics(ChartArea, VictoryArea); diff --git a/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.test.tsx index 8555b10f3e1..bf763765772 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.test.tsx @@ -5,7 +5,7 @@ import { ChartAxis } from './ChartAxis'; import { ChartGroup } from '../ChartGroup'; import { ChartLine } from '../ChartLine'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartAxis', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.tsx b/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.tsx index 77f52cb57a6..b4dd9a6a413 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartAxis/ChartAxis.tsx @@ -9,7 +9,7 @@ import { PaddingProps, ScalePropType, VictoryAxis, - VictoryAxisProps, + VictoryAxisProps } from 'victory'; import { ChartContainer } from '../ChartContainer'; import { ChartThemeDefinition } from '../ChartTheme'; @@ -193,7 +193,7 @@ export interface ChartAxisProps extends VictoryAxisProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -208,7 +208,7 @@ export interface ChartAxisProps extends VictoryAxisProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * ChartAxis uses the standard name prop */ @@ -249,17 +249,20 @@ export interface ChartAxisProps extends VictoryAxisProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The scale prop determines which scales your chart should use. This prop can be * given as a string specifying a supported scale ("linear", "time", "log", "sqrt"), * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -285,7 +288,7 @@ export interface ChartAxisProps extends VictoryAxisProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * The standalone prop determines whether the component will render a standalone svg * or a tag that will be included in an external svg. Set standalone to false to @@ -310,22 +313,13 @@ export interface ChartAxisProps extends VictoryAxisProps { axis?: React.CSSProperties; axisLabel?: React.CSSProperties; grid?: { - [K in keyof React.CSSProperties]: - | string - | number - | ((tick?: any) => string | number) + [K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); }; ticks?: { - [K in keyof React.CSSProperties]: - | string - | number - | ((tick?: any) => string | number) + [K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); }; tickLabels?: { - [K in keyof React.CSSProperties]: - | string - | number - | ((tick?: any) => string | number) + [K in keyof React.CSSProperties]: string | number | ((tick?: any) => string | number); }; }; /** diff --git a/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.test.tsx index 48237775359..e0a4d6fb0b6 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.test.tsx @@ -4,7 +4,7 @@ import { Chart } from '../Chart'; import { ChartBar } from './ChartBar'; import { ChartGroup } from '../ChartGroup'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBar', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.tsx b/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.tsx index 8635f5cc7ca..4e13b7d62bb 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBar/ChartBar.tsx @@ -15,7 +15,7 @@ import { StringOrNumberOrCallback, VictoryStyleInterface, VictoryBar, - VictoryBarProps, + VictoryBarProps } from 'victory'; import { ChartContainer } from '../ChartContainer'; import { ChartThemeDefinition } from '../ChartTheme'; @@ -82,15 +82,16 @@ export interface ChartBarProps extends VictoryBarProps { * If this prop is given as a single number, the radius will only be applied to the top of each bar. * When this prop is given as a function, it will be evaluated with the arguments datum, and active. */ - cornerRadius?: NumberOrCallback + cornerRadius?: + | NumberOrCallback | { - top?: number | (NumberOrCallback), - topLeft?: number | (NumberOrCallback), - topRight?: number | (NumberOrCallback), - bottom?: number | (NumberOrCallback), - bottomLeft?: number | (NumberOrCallback), - bottomRight?: number | (NumberOrCallback) - }; + top?: number | (NumberOrCallback); + topLeft?: number | (NumberOrCallback); + topRight?: number | (NumberOrCallback); + bottom?: number | (NumberOrCallback); + bottomLeft?: number | (NumberOrCallback); + bottomRight?: number | (NumberOrCallback); + }; /** * The data prop specifies the data to be plotted. Data should be in the form of an array * of data points, or an array of arrays of data points for multiple datasets. @@ -228,7 +229,7 @@ export interface ChartBarProps extends VictoryBarProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -243,7 +244,7 @@ export interface ChartBarProps extends VictoryBarProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The name prop is used to reference a component instance when defining shared events. */ @@ -252,7 +253,7 @@ export interface ChartBarProps extends VictoryBarProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -278,7 +279,7 @@ export interface ChartBarProps extends VictoryBarProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The samples prop specifies how many individual points to plot when plotting * y as a function of x. Samples is ignored if x props are provided instead. @@ -290,10 +291,13 @@ export interface ChartBarProps extends VictoryBarProps { * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -315,7 +319,7 @@ export interface ChartBarProps extends VictoryBarProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * Use the sortKey prop to indicate how data should be sorted. This prop * is given directly to the lodash sortBy function to be executed on the @@ -405,7 +409,7 @@ export const ChartBar: React.FunctionComponent = ({ themeColor, themeVariant, - // destructure last + // destructure last theme = getTheme(themeColor, themeVariant), ...rest }: ChartBarProps) => { @@ -415,7 +419,7 @@ export const ChartBar: React.FunctionComponent = ({ ...containerComponent.props }); return ; -} +}; // Note: VictoryBar.getDomain & VictoryBar.role must be hoisted hoistNonReactStatics(ChartBar, VictoryBar); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.test.tsx index 1860a3d6123..39a839116b9 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBullet } from './ChartBullet'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletQualitativeRange', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -14,9 +14,9 @@ test('renders component data', () => { `${datum.name}: ${datum.y}`} - maxDomain={{y: 100}} + maxDomain={{ y: 100 }} primarySegmentedMeasureData={[{ name: 'Measure', y: 50 }]} qualitativeRangeData={[{ name: 'Range', y: 50 }, { name: 'Range', y: 75 }]} width={450} diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.tsx index e004ca84467..683616b59b5 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBullet.tsx @@ -1,11 +1,6 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - DataGetterPropType, - DomainPropType, - PaddingProps, - VictoryChart, -} from 'victory'; +import { DataGetterPropType, DomainPropType, PaddingProps, VictoryChart } from 'victory'; import { getComparativeMeasureErrorWidth, getComparativeMeasureWidth, @@ -243,7 +238,7 @@ export interface ChartBulletProps { * * Note: The x domain is expected to be `x: 2` in order to position all measures properly */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -260,7 +255,7 @@ export interface ChartBulletProps { * * Note: The x domain is expected to be `x: 0` in order to position all measures properly */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -540,10 +535,10 @@ export const ChartBullet: React.FunctionComponent = ({ }; const defaultPadding = { - bottom: getPaddingForSide('bottom', padding, theme.chart.padding), + bottom: getPaddingForSide('bottom', padding, theme.chart.padding), left: getPaddingForSide('left', padding, theme.chart.padding), right: getPaddingForSide('right', padding, theme.chart.padding), - top: getPaddingForSide('top', padding, theme.chart.padding), + top: getPaddingForSide('top', padding, theme.chart.padding) }; // Bullet group title @@ -574,7 +569,7 @@ export const ChartBullet: React.FunctionComponent = ({ // Comparative error measure const comparativeErrorMeasure = React.cloneElement(comparativeErrorMeasureComponent, { allowTooltip, - barWidth: getComparativeMeasureErrorWidth({height: chartSize.height, horizontal, width: chartSize.width}), + barWidth: getComparativeMeasureErrorWidth({ height: chartSize.height, horizontal, width: chartSize.width }), constrainToVisibleArea, data: comparativeErrorMeasureData, domain, @@ -592,7 +587,7 @@ export const ChartBullet: React.FunctionComponent = ({ // Comparative warning measure const comparativeWarningMeasure = React.cloneElement(comparativeWarningMeasureComponent, { allowTooltip, - barWidth: getComparativeMeasureWarningWidth({height: chartSize.height, horizontal, width: chartSize.width}), + barWidth: getComparativeMeasureWarningWidth({ height: chartSize.height, horizontal, width: chartSize.width }), constrainToVisibleArea, data: comparativeWarningMeasureData, domain, @@ -609,8 +604,8 @@ export const ChartBullet: React.FunctionComponent = ({ // Comparative zero measure const comparativeZeroMeasure = React.cloneElement(comparativeZeroMeasureComponent, { - barWidth: getComparativeMeasureWidth({height: chartSize.height, horizontal, width: chartSize.width}), - data: [{y: 0}], + barWidth: getComparativeMeasureWidth({ height: chartSize.height, horizontal, width: chartSize.width }), + data: [{ y: 0 }], domain, height: chartSize.height, horizontal, @@ -618,7 +613,7 @@ export const ChartBullet: React.FunctionComponent = ({ standalone: false, width: chartSize.width, ...comparativeZeroMeasureComponent.props - }) + }); // Legend const legend = React.cloneElement(legendComponent, { @@ -648,7 +643,7 @@ export const ChartBullet: React.FunctionComponent = ({ labelComponent: allowTooltip ? : undefined, labels, padding, - size: getPrimaryDotMeasureSize({height: chartSize.height, horizontal, width: chartSize.width}), + size: getPrimaryDotMeasureSize({ height: chartSize.height, horizontal, width: chartSize.width }), standalone: false, themeColor, themeVariant, @@ -661,7 +656,7 @@ export const ChartBullet: React.FunctionComponent = ({ const primarySegmentedMeasure = React.cloneElement(primarySegmentedMeasureComponent, { allowTooltip, constrainToVisibleArea, - barWidth: getPrimarySegmentedMeasureWidth({height: chartSize.height, horizontal, width: chartSize.width}), + barWidth: getPrimarySegmentedMeasureWidth({ height: chartSize.height, horizontal, width: chartSize.width }), data: primarySegmentedMeasureData, domain, height: chartSize.height, @@ -682,7 +677,7 @@ export const ChartBullet: React.FunctionComponent = ({ const qualitativeRange = React.cloneElement(qualitativeRangeComponent, { allowTooltip, constrainToVisibleArea, - barWidth: getQualitativeRangeBarWidth({height: chartSize.height, horizontal, width: chartSize.width}), + barWidth: getQualitativeRangeBarWidth({ height: chartSize.height, horizontal, width: chartSize.width }), data: qualitativeRangeData, domain, height: chartSize.height, @@ -710,7 +705,7 @@ export const ChartBullet: React.FunctionComponent = ({ range = maxVal - minVal; } const tickInterval = range / (ChartBulletStyles.axisTickCount - 1); - for (let i = minVal; i < maxVal;) { + for (let i = minVal; i < maxVal; ) { i += tickInterval; tickValues.push(Math.ceil(i)); } @@ -728,12 +723,16 @@ export const ChartBullet: React.FunctionComponent = ({ // Adjust for padding if (legendPosition === ChartLegendPosition.bottom) { dy = horizontal - ? defaultPadding.top * .5 + (defaultPadding.bottom * .5 - (defaultPadding.bottom)) - 25 - : title ? -defaultPadding.bottom + 60 : -defaultPadding.bottom; + ? defaultPadding.top * 0.5 + (defaultPadding.bottom * 0.5 - defaultPadding.bottom) - 25 + : title + ? -defaultPadding.bottom + 60 + : -defaultPadding.bottom; } else if (legendPosition === ChartLegendPosition.bottomLeft) { dy = horizontal - ? defaultPadding.top * .5 + (defaultPadding.bottom * .5 - (defaultPadding.bottom)) - 25 - : title ? -defaultPadding.bottom + 60 : -defaultPadding.bottom; + ? defaultPadding.top * 0.5 + (defaultPadding.bottom * 0.5 - defaultPadding.bottom) - 25 + : title + ? -defaultPadding.bottom + 60 + : -defaultPadding.bottom; dx = -10; } return ( @@ -755,12 +754,12 @@ export const ChartBullet: React.FunctionComponent = ({ // Returns comparative zero measure const getComparativeZeroMeasure = () => { const _domain: any = domain; - const low = Array.isArray(_domain) - ? _domain[0] - : _domain.y && Array.isArray(_domain.y) ? _domain.y[0] : 0; + const low = Array.isArray(_domain) ? _domain[0] : _domain.y && Array.isArray(_domain.y) ? _domain.y[0] : 0; const high = Array.isArray(_domain) ? _domain[_domain.length - 1] - : _domain.y && Array.isArray(_domain.y) ? _domain.y[_domain.y.length - 1] : 0; + : _domain.y && Array.isArray(_domain.y) + ? _domain.y[_domain.y.length - 1] + : 0; if (low < 0 && high > 0) { return comparativeZeroMeasure; @@ -771,14 +770,16 @@ export const ChartBullet: React.FunctionComponent = ({ // Axis component for custom tick values const axis = React.cloneElement(axisComponent, { dependentAxis: horizontal ? false : true, - domain: !horizontal ? domain : { - x: (domain as any).y, - y: (domain as any).x - }, + domain: !horizontal + ? domain + : { + x: (domain as any).y, + y: (domain as any).x + }, height: chartSize.height, // Adjust for padding - offsetX: !horizontal ? defaultPadding.left * .5 + (defaultPadding.right * .5 - (defaultPadding.right - 55)) : 0, - offsetY: horizontal ? 80 - defaultPadding.top * .5 + (defaultPadding.bottom * .5 - 25) : 0, + offsetX: !horizontal ? defaultPadding.left * 0.5 + (defaultPadding.right * 0.5 - (defaultPadding.right - 55)) : 0, + offsetY: horizontal ? 80 - defaultPadding.top * 0.5 + (defaultPadding.bottom * 0.5 - 25) : 0, padding, standalone: false, tickCount: ChartBulletStyles.axisTickCount, @@ -803,19 +804,11 @@ export const ChartBullet: React.FunctionComponent = ({ ); return standalone ? ( - + {bulletChart} ) : ( - - {bulletChart} - + {bulletChart} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.test.tsx index 70ec37eef46..b68c2fe56e7 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletComparativeErrorMeasure } from './ChartBulletComparativeErrorMeasure'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletComparativeErrorMeasure', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -10,12 +10,6 @@ Object.values([true, false]).forEach((isRead) => { }); test('renders component data', () => { - const view = shallow( - - ); + const view = shallow(); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.tsx index d7ed97682c6..5a216ee9548 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeErrorMeasure.tsx @@ -1,14 +1,8 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - DataGetterPropType, - DomainPropType, - NumberOrCallback, - PaddingProps, - VictoryBar, -} from 'victory'; +import { DataGetterPropType, DomainPropType, NumberOrCallback, PaddingProps, VictoryBar } from 'victory'; import { ChartContainer } from '../ChartContainer'; -import { ChartThemeDefinition} from '../ChartTheme'; +import { ChartThemeDefinition } from '../ChartTheme'; import { getBulletComparativeErrorMeasureTheme } from '../ChartUtils'; import { ChartBulletComparativeMeasure } from './ChartBulletComparativeMeasure'; @@ -211,9 +205,7 @@ export const ChartBulletComparativeErrorMeasure: React.FunctionComponent ) : ( - - {measure} - + {measure} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.test.tsx index 15affe868a5..d65dd925056 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletComparativeMeasure } from './ChartBulletComparativeMeasure'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletComparativeMeasure', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -10,12 +10,6 @@ Object.values([true, false]).forEach((isRead) => { }); test('renders component data', () => { - const view = shallow( - - ); + const view = shallow(); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.tsx index 34ceea44e1a..3fc31dbc4f4 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeMeasure.tsx @@ -1,16 +1,10 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - DataGetterPropType, - DomainPropType, - NumberOrCallback, - PaddingProps, - VictoryBar, -} from 'victory'; -import { getComparativeMeasureData } from './utils'; +import { DataGetterPropType, DomainPropType, NumberOrCallback, PaddingProps, VictoryBar } from 'victory'; +import { getComparativeMeasureData } from './utils'; import { ChartBar } from '../ChartBar'; import { ChartContainer } from '../ChartContainer'; -import { ChartBulletStyles, ChartThemeDefinition} from '../ChartTheme'; +import { ChartBulletStyles, ChartThemeDefinition } from '../ChartTheme'; import { ChartTooltip } from '../ChartTooltip'; import { getBulletComparativeMeasureTheme } from '../ChartUtils'; @@ -202,14 +196,14 @@ export const ChartBulletComparativeMeasure: React.FunctionComponent { if (!horizontal) { return 0; } - const result = (typeof barWidth === 'function') ? barWidth(data, false) : barWidth; + const result = typeof barWidth === 'function' ? barWidth(data, false) : barWidth; return -(result / 2); }, orientation: 'top', @@ -219,7 +213,7 @@ export const ChartBulletComparativeMeasure: React.FunctionComponent { return React.cloneElement(measureComponent, { barWidth, - data: [{...dataPoint}], + data: [{ ...dataPoint }], domain, height, horizontal, @@ -239,9 +233,7 @@ export const ChartBulletComparativeMeasure: React.FunctionComponent ) : ( - - {measure} - + {measure} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.test.tsx index ce00bdfb564..f87bf35ce3e 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletComparativeWarningMeasure } from './ChartBulletComparativeWarningMeasure'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletComparativeZeroMeasure', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -11,11 +11,7 @@ Object.values([true, false]).forEach((isRead) => { test('renders component data', () => { const view = shallow( - + ); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.tsx index ec1006b3cad..c9623972e4a 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletComparativeWarningMeasure.tsx @@ -1,14 +1,8 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - DataGetterPropType, - DomainPropType, - NumberOrCallback, - PaddingProps, - VictoryBar, -} from 'victory'; +import { DataGetterPropType, DomainPropType, NumberOrCallback, PaddingProps, VictoryBar } from 'victory'; import { ChartContainer } from '../ChartContainer'; -import { ChartThemeDefinition} from '../ChartTheme'; +import { ChartThemeDefinition } from '../ChartTheme'; import { getBulletComparativeWarningMeasureTheme } from '../ChartUtils'; import { ChartBulletComparativeMeasure } from './ChartBulletComparativeMeasure'; @@ -161,7 +155,9 @@ export interface ChartBulletComparativeWarningMeasureProps { y?: DataGetterPropType; } -export const ChartBulletComparativeWarningMeasure: React.FunctionComponent = ({ +export const ChartBulletComparativeWarningMeasure: React.FunctionComponent< + ChartBulletComparativeWarningMeasureProps +> = ({ allowTooltip = true, ariaDesc, ariaTitle, @@ -211,9 +207,7 @@ export const ChartBulletComparativeWarningMeasure: React.FunctionComponent ) : ( - - {measure} - + {measure} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.test.tsx index 3eab6fe3dbb..700d3873f1a 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletGroupTitle } from './ChartBulletGroupTitle'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletGroupTitle', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -10,11 +10,6 @@ Object.values([true, false]).forEach((isRead) => { }); test('renders component data', () => { - const view = shallow( - - ); + const view = shallow(); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.tsx index 89a723dbe3d..a333ffd272f 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletGroupTitle.tsx @@ -1,13 +1,16 @@ import * as React from 'react'; -import { - PaddingProps, - StringOrNumberOrCallback, -} from 'victory'; +import { PaddingProps, StringOrNumberOrCallback } from 'victory'; import { Line } from 'victory-core'; import { ChartContainer } from '../ChartContainer'; import { ChartLabel } from '../ChartLabel'; import { ChartBulletStyles, ChartThemeDefinition } from '../ChartTheme'; -import { getBulletGroupTitleTheme, getLabelTextSize, getBulletLabelX, getBulletLabelY, getPaddingForSide } from '../ChartUtils'; +import { + getBulletGroupTitleTheme, + getLabelTextSize, + getBulletLabelX, + getBulletLabelY, + getPaddingForSide +} from '../ChartUtils'; /** * See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/victory/index.d.ts @@ -130,26 +133,27 @@ export const ChartBulletGroupTitle: React.FunctionComponent { const defaultPadding = { - bottom: getPaddingForSide('bottom', padding, theme.chart.padding), + bottom: getPaddingForSide('bottom', padding, theme.chart.padding), left: getPaddingForSide('left', padding, theme.chart.padding), right: getPaddingForSide('right', padding, theme.chart.padding), - top: getPaddingForSide('top', padding, theme.chart.padding), + top: getPaddingForSide('top', padding, theme.chart.padding) }; const labelPadding = { - bottom: getPaddingForSide('bottom', padding, theme.legend.style.labels.padding), + bottom: getPaddingForSide('bottom', padding, theme.legend.style.labels.padding), left: getPaddingForSide('left', padding, theme.legend.style.labels.padding), right: getPaddingForSide('right', padding, theme.legend.style.labels.padding), - top: getPaddingForSide('top', padding, theme.legend.style.labels.padding), + top: getPaddingForSide('top', padding, theme.legend.style.labels.padding) }; // Horizontal divider to render under the group title const getDivider = () => { - const titleSize = getLabelTextSize({text: title, theme}); - const subTitleSize = getLabelTextSize({text: subTitle, theme}); - const dy = title && subTitle - ? titleSize.height + subTitleSize.height + labelPadding.top + labelPadding.bottom - : titleSize.height + labelPadding.top + labelPadding.bottom; + const titleSize = getLabelTextSize({ text: title, theme }); + const subTitleSize = getLabelTextSize({ text: subTitle, theme }); + const dy = + title && subTitle + ? titleSize.height + subTitleSize.height + labelPadding.top + labelPadding.bottom + : titleSize.height + labelPadding.top + labelPadding.bottom; return React.cloneElement(dividerComponent, { x1: defaultPadding.left, @@ -166,7 +170,7 @@ export const ChartBulletGroupTitle: React.FunctionComponent - {getTitle()} - {getDivider()} - - ) + const groupTitle = Boolean(title) && ( + + {getTitle()} + {getDivider()} + ); return standalone ? ( @@ -198,8 +200,6 @@ export const ChartBulletGroupTitle: React.FunctionComponent ) : ( - - {groupTitle} - + {groupTitle} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.test.tsx index 297eecccbed..a8fedaeb9c9 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletPrimaryDotMeasure } from './ChartBulletPrimaryDotMeasure'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletPrimaryDotMeasure', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -11,10 +11,7 @@ Object.values([true, false]).forEach((isRead) => { test('renders component data', () => { const view = shallow( - + ); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.tsx index 28a32ff33ae..1cf3a31d472 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimaryDotMeasure.tsx @@ -1,12 +1,7 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - DataGetterPropType, - DomainPropType, - PaddingProps, - VictoryScatter -} from 'victory'; -import { getPrimaryDotMeasureData } from './utils'; +import { DataGetterPropType, DomainPropType, PaddingProps, VictoryScatter } from 'victory'; +import { getPrimaryDotMeasureData } from './utils'; import { ChartContainer } from '../ChartContainer'; import { ChartScatter } from '../ChartScatter'; import { ChartBulletStyles, ChartThemeDefinition } from '../ChartTheme'; @@ -209,14 +204,14 @@ export const ChartBulletPrimaryDotMeasure: React.FunctionComponent { return React.cloneElement(measureComponent, { - data: [{...dataPoint}], + data: [{ ...dataPoint }], domain, height, horizontal, @@ -242,9 +237,7 @@ export const ChartBulletPrimaryDotMeasure: React.FunctionComponent ) : ( - - {measure} - + {measure} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.test.tsx index b79dbdbd416..82b8c90bbc2 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletPrimarySegmentedMeasure } from './ChartBulletPrimarySegmentedMeasure'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletPrimarySegmentedMeasure', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -11,10 +11,7 @@ Object.values([true, false]).forEach((isRead) => { test('renders component data', () => { const view = shallow( - + ); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.tsx index 748dd5c3f43..0e00f5753b3 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletPrimarySegmentedMeasure.tsx @@ -1,13 +1,7 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - DataGetterPropType, - DomainPropType, - NumberOrCallback, - PaddingProps, - VictoryBar, -} from 'victory'; -import { getPrimarySegmentedMeasureData } from './utils'; +import { DataGetterPropType, DomainPropType, NumberOrCallback, PaddingProps, VictoryBar } from 'victory'; +import { getPrimarySegmentedMeasureData } from './utils'; import { ChartBar } from '../ChartBar'; import { ChartContainer } from '../ChartContainer'; import { ChartBulletStyles, ChartThemeDefinition } from '../ChartTheme'; @@ -227,14 +221,14 @@ export const ChartBulletPrimarySegmentedMeasure: React.FunctionComponent { if (!horizontal) { return 0; } - const result = (typeof barWidth === 'function') ? barWidth(data, false) : barWidth; + const result = typeof barWidth === 'function' ? barWidth(data, false) : barWidth; return -(result / 2); }, orientation: 'top', @@ -244,7 +238,7 @@ export const ChartBulletPrimarySegmentedMeasure: React.FunctionComponent { return React.cloneElement(measureComponent, { barWidth, - data: [{...dataPoint}], + data: [{ ...dataPoint }], domain, height, horizontal, @@ -269,9 +263,7 @@ export const ChartBulletPrimarySegmentedMeasure: React.FunctionComponent ) : ( - - {measure} - + {measure} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.test.tsx index 19d6251f36e..d34ce604ec8 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletQualitativeRange } from './ChartBulletQualitativeRange'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletQualitativeRange', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -11,10 +11,7 @@ Object.values([true, false]).forEach((isRead) => { test('renders component data', () => { const view = shallow( - + ); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.tsx index 9812095581b..dfbd5f4d8f8 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletQualitativeRange.tsx @@ -1,13 +1,7 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - DataGetterPropType, - DomainPropType, - NumberOrCallback, - PaddingProps, - VictoryBar -} from 'victory'; -import { getQualitativeRangeData } from './utils'; +import { DataGetterPropType, DomainPropType, NumberOrCallback, PaddingProps, VictoryBar } from 'victory'; +import { getQualitativeRangeData } from './utils'; import { ChartBar } from '../ChartBar'; import { ChartContainer } from '../ChartContainer'; import { ChartBulletStyles, ChartThemeDefinition } from '../ChartTheme'; @@ -238,14 +232,14 @@ export const ChartBulletQualitativeRange: React.FunctionComponent { if (!horizontal) { return 0; } - const result = (typeof barWidth === 'function') ? barWidth(data, false) : barWidth; + const result = typeof barWidth === 'function' ? barWidth(data, false) : barWidth; return -(result / 2); }, orientation: 'top', @@ -255,7 +249,7 @@ export const ChartBulletQualitativeRange: React.FunctionComponent { return React.cloneElement(measureComponent, { barWidth, - data: [{...dataPoint}], + data: [{ ...dataPoint }], domain, height, horizontal, @@ -280,9 +274,7 @@ export const ChartBulletQualitativeRange: React.FunctionComponent ) : ( - - {measure} - + {measure} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.test.tsx index 1852fc9f663..58d66cd4dc1 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartBulletTitle } from './ChartBulletTitle'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartBulletTitle', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -10,11 +10,6 @@ Object.values([true, false]).forEach((isRead) => { }); test('renders component data', () => { - const view = shallow( - - ); + const view = shallow(); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.tsx b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.tsx index 889d5bc3046..7ee6ab48c15 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/ChartBulletTitle.tsx @@ -1,8 +1,5 @@ import * as React from 'react'; -import { - PaddingProps, - StringOrNumberOrCallback, -} from 'victory'; +import { PaddingProps, StringOrNumberOrCallback } from 'victory'; import { ChartContainer } from '../ChartContainer'; import { ChartLabel } from '../ChartLabel'; import { ChartLegendPosition } from '../ChartLegend'; @@ -150,10 +147,10 @@ export const ChartBulletTitle: React.FunctionComponent = }; const defaultPadding = { - bottom: getPaddingForSide('bottom', padding, theme.chart.padding), + bottom: getPaddingForSide('bottom', padding, theme.chart.padding), left: getPaddingForSide('left', padding, theme.chart.padding), right: getPaddingForSide('right', padding, theme.chart.padding), - top: getPaddingForSide('top', padding, theme.chart.padding), + top: getPaddingForSide('top', padding, theme.chart.padding) }; // Returns title @@ -168,7 +165,7 @@ export const ChartBulletTitle: React.FunctionComponent = // The x and y calculations below are used to adjust the position of the title, based on padding and scale. // This ensures that when padding is adjusted, the title moves along with the chart's position. return React.cloneElement(titleComponent, { - ...showBoth && { capHeight }, + ...(showBoth && { capHeight }), style: [ChartBulletStyles.label.title, ChartBulletStyles.label.subTitle], text: showBoth ? [title, subTitle] : title, textAnchor: labelPosition === 'top-left' ? 'start' : horizontal ? 'end' : 'middle', @@ -176,24 +173,30 @@ export const ChartBulletTitle: React.FunctionComponent = // Adjust for padding x: horizontal ? getBulletLabelX({ - chartWidth: chartSize.width, - dx: labelPosition === 'top-left' - ? defaultPadding.left - : defaultPadding.left - ChartCommonStyles.label.margin * 1.75, - labelPosition: 'left', // skip 'bottom' - legendPosition, - svgWidth: width - }) - : defaultPadding.left * .5 + (defaultPadding.right * .5 - (defaultPadding.right - 50)) + + chartWidth: chartSize.width, + dx: + labelPosition === 'top-left' + ? defaultPadding.left + : defaultPadding.left - ChartCommonStyles.label.margin * 1.75, + labelPosition: 'left', // skip 'bottom' + legendPosition, + svgWidth: width + }) + : defaultPadding.left * 0.5 + + (defaultPadding.right * 0.5 - (defaultPadding.right - 50)) + ChartBulletStyles.qualitativeRangeWidth / 2, y: getBulletLabelY({ chartHeight: chartSize.height, // Adjust for padding - dy: labelPosition === 'top-left' - ? defaultPadding.top * .5 + (defaultPadding.bottom * .5 - (defaultPadding.bottom)) + 58 - - ChartCommonStyles.legend.margin + (showBoth ? 0 : 1) - : horizontal - ? defaultPadding.top * .5 + (defaultPadding.bottom * .5 - (defaultPadding.bottom)) + dy: + labelPosition === 'top-left' + ? defaultPadding.top * 0.5 + + (defaultPadding.bottom * 0.5 - defaultPadding.bottom) + + 58 - + ChartCommonStyles.legend.margin + + (showBoth ? 0 : 1) + : horizontal + ? defaultPadding.top * 0.5 + (defaultPadding.bottom * 0.5 - defaultPadding.bottom) : ChartCommonStyles.legend.margin * 2 - defaultPadding.bottom, labelPosition }), @@ -206,8 +209,6 @@ export const ChartBulletTitle: React.FunctionComponent = {getTitle()} ) : ( - - {getTitle()} - + {getTitle()} ); }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-data.ts b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-data.ts index 6ac6b8a7294..c16d8226d2b 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-data.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-data.ts @@ -51,12 +51,12 @@ export const getComparativeMeasureData = ({ }: ChartBulletDataInterface) => { const datum: any[] = []; - Data.formatData(data, {y}, ['y']).forEach(((dataPoint: any, index: number) => { + Data.formatData(data, { y }, ['y']).forEach((dataPoint: any, index: number) => { datum.push({ ...dataPoint, _index: index // Save to sync legend color }); - })); + }); const computedData = datum.map((dataPoint: any, index: number) => { return { @@ -126,7 +126,7 @@ export const getPrimarySegmentedMeasureData = ({ const negativeDatum: any[] = []; const positiveDatum: any[] = []; - Data.formatData(data, {y, y0}, ['y', 'y0']).forEach(((dataPoint: any, index: number) => { + Data.formatData(data, { y, y0 }, ['y', 'y0']).forEach((dataPoint: any, index: number) => { if (dataPoint._y < 0) { negativeDatum.push({ ...dataPoint, @@ -138,11 +138,12 @@ export const getPrimarySegmentedMeasureData = ({ _index: index // Save to sync legend color }); } - })); + }); // Instead of relying on colorScale, colors must be added to each measure in ascending order - const negativeComputedData = negativeDatum.sort((a: any, b: any) => b._y - a._y). - map((dataPoint: any, index: number) => { + const negativeComputedData = negativeDatum + .sort((a: any, b: any) => b._y - a._y) + .map((dataPoint: any, index: number) => { return { ...dataPoint, x: 1, @@ -152,11 +153,13 @@ export const getPrimarySegmentedMeasureData = ({ : negativeMeasureTheme.group.colorScale[index % theme.group.colorScale.length] }; // Sort descending so largest bar is appears behind others - }).reverse(); + }) + .reverse(); // Instead of relying on colorScale, colors must be added to each measure in ascending order - const positiveComputedData = positiveDatum.sort((a: any, b: any) => a._y - b._y). - map((dataPoint: any, index: number) => { + const positiveComputedData = positiveDatum + .sort((a: any, b: any) => a._y - b._y) + .map((dataPoint: any, index: number) => { return { ...dataPoint, x: 1, @@ -166,12 +169,10 @@ export const getPrimarySegmentedMeasureData = ({ : theme.group.colorScale[index % theme.group.colorScale.length] }; // Sort descending so largest bar is appears behind others - }).reverse(); + }) + .reverse(); - return [ - ...negativeComputedData, - ...positiveComputedData - ]; + return [...negativeComputedData, ...positiveComputedData]; }; export const getQualitativeRangeData = ({ @@ -187,15 +188,16 @@ export const getQualitativeRangeData = ({ }: ChartBulletDataInterface) => { const datum: any[] = []; - Data.formatData(data, {y, y0}, ['y', 'y0']).forEach(((dataPoint: any, index: number) => { + Data.formatData(data, { y, y0 }, ['y', 'y0']).forEach((dataPoint: any, index: number) => { datum.push({ ...dataPoint, _index: index // Save to sync legend color }); - })); + }); - const computedData = datum.sort((a: any, b: any) => invert ? b._y - a._y : a._y - b._y). - map((dataPoint: any, index: number) => { + const computedData = datum + .sort((a: any, b: any) => (invert ? b._y - a._y : a._y - b._y)) + .map((dataPoint: any, index: number) => { return { ...dataPoint, x: 1, @@ -204,7 +206,8 @@ export const getQualitativeRangeData = ({ _color: theme.group.colorScale[index % theme.group.colorScale.length] }; // Sort descending so largest bar is appears behind others - }).reverse(); + }) + .reverse(); return computedData; }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-domain.ts b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-domain.ts index 984b4e08805..cf094f19fac 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-domain.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-domain.ts @@ -1,4 +1,4 @@ -import * as React from "react"; +import * as React from 'react'; import { ChartDomain, getDomains } from '../../ChartUtils'; interface ChartBulletDomainInterface { @@ -34,22 +34,28 @@ export const getBulletDomain = ({ const domain = getDomains({ maxDomain, minDomain, - sources: [{ - component: comparativeErrorMeasureComponent, - data: comparativeErrorMeasureData - }, { - component: comparativeWarningMeasureComponent, - data: comparativeWarningMeasureData - }, { - component: primaryDotMeasureComponent, - data: primaryDotMeasureData - }, { - component: primarySegmentedMeasureComponent, - data: primarySegmentedMeasureData - }, { - component: qualitativeRangeComponent, - data: qualitativeRangeData - }] + sources: [ + { + component: comparativeErrorMeasureComponent, + data: comparativeErrorMeasureData + }, + { + component: comparativeWarningMeasureComponent, + data: comparativeWarningMeasureData + }, + { + component: primaryDotMeasureComponent, + data: primaryDotMeasureData + }, + { + component: primarySegmentedMeasureComponent, + data: primarySegmentedMeasureData + }, + { + component: qualitativeRangeComponent, + data: qualitativeRangeData + } + ] }); // Note that comparative measures and qualitative range bars are currently given an x-value of 1, while the bar widths // fill the domain. At one point, lines were used to represent comparative warning, comparative error, and zero diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-size.ts b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-size.ts index 680fdcbe94a..95ebc4762a1 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-size.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-size.ts @@ -1,5 +1,5 @@ import { ChartThemeDefinition } from '../../ChartTheme'; -import { ChartBulletStyles } from '../../ChartTheme'; +import { ChartBulletStyles } from '../../ChartTheme'; import { getBulletComparativeErrorMeasureTheme, getBulletComparativeMeasureTheme, @@ -24,7 +24,7 @@ interface ChartBulletSizeInterface { theme?: ChartThemeDefinition; themeColor?: string; themeVariant?: string; - width: number; // The chart width -- not SVG width + width: number; // The chart width -- not SVG width } export const getComparativeMeasureErrorWidth = ({ @@ -35,14 +35,15 @@ export const getComparativeMeasureErrorWidth = ({ width, // destructure last - theme = getBulletComparativeErrorMeasureTheme(themeColor, themeVariant), -}: ChartBulletSizeInterface) => scaleBarWidth({ - defaultSize: theme.bar.height, - height, - horizontal, - value: ChartBulletStyles.comparativeMeasureErrorWidth, - width -}); + theme = getBulletComparativeErrorMeasureTheme(themeColor, themeVariant) +}: ChartBulletSizeInterface) => + scaleBarWidth({ + defaultSize: theme.bar.height, + height, + horizontal, + value: ChartBulletStyles.comparativeMeasureErrorWidth, + width + }); export const getComparativeMeasureWidth = ({ height, @@ -52,14 +53,15 @@ export const getComparativeMeasureWidth = ({ width, // destructure last - theme = getBulletComparativeMeasureTheme(themeColor, themeVariant), -}: ChartBulletSizeInterface) => scaleBarWidth({ - defaultSize: theme.bar.height, - height, - horizontal, - value: ChartBulletStyles.comparativeMeasureWidth, - width -}); + theme = getBulletComparativeMeasureTheme(themeColor, themeVariant) +}: ChartBulletSizeInterface) => + scaleBarWidth({ + defaultSize: theme.bar.height, + height, + horizontal, + value: ChartBulletStyles.comparativeMeasureWidth, + width + }); export const getComparativeMeasureWarningWidth = ({ height, @@ -69,14 +71,15 @@ export const getComparativeMeasureWarningWidth = ({ width, // destructure last - theme = getBulletComparativeWarningMeasureTheme(themeColor, themeVariant), -}: ChartBulletSizeInterface) => scaleBarWidth({ - defaultSize: theme.bar.height, - height, - horizontal, - value: ChartBulletStyles.comparativeMeasureWarningWidth, - width -}); + theme = getBulletComparativeWarningMeasureTheme(themeColor, themeVariant) +}: ChartBulletSizeInterface) => + scaleBarWidth({ + defaultSize: theme.bar.height, + height, + horizontal, + value: ChartBulletStyles.comparativeMeasureWarningWidth, + width + }); export const getPrimaryDotMeasureSize = ({ height, @@ -86,14 +89,15 @@ export const getPrimaryDotMeasureSize = ({ width, // destructure last - theme = getBulletPrimaryDotMeasureTheme(themeColor, themeVariant), -}: ChartBulletSizeInterface) => scaleSize({ - defaultSize: theme.group.height, - height, - horizontal, - value: ChartBulletStyles.primaryDotMeasureSize, - width -}); + theme = getBulletPrimaryDotMeasureTheme(themeColor, themeVariant) +}: ChartBulletSizeInterface) => + scaleSize({ + defaultSize: theme.group.height, + height, + horizontal, + value: ChartBulletStyles.primaryDotMeasureSize, + width + }); export const getPrimarySegmentedMeasureWidth = ({ height, @@ -103,15 +107,16 @@ export const getPrimarySegmentedMeasureWidth = ({ width, // destructure last - theme = getBulletPrimarySegmentedMeasureTheme(themeColor, themeVariant), -}: ChartBulletSizeInterface) => scaleBarWidth({ - defaultSize: theme.group.height, - height, - horizontal, - scale: .3, - value: ChartBulletStyles.primarySegmentedMeasureWidth, - width -}); + theme = getBulletPrimarySegmentedMeasureTheme(themeColor, themeVariant) +}: ChartBulletSizeInterface) => + scaleBarWidth({ + defaultSize: theme.group.height, + height, + horizontal, + scale: 0.3, + value: ChartBulletStyles.primarySegmentedMeasureWidth, + width + }); export const getQualitativeRangeBarWidth = ({ height, @@ -121,27 +126,22 @@ export const getQualitativeRangeBarWidth = ({ width, // destructure last - theme = getBulletQualitativeRangeTheme(themeColor, themeVariant), -}: ChartBulletSizeInterface) => scaleBarWidth({ - defaultSize: theme.group.height, - height, - horizontal, - value: ChartBulletStyles.qualitativeRangeWidth, - width -}); - -const scale = ({ - defaultSize, - height, - horizontal = true, - scale = 1, - value, - width -}: ChartBulletScaleInterface) => horizontal - ? height > defaultSize - ? value + (height - defaultSize) * scale - : value - (defaultSize - height) * scale - : width > defaultSize + theme = getBulletQualitativeRangeTheme(themeColor, themeVariant) +}: ChartBulletSizeInterface) => + scaleBarWidth({ + defaultSize: theme.group.height, + height, + horizontal, + value: ChartBulletStyles.qualitativeRangeWidth, + width + }); + +const scale = ({ defaultSize, height, horizontal = true, scale = 1, value, width }: ChartBulletScaleInterface) => + horizontal + ? height > defaultSize + ? value + (height - defaultSize) * scale + : value - (defaultSize - height) * scale + : width > defaultSize ? value + (width - defaultSize) * scale : value - (defaultSize - width) * scale; @@ -149,13 +149,11 @@ const scale = ({ export const scaleBarWidth = (props: ChartBulletScaleInterface) => Math.max(scale(props), 0); // Scale size per the given size properties -export const scaleSize = ({ - value, - ...rest -}: ChartBulletScaleInterface) => Math.round( - scale({ - scale: 1 / value, - value, - ...rest, - }) -); +export const scaleSize = ({ value, ...rest }: ChartBulletScaleInterface) => + Math.round( + scale({ + scale: 1 / value, + value, + ...rest + }) + ); diff --git a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-theme.ts index 5c2d25d3fcb..a95f5d98df6 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartBullet/utils/chart-bullet-theme.ts @@ -4,7 +4,7 @@ import { getComparativeWarningMeasureData, getPrimarySegmentedMeasureData, getQualitativeRangeData -} from './chart-bullet-data'; +} from './chart-bullet-data'; import { ChartThemeDefinition } from '../../ChartTheme'; import { getBulletTheme } from '../../ChartUtils'; @@ -125,7 +125,8 @@ export const getBulletThemeWithLegendColorScale = ({ qualitativeRangeData, qualitativeRangeLegendData, themeColor, - themeVariant}); + themeVariant + }); const theme = getBulletTheme(themeColor, themeVariant); theme.legend.colorScale = [...colorScale]; diff --git a/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.test.tsx index 25ed039c08d..6ac0370f3af 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.test.tsx @@ -3,7 +3,7 @@ import { shallow } from 'enzyme'; import { ChartContainer } from './ChartContainer'; import { ChartLegend } from '../ChartLegend'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartContainer', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.tsx b/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.tsx index 9f596bd3e1d..1a5c989eba4 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartContainer/ChartContainer.tsx @@ -1,9 +1,6 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - VictoryContainer, - VictoryContainerProps -} from 'victory'; +import { VictoryContainer, VictoryContainerProps } from 'victory'; import { ChartThemeDefinition } from '../ChartTheme'; import { getClassName, getTheme } from '../ChartUtils'; @@ -116,12 +113,12 @@ export const ChartContainer: React.FunctionComponent = ({ theme = getTheme(themeColor, themeVariant), ...rest }: ChartContainerProps) => { - const chartClassName = getClassName({className}); + const chartClassName = getClassName({ className }); // Note: theme is valid, but @types/victory is missing a prop type // @ts-ignore return ; -} +}; // Note: VictoryContainer.role must be hoisted hoistNonReactStatics(ChartContainer, VictoryContainer); diff --git a/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.test.tsx index b8b58c42a7c..3e0f7cc5303 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartDonut } from './ChartDonut'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartDonut', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.tsx b/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.tsx index 9b8b16d24f1..37bcbd0dd90 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartDonut/ChartDonut.tsx @@ -11,7 +11,7 @@ import { VictoryPie, VictoryStyleInterface } from 'victory'; -import { Helpers } from "victory-core"; +import { Helpers } from 'victory-core'; import { getDonutTheme } from '../ChartUtils/chart-theme'; import { ChartContainer } from '../ChartContainer'; import { ChartLabel } from '../ChartLabel'; @@ -297,7 +297,7 @@ export interface ChartDonutProps extends ChartPieProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padAngle prop determines the amount of separation between adjacent data slices * in number of degrees @@ -454,16 +454,18 @@ export const ChartDonut: React.FunctionComponent = ({ ...rest }: ChartDonutProps) => { const defaultPadding = { - bottom: getPaddingForSide('bottom', padding, theme.pie.padding), + bottom: getPaddingForSide('bottom', padding, theme.pie.padding), left: getPaddingForSide('left', padding, theme.pie.padding), right: getPaddingForSide('right', padding, theme.pie.padding), - top: getPaddingForSide('top', padding, theme.pie.padding), + top: getPaddingForSide('top', padding, theme.pie.padding) }; - const chartRadius = radius ? radius : Helpers.getRadius({ - height, - width, - padding: defaultPadding - }); + const chartRadius = radius + ? radius + : Helpers.getRadius({ + height, + width, + padding: defaultPadding + }); const chartInnerRadius = innerRadius ? innerRadius : chartRadius - 9; // Todo: Add pf-core variable // Returns subtitle @@ -505,7 +507,7 @@ export const ChartDonut: React.FunctionComponent = ({ const showBoth = title && subTitle && subTitlePosition == ChartDonutSubTitlePosition.center; return React.cloneElement(titleComponent, { - ...showBoth && { capHeight }, + ...(showBoth && { capHeight }), key: 'pf-chart-donut-title', style: [ChartDonutStyles.label.title, ChartDonutStyles.label.subTitle], text: showBoth ? [title, subTitle] : title, @@ -545,19 +547,21 @@ export const ChartDonut: React.FunctionComponent = ({ ); // Clone so users can override container props - const container = React.cloneElement(containerComponent, { - desc: ariaDesc, - height, - title: ariaTitle, - width, - theme, - ...containerComponent.props - }, [chart, getTitle(), getSubTitle()]); + const container = React.cloneElement( + containerComponent, + { + desc: ariaDesc, + height, + title: ariaTitle, + width, + theme, + ...containerComponent.props + }, + [chart, getTitle(), getSubTitle()] + ); return standalone ? ( - - {container} - + {container} ) : ( {chart} diff --git a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.test.tsx index b1d80e3f66a..cd32d654816 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartDonutThreshold } from './ChartDonutThreshold'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartDonutThreshold', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.tsx b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.tsx index 4d205581182..b4fdfa5e0dc 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutThreshold.tsx @@ -270,7 +270,7 @@ export interface ChartDonutThresholdProps extends ChartDonutProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * It should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padAngle prop determines the amount of separation between adjacent data slices * in number of degrees @@ -420,40 +420,45 @@ export const ChartDonutThreshold: React.FunctionComponent { const defaultPadding = { - bottom: getPaddingForSide('bottom', padding, theme.pie.padding), + bottom: getPaddingForSide('bottom', padding, theme.pie.padding), left: getPaddingForSide('left', padding, theme.pie.padding), right: getPaddingForSide('right', padding, theme.pie.padding), - top: getPaddingForSide('top', padding, theme.pie.padding), + top: getPaddingForSide('top', padding, theme.pie.padding) }; - const chartRadius = radius | Helpers.getRadius({ - height, - width, - padding: defaultPadding - }); + const chartRadius = + radius | + Helpers.getRadius({ + height, + width, + padding: defaultPadding + }); // Returns computed data representing pie chart slices const getComputedData = () => { // Format and sort data. Sorting ensures thresholds are displayed in the correct order and simplifies calculations. - const datum = Data.formatData(data, {x, y, ...rest}, ['x', 'y']).sort((a: any, b: any) => a._y - b._y); + const datum = Data.formatData(data, { x, y, ...rest }, ['x', 'y']).sort((a: any, b: any) => a._y - b._y); // Data must be offset so that the sum of all data point y-values (including the final slice) == 100. - const [prev, computedData] = datum.reduce((acc: [number, any], dataPoint: {_x: number | string, _y: number}) => { - return [ - dataPoint._y, // Set the previous value to current y value - [ - ...acc[1], - { - x: dataPoint._x, // Conditionally add x property only if it is in the original data object - y: dataPoint._y - acc[0] // Must be offset by previous value - } - ] - ]; - }, [0, []]); + const [prev, computedData] = datum.reduce( + (acc: [number, any], dataPoint: { _x: number | string; _y: number }) => { + return [ + dataPoint._y, // Set the previous value to current y value + [ + ...acc[1], + { + x: dataPoint._x, // Conditionally add x property only if it is in the original data object + y: dataPoint._y - acc[0] // Must be offset by previous value + } + ] + ]; + }, + [0, []] + ); return [ ...computedData, { - y: prev ? (100 - prev) : 0 + y: prev ? 100 - prev : 0 } ]; }; @@ -464,9 +469,9 @@ export const ChartDonutThreshold: React.FunctionComponent - {container} - + {container} ) : ( {chart} diff --git a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.test.tsx index 59536336d51..00e55e5822c 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartDonutUtilization } from './ChartDonutUtilization'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartDonutUtilization', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -10,12 +10,6 @@ Object.values([true, false]).forEach((isRead) => { }); test('renders component data', () => { - const view = shallow( - - ); + const view = shallow(); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.tsx b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.tsx index ae013d63948..e08e2579217 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartDonutUtilization/ChartDonutUtilization.tsx @@ -320,7 +320,7 @@ export interface ChartDonutUtilizationProps extends ChartDonutProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padAngle prop determines the amount of separation between adjacent data slices * in number of degrees @@ -481,7 +481,7 @@ export const ChartDonutUtilization: React.FunctionComponent { const datum = getData(); - const computedData: [{ x?: any, y: any}] = [{ x: datum[0]._x, y: datum[0]._y || 0 }]; + const computedData: [{ x?: any; y: any }] = [{ x: datum[0]._x, y: datum[0]._y || 0 }]; if (showStatic) { computedData.push({ y: datum[0]._x ? Math.abs(100 - datum[0]._y) : 100 }); } @@ -503,7 +503,8 @@ export const ChartDonutUtilization: React.FunctionComponent - {container} - - ) : ( - - {chart} - + const container = React.cloneElement( + containerComponent, + { + desc: ariaDesc, + height, + title: ariaTitle, + width, + theme, + ...containerComponent.props + }, + [chart] ); + + return standalone ? {container} : {chart}; }; // Note: VictoryPie.role must be hoisted diff --git a/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.test.tsx index 9041c15dcfe..2ead03e167b 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.test.tsx @@ -3,7 +3,7 @@ import { shallow } from 'enzyme'; import { ChartArea } from '../ChartArea'; import { ChartGroup } from './ChartGroup'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartGroup', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.tsx b/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.tsx index d7fc23edb50..adef2134eb5 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartGroup/ChartGroup.tsx @@ -225,7 +225,7 @@ export interface ChartGroupProps extends VictoryGroupProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -240,7 +240,7 @@ export interface ChartGroupProps extends VictoryGroupProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The name prop is used to reference a component instance when defining shared events. */ @@ -256,7 +256,7 @@ export interface ChartGroupProps extends VictoryGroupProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -282,7 +282,7 @@ export interface ChartGroupProps extends VictoryGroupProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The samples prop specifies how many individual points to plot when plotting * y as a function of x. Samples is ignored if x props are provided instead. @@ -294,10 +294,13 @@ export interface ChartGroupProps extends VictoryGroupProps { * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -319,7 +322,7 @@ export interface ChartGroupProps extends VictoryGroupProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * Use the sortKey prop to indicate how data should be sorted. This prop * is given directly to the lodash sortBy function to be executed on the @@ -420,9 +423,13 @@ export const ChartGroup: React.FunctionComponent = ({ title: ariaTitle, theme, ...containerComponent.props, - className: getClassName({className: containerComponent.props.className}) // Override VictoryContainer class name + className: getClassName({ className: containerComponent.props.className }) // Override VictoryContainer class name }); - return {children}; + return ( + + {children} + + ); }; // Note: VictoryGroup.role must be hoisted diff --git a/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.test.tsx index 9972c4be9c2..e2ee380e557 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartLabel } from './ChartLabel'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartLabel', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.tsx b/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.tsx index e2e1c40b37b..faf6c823d69 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartLabel/ChartLabel.tsx @@ -1,11 +1,7 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { defaults } from 'lodash'; -import { - StringOrNumberOrCallback, - VictoryLabel, - VictoryLabelProps -} from 'victory'; +import { StringOrNumberOrCallback, VictoryLabel, VictoryLabelProps } from 'victory'; import { ChartCommonStyles } from '../ChartTheme'; export enum ChartLabelDirection { @@ -109,7 +105,7 @@ export interface ChartLabelProps extends VictoryLabelProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * Victory components can pass a boolean polar prop to specify whether a label is part of a polar chart. * **This prop should not be set manually.** @@ -124,7 +120,7 @@ export interface ChartLabelProps extends VictoryLabelProps { * Victory components can pass a scale prop to their label component. This can be used to calculate the position of * label elements from datum. This prop should not be set manually. */ - scale?: { x?: any, y?: any }; + scale?: { x?: any; y?: any }; /** * The style prop applies CSS properties to the rendered `` element. */ @@ -162,15 +158,13 @@ export interface ChartLabelProps extends VictoryLabelProps { y?: number; } -export const ChartLabel: React.FunctionComponent = ({ - style, - ...rest -}: ChartLabelProps) => { - const applyDefaultStyle = (customStyle: React.CSSProperties) => defaults(customStyle, { - fontFamily: ChartCommonStyles.label.fontFamily, - fontSize: ChartCommonStyles.label.fontSize, - letterSpacing: ChartCommonStyles.label.letterSpacing - }); +export const ChartLabel: React.FunctionComponent = ({ style, ...rest }: ChartLabelProps) => { + const applyDefaultStyle = (customStyle: React.CSSProperties) => + defaults(customStyle, { + fontFamily: ChartCommonStyles.label.fontFamily, + fontSize: ChartCommonStyles.label.fontSize, + letterSpacing: ChartCommonStyles.label.letterSpacing + }); const newStyle = Array.isArray(style) ? style.map(applyDefaultStyle) : applyDefaultStyle(style); return ; }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.test.tsx index 9d4f6660e4b..808284cb00b 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartLegend } from './ChartLegend'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartLegend', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.tsx b/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.tsx index 15ded51d46a..155a323e66d 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegend.tsx @@ -10,7 +10,7 @@ import { StringOrNumberOrCallback, VictoryLegend, VictoryLegendProps, - VictoryStyleInterface, + VictoryStyleInterface } from 'victory'; import { ChartContainer } from '../ChartContainer'; import { ChartPoint } from '../ChartPoint'; @@ -137,7 +137,7 @@ export interface ChartLegendProps extends VictoryLegendProps { * gutters are between columns. When orientation is vertical, gutters * are the space between rows. */ - gutter?: number | {left: number, right: number}; + gutter?: number | { left: number; right: number }; /** * Specifies the height the svg viewBox of the chart container. This value should be given as a * number of pixels. @@ -304,4 +304,4 @@ export const ChartLegend: React.FunctionComponent = ({ }; // Note: VictoryLegend.role must be hoisted, but getBaseProps causes error with ChartVoronoiContainer -hoistNonReactStatics(ChartLegend, VictoryLegend, { getBaseProps: true}); +hoistNonReactStatics(ChartLegend, VictoryLegend, { getBaseProps: true }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegendWrapper.tsx b/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegendWrapper.tsx index 2fbd6ef1fe8..a5c147dbd56 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegendWrapper.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartLegend/ChartLegendWrapper.tsx @@ -147,7 +147,7 @@ export const ChartLegendWrapper: React.FunctionComponent - {legend} - - ); + return {legend}; }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.test.tsx index d1f9ec35543..fd042c7655a 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.test.tsx @@ -4,7 +4,7 @@ import { Chart } from '../Chart'; import { ChartGroup } from '../ChartGroup'; import { ChartLine } from './ChartLine'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartLine', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.tsx b/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.tsx index 5a035fd241b..8fe61608dca 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartLine/ChartLine.tsx @@ -14,7 +14,7 @@ import { StringOrNumberOrCallback, VictoryStyleInterface, VictoryLine, - VictoryLineProps, + VictoryLineProps } from 'victory'; import { ChartContainer } from '../ChartContainer'; import { ChartThemeDefinition } from '../ChartTheme'; @@ -198,7 +198,7 @@ export interface ChartLineProps extends VictoryLineProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -213,7 +213,7 @@ export interface ChartLineProps extends VictoryLineProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The name prop is used to reference a component instance when defining shared events. */ @@ -222,7 +222,7 @@ export interface ChartLineProps extends VictoryLineProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -248,7 +248,7 @@ export interface ChartLineProps extends VictoryLineProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The samples prop specifies how many individual points to plot when plotting * y as a function of x. Samples is ignored if x props are provided instead. @@ -260,10 +260,13 @@ export interface ChartLineProps extends VictoryLineProps { * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -285,7 +288,7 @@ export interface ChartLineProps extends VictoryLineProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * Use the sortKey prop to indicate how data should be sorted. This prop * is given directly to the lodash sortBy function to be executed on the @@ -385,7 +388,7 @@ export const ChartLine: React.FunctionComponent = ({ ...containerComponent.props }); return ; -} +}; // Note: VictoryLine.role must be hoisted hoistNonReactStatics(ChartLine, VictoryLine); diff --git a/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.test.tsx index 3bc3ff60c17..75adc55423e 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { shallow } from 'enzyme'; import { ChartPie } from './ChartPie'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartPie', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.tsx b/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.tsx index c2cf316ca38..0a415309828 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartPie/ChartPie.tsx @@ -290,7 +290,7 @@ export interface ChartPieProps extends VictoryPieProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padAngle prop determines the amount of separation between adjacent data slices * in number of degrees @@ -396,7 +396,7 @@ export interface ChartPieProps extends VictoryPieProps { y?: DataGetterPropType; } -let someId = 0; +const someId = 0; export const ChartPie: React.FunctionComponent = ({ allowTooltip = true, @@ -416,23 +416,29 @@ export const ChartPie: React.FunctionComponent = ({ // destructure last theme = getTheme(themeColor, themeVariant), - labelComponent = allowTooltip ? : undefined, + labelComponent = allowTooltip ? ( + + ) : ( + undefined + ), legendOrientation = theme.legend.orientation as ChartLegendOrientation, height = theme.pie.height, width = theme.pie.width, ...rest }: ChartPieProps) => { const defaultPadding = { - bottom: getPaddingForSide('bottom', padding, theme.pie.padding), + bottom: getPaddingForSide('bottom', padding, theme.pie.padding), left: getPaddingForSide('left', padding, theme.pie.padding), right: getPaddingForSide('right', padding, theme.pie.padding), - top: getPaddingForSide('top', padding, theme.pie.padding), + top: getPaddingForSide('top', padding, theme.pie.padding) }; - const chartRadius = radius ? radius : Helpers.getRadius({ - height, - width, - padding: defaultPadding - }); + const chartRadius = radius + ? radius + : Helpers.getRadius({ + height, + width, + padding: defaultPadding + }); const chart = ( = ({ }; // Clone so users can override container props - const container = React.cloneElement(containerComponent, { - desc: ariaDesc, - height, - title: ariaTitle, - width, - theme, - ...containerComponent.props - }, [chart, getWrappedLegend()]); + const container = React.cloneElement( + containerComponent, + { + desc: ariaDesc, + height, + title: ariaTitle, + width, + theme, + ...containerComponent.props + }, + [chart, getWrappedLegend()] + ); return standalone ? ( - - {container} - + {container} ) : ( {chart} diff --git a/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.test.tsx index cbb16660766..b12bbdd21c0 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.test.tsx @@ -3,7 +3,7 @@ import { shallow } from 'enzyme'; import { ChartLegend } from '../ChartLegend'; import { ChartPoint } from './ChartPoint'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartPoint', () => { const view = shallow(} />); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.tsx b/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.tsx index 1f6428a1999..607a8a80246 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartPoint/ChartPoint.tsx @@ -42,7 +42,7 @@ export interface ChartPointProps { /** * The svg coordinates of the center point of a polar chart */ - origin?: { x?: number, y?: number }; + origin?: { x?: number; y?: number }; /** * The rendered path element */ @@ -75,8 +75,18 @@ export interface ChartPointProps { * The 'circle', 'diamond', 'plus', 'minus', 'square', 'star', 'triangleDown', 'triangleUp', or 'dash' which symbol * the point should render */ - symbol?: 'circle' | 'diamond' | 'plus' | 'minus' | 'square' | 'star' | 'triangleDown' | 'triangleUp' | 'dash' | - 'threshold' | Function; + symbol?: + | 'circle' + | 'diamond' + | 'plus' + | 'minus' + | 'square' + | 'star' + | 'triangleDown' + | 'triangleUp' + | 'dash' + | 'threshold' + | Function; /** * A transform that will be supplied to elements this component renders */ @@ -129,7 +139,7 @@ export const ChartPoint: React.FunctionComponent = ({ return React.cloneElement(pathComponent, { className, clipPath, - d: getPath({datum, active, ...rest}), + d: getPath({ datum, active, ...rest }), events, role, shapeRendering, diff --git a/packages/patternfly-4/react-charts/src/components/ChartPoint/path-helpers.ts b/packages/patternfly-4/react-charts/src/components/ChartPoint/path-helpers.ts index 4f17fc381db..e6b3175c2b6 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartPoint/path-helpers.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartPoint/path-helpers.ts @@ -89,7 +89,7 @@ export const PathHelpers = { const baseSize = 1.35 * size; const angle = Math.PI / 5; const range = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - const starCoords = range.map((index) => { + const starCoords = range.map(index => { const length = index % 2 === 0 ? baseSize : baseSize / 2; return `${length * Math.sin(angle * (index + 1)) + x}, ${length * Math.cos(angle * (index + 1)) + y}`; diff --git a/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.test.tsx index c6175d6e2f3..6436a9d29f6 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.test.tsx @@ -4,7 +4,7 @@ import { Chart } from '../Chart/Chart'; import { ChartGroup } from '../ChartGroup/ChartGroup'; import { ChartScatter } from './ChartScatter'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartScatter', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.tsx b/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.tsx index b10e82429e5..726f513a3e4 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartScatter/ChartScatter.tsx @@ -203,7 +203,7 @@ export interface ChartScatterProps extends VictoryScatterProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minBubbleSize prop sets a lower limit for scaling data points in a bubble chart */ @@ -222,7 +222,7 @@ export interface ChartScatterProps extends VictoryScatterProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The name prop is used to reference a component instance when defining shared events. */ @@ -231,7 +231,7 @@ export interface ChartScatterProps extends VictoryScatterProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -257,7 +257,7 @@ export interface ChartScatterProps extends VictoryScatterProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The samples prop specifies how many individual points to plot when plotting * y as a function of x. Samples is ignored if x props are provided instead. @@ -269,10 +269,13 @@ export interface ChartScatterProps extends VictoryScatterProps { * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -294,7 +297,7 @@ export interface ChartScatterProps extends VictoryScatterProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * The size prop determines how to scale each data point */ @@ -402,7 +405,7 @@ export const ChartScatter: React.FunctionComponent = ({ ...containerComponent.props }); return ; -} +}; // Note: VictoryLine.role must be hoisted hoistNonReactStatics(ChartScatter, VictoryScatter); diff --git a/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.test.tsx index 96ebbf158ac..6525217cd60 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.test.tsx @@ -4,7 +4,7 @@ import { Chart } from '../Chart'; import { ChartBar } from '../ChartBar'; import { ChartStack } from './ChartStack'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartStack', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.tsx b/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.tsx index d7c80475f39..955abd3532d 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartStack/ChartStack.tsx @@ -204,7 +204,7 @@ export interface ChartStackProps extends VictoryStackProps { * maxDomain={0} * maxDomain={{ y: 0 }} */ - maxDomain?: number | { x?: number, y?: number }; + maxDomain?: number | { x?: number; y?: number }; /** * The minDomain prop defines a minimum domain value for a chart. This prop is useful in situations where the minimum * domain of a chart is static, while the maximum value depends on data or other variable information. If the domain @@ -219,7 +219,7 @@ export interface ChartStackProps extends VictoryStackProps { * minDomain={0} * minDomain={{ y: 0 }} */ - minDomain?: number | { x?: number, y?: number }; + minDomain?: number | { x?: number; y?: number }; /** * The name prop is used to reference a component instance when defining shared events. */ @@ -228,7 +228,7 @@ export interface ChartStackProps extends VictoryStackProps { * Victory components will pass an origin prop is to define the center point in svg coordinates for polar charts. * **This prop should not be set manually.** */ - origin?: { x: number, y: number }; + origin?: { x: number; y: number }; /** * The padding props specifies the amount of padding in number of pixels between * the edge of the chart and any rendered child components. This prop can be given @@ -254,17 +254,20 @@ export interface ChartStackProps extends VictoryStackProps { * Cartesian: range={{ x: [50, 250], y: [50, 250] }} * Polar: range={{ x: [0, 360], y: [0, 250] }} */ - range?: [number, number] | { x?: [number, number], y?: [number, number] }; + range?: [number, number] | { x?: [number, number]; y?: [number, number] }; /** * The scale prop determines which scales your chart should use. This prop can be * given as a string specifying a supported scale ("linear", "time", "log", "sqrt"), * as a d3 scale function, or as an object with scales specified for x and y * @example d3Scale.time(), {x: "linear", y: "log"} */ - scale?: ScalePropType | D3Scale | { - x?: ScalePropType | D3Scale; - y?: ScalePropType | D3Scale; - }; + scale?: + | ScalePropType + | D3Scale + | { + x?: ScalePropType | D3Scale; + y?: ScalePropType | D3Scale; + }; /** * The sharedEvents prop is used internally to coordinate events between components. It should not be set manually. */ @@ -286,7 +289,7 @@ export interface ChartStackProps extends VictoryStackProps { * singleQuadrantDomainPadding={false} * singleQuadrantDomainPadding={{ x: false }} */ - singleQuadrantDomainPadding?: boolean | { x: boolean, y: boolean }; + singleQuadrantDomainPadding?: boolean | { x: boolean; y: boolean }; /** * The standalone prop determines whether the component will render a standalone svg * or a tag that will be included in an external svg. Set standalone to false to @@ -352,10 +355,14 @@ export const ChartStack: React.FunctionComponent = ({ title: ariaTitle, theme, ...containerComponent.props, - className: getClassName({className: containerComponent.props.className}) // Override VictoryContainer class name + className: getClassName({ className: containerComponent.props.className }) // Override VictoryContainer class name }); - return {children}; -} + return ( + + {children} + + ); +}; // Note: VictoryStack.getChildren & VictoryStack.role must be hoisted hoistNonReactStatics(ChartStack, VictoryStack); diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/ChartTheme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/ChartTheme.ts index 9e3e34dc075..0b96d5de731 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/ChartTheme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/ChartTheme.ts @@ -14,14 +14,8 @@ import { } from './themes/bullet-theme'; import { DonutTheme } from './themes/donut-theme'; import { ThresholdTheme } from './themes/threshold-theme'; -import { - DonutThresholdDynamicTheme, - DonutThresholdStaticTheme -} from './themes/donut-threshold-theme'; -import { - DonutUtilizationDynamicTheme, - DonutUtilizationStaticTheme -} from './themes/donut-utilization-theme'; +import { DonutThresholdDynamicTheme, DonutThresholdStaticTheme } from './themes/donut-threshold-theme'; +import { DonutUtilizationDynamicTheme, DonutUtilizationStaticTheme } from './themes/donut-utilization-theme'; export interface ChartThemeDefinitionInterface extends VictoryThemeDefinition { area?: any; diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/common-styles.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/common-styles.ts index c8b1a925ef6..e65bf3f4260 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/common-styles.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/common-styles.ts @@ -17,10 +17,10 @@ export const CommonStyles = { fontFamily: TYPOGRAPHY_FONT_FAMILY, fontSize: TYPOGRAPHY_FONT_SIZE, letterSpacing: TYPOGRAPHY_LETTER_SPACING, - margin: chart_global_label_Margin.value, + margin: chart_global_label_Margin.value }, legend: { margin: chart_legend_Margin.value, position: chart_legend_position.value - }, + } }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/donut-utilization-styles.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/donut-utilization-styles.ts index b2d23728b3f..672997d07c1 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/donut-utilization-styles.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/styles/donut-utilization-styles.ts @@ -1,15 +1,9 @@ /* eslint-disable camelcase */ -import { - chart_donut_threshold_warning_Color, - chart_donut_threshold_danger_Color, -} from '@patternfly/react-tokens'; +import { chart_donut_threshold_warning_Color, chart_donut_threshold_danger_Color } from '@patternfly/react-tokens'; // Donut utilization styles export const DonutUtilizationStyles = { thresholds: { - colorScale: [ - chart_donut_threshold_warning_Color.value, - chart_donut_threshold_danger_Color.value - ] + colorScale: [chart_donut_threshold_warning_Color.value, chart_donut_threshold_danger_Color.value] } }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/axis-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/axis-theme.ts index 090899e63b7..48787097eb3 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/axis-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/axis-theme.ts @@ -1,8 +1,5 @@ /* eslint-disable camelcase */ -import { - chart_axis_grid_stroke_Color, - chart_axis_tick_stroke_Color -} from '@patternfly/react-tokens'; +import { chart_axis_grid_stroke_Color, chart_axis_tick_stroke_Color } from '@patternfly/react-tokens'; // Axis theme export const AxisTheme = { @@ -15,5 +12,5 @@ export const AxisTheme = { stroke: chart_axis_tick_stroke_Color.value } } - }, + } }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/base-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/base-theme.ts index c1f7c79c04e..5c8c383b678 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/base-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/base-theme.ts @@ -96,7 +96,7 @@ import { chart_voronoi_flyout_stroke_Width, chart_voronoi_flyout_PointerEvents, chart_voronoi_flyout_stroke_Color, - chart_voronoi_flyout_stroke_Fill, + chart_voronoi_flyout_stroke_Fill } from '@patternfly/react-tokens'; // Note: Values must be in pixles @@ -361,7 +361,7 @@ export const BaseTheme = { fill: chart_voronoi_flyout_stroke_Fill.value, // background pointerEvents: chart_voronoi_flyout_PointerEvents.value, stroke: chart_voronoi_flyout_stroke_Color.value, // border - strokeWidth: chart_voronoi_flyout_stroke_Width.value, + strokeWidth: chart_voronoi_flyout_stroke_Width.value } } } diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/color-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/color-theme.ts index 730b33a3759..00ff87b38de 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/color-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/color-theme.ts @@ -4,9 +4,7 @@ interface ColorThemeInterface { // Victory theme properties only export const ColorTheme = (props: ColorThemeInterface) => { - const { - COLOR_SCALE - } = props; + const { COLOR_SCALE } = props; return { area: { diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/cyan-color-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/cyan-color-theme.ts index 039a89eb594..0e1d514c86c 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/cyan-color-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/cyan-color-theme.ts @@ -20,4 +20,4 @@ const COLOR_SCALE = [ export const DarkCyanColorTheme = ColorTheme({ COLOR_SCALE -}) ; +}); diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/gold-color-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/gold-color-theme.ts index 1b67e5c8273..a273d911ad7 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/gold-color-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/gold-color-theme.ts @@ -15,10 +15,9 @@ const COLOR_SCALE = [ chart_color_gold_100.value, chart_color_gold_500.value, chart_color_gold_200.value, - chart_color_gold_400.value, - + chart_color_gold_400.value ]; export const DarkGoldColorTheme = ColorTheme({ COLOR_SCALE -}) ; +}); diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/orange-color-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/orange-color-theme.ts index 52df58f9472..9cd224804ac 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/orange-color-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/dark/orange-color-theme.ts @@ -15,8 +15,7 @@ const COLOR_SCALE = [ chart_color_orange_100.value, chart_color_orange_500.value, chart_color_orange_200.value, - chart_color_orange_400.value, - + chart_color_orange_400.value ]; export const DarkOrangeColorTheme = ColorTheme({ diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-threshold-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-threshold-theme.ts index 88c4a659f23..9cfbd8e5d30 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-threshold-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-threshold-theme.ts @@ -15,10 +15,7 @@ import { // Donut threshold dynamic theme export const DonutThresholdDynamicTheme = { legend: { - colorScale: [ - chart_donut_threshold_second_Color.value, - chart_donut_threshold_third_Color.value - ] + colorScale: [chart_donut_threshold_second_Color.value, chart_donut_threshold_third_Color.value] }, pie: { height: chart_donut_threshold_dynamic_pie_Height.value, diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-utilization-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-utilization-theme.ts index 31c8cad58e1..a422f71f1f4 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-utilization-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/donut-utilization-theme.ts @@ -7,7 +7,7 @@ import { chart_donut_utilization_dynamic_pie_angle_Padding, chart_donut_utilization_dynamic_pie_Padding, chart_donut_utilization_dynamic_pie_Width, - chart_donut_utilization_static_pie_Padding, + chart_donut_utilization_static_pie_Padding } from '@patternfly/react-tokens'; // Donut utilization dynamic theme @@ -27,12 +27,10 @@ export const DonutUtilizationStaticTheme = { chart_donut_threshold_first_Color.value, chart_donut_threshold_second_Color.value, chart_donut_threshold_third_Color.value - ], + ] }, pie: { - colorScale: [ - chart_donut_threshold_first_Color.value - ], + colorScale: [chart_donut_threshold_first_Color.value], padding: chart_donut_utilization_static_pie_Padding.value } }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/gold-color-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/gold-color-theme.ts index 40ce58cbad0..da90e67def5 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/gold-color-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/gold-color-theme.ts @@ -15,8 +15,7 @@ const COLOR_SCALE = [ chart_color_gold_100.value, chart_color_gold_500.value, chart_color_gold_200.value, - chart_color_gold_400.value, - + chart_color_gold_400.value ]; export const LightGoldColorTheme = ColorTheme({ diff --git a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/orange-color-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/orange-color-theme.ts index 55d0ea6508e..1b15441aaf6 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/orange-color-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartTheme/themes/light/orange-color-theme.ts @@ -15,8 +15,7 @@ const COLOR_SCALE = [ chart_color_orange_100.value, chart_color_orange_500.value, chart_color_orange_200.value, - chart_color_orange_400.value, - + chart_color_orange_400.value ]; export const LightOrangeColorTheme = ColorTheme({ diff --git a/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.test.tsx index ad7dcac0e25..10bd51e2358 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.test.tsx @@ -5,7 +5,7 @@ import { ChartGroup } from '../ChartGroup'; import { ChartThreshold } from './ChartThreshold'; import { ChartThemeColor, ChartThemeVariant } from '../ChartTheme'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartThreshold', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -17,16 +17,12 @@ test('renders component data', () => { { name: 'Birds Threshold', x: 0, y: 2 }, { name: 'Birds Threshold', x: 2, y: 2 }, { name: 'Birds Threshold', x: 2, y: 3 }, - { name: 'Birds Threshold', x: 5, y: 3 }, + { name: 'Birds Threshold', x: 5, y: 3 } ]; const view = shallow( - + ); diff --git a/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.tsx b/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.tsx index 4c0810646b4..ac15e01ff5a 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartThreshold/ChartThreshold.tsx @@ -11,9 +11,7 @@ export const ChartThreshold: React.FunctionComponent = ({ ...rest }: ChartLineProps) => { const theme = getThresholdTheme(themeColor, themeVariant); - return ( - - ); + return ; }; // Note: VictoryPie.role must be hoisted diff --git a/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.test.tsx index 95b74833919..8fc8b5e48b7 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.test.tsx @@ -5,7 +5,7 @@ import { ChartGroup } from '../ChartGroup'; import { ChartVoronoiContainer } from '../ChartVoronoiContainer'; import { ChartTooltip } from './ChartTooltip'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartTooltip', () => { const view = shallow(); expect(view).toMatchSnapshot(); @@ -15,7 +15,7 @@ Object.values([true, false]).forEach((isRead) => { test('allows tooltip via container component', () => { const view = shallow( 'y: ' + point.y} />} + containerComponent={ 'y: ' + point.y} />} height={200} width={200} > diff --git a/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.tsx b/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.tsx index 72a7eaadbf1..511daed0350 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartTooltip/ChartTooltip.tsx @@ -6,7 +6,7 @@ import { StringOrNumberOrCallback, VictoryStyleObject, VictoryTooltip, - VictoryTooltipProps, + VictoryTooltipProps } from 'victory'; import { ChartThemeDefinition } from '../ChartTheme'; import { getTheme } from '../ChartUtils'; @@ -34,14 +34,14 @@ export interface ChartTooltipProps extends VictoryTooltipProps { * ChartVoronoiContainer, the center prop is what enables the mouseFollowTooltips option. When this prop is set, * non-zero pointerLength values will no longer be respected. */ - center?: { x: number, y: number }; + center?: { x: number; y: number }; /** * The centerOffset prop determines the position of the center of the tooltip flyout in relation to the flyout * pointer. This prop should be given as an object of x and y, where each is either a numeric offset value or a * function that returns a numeric value. When this prop is set, non-zero pointerLength values will no longer be * respected. */ - centerOffset?: { x: number | Function, y: number | Function }; + centerOffset?: { x: number | Function; y: number | Function }; /** * The constrainToVisibleArea prop determines whether to coerce tooltips so that they fit within the visible area of * the chart. When this prop is set to true, tooltip pointers will still point to the correct data point, but the @@ -104,7 +104,7 @@ export interface ChartTooltipProps extends VictoryTooltipProps { * function of datum. If this prop is not set, flyoutWidth will be determined based on an approximate text size * calculated from the text and style props provided to VictoryTooltip. */ - flyoutWidth?: NumberOrCallback, + flyoutWidth?: NumberOrCallback; /** * The groupComponent prop takes a component instance which will be used to create group elements for use within * container elements. This prop defaults to a tag.} @@ -211,7 +211,7 @@ export const ChartTooltip: React.FunctionComponent = ({ // @ts-ignore return ; -} +}; // Note: VictoryTooltip.defaultEvents must be hoisted hoistNonReactStatics(ChartTooltip, VictoryTooltip); diff --git a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-domain.ts b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-domain.ts index 109eb724110..88494dcb043 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-domain.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-domain.ts @@ -19,16 +19,13 @@ interface SourcesInterface { }[]; } -export interface ChartDomain {x: [number, number], y: [number, number]} +export interface ChartDomain { + x: [number, number]; + y: [number, number]; +} // Returns the min and max domain for given data -export const getDomain = ({ - data, - maxDomain, - minDomain, - x, - y -}: DomainInterface): ChartDomain => { +export const getDomain = ({ data, maxDomain, minDomain, x, y }: DomainInterface): ChartDomain => { // x-domain let xLow = 0; let xHigh = 0; @@ -70,7 +67,7 @@ export const getDomain = ({ } // Search data for max / min range - const datum = Data.formatData(data, {x, y}, ['x', 'y']); + const datum = Data.formatData(data, { x, y }, ['x', 'y']); datum.forEach((dataPoint: any) => { if (xLowSearch) { if (dataPoint._x < xLow) { @@ -93,17 +90,13 @@ export const getDomain = ({ } } }); - return {x: [xLow, xHigh], y: [yLow, yHigh]}; + return { x: [xLow, xHigh], y: [yLow, yHigh] }; }; -export const getDomains = ({ - maxDomain, - minDomain, - sources -}: SourcesInterface): ChartDomain => { +export const getDomains = ({ maxDomain, minDomain, sources }: SourcesInterface): ChartDomain => { const domains: ChartDomain[] = []; - sources.forEach((source) => { - const {data: compData = source.data} = source.component ? source.component.props : undefined; + sources.forEach(source => { + const { data: compData = source.data } = source.component ? source.component.props : undefined; const domain = getDomain({ data: compData, maxDomain, @@ -126,5 +119,5 @@ export const getDomains = ({ const yLow = Math.min(...yDomains); const yHigh = Math.max(...yDomains); - return {x: [xLow, xHigh], y: [yLow, yHigh]}; + return { x: [xLow, xHigh], y: [yLow, yHigh] }; }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-helpers.ts b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-helpers.ts index c0dfe1eb46e..be00355ffa4 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-helpers.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-helpers.ts @@ -5,16 +5,16 @@ interface ChartClassNameInterface { } // Returns the class name that will be applied to the outer-most div rendered by the chart's container -export const getClassName = ({ - className -}: ChartClassNameInterface) => { +export const getClassName = ({ className }: ChartClassNameInterface) => { let cleanClassName; // Workaround for VictoryContainer class name if (className) { - cleanClassName = className.replace(/VictoryContainer/g, '') + cleanClassName = className + .replace(/VictoryContainer/g, '') .replace(/pf-c-chart/g, '') - .replace(/\s+/g,' ').trim(); + .replace(/\s+/g, ' ') + .trim(); } - return (cleanClassName && cleanClassName.length) ? `pf-c-chart ${cleanClassName}` : 'pf-c-chart'; -} + return cleanClassName && cleanClassName.length ? `pf-c-chart ${cleanClassName}` : 'pf-c-chart'; +}; diff --git a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-label.ts b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-label.ts index 731c259868a..5465b3d63d9 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-label.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-label.ts @@ -18,7 +18,7 @@ interface ChartPieLabelInterface { dx?: number; // Horizontal shift from the x coordinate dy?: number; // Horizontal shift from the y coordinate height: number; // Chart height - labelPosition?: 'bottom' | 'center' | 'right' ; // Position of label + labelPosition?: 'bottom' | 'center' | 'right'; // Position of label legendPosition?: 'bottom' | 'right'; // Position of legend padding: any; // Chart padding width: number; // Chart width @@ -30,20 +30,12 @@ interface ChartLabelTextSizeInterface { } // Returns x coordinate for bullet labels -export const getBulletLabelX = ({ - chartWidth, - dx = 0, - labelPosition -}: ChartBulletLabelInterface) => { - return (labelPosition === 'top' && chartWidth) ? Math.round(chartWidth / 2) : dx; +export const getBulletLabelX = ({ chartWidth, dx = 0, labelPosition }: ChartBulletLabelInterface) => { + return labelPosition === 'top' && chartWidth ? Math.round(chartWidth / 2) : dx; }; // Returns y coordinate for bullet labels -export const getBulletLabelY = ({ - chartHeight, - dy = 0, - labelPosition -}: ChartBulletLabelInterface) => { +export const getBulletLabelY = ({ chartHeight, dy = 0, labelPosition }: ChartBulletLabelInterface) => { switch (labelPosition) { case 'bottom': return chartHeight + ChartCommonStyles.label.margin + dy; @@ -85,13 +77,7 @@ export const getPieLabelX = ({ }; // Returns x coordinate for pie labels -export const getPieLabelY = ({ - dy = 0, - height, - labelPosition, - padding, - width -}: ChartPieLabelInterface) => { +export const getPieLabelY = ({ dy = 0, height, labelPosition, padding, width }: ChartPieLabelInterface) => { const origin = getPieOrigin({ height, padding, width }); const radius = Helpers.getRadius({ height, width, padding }); @@ -110,12 +96,9 @@ export const getPieLabelY = ({ export const overpassFontCharacterConstant = 2.5875; // Returns an approximate size for the give text -export const getLabelTextSize = ({ - text, - theme -}: ChartLabelTextSizeInterface): {height: number, width: number} => { +export const getLabelTextSize = ({ text, theme }: ChartLabelTextSizeInterface): { height: number; width: number } => { const style = theme.legend.style.labels; - return TextSize.approximateTextSize(text, { + return TextSize.approximateTextSize(text, { ...style, characterConstant: overpassFontCharacterConstant }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-legend.ts b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-legend.ts index 402271eefca..d63d8af1305 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-legend.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-legend.ts @@ -3,7 +3,7 @@ import { Helpers, TextSize } from 'victory-core'; import { ChartLegendProps } from '../ChartLegend'; import { ChartCommonStyles, ChartThemeDefinition } from '../ChartTheme'; import { overpassFontCharacterConstant } from './chart-label'; -import {getPieOrigin} from "./chart-origin"; +import { getPieOrigin } from './chart-origin'; interface ChartLegendInterface { chartType?: string; // The type of chart (e.g., pie) to lookup for props @@ -51,16 +51,11 @@ export const getLegendDimensions = ({ }; // Returns x coordinate for legend -export const getLegendX = ({ - chartType, - ...rest -}: ChartLegendInterface) => (chartType === 'pie') ? getPieLegendX(rest) : getChartLegendX(rest); +export const getLegendX = ({ chartType, ...rest }: ChartLegendInterface) => + chartType === 'pie' ? getPieLegendX(rest) : getChartLegendX(rest); // Returns y coordinate for legend -export const getLegendY = ({ - chartType, - ...rest -}: ChartLegendInterface) => { +export const getLegendY = ({ chartType, ...rest }: ChartLegendInterface) => { switch (chartType) { case 'pie': return getPieLegendY(rest); @@ -69,7 +64,7 @@ export const getLegendY = ({ default: return getChartLegendY(rest); } -} +}; // Returns y coordinate for bullet legends export const getBulletLegendY = ({ @@ -83,9 +78,9 @@ export const getBulletLegendY = ({ theme, width }: ChartLegendInterface) => { - const { left, right } = Helpers.getPadding({padding}); + const { left, right } = Helpers.getPadding({ padding }); const chartSize = { - height: height, // Fixed size + height, // Fixed size width: width - left - right }; @@ -121,7 +116,7 @@ export const getChartLegendX = ({ theme, width }: ChartLegendInterface) => { - const { top, bottom, left, right } = Helpers.getPadding({padding}); + const { top, bottom, left, right } = Helpers.getPadding({ padding }); const chartSize = { height: Math.abs(height - (bottom + top)), width: Math.abs(width - (left + right)) @@ -141,7 +136,8 @@ export const getChartLegendX = ({ switch (legendPosition) { case 'bottom': return width > legendDimensions.width - textSizeWorkAround - ? Math.round((width - (legendDimensions.width - textSizeWorkAround)) / 2) + dx : dx; + ? Math.round((width - (legendDimensions.width - textSizeWorkAround)) / 2) + dx + : dx; case 'bottom-left': return left + dx; case 'right': @@ -163,7 +159,7 @@ export const getChartLegendY = ({ theme, width }: ChartLegendInterface) => { - const { top, bottom, left, right } = Helpers.getPadding({padding}); + const { top, bottom, left, right } = Helpers.getPadding({ padding }); const chartSize = { height: Math.abs(height - (bottom + top)), width: Math.abs(width - (left + right)) @@ -183,7 +179,7 @@ export const getChartLegendY = ({ }); const originX = chartSize.height / 2 + top; const legendPadding = (legendData: any[]) => (legendData && legendData.length > 0 ? 2 : 0); - return (originX - legendDimensions.height / 2) + legendPadding(legendData); + return originX - legendDimensions.height / 2 + legendPadding(legendData); } default: return dy; @@ -219,7 +215,8 @@ export const getPieLegendX = ({ switch (legendPosition) { case 'bottom': return width > legendDimensions.width - textSizeWorkAround - ? Math.round((width - (legendDimensions.width - textSizeWorkAround)) / 2) + dx : dx; + ? Math.round((width - (legendDimensions.width - textSizeWorkAround)) / 2) + dx + : dx; case 'right': return origin.x + ChartCommonStyles.label.margin + dx + radius; default: @@ -254,7 +251,7 @@ export const getPieLegendY = ({ theme }); const legendPadding = (legendData: any[]) => (legendData && legendData.length > 0 ? 2 : 0); - return (origin.y - legendDimensions.height / 2) + legendPadding(legendData); + return origin.y - legendDimensions.height / 2 + legendPadding(legendData); } default: return dy; @@ -264,11 +261,7 @@ export const getPieLegendY = ({ // Returns an approximation of over-sized text width due to growing character count // // See https://github.com/FormidableLabs/victory/issues/864 -const getTextSizeWorkAround = ({ - legendData, - legendOrientation, - theme -}: ChartLegendTextSizeInterface) => { +const getTextSizeWorkAround = ({ legendData, legendOrientation, theme }: ChartLegendTextSizeInterface) => { const style = theme.legend.style.labels; if (!(legendData && legendData.length)) { return 0; @@ -279,14 +272,14 @@ const getTextSizeWorkAround = ({ // For vertical legends, account for the growing char count of the longest legend item if (legendOrientation === 'vertical') { - legendData.forEach((data) => { + legendData.forEach(data => { if (data.name && data.name.length > result.length) { result = data.name; } }); } - const textSize = TextSize.approximateTextSize(result, style); - const adjustedTextSize = TextSize.approximateTextSize(result, { + const textSize = TextSize.approximateTextSize(result, style); + const adjustedTextSize = TextSize.approximateTextSize(result, { ...style, characterConstant: overpassFontCharacterConstant }); diff --git a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-origin.ts b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-origin.ts index a8714a7bef8..0a357941113 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-origin.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-origin.ts @@ -8,12 +8,8 @@ interface ChartPieOriginInterface { // Returns te origin for pie based charts. For example, something with a radius such as pie, donut, donut utilization, // and donut threshold. -export const getPieOrigin = ({ - height, - padding, - width -}: ChartPieOriginInterface) => { - const { top, bottom, left, right } = Helpers.getPadding({padding}); +export const getPieOrigin = ({ height, padding, width }: ChartPieOriginInterface) => { + const { top, bottom, left, right } = Helpers.getPadding({ padding }); const radius = Helpers.getRadius({ height, width, padding }); const offsetX = (width - radius * 2 - left - right) / 2; const offsetY = (height - radius * 2 - top - bottom) / 2; @@ -21,4 +17,4 @@ export const getPieOrigin = ({ x: radius + left + offsetX, y: radius + top + offsetY }; -} +}; diff --git a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-padding.ts b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-padding.ts index a10859d6522..d7bdd25a4d7 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-padding.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-padding.ts @@ -1,7 +1,11 @@ import { get, isEmpty, isFinite } from 'lodash'; import { PaddingProps } from 'victory'; -export const getPaddingForSide = (side: 'bottom' | 'left' | 'right' | 'top', padding: PaddingProps, fallback: PaddingProps): number => { +export const getPaddingForSide = ( + side: 'bottom' | 'left' | 'right' | 'top', + padding: PaddingProps, + fallback: PaddingProps +): number => { if (!isEmpty(padding)) { return get(padding, side, 0); } diff --git a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-theme.ts b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-theme.ts index 21df85ccbae..ae7fd017b9a 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-theme.ts +++ b/packages/patternfly-4/react-charts/src/components/ChartUtils/chart-theme.ts @@ -42,9 +42,11 @@ import { import { cloneDeep } from 'lodash'; // Apply custom properties to base and color themes -export const getCustomTheme = (themeColor: string, themeVariant: string, customTheme: ChartThemeDefinition -): ChartThemeDefinition => - merge(getTheme(themeColor, themeVariant), customTheme); +export const getCustomTheme = ( + themeColor: string, + themeVariant: string, + customTheme: ChartThemeDefinition +): ChartThemeDefinition => merge(getTheme(themeColor, themeVariant), customTheme); // Returns axis theme export const getAxisTheme = (themeColor: string, themeVariant: string): ChartThemeDefinition => { @@ -65,8 +67,10 @@ export const getBulletComparativeMeasureTheme = (themeColor: string, themeVarian getCustomTheme(themeColor, themeVariant, ChartBulletComparativeMeasureTheme); // Returns comparative warning measure theme for bullet chart -export const getBulletComparativeWarningMeasureTheme = (themeColor: string, themeVariant: string): ChartThemeDefinition => - getCustomTheme(themeColor, themeVariant, ChartBulletComparativeWarningMeasureTheme); +export const getBulletComparativeWarningMeasureTheme = ( + themeColor: string, + themeVariant: string +): ChartThemeDefinition => getCustomTheme(themeColor, themeVariant, ChartBulletComparativeWarningMeasureTheme); // Returns group title theme for bullet chart export const getBulletGroupTitleTheme = (themeColor: string, themeVariant: string): ChartThemeDefinition => @@ -105,7 +109,10 @@ export const getDonutThresholdDynamicTheme = (themeColor: string, themeVariant: }; // Returns static donut threshold theme -export const getDonutThresholdStaticTheme = (themeColor: string, themeVariant: string, invert?: boolean +export const getDonutThresholdStaticTheme = ( + themeColor: string, + themeVariant: string, + invert?: boolean ): ChartThemeDefinition => { const staticTheme = cloneDeep(ChartDonutThresholdStaticTheme); if (invert) { @@ -120,8 +127,7 @@ export const getDonutUtilizationTheme = (themeColor: string, themeVariant: strin // Merge just the first color of dynamic (blue, green, etc.) with static (grey) for expected colorScale theme.pie.colorScale = [theme.pie.colorScale[0], ...ChartDonutUtilizationStaticTheme.pie.colorScale]; - theme.legend.colorScale = [theme.legend.colorScale[0], - ...ChartDonutUtilizationStaticTheme.legend.colorScale]; + theme.legend.colorScale = [theme.legend.colorScale[0], ...ChartDonutUtilizationStaticTheme.legend.colorScale]; return theme; }; diff --git a/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoContainer.test.tsx b/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoContainer.test.tsx index 08625ba985f..b3748e0d696 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoContainer.test.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoContainer.test.tsx @@ -4,7 +4,7 @@ import { ChartArea } from '../ChartArea'; import { ChartGroup } from '../ChartGroup'; import { ChartVoronoiContainer } from './ChartVoronoiContainer'; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('ChartVoronoiContainer', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoiContainer.tsx b/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoiContainer.tsx index 841ee35c3ee..fe68e72d09d 100644 --- a/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoiContainer.tsx +++ b/packages/patternfly-4/react-charts/src/components/ChartVoronoiContainer/ChartVoronoiContainer.tsx @@ -1,9 +1,6 @@ import * as React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { - VictoryVoronoiContainer, - VictoryVoronoiContainerProps -} from 'victory'; +import { VictoryVoronoiContainer, VictoryVoronoiContainerProps } from 'victory'; import { ChartThemeDefinition } from '../ChartTheme'; import { ChartTooltip } from '../ChartTooltip'; import { getClassName, getTheme } from '../ChartUtils'; @@ -70,7 +67,7 @@ export interface ChartVoronoiContainerProps extends VictoryVoronoiContainerProps * When the mouseFollowTooltip prop is set on VictoryVoronoiContainer, The position of the center of the tooltip * follows the position of the mouse. */ - mouseFollowTooltips?: boolean, + mouseFollowTooltips?: boolean; /** * The onActivated prop accepts a function to be called whenever new data points are activated. * The function is called with the parameters points (an array of active data objects) and props @@ -158,16 +155,16 @@ export const ChartVoronoiContainer: React.FunctionComponent : undefined, ...rest }: ChartVoronoiContainerProps) => { - const chartClassName = getClassName({className}); + const chartClassName = getClassName({ className }); const chartLabelComponent = React.cloneElement(labelComponent, { constrainToVisibleArea, theme, - ...labelComponent.props, + ...labelComponent.props }); // Note: theme is required by voronoiContainerMixin, but @types/victory is missing a prop type // @ts-ignore - return ; + return ; // prettier-ignore }; ChartVoronoiContainer.defaultProps = (VictoryVoronoiContainer as any).defaultProps; diff --git a/packages/patternfly-4/react-core/package.json b/packages/patternfly-4/react-core/package.json index 9cb5ab76a70..ee2381ded15 100644 --- a/packages/patternfly-4/react-core/package.json +++ b/packages/patternfly-4/react-core/package.json @@ -67,9 +67,6 @@ "fs-extra": "^6.0.1", "glob": "^7.1.2", "rimraf": "^2.6.2", - "tslint": "^5.12.0", - "tslint-config-prettier": "^1.17.0", - "tslint-react": "^3.6.0", "typescript": "3.4.5" }, "peerDependencies": { diff --git a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.test.tsx b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.test.tsx index d54cb7ef581..2fa6ede8f78 100644 --- a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.test.tsx +++ b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.test.tsx @@ -8,65 +8,65 @@ const mockListener = jest.spyOn(ReactDOM, 'createPortal'); jest.spyOn(document, 'createElement'); jest.spyOn(document, 'addEventListener'); -mockListener.mockImplementation((node) => node as React.ReactPortal); +mockListener.mockImplementation(node => node as React.ReactPortal); const props = { - onClose: jest.fn(), - children: 'modal content', - productName: 'Product Name', - trademark: 'Trademark and copyright information here', - brandImageSrc: 'brandImg...', - brandImageAlt: 'Brand Image', - logoImageSrc: 'logoImg...', - logoImageAlt: 'AboutModal Logo' + onClose: jest.fn(), + children: 'modal content', + productName: 'Product Name', + trademark: 'Trademark and copyright information here', + brandImageSrc: 'brandImg...', + brandImageAlt: 'Brand Image', + logoImageSrc: 'logoImg...', + logoImageAlt: 'AboutModal Logo' }; test('AboutModal creates a container element once for div', () => { - const view = shallow( Test About Modal ); - view.update(); - expect(document.createElement).toBeCalledWith('div'); - expect(document.createElement).toHaveBeenCalledTimes(1); + const view = shallow( Test About Modal ); + view.update(); + expect(document.createElement).toBeCalledWith('div'); + expect(document.createElement).toHaveBeenCalledTimes(1); }); test('About Modal closes with escape', () => { - shallow( - - Test About Modal - - ); - const [event, handler] = (document.addEventListener as any).mock.calls[0]; - expect(event).toBe('keydown'); - handler({ keyCode: KEY_CODES.ESCAPE_KEY }); - expect(props.onClose).toBeCalled(); + shallow( + + Test About Modal + + ); + const [event, handler] = (document.addEventListener as any).mock.calls[0]; + expect(event).toBe('keydown'); + handler({ keyCode: KEY_CODES.ESCAPE_KEY }); + expect(props.onClose).toBeCalled(); }); test('modal does not call onClose for esc key if it is not open', () => { - shallow(); - const [event, handler] = (document.addEventListener as any).mock.calls[0]; - expect(event).toBe('keydown'); - handler({ keyCode: KEY_CODES.ESCAPE_KEY }); - expect(props.onClose).not.toBeCalled(); + shallow(); + const [event, handler] = (document.addEventListener as any).mock.calls[0]; + expect(event).toBe('keydown'); + handler({ keyCode: KEY_CODES.ESCAPE_KEY }); + expect(props.onClose).not.toBeCalled(); }); test('Each modal is given new ariaDescribedById and ariaLabelledbyId', () => { - const first = new AboutModal(props); - const second = new AboutModal(props); - expect(first.ariaLabelledBy).not.toBe(second.ariaLabelledBy); - expect(first.ariaDescribedBy).not.toBe(second.ariaDescribedBy); + const first = new AboutModal(props); + const second = new AboutModal(props); + expect(first.ariaLabelledBy).not.toBe(second.ariaLabelledBy); + expect(first.ariaDescribedBy).not.toBe(second.ariaDescribedBy); }); test('Console error is generated when the logoImageSrc is provided without logoImageAlt', () => { - const noImgAltrops = { - onClose: jest.fn(), - children: 'modal content', - productName: 'Product Name', - trademark: 'Trademark and copyright information here', - brandImageSrc: 'brandImg...', - logoImageSrc: 'logoImg...' - }; - const myMock = jest.fn() as any; - global.console = { error: myMock } as any; - const JSAboutModal = AboutModal as any; - shallow( Test About Modal ); - expect(myMock).toBeCalled(); + const noImgAltrops = { + onClose: jest.fn(), + children: 'modal content', + productName: 'Product Name', + trademark: 'Trademark and copyright information here', + brandImageSrc: 'brandImg...', + logoImageSrc: 'logoImg...' + }; + const myMock = jest.fn() as any; + global.console = { error: myMock } as any; + const JSAboutModal = AboutModal as any; + shallow( Test About Modal ); + expect(myMock).toBeCalled(); }); diff --git a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.tsx b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.tsx index 1f0efbef6c7..710d4e375ee 100644 --- a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.tsx +++ b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModal.tsx @@ -65,7 +65,7 @@ export class AboutModal extends React.Component { if (event.keyCode === KEY_CODES.ESCAPE_KEY && this.props.isOpen) { this.props.onClose(); } - } + }; toggleSiblingsFromScreenReaders = (hide: boolean) => { const bodyChildren = document.body.children; @@ -74,20 +74,20 @@ export class AboutModal extends React.Component { hide ? child.setAttribute('aria-hidden', '' + hide) : child.removeAttribute('aria-hidden'); } } - } + }; componentDidMount() { - const container = document.createElement('div'); - this.setState({ container }); - document.body.appendChild(container); - document.addEventListener('keydown', this.handleEscKeyClick, false); + const container = document.createElement('div'); + this.setState({ container }); + document.body.appendChild(container); + document.addEventListener('keydown', this.handleEscKeyClick, false); - if (this.props.isOpen) { - document.body.classList.add(css(styles.backdropOpen)); - } else { - document.body.classList.remove(css(styles.backdropOpen)); - } + if (this.props.isOpen) { + document.body.classList.add(css(styles.backdropOpen)); + } else { + document.body.classList.remove(css(styles.backdropOpen)); } + } componentDidUpdate() { if (this.props.isOpen) { @@ -107,7 +107,6 @@ export class AboutModal extends React.Component { } render() { - const { ...props } = this.props; const { container } = this.state; diff --git a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxCloseButton.tsx b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxCloseButton.tsx index 7049709da3f..72bca454af2 100644 --- a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxCloseButton.tsx +++ b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxCloseButton.tsx @@ -16,9 +16,9 @@ export const AboutModalBoxCloseButton: React.SFC onClose = () => undefined as any, ...props }: AboutModalBoxCloseButtonProps) => ( -
- -
+
+ +
); diff --git a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxContent.tsx b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxContent.tsx index 4201d246d6c..2a8b7977584 100644 --- a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxContent.tsx +++ b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxContent.tsx @@ -28,8 +28,6 @@ export const AboutModalBoxContent: React.SFC = ({
{noAboutModalBoxContentContainer ? children :
{children}
}
-

- {trademark} -

+

{trademark}

); diff --git a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxHero.tsx b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxHero.tsx index f185ac5d9bc..d3366f5a3c9 100644 --- a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxHero.tsx +++ b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalBoxHero.tsx @@ -16,9 +16,12 @@ export const AboutModalBoxHero: React.SFC = ({ ...props }: AboutModalBoxHeroProps) => (
+ {...props} + /> ); diff --git a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalContainer.tsx b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalContainer.tsx index 30554b11685..949b8a5d829 100644 --- a/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalContainer.tsx +++ b/packages/patternfly-4/react-core/src/components/AboutModal/AboutModalContainer.tsx @@ -63,7 +63,12 @@ export const AboutModalContainer: React.SFC = ({ {productName && } - + {children} diff --git a/packages/patternfly-4/react-core/src/components/Accordion/Accordion.test.tsx b/packages/patternfly-4/react-core/src/components/Accordion/Accordion.test.tsx index ef90dae58d5..8ab417f3b13 100644 --- a/packages/patternfly-4/react-core/src/components/Accordion/Accordion.test.tsx +++ b/packages/patternfly-4/react-core/src/components/Accordion/Accordion.test.tsx @@ -51,7 +51,9 @@ describe('Accordion', () => { const view = mount( - Item One + + Item One + Item One Content diff --git a/packages/patternfly-4/react-core/src/components/Accordion/Accordion.tsx b/packages/patternfly-4/react-core/src/components/Accordion/Accordion.tsx index 94e5e8ef446..b5fd20ddb1d 100644 --- a/packages/patternfly-4/react-core/src/components/Accordion/Accordion.tsx +++ b/packages/patternfly-4/react-core/src/components/Accordion/Accordion.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/Accordion/accordion'; -import {AccordionContext} from './AccordionContext'; +import { AccordionContext } from './AccordionContext'; export interface AccordionProps extends React.HTMLProps { /** Content rendered inside the Accordion */ @@ -27,10 +27,12 @@ export const Accordion: React.FunctionComponent = ({ const AccordionList: any = asDefinitionList ? 'dl' : 'div'; return ( - + {children} diff --git a/packages/patternfly-4/react-core/src/components/Alert/Alert.test.tsx b/packages/patternfly-4/react-core/src/components/Alert/Alert.test.tsx index 5a981bd6d88..189cba66290 100644 --- a/packages/patternfly-4/react-core/src/components/Alert/Alert.test.tsx +++ b/packages/patternfly-4/react-core/src/components/Alert/Alert.test.tsx @@ -2,15 +2,20 @@ import * as React from 'react'; import { mount } from 'enzyme'; import { Alert, AlertVariant } from './Alert'; -import { AlertActionLink } from './AlertActionLink'; +import { AlertActionLink } from './AlertActionLink'; import { AlertActionCloseButton } from './AlertActionCloseButton'; test('default Alert variant is info', () => { const view = mount(Alert testing); - expect(view.find('Alert').childAt(0).prop('className')).toContain('pf-m-info'); + expect( + view + .find('Alert') + .childAt(0) + .prop('className') + ).toContain('pf-m-info'); }); -Object.values(AlertVariant).forEach((variant) => { +Object.values(AlertVariant).forEach(variant => { describe(`Alert - ${variant}`, () => { test('Description', () => { const view = mount( @@ -72,16 +77,11 @@ Object.values(AlertVariant).forEach((variant) => { ); expect(view).toMatchSnapshot(); - }); test('inline variation', () => { const view = mount( - + Some alert ); diff --git a/packages/patternfly-4/react-core/src/components/Alert/Alert.tsx b/packages/patternfly-4/react-core/src/components/Alert/Alert.tsx index 6ca3f43a745..46ba62ef494 100644 --- a/packages/patternfly-4/react-core/src/components/Alert/Alert.tsx +++ b/packages/patternfly-4/react-core/src/components/Alert/Alert.tsx @@ -15,8 +15,7 @@ export enum AlertVariant { default = 'default' } -export interface AlertProps - extends Omit, 'action' | 'title'> { +export interface AlertProps extends Omit, 'action' | 'title'> { /** Adds Alert variant styles */ variant?: 'success' | 'danger' | 'warning' | 'info' | 'default'; /** Flag to indicate if the Alert is inline */ @@ -55,25 +54,26 @@ const Alert: React.FunctionComponent = ({ ); - const customClassName = css(styles.alert, isInline && styles.modifiers.inline, (variant !== AlertVariant.default ) && getModifier(styles, variant, styles.modifiers.info), className); + const customClassName = css( + styles.alert, + isInline && styles.modifiers.inline, + variant !== AlertVariant.default && getModifier(styles, variant, styles.modifiers.info), + className + ); return (

{readerTitle}

- {children && ( -
- {children} -
- )} + {children &&
{children}
} {action && (
{React.cloneElement(action as any, { title, variantLabel })}
)} diff --git a/packages/patternfly-4/react-core/src/components/Alert/AlertIcon.tsx b/packages/patternfly-4/react-core/src/components/Alert/AlertIcon.tsx index 24fae539106..bcf8aa04be7 100644 --- a/packages/patternfly-4/react-core/src/components/Alert/AlertIcon.tsx +++ b/packages/patternfly-4/react-core/src/components/Alert/AlertIcon.tsx @@ -24,11 +24,7 @@ export interface AlertIconProps extends React.HTMLProps { className?: string; } -export const AlertIcon = ({ - variant, - className = '', - ...props -}: AlertIconProps) => { +export const AlertIcon = ({ variant, className = '', ...props }: AlertIconProps) => { const Icon = variantIcons[variant]; return (
diff --git a/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncher.tsx b/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncher.tsx index d667ee68669..795b94114c2 100644 --- a/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncher.tsx +++ b/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncher.tsx @@ -5,51 +5,51 @@ import { DropdownDirection, DropdownPosition, DropdownToggle, DropdownContext } import { DropdownWithContext } from '../Dropdown/DropdownWithContext'; export interface ApplicationLauncherProps extends React.HTMLProps { - /** Additional element css classes */ - className?: string; - /** Display menu above or below dropdown toggle */ - direction?: DropdownDirection; - /** - * @deprecated - * Use the items prop instead - * - * Array of DropdownItem nodes that will be rendered in the dropdown Menu list - */ - dropdownItems?: React.ReactNode[]; - /** Array of application launcher items */ - items?: React.ReactNode[]; - /** Render Application launcher toggle as disabled icon */ - isDisabled?: boolean; - /** open bool */ - isOpen?: boolean; - /** Indicates where menu will be alligned horizontally */ - position?: DropdownPosition; - /** Function callback called when user selects item */ - onSelect?: (event: any) => void; - /** Callback called when application launcher toggle is clicked */ - onToggle?: (value: boolean) => void; - /** Adds accessible text to the button. Required for plain buttons */ - 'aria-label'?: string; - /** Flag to indicate if application launcher has groups */ - isGrouped?: boolean; - /** Toggle Icon, optional to override the icon used for the toggle */ - toggleIcon?: React.ReactNode; + /** Additional element css classes */ + className?: string; + /** Display menu above or below dropdown toggle */ + direction?: DropdownDirection; + /** + * @deprecated + * Use the items prop instead + * + * Array of DropdownItem nodes that will be rendered in the dropdown Menu list + */ + dropdownItems?: React.ReactNode[]; + /** Array of application launcher items */ + items?: React.ReactNode[]; + /** Render Application launcher toggle as disabled icon */ + isDisabled?: boolean; + /** open bool */ + isOpen?: boolean; + /** Indicates where menu will be alligned horizontally */ + position?: DropdownPosition; + /** Function callback called when user selects item */ + onSelect?: (event: any) => void; + /** Callback called when application launcher toggle is clicked */ + onToggle?: (value: boolean) => void; + /** Adds accessible text to the button. Required for plain buttons */ + 'aria-label'?: string; + /** Flag to indicate if application launcher has groups */ + isGrouped?: boolean; + /** Toggle Icon, optional to override the icon used for the toggle */ + toggleIcon?: React.ReactNode; } export class ApplicationLauncher extends React.Component { static defaultProps = { - "className": '', - "isDisabled": false, - "direction": DropdownDirection.down, - "dropdownItems": [] as React.ReactNode[], - "items": [] as React.ReactNode[], - "isOpen": false, - "position": DropdownPosition.left, - "onSelect": (_event: any): any => undefined, - "onToggle": (_value: boolean): any => undefined, + className: '', + isDisabled: false, + direction: DropdownDirection.down, + dropdownItems: [] as React.ReactNode[], + items: [] as React.ReactNode[], + isOpen: false, + position: DropdownPosition.left, + onSelect: (_event: any): any => undefined, + onToggle: (_value: boolean): any => undefined, 'aria-label': 'Application launcher', - "isGrouped": false, - "toggleIcon": + isGrouped: false, + toggleIcon: }; render() { const { @@ -67,20 +67,22 @@ export class ApplicationLauncher extends React.Component + {children} : children} {isExternal && ( <> - + + + (opens new window) )} diff --git a/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherGroup.tsx b/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherGroup.tsx index 57ac2e204ee..fd4270e58a5 100644 --- a/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherGroup.tsx +++ b/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherGroup.tsx @@ -4,8 +4,4 @@ import { DropdownGroup, DropdownGroupProps } from '../Dropdown'; export const ApplicationLauncherGroup: React.FunctionComponent = ({ children, ...props -}: DropdownGroupProps) => ( - - {children} - -); +}: DropdownGroupProps) => {children}; diff --git a/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherSeparator.tsx b/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherSeparator.tsx index e750237637b..0f0bed66564 100644 --- a/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherSeparator.tsx +++ b/packages/patternfly-4/react-core/src/components/ApplicationLauncher/ApplicationLauncherSeparator.tsx @@ -4,6 +4,4 @@ import { DropdownSeparator, SeparatorProps } from '../Dropdown'; export const ApplicationLauncherSeparator: React.FunctionComponent = ({ children, ...props -}: SeparatorProps) => ( - -); +}: SeparatorProps) => ; diff --git a/packages/patternfly-4/react-core/src/components/Avatar/Avatar.tsx b/packages/patternfly-4/react-core/src/components/Avatar/Avatar.tsx index 30c17d7105f..95e144d9ca4 100644 --- a/packages/patternfly-4/react-core/src/components/Avatar/Avatar.tsx +++ b/packages/patternfly-4/react-core/src/components/Avatar/Avatar.tsx @@ -12,11 +12,6 @@ export interface AvatarProps alt: string; } -export const Avatar: React.SFC = ({ - className = '', - src = '', - alt, - ...props -}: AvatarProps) => ( +export const Avatar: React.SFC = ({ className = '', src = '', alt, ...props }: AvatarProps) => ( {alt} ); diff --git a/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.test.tsx b/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.test.tsx index f6a0f1fe5c8..dd409af5b45 100644 --- a/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.test.tsx +++ b/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.test.tsx @@ -11,7 +11,7 @@ const images = { [BackgroundImageSrc.filter]: '/assets/images/background-filter.svg' }; -Object.values([true, false]).forEach((isRead) => { +Object.values([true, false]).forEach(isRead => { test('BackgroundImage', () => { const view = shallow(); expect(view).toMatchSnapshot(); diff --git a/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.tsx b/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.tsx index 485de49a518..f8f3655756c 100644 --- a/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.tsx +++ b/packages/patternfly-4/react-core/src/components/BackgroundImage/BackgroundImage.tsx @@ -27,7 +27,7 @@ const cssVariables = { [BackgroundImageSrc.xs2x]: c_background_image_BackgroundImage_2x && c_background_image_BackgroundImage_2x.name, [BackgroundImageSrc.sm]: c_background_image_BackgroundImage_sm && c_background_image_BackgroundImage_sm.name, [BackgroundImageSrc.sm2x]: c_background_image_BackgroundImage_sm_2x && c_background_image_BackgroundImage_sm_2x.name, - [BackgroundImageSrc.lg]: c_background_image_BackgroundImage_lg && c_background_image_BackgroundImage_lg.name, + [BackgroundImageSrc.lg]: c_background_image_BackgroundImage_lg && c_background_image_BackgroundImage_lg.name }; export interface BackgroundImageSrcMap { @@ -60,13 +60,13 @@ export const BackgroundImage: React.FunctionComponent = ({ [BackgroundImageSrc.sm]: src, [BackgroundImageSrc.sm2x]: src, [BackgroundImageSrc.lg]: src, - [BackgroundImageSrc.filter]: '', // unused + [BackgroundImageSrc.filter]: '' // unused }; } // Build stylesheet string based on cssVariables let cssSheet = ''; - (Object.keys(cssVariables) as [keyof typeof srcMap]).forEach((size) => { + (Object.keys(cssVariables) as [keyof typeof srcMap]).forEach(size => { cssSheet += `${cssVariables[size as keyof typeof cssVariables]}: url('${srcMap[size]}');`; }); @@ -74,13 +74,15 @@ export const BackgroundImage: React.FunctionComponent = ({ const bgStyles = StyleSheet.create({ bgOverrides: `&.pf-c-background-image { ${cssSheet} - }`}); + }` + }); return (
- {icon}} - {children} - + + {icon && variant === ButtonVariant.link && {icon}} + {children} + ); }; -const ButtonWithOuiaContext = withOuiaContext(Button); +const ButtonWithOuiaContext = withOuiaContext(Button); export { ButtonWithOuiaContext as Button }; diff --git a/packages/patternfly-4/react-core/src/components/Card/Card.tsx b/packages/patternfly-4/react-core/src/components/Card/Card.tsx index 408c8efe4e8..bff3f12aeee 100644 --- a/packages/patternfly-4/react-core/src/components/Card/Card.tsx +++ b/packages/patternfly-4/react-core/src/components/Card/Card.tsx @@ -25,7 +25,16 @@ export const Card: React.FunctionComponent = ({ }: CardProps) => { const Component = component as any; return ( - - {children} - -);}; + + {children} + + ); +}; diff --git a/packages/patternfly-4/react-core/src/components/Card/CardBody.tsx b/packages/patternfly-4/react-core/src/components/Card/CardBody.tsx index 1edad8a95cf..062b9906918 100644 --- a/packages/patternfly-4/react-core/src/components/Card/CardBody.tsx +++ b/packages/patternfly-4/react-core/src/components/Card/CardBody.tsx @@ -22,7 +22,8 @@ export const CardBody: React.FunctionComponent = ({ }: CardBodyProps) => { const Component = component as any; return ( - - {children} - -); }; + + {children} + + ); +}; diff --git a/packages/patternfly-4/react-core/src/components/Card/CardFooter.tsx b/packages/patternfly-4/react-core/src/components/Card/CardFooter.tsx index 769b4daf42f..e8e1e8ea8fc 100644 --- a/packages/patternfly-4/react-core/src/components/Card/CardFooter.tsx +++ b/packages/patternfly-4/react-core/src/components/Card/CardFooter.tsx @@ -19,7 +19,8 @@ export const CardFooter: React.FunctionComponent = ({ }: CardFooterProps) => { const Component = component as any; return ( - - {children} - -);}; + + {children} + + ); +}; diff --git a/packages/patternfly-4/react-core/src/components/Card/CardHeader.tsx b/packages/patternfly-4/react-core/src/components/Card/CardHeader.tsx index a23c6c14f84..ee676fab733 100644 --- a/packages/patternfly-4/react-core/src/components/Card/CardHeader.tsx +++ b/packages/patternfly-4/react-core/src/components/Card/CardHeader.tsx @@ -4,18 +4,18 @@ import styles from '@patternfly/react-styles/css/components/Card/card'; import titleStyles from '@patternfly/react-styles/css/components/Title/title'; export interface CardHeaderProps extends React.HTMLProps { - /** Content rendered inside the Card Footer */ - children?: React.ReactNode; - /** Additional classes added to the Header */ - className?: string; + /** Content rendered inside the Card Footer */ + children?: React.ReactNode; + /** Additional classes added to the Header */ + className?: string; } export const CardHeader: React.FunctionComponent = ({ - children = null, - className = '', - ...props + children = null, + className = '', + ...props }: CardHeaderProps) => ( -
- {children} -
+
+ {children} +
); diff --git a/packages/patternfly-4/react-core/src/components/Checkbox/Checkbox.tsx b/packages/patternfly-4/react-core/src/components/Checkbox/Checkbox.tsx index 465bf6fa094..34f19233b55 100644 --- a/packages/patternfly-4/react-core/src/components/Checkbox/Checkbox.tsx +++ b/packages/patternfly-4/react-core/src/components/Checkbox/Checkbox.tsx @@ -42,7 +42,7 @@ export class Checkbox extends React.Component { private handleChange = (event: React.FormEvent): void => { this.props.onChange(event.currentTarget.checked, event); - } + }; render() { const { @@ -59,7 +59,7 @@ export class Checkbox extends React.Component { } = this.props; const checkedProps: { checked?: boolean; defaultChecked?: boolean } = {}; if ([true, false].includes(checked) || isChecked === true) { - checkedProps.checked = checked || isChecked; + checkedProps.checked = checked || isChecked; } if (onChange !== defaultOnChange) { checkedProps.checked = isChecked; @@ -79,7 +79,7 @@ export class Checkbox extends React.Component { aria-invalid={!isValid} aria-label={ariaLabel} disabled={isDisabled} - ref={(elem) => elem && (elem.indeterminate = isChecked === null)} + ref={elem => elem && (elem.indeterminate = isChecked === null)} {...checkedProps} /> {label && ( diff --git a/packages/patternfly-4/react-core/src/components/ChipGroup/Chip.tsx b/packages/patternfly-4/react-core/src/components/ChipGroup/Chip.tsx index 1e49bc6de0a..1ee472b23aa 100644 --- a/packages/patternfly-4/react-core/src/components/ChipGroup/Chip.tsx +++ b/packages/patternfly-4/react-core/src/components/ChipGroup/Chip.tsx @@ -51,8 +51,7 @@ export class Chip extends React.Component { componentDidMount() { this.setState({ - isTooltipVisible: Boolean(this.span.current && - this.span.current.offsetWidth < this.span.current.scrollWidth) + isTooltipVisible: Boolean(this.span.current && this.span.current.offsetWidth < this.span.current.scrollWidth) }); } @@ -66,17 +65,10 @@ export class Chip extends React.Component { ); - } + }; renderChip = (randomId: string) => { - const { - children, - closeBtnAriaLabel, - tooltipPosition, - className, - onClick, - isReadOnly - } = this.props; + const { children, closeBtnAriaLabel, tooltipPosition, className, onClick, isReadOnly } = this.props; const Component = this.props.component as any; if (this.state.isTooltipVisible) { return ( @@ -116,12 +108,12 @@ export class Chip extends React.Component { )} ); - } + }; render() { const { isOverflowChip } = this.props; return ( - {(randomId) => (isOverflowChip ? this.renderOverflowChip() : this.renderChip(randomId))} + {randomId => (isOverflowChip ? this.renderOverflowChip() : this.renderChip(randomId))} ); } } diff --git a/packages/patternfly-4/react-core/src/components/ChipGroup/ChipButton.tsx b/packages/patternfly-4/react-core/src/components/ChipGroup/ChipButton.tsx index 15d861f4f22..ae454cb258a 100644 --- a/packages/patternfly-4/react-core/src/components/ChipGroup/ChipButton.tsx +++ b/packages/patternfly-4/react-core/src/components/ChipGroup/ChipButton.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Button, ButtonProps } from '../Button'; +import { Button, ButtonProps } from '../Button'; export interface ChipButtonProps extends ButtonProps { /** Aria label for chip button */ @@ -13,14 +13,15 @@ export interface ChipButtonProps extends ButtonProps { } export const ChipButton: React.FunctionComponent = ({ - ariaLabel = 'close', - children = null, - className = '', - onClick = () => undefined, - ...props + ariaLabel = 'close', + children = null, + className = '', + onClick = () => undefined, + ...props }: ChipButtonProps) => { - return ( + return ( ); - }; + + ); +}; diff --git a/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroup.tsx b/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroup.tsx index 3a1db6fdfc8..b6848094e71 100644 --- a/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroup.tsx +++ b/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroup.tsx @@ -22,7 +22,7 @@ export interface ChipGroupProps extends React.HTMLProps { /** Set heading level to the chip item label */ headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; /** Set number of chips to show before overflow */ - numChips?: number; + numChips?: number; } interface ChipGroupState { @@ -41,10 +41,10 @@ export class ChipGroup extends React.Component { className: '', expandedText: 'Show Less', collapsedText: '${remaining} more', - withToolbar: false, + withToolbar: false, defaultIsOpen: false, numChips: 3 - } + }; toggleCollapse = () => { this.setState(prevState => ({ @@ -57,11 +57,7 @@ export class ChipGroup extends React.Component { const { headingLevel = 'h4' } = this.props; return ( - + ); } @@ -71,11 +67,7 @@ export class ChipGroup extends React.Component { const { isOpen } = this.state; return (
    - +
); } @@ -96,9 +88,11 @@ interface InnerChipGroupProps extends ChipGroupProps { const InnerChipGroup = (props: InnerChipGroupProps) => { const { children, expandedText, isOpen, onToggleCollapse, collapsedText, withToolbar, numChips } = props; - - const collapsedTextResult = fillTemplate(collapsedText as string, { remaining: React.Children.count(children) - numChips }); - const mappedChildren = React.Children.map(children, (c) => { + + const collapsedTextResult = fillTemplate(collapsedText as string, { + remaining: React.Children.count(children) - numChips + }); + const mappedChildren = React.Children.map(children, c => { const child = c as React.ReactElement; if (withToolbar) { return React.cloneElement(child, { diff --git a/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroupToolbarItem.tsx b/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroupToolbarItem.tsx index ef502104f2e..02383241e0b 100644 --- a/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroupToolbarItem.tsx +++ b/packages/patternfly-4/react-core/src/components/ChipGroup/ChipGroupToolbarItem.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { css } from '@patternfly/react-styles'; import styles from '@patternfly/react-styles/css/components/ChipGroup/chip-group'; -import {ChipGroupContext} from './ChipGroup'; +import { ChipGroupContext } from './ChipGroup'; export interface ChipGroupToolbarItemProps extends React.HTMLProps { /** Category name text */ @@ -18,21 +18,21 @@ export const ChipGroupToolbarItem: React.FunctionComponent { - if (React.Children.count(children)) { - return ( - - {(HeadingLevel: any) => { - return ( -
    -
  • - {categoryName} -
      {children}
    -
  • -
- ); - }} -
- ); - } - return null; - }; + if (React.Children.count(children)) { + return ( + + {(HeadingLevel: any) => { + return ( +
    +
  • + {categoryName} +
      {children}
    +
  • +
+ ); + }} +
+ ); + } + return null; +}; diff --git a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx index 7dedf4b8ef4..d6711642d0f 100644 --- a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx +++ b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopy.tsx @@ -85,7 +85,7 @@ export class ClipboardCopy extends React.Component) => { - this.setState((prevState) => ({ + this.setState(prevState => ({ expanded: !prevState.expanded })); - } + }; updateText = (text: string | number) => { this.setState({ text }); this.props.onChange(text); - } + }; render = () => { const { @@ -143,7 +143,7 @@ export class ClipboardCopy extends React.Component - {(id) => ( + {id => (
{variant === 'expansion' && ( @@ -189,7 +189,12 @@ export class ClipboardCopy extends React.Component
{this.state.expanded && ( - + {this.state.text} )} @@ -198,5 +203,5 @@ export class ClipboardCopy extends React.Component
); - } + }; } diff --git a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.test.tsx b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.test.tsx index 617be02d754..6195a01f415 100644 --- a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.test.tsx +++ b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.test.tsx @@ -3,14 +3,14 @@ import { shallow } from 'enzyme'; import { ClipboardCopyButton } from './ClipboardCopyButton'; const props = { - "id": 'my-id', - "textId": 'my-text-id', - "className": 'fancy-copy-button', - "onClick": jest.fn(), - "exitDelay": 1000, - "entryDelay": 2000, - "maxWidth": '500px', - "position": 'right' as 'right', + id: 'my-id', + textId: 'my-text-id', + className: 'fancy-copy-button', + onClick: jest.fn(), + exitDelay: 1000, + entryDelay: 2000, + maxWidth: '500px', + position: 'right' as 'right', 'aria-label': 'click this button to copy text' }; diff --git a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.tsx b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.tsx index 603755ab12d..51fab79c328 100644 --- a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.tsx +++ b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyButton.tsx @@ -4,7 +4,8 @@ import { css } from '@patternfly/react-styles'; import { CopyIcon } from '@patternfly/react-icons'; import { Tooltip } from '../Tooltip'; -export interface ClipboardCopyButtonProps extends React.DetailedHTMLProps, HTMLButtonElement> { +export interface ClipboardCopyButtonProps + extends React.DetailedHTMLProps, HTMLButtonElement> { onClick: (event: React.MouseEvent) => void; children: React.ReactNode; id: string; diff --git a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.test.tsx b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.test.tsx index 9e81d9f36c8..77e81629c03 100644 --- a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.test.tsx +++ b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.test.tsx @@ -8,10 +8,6 @@ const props = { }; test('expanded content render', () => { - const view = shallow( - - This is my text - - ); + const view = shallow(This is my text); expect(view).toMatchSnapshot(); }); diff --git a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx index c4d788e120a..5146012a664 100644 --- a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx +++ b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx @@ -33,16 +33,17 @@ export class ClipboardCopyExpanded extends React.Component onChange(e.target.innerText, e)} - contentEditable={!isReadOnly} - {...props} - />; + const clipboardCopyExpandableComponent = ( +
onChange(e.target.innerText, e)} + contentEditable={!isReadOnly} + {...props} + /> + ); - return (isCode ?
{clipboardCopyExpandableComponent}
: clipboardCopyExpandableComponent); + return isCode ?
{clipboardCopyExpandableComponent}
: clipboardCopyExpandableComponent; } } diff --git a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyToggle.tsx b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyToggle.tsx index 675f5045073..d88aaa38029 100644 --- a/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyToggle.tsx +++ b/packages/patternfly-4/react-core/src/components/ClipboardCopy/ClipboardCopyToggle.tsx @@ -3,7 +3,8 @@ import styles from '@patternfly/react-styles/css/components/ClipboardCopy/clipbo import { css } from '@patternfly/react-styles'; import { AngleRightIcon } from '@patternfly/react-icons'; -export interface ClipboardCopyToggleProps extends React.DetailedHTMLProps, HTMLButtonElement> { +export interface ClipboardCopyToggleProps + extends React.DetailedHTMLProps, HTMLButtonElement> { onClick: (event: React.MouseEvent) => void; id: string; textId: string; @@ -22,7 +23,7 @@ export const ClipboardCopyToggle: React.FunctionComponent { return ( - + ); expect(view.props().className).toBe('pf-c-empty-state__primary custom-empty-state-prim-cls'); diff --git a/packages/patternfly-4/react-core/src/components/EmptyState/EmptyStateIcon.tsx b/packages/patternfly-4/react-core/src/components/EmptyState/EmptyStateIcon.tsx index ee2b28e080c..1a41fe002e8 100644 --- a/packages/patternfly-4/react-core/src/components/EmptyState/EmptyStateIcon.tsx +++ b/packages/patternfly-4/react-core/src/components/EmptyState/EmptyStateIcon.tsx @@ -20,9 +20,9 @@ export interface EmptyStateIconProps extends IconProps { /** Additional classes added to the EmptyState */ className?: string; /** Icon component to be rendered inside the EmptyState on icon variant */ - icon?: string | React.FunctionComponent + icon?: string | React.FunctionComponent; /** Component to be rendered inside the EmptyState on container variant */ - component?: React.FunctionComponent; + component?: React.FunctionComponent; /** Adds empty state icon variant styles */ variant?: 'icon' | 'container'; } @@ -38,6 +38,8 @@ export const EmptyStateIcon: React.FunctionComponent = ({ return variant === 'icon' ? (