Skip to content

Commit

Permalink
Make requested changes (update peer-dependencies, clarify naming in s…
Browse files Browse the repository at this point in the history
…tyles.js), upgrade to stable version of react
  • Loading branch information
xadn committed Feb 17, 2019
1 parent 61e1920 commit 24d512a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9,753 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
node_modules
npm-debug.log
.DS_Store
jsconfig.json

react-codemod
gh-pages/
lib
build
*.log
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"expect": "^22.4.3",
"jest": "^22.4.3",
"prettier": "^1.16.3",
"react": "^16.8.0-alpha.1",
"react-dom": "^16.8.0-alpha.1",
"react": "^16.8.2",
"react-dom": "^16.8.2",
"react-hot-loader": "^4.0.1",
"react-test-renderer": "^16.8.0-alpha.1",
"rebug": "^0.0.3",
Expand All @@ -78,6 +78,6 @@
"webpack-dev-server": "^3.1.3"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0 || ^16.0.0"
"react": "^16.8.0"
}
}
10 changes: 6 additions & 4 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ const ThemeContext = createContext(base(themes[DEFAULT_THEME_NAME]));

/**
* Hook to get the component styles for the current theme.
* @param {string} baseStylesKey - Name of the component to be styled
*/
export const useStyles = key => {
export const useStyles = baseStylesKey => {
const themeStyles = useContext(ThemeContext);
return themeStyles[key];
return themeStyles[baseStylesKey];
};

/**
* HOC to create a component that accepts a "theme" prop and uses it to set
* the current theme. This is intended to be used by the top-level inspector
* components.
* @param {Object} WrappedComponent - React component to be wrapped
*/
export const themeAcceptor = Component => {
export const themeAcceptor = WrappedComponent => {
const ThemeAcceptor = ({ theme = DEFAULT_THEME_NAME, ...restProps }) => {
const themeStyles = useMemo(() => {
switch (Object.prototype.toString.call(theme)) {
Expand All @@ -36,7 +38,7 @@ export const themeAcceptor = Component => {

return (
<ThemeContext.Provider value={themeStyles}>
<Component {...restProps} />
<WrappedComponent {...restProps} />
</ThemeContext.Provider>
);
};
Expand Down
Loading

0 comments on commit 24d512a

Please sign in to comment.