From 7fd8df7d2bb4bc5293d250bbfcfe7caf1e5375d0 Mon Sep 17 00:00:00 2001 From: Sendya <18x@loacg.com> Date: Thu, 10 Oct 2019 17:30:30 +0800 Subject: [PATCH] refactor: svg file to functional component icon - update jest snapshot --- .../__tests__/__snapshots__/demo.test.js.snap | 200 ++++++++++- components/result/index.jsx | 12 +- components/result/noFound.jsx | 289 +++++++++++++++ components/result/noFound.svg | 280 --------------- components/result/serverError.jsx | 334 ++++++++++++++++++ components/result/serverError.svg | 325 ----------------- components/result/unauthorized.jsx | 283 +++++++++++++++ components/result/unauthorized.svg | 141 -------- 8 files changed, 1109 insertions(+), 755 deletions(-) create mode 100644 components/result/noFound.jsx delete mode 100644 components/result/noFound.svg create mode 100644 components/result/serverError.jsx delete mode 100644 components/result/serverError.svg create mode 100644 components/result/unauthorized.jsx delete mode 100644 components/result/unauthorized.svg diff --git a/components/result/__tests__/__snapshots__/demo.test.js.snap b/components/result/__tests__/__snapshots__/demo.test.js.snap index fbcd0e50d..01b14d639 100644 --- a/components/result/__tests__/__snapshots__/demo.test.js.snap +++ b/components/result/__tests__/__snapshots__/demo.test.js.snap @@ -2,7 +2,64 @@ exports[`renders ./components/result/demo/403.md correctly 1`] = `
-
403
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
403
Sorry, you are not authorized to access this page.
@@ -11,7 +68,72 @@ exports[`renders ./components/result/demo/403.md correctly 1`] = ` exports[`renders ./components/result/demo/404.md correctly 1`] = `
-
404
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
404
Sorry, the page you visited does not exist.
@@ -20,7 +142,79 @@ exports[`renders ./components/result/demo/404.md correctly 1`] = ` exports[`renders ./components/result/demo/500.md correctly 1`] = `
-
500
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
500
Sorry, the server is wrong.
diff --git a/components/result/index.jsx b/components/result/index.jsx index 5c75e27e8..b53f0072c 100644 --- a/components/result/index.jsx +++ b/components/result/index.jsx @@ -3,9 +3,9 @@ import { getOptionProps, getComponentFromProp } from '../_util/props-util'; import { ConfigConsumerProps } from '../config-provider'; import Icon from '../icon'; import Base from '../base'; -import noFound from './noFound.svg'; -import serverError from './serverError.svg'; -import unauthorized from './unauthorized.svg'; +import noFound from './noFound'; +import serverError from './serverError'; +import unauthorized from './unauthorized'; export const IconMap = { success: 'check-circle', @@ -34,10 +34,10 @@ export const ResultProps = { const renderIcon = (h, prefixCls, { status, icon }) => { if (ExceptionStatus.includes(status)) { - const svgImg = ExceptionMap[status]; + const SVGComponent = ExceptionMap[status]; return (
- {status} +
); } @@ -60,7 +60,7 @@ const Result = { prefixCls: customizePrefixCls, status, ...restProps - } = getOptionProps(this); + } = this; const getPrefixCls = this.configProvider.getPrefixCls; const prefixCls = getPrefixCls('result', customizePrefixCls); diff --git a/components/result/noFound.jsx b/components/result/noFound.jsx new file mode 100644 index 000000000..9f352ed89 --- /dev/null +++ b/components/result/noFound.jsx @@ -0,0 +1,289 @@ +const NoFound = { + functional: true, + render() { + return( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); + }, +}; + +export default NoFound; diff --git a/components/result/noFound.svg b/components/result/noFound.svg deleted file mode 100644 index 5246a5cdf..000000000 --- a/components/result/noFound.svg +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/result/serverError.jsx b/components/result/serverError.jsx new file mode 100644 index 000000000..986d03372 --- /dev/null +++ b/components/result/serverError.jsx @@ -0,0 +1,334 @@ +const ServerError = { + functional: true, + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); + }, +}; + +export default ServerError; diff --git a/components/result/serverError.svg b/components/result/serverError.svg deleted file mode 100644 index a8e933bb9..000000000 --- a/components/result/serverError.svg +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/result/unauthorized.jsx b/components/result/unauthorized.jsx new file mode 100644 index 000000000..9fd2f4ac5 --- /dev/null +++ b/components/result/unauthorized.jsx @@ -0,0 +1,283 @@ +const Unauthorized = { + functional: true, + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); + }, +}; + +export default Unauthorized; diff --git a/components/result/unauthorized.svg b/components/result/unauthorized.svg deleted file mode 100644 index e3974c977..000000000 --- a/components/result/unauthorized.svg +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -