Skip to content

Commit 4a678b3

Browse files
committed
Use modularized methods from lodash
Avoids including the full lodash build.
1 parent 5f410fc commit 4a678b3

File tree

11 files changed

+33
-29
lines changed

11 files changed

+33
-29
lines changed

modules/react-documentation/src/components/Docs.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import React from 'react'
44
import reactCSS from 'reactcss'
5-
import _ from 'lodash'
5+
import map from 'lodash/map'
6+
import throttle from 'lodash/throttle'
67
import markdown from '../helpers/markdown'
78

89
import { Grid } from '../../../react-basic-layout'
@@ -23,7 +24,7 @@ class Docs extends React.Component {
2324
this.changeSelection = this.changeSelection.bind(this);
2425
this.attachSidebar = this.attachSidebar.bind(this);
2526
this.handleScroll = this.handleScroll.bind(this);
26-
this.handleScroll = _.throttle(this.handleScroll, 200);
27+
this.handleScroll = throttle(this.handleScroll, 200);
2728
}
2829

2930
componentDidMount() {
@@ -59,7 +60,7 @@ class Docs extends React.Component {
5960
const items = document.getElementsByClassName('file');
6061
const doc = document.documentElement;
6162
const top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
62-
_.map(items, (item) => {
63+
map(items, (item) => {
6364
const bottomOfItem = item.offsetTop + item.clientHeight;
6465
if (item.offsetTop < top && bottomOfItem > top) {
6566
if (this.state.visible !== item.id) {

modules/react-material-design/src/components/Link.cjsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
React = require('react')
4-
_ = require('lodash')
4+
isString = require('lodash/isString')
55

66

77
module.exports = class Link extends React.Component
@@ -27,7 +27,7 @@ module.exports = class Link extends React.Component
2727
handleClick: (e) => @props.onClick?(e, @props.callbackValue)
2828

2929
render: ->
30-
if _.isString(@props.onClick)
30+
if isString(@props.onClick)
3131
<a style={ textDecoration: 'none' } href={ @props.onClick } target={ '_blank' if @props.newTab }>{ @props.children }</a>
3232
else
3333
<a style={ textDecoration: 'none' } onClick={ @handleClick }>{ @props.children }</a>

modules/react-material-design/src/components/Tabs.cjsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
React = require('react')
44
css = require('reactcss')
5-
_ = require('lodash')
5+
isString = require('lodash/isString')
66

77
Tab = require('./Tab')
88
Link = require('./Link')
@@ -155,7 +155,7 @@ class Tabs extends React.Component
155155
<div is="tabs" ref="tabs">
156156
<div is="tabWrap" className="flexbox-fix">
157157
{ for tab, i in @props.tabs
158-
if _.isString(tab)
158+
if isString(tab)
159159
label = tab
160160
callback = null
161161
else

src/autoprefix.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import _ from 'lodash'
3+
import map from 'lodash/map'
44

55
const transforms = {
66
borderRadius: (value) => {
@@ -96,9 +96,9 @@ const transforms = {
9696

9797
export const autoprefix = (elements) => {
9898
const prefixed = {}
99-
_.map(elements, (styles, element) => {
99+
map(elements, (styles, element) => {
100100
const expanded = {}
101-
_.map(styles, (value, key) => {
101+
map(styles, (value, key) => {
102102
const transform = transforms[key]
103103
if (transform) {
104104
Object.assign(expanded, transform(value))

src/deprecated/Component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import React from 'react'
44
import inline from './inline'
5-
import _ from 'lodash'
5+
import once from 'lodash/once'
66

7-
const warning = _.once(() => console.warn(`Extending ReactCSS.Component
7+
const warning = once(() => console.warn(`Extending ReactCSS.Component
88
is deprecated in ReactCSS 1.0.0`))
99

1010
export class ReactCSSComponent extends React.Component {

src/deprecated/check-class-structure.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/* eslint no-console: 0 */
22

3-
import _ from 'lodash'
3+
import map from 'lodash/map'
4+
import isObject from 'lodash/isObject'
45

56
export const checkClassStructure = (classes) => {
6-
_.map(classes, (elements, className) => {
7+
map(classes, (elements, className) => {
78
if (classes.hasOwnProperty(className)) {
8-
if (!_.isObject(elements)) {
9+
if (!isObject(elements)) {
910
console.warn(`Make sure the value of \`${ className }\` is an object of
1011
html elements. You passed it \`${ elements }\``)
1112
} else {
12-
_.map(elements, (css, elementName) => {
13+
map(elements, (css, elementName) => {
1314
if (elements.hasOwnProperty(elementName)) {
14-
if (!_.isObject(css)) {
15+
if (!isObject(css)) {
1516
console.warn(`Make sure the value of the element \`${ className }\`
1617
is an object of css. You passed it \`${ elements }\``)
1718
}

src/deprecated/inline.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import _ from 'lodash'
3+
import isObject from 'lodash/isObject'
44
import checkClassStructure from './check-class-structure'
55
import combine from './combine'
66

@@ -33,7 +33,7 @@ module.exports = function (declaredClasses) {
3333

3434
for (var prop in this.props) {
3535
let value = this.props[prop]
36-
if (!_.isObject(value)) {
36+
if (!isObject(value)) {
3737

3838
if (value === true) {
3939
activateClass(prop)

src/deprecated/merge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict'
22

33
import mrg from 'merge'
4-
import _ from 'lodash'
4+
import isObject from 'lodash/isObject'
55

66
const merge = (toMerge) => {
77
// If its an object, lets just return it
8-
if (_.isObject(toMerge) && !_.isArray(toMerge)) {
8+
if (isObject(toMerge) && !Array.isArray(toMerge)) {
99
return toMerge
1010
}
1111

src/deprecated/transform-mixins.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
import _ from 'lodash'
3+
import isObject from 'lodash/isObject'
44
import merge from 'merge'
55

66
/*
@@ -131,7 +131,7 @@ const transform = (styleObject, customFuncs, parent) => {
131131
var value = styleObject[key]
132132

133133
// If its an object
134-
if (_.isObject(value) && !_.isArray(value)) {
134+
if (isObject(value) && !Array.isArray(value)) {
135135
// Lets go ahead and run again
136136
obj[key] = transform(value, customFuncs, styleObject)
137137
} else {

src/flattenNames.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
'use strict'
22

3-
import _ from 'lodash'
3+
import map from 'lodash/map'
4+
import isPlainObject from 'lodash/isPlainObject'
5+
import isString from 'lodash/isString'
46

57
export const flattenNames = (things) => {
68
const names = []
79

810
things.map((thing) => {
9-
_.isArray(thing) && flattenNames(thing).map((name) => names.push(name))
10-
_.isPlainObject(thing) && _.map(thing, (value, key) => {
11+
Array.isArray(thing) && flattenNames(thing).map((name) => names.push(name))
12+
isPlainObject(thing) && map(thing, (value, key) => {
1113
value === true && names.push(key)
1214
names.push(`${ key }-${ value }`)
1315
})
14-
_.isString(thing) && names.push(thing)
16+
isString(thing) && names.push(thing)
1517
return thing
1618
})
1719

0 commit comments

Comments
 (0)