Skip to content

Commit bf0e5d8

Browse files
authored
Update config.js
1 parent e4d5d21 commit bf0e5d8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/utils/config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ const getConfigParam = key => {
3939
return JSON.parse(JSON.stringify(get(config, key, get(getDefaults(), key))))
4040
}
4141

42+
// Method to grab a config value for a particular component.
43+
// Returns a deep clone (immutable) copy
44+
const getConfigComponent = (cmpName, key = null) => {
45+
if (key) {
46+
// Return the particular config value for key for specified component
47+
return getConfigParam(`${cmpName}.${key}`)
48+
} else {
49+
// return the components full config
50+
return getConfigParam(cmpName) || {}
51+
}
52+
}
53+
4254
// Convenience method for getting all breakpoint names
4355
const getBreakpointsAll = () => {
4456
const bpts = getConfigParam('breakpoints')
@@ -68,6 +80,7 @@ const getBreakpointsDown = () => {
6880
export {
6981
getDefaults,
7082
getConfigParam,
83+
getConfigComponent,
7184
getBreakpointsAll,
7285
getBreakpointsUp,
7386
getBreakpointsDown

0 commit comments

Comments
 (0)