Skip to content

Commit

Permalink
import minimal lodash packages (#4127)
Browse files Browse the repository at this point in the history
  • Loading branch information
smhutch authored Oct 12, 2020
1 parent 76336d3 commit 01c6986
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
7 changes: 4 additions & 3 deletions src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import _ from 'lodash';
import find from 'lodash/find';
import findIndex from 'lodash/findIndex';

import {
EuiCollapsibleNav,
Expand Down Expand Up @@ -97,7 +98,7 @@ export default () => {
>(JSON.parse(String(localStorage.getItem('pinnedItems'))) || []);

const addPin = (item: any) => {
if (!item || _.find(pinnedItems, { label: item.label })) {
if (!item || find(pinnedItems, { label: item.label })) {
return;
}
item.pinned = true;
Expand All @@ -107,7 +108,7 @@ export default () => {
};

const removePin = (item: any) => {
const pinIndex = _.findIndex(pinnedItems, { label: item.label });
const pinIndex = findIndex(pinnedItems, { label: item.label });
if (pinIndex > -1) {
item.pinned = false;
const newPinnedItems = pinnedItems;
Expand Down
3 changes: 2 additions & 1 deletion src-docs/src/views/elastic_charts/category_chart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, Fragment, useContext } from 'react';
import { orderBy, round } from 'lodash';
import orderBy from 'lodash/orderBy';
import round from 'lodash/round';

import { ThemeContext } from '../../components';
import { Chart, Settings, Axis } from '@elastic/charts';
Expand Down
18 changes: 11 additions & 7 deletions src-docs/src/views/elastic_charts/pie_alts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* eslint-disable no-nested-ternary */
import React, { useState, Fragment, useContext } from 'react';
import _ from 'lodash';
import groupBy from 'lodash/groupBy';
import mapValues from 'lodash/mapValues';
import orderBy from 'lodash/orderBy';
import sortBy from 'lodash/sortBy';
import sumBy from 'lodash/sumBy';

import { ThemeContext } from '../../components';
import { Chart, Settings, Axis, BarSeries } from '@elastic/charts';
Expand Down Expand Up @@ -58,21 +62,21 @@ export default () => {
let usesRainData;
if (formatted && formattedData) {
data = ordered
? _.orderBy(DAYS_OF_RAIN, ['precipitation', 'days'], ['desc', 'asc'])
? orderBy(DAYS_OF_RAIN, ['precipitation', 'days'], ['desc', 'asc'])
: DAYS_OF_RAIN;
usesRainData = true;
color = euiPaletteForTemperature(3);
} else {
const DATASET = grouped ? GITHUB_DATASET_MOD : GITHUB_DATASET;
data = _.orderBy(DATASET, 'issueType', 'asc');
data = orderBy(DATASET, 'issueType', 'asc');

if (ordered) {
const totals = _.mapValues(_.groupBy(DATASET, 'vizType'), (groups) =>
_.sumBy(groups, 'count')
const totals = mapValues(groupBy(DATASET, 'vizType'), (groups) =>
sumBy(groups, 'count')
);

data = _.orderBy(DATASET, 'issueType', 'desc');
const sortedData = _.sortBy(data, [
data = orderBy(DATASET, 'issueType', 'desc');
const sortedData = sortBy(data, [
({ vizType }) => totals[vizType],
]).reverse();
data = sortedData;
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/elastic_charts/sparklines.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext, Fragment } from 'react';
import { cloneDeep } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import { ThemeContext } from '../../components';
import {
Chart,
Expand Down
2 changes: 1 addition & 1 deletion src/components/token/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React, { FunctionComponent, HTMLAttributes } from 'react';
import { defaults } from 'lodash';
import defaults from 'lodash/defaults';
import classNames from 'classnames';
import { CommonProps, keysOf } from '../common';
import { isColorDark, hexToRgb } from '../../services';
Expand Down

0 comments on commit 01c6986

Please sign in to comment.