From 8e48c01e7aada6978e92a6da1d040f3ef0d37945 Mon Sep 17 00:00:00 2001 From: Haishan Date: Fri, 20 Mar 2020 22:19:56 +0800 Subject: feat: remembers group collapse state for https://github.com/haishanh/yacd/issues/480 --- babel.config.js | 4 +- package.json | 8 +- src/components/Button.js | 21 +- src/components/CollapsibleSectionHeader.js | 2 +- src/components/CollapsibleSectionHeader.module.css | 4 + src/components/ProxyGroup.js | 20 +- src/components/ProxyProvider.js | 33 +- src/components/StateProvider.js | 2 + src/misc/utils.js | 23 + src/store/app.js | 19 +- src/store/index.js | 9 +- yarn.lock | 577 ++++++++++++--------- 12 files changed, 457 insertions(+), 265 deletions(-) create mode 100644 src/misc/utils.js diff --git a/babel.config.js b/babel.config.js index 75d8acc..70c5432 100644 --- a/babel.config.js +++ b/babel.config.js @@ -7,7 +7,9 @@ const presets = [ modules: false, // see also zloirock/core-js https://bit.ly/2JLnrgw useBuiltIns: 'usage', - corejs: 3 + corejs: 3, + // new in babel 7.9.0 https://babeljs.io/blog/2020/03/16/7.9.0 + bugfixes: true } ], '@babel/preset-react', diff --git a/package.json b/package.json index 2d59a62..7315932 100644 --- a/package.json +++ b/package.json @@ -34,12 +34,12 @@ "dependencies": { "@babel/runtime": "^7.7.7", "@hsjs/react-cache": "0.0.0-alpha.aa94237", - "@sentry/browser": "^5.9.1", + "@sentry/browser": "^5.15.0", "chart.js": "^2.9.2", "classnames": "^2.2.6", "core-js": "^3.6.2", "date-fns": "^2.8.1", - "framer-motion": "^1.7.0", + "framer-motion": "^1.10.0", "history": "^4.7.2", "immer": "^5.1.0", "invariant": "^2.2.4", @@ -86,8 +86,8 @@ "eslint-plugin-jest": "^23.6.0", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-react": "^7.17.0", - "eslint-plugin-react-hooks": "^2.2.0", - "file-loader": "^5.0.2", + "eslint-plugin-react-hooks": "^2.5.1", + "file-loader": "^6.0.0", "html-webpack-plugin": "^3.2.0", "husky": "^4.0.0", "lint-staged": "^10.0.7", diff --git a/src/components/Button.js b/src/components/Button.js index d5b88cf..2ec0c22 100644 --- a/src/components/Button.js +++ b/src/components/Button.js @@ -16,10 +16,17 @@ type ButtonProps = { isLoading?: boolean, start?: Element | (() => Element), onClick?: (SyntheticEvent) => mixed, - kind?: 'primary' | 'minimal' + kind?: 'primary' | 'minimal', + className?: string }; function Button(props: ButtonProps, ref) { - const { onClick, isLoading, kind = 'primary', ...restProps } = props; + const { + onClick, + isLoading, + kind = 'primary', + className, + ...restProps + } = props; const internalOnClick = useCallback( e => { if (isLoading) return; @@ -27,9 +34,13 @@ function Button(props: ButtonProps, ref) { }, [isLoading, onClick] ); - const btnClassName = cx(s0.btn, { - [s0.minimal]: kind === 'minimal' - }); + const btnClassName = cx( + s0.btn, + { + [s0.minimal]: kind === 'minimal' + }, + className + ); return (