├── .eslintignore ├── .eslintrc.json ├── .github └── workflows │ └── node.js.yml ├── .gitignore ├── .prettierrc ├── Dockerfile ├── LICENSE ├── README.md ├── craco.config.js ├── package.json ├── public ├── favicon.ico └── index.html ├── src ├── components │ ├── Button │ │ └── index.tsx │ ├── EventTracker │ │ └── index.tsx │ ├── Header │ │ ├── index.module.scss │ │ └── index.tsx │ └── Icon │ │ └── index.tsx ├── constants │ └── api │ │ ├── content_type.ts │ │ └── index.ts ├── hooks.ts ├── iconfont │ ├── iconfont.css │ ├── iconfont.ttf │ ├── iconfont.woff │ └── iconfont.woff2 ├── images │ ├── ball-left.png │ ├── ball-right.png │ ├── corn1.png │ ├── corn2.png │ ├── corn3.png │ ├── footer.png │ ├── logo-text-dark.png │ ├── logo-text-light.png │ ├── logo.svg │ ├── start-bg.png │ ├── start-box.png │ ├── task-result-en.png │ ├── task-result.png │ ├── task1.png │ ├── task2.png │ ├── task3.png │ ├── task4-result-en.png │ ├── task4-result.png │ └── task4.png ├── index.scss ├── index.tsx ├── interfaces │ └── index.d.ts ├── layout │ └── BasicLayout.tsx ├── locales │ ├── en-US.json │ ├── intl.tsx │ └── zh-CN.json ├── pages │ └── home │ │ ├── index.module.scss │ │ └── index.tsx ├── react-app-env.d.ts ├── router │ ├── index.tsx │ └── routes.ts ├── semantic-ui │ ├── site │ │ ├── collections │ │ │ ├── breadcrumb.overrides │ │ │ ├── breadcrumb.variables │ │ │ ├── form.overrides │ │ │ ├── form.variables │ │ │ ├── grid.overrides │ │ │ ├── grid.variables │ │ │ ├── menu.overrides │ │ │ ├── menu.variables │ │ │ ├── message.overrides │ │ │ ├── message.variables │ │ │ ├── table.overrides │ │ │ └── table.variables │ │ ├── elements │ │ │ ├── button.overrides │ │ │ ├── button.variables │ │ │ ├── container.overrides │ │ │ ├── container.variables │ │ │ ├── divider.overrides │ │ │ ├── divider.variables │ │ │ ├── flag.overrides │ │ │ ├── flag.variables │ │ │ ├── header.overrides │ │ │ ├── header.variables │ │ │ ├── icon.overrides │ │ │ ├── icon.variables │ │ │ ├── image.overrides │ │ │ ├── image.variables │ │ │ ├── input.overrides │ │ │ ├── input.variables │ │ │ ├── label.overrides │ │ │ ├── label.variables │ │ │ ├── list.overrides │ │ │ ├── list.variables │ │ │ ├── loader.overrides │ │ │ ├── loader.variables │ │ │ ├── rail.overrides │ │ │ ├── rail.variables │ │ │ ├── reveal.overrides │ │ │ ├── reveal.variables │ │ │ ├── segment.overrides │ │ │ ├── segment.variables │ │ │ ├── step.overrides │ │ │ └── step.variables │ │ ├── globals │ │ │ ├── reset.overrides │ │ │ ├── reset.variables │ │ │ ├── site.overrides │ │ │ └── site.variables │ │ ├── modules │ │ │ ├── accordion.overrides │ │ │ ├── accordion.variables │ │ │ ├── chatroom.overrides │ │ │ ├── chatroom.variables │ │ │ ├── checkbox.overrides │ │ │ ├── checkbox.variables │ │ │ ├── dimmer.overrides │ │ │ ├── dimmer.variables │ │ │ ├── dropdown.overrides │ │ │ ├── dropdown.variables │ │ │ ├── embed.overrides │ │ │ ├── embed.variables │ │ │ ├── modal.overrides │ │ │ ├── modal.variables │ │ │ ├── nag.overrides │ │ │ ├── nag.variables │ │ │ ├── popup.overrides │ │ │ ├── popup.variables │ │ │ ├── progress.overrides │ │ │ ├── progress.variables │ │ │ ├── rating.overrides │ │ │ ├── rating.variables │ │ │ ├── search.overrides │ │ │ ├── search.variables │ │ │ ├── shape.overrides │ │ │ ├── shape.variables │ │ │ ├── sidebar.overrides │ │ │ ├── sidebar.variables │ │ │ ├── sticky.overrides │ │ │ ├── sticky.variables │ │ │ ├── tab.overrides │ │ │ ├── tab.variables │ │ │ ├── transition.overrides │ │ │ └── transition.variables │ │ └── views │ │ │ ├── ad.overrides │ │ │ ├── ad.variables │ │ │ ├── card.overrides │ │ │ ├── card.variables │ │ │ ├── comment.overrides │ │ │ ├── comment.variables │ │ │ ├── feed.overrides │ │ │ ├── feed.variables │ │ │ ├── item.overrides │ │ │ ├── item.variables │ │ │ ├── statistic.overrides │ │ │ └── statistic.variables │ └── theme.config ├── services │ └── index.ts ├── setupProxy.ts └── utils │ ├── hooks.ts │ ├── request.ts │ └── track.ts ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env":{ 3 | "browser":true, 4 | "es2021":true 5 | }, 6 | "extends":[ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/recommended", 9 | "prettier" 10 | ], 11 | "parser":"@typescript-eslint/parser", 12 | "parserOptions":{ 13 | "ecmaVersion":"latest", 14 | "sourceType":"module" 15 | }, 16 | "plugins":[ 17 | "@typescript-eslint", 18 | "check-file", 19 | "import" 20 | ], 21 | "rules":{ 22 | // ESM imports need extensions, but TS doesn't re-write them. 23 | // this forces us to add `.js` to all imports, which makes sure our ESM modules work. 24 | "linebreak-style":[ 25 | "warn", 26 | "unix" 27 | ], 28 | "quotes":[ 29 | "error", 30 | "single" 31 | ], 32 | "semi":[ 33 | "error", 34 | "always" 35 | ], 36 | "check-file/filename-naming-convention":[ 37 | "warn", 38 | { 39 | "**/*.{js,ts}":"KEBAB_CASE" 40 | }, 41 | { 42 | "ignoreMiddleExtensions": true 43 | } 44 | ], 45 | "@typescript-eslint/ban-ts-ignore": "off" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ "main" ] 9 | pull_request: 10 | branches: [ "main" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | node-version: [16.x] 20 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 21 | 22 | steps: 23 | - uses: actions/checkout@v3 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v3 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | - run: yarn install --frozen-lockfile 29 | - run: yarn build 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | dist 4 | package-lock.json 5 | yarn-error.log 6 | .vscode 7 | build/ 8 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "printWidth": 120 4 | } 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16.13.1 as build 2 | WORKDIR /app 3 | COPY package.json ./ 4 | COPY yarn.lock ./ 5 | RUN yarn 6 | COPY . ./ 7 | RUN yarn build 8 | 9 | FROM nginx 10 | COPY --from=build /app/build /usr/share/nginx/html 11 | EXPOSE 8081 12 | 13 | CMD ["nginx", "-g", "daemon off;"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # feature-probe-demo-ui 2 | 3 | This demo page supports users to directly experience the core features of FeatureProbe without setting up a docker environment. 4 | 5 | ## Getting Started 6 | 7 | ### Installation 8 | 9 | ``` 10 | yarn 11 | ``` 12 | 13 | ### Local Development 14 | 15 | ``` 16 | yarn start 17 | ``` 18 | 19 | This command starts a local development server and opens up a browser window. 20 | 21 | ### Build 22 | 23 | ``` 24 | $ yarn build 25 | ``` 26 | 27 | ## Contributing 28 | We are working on continue evolving FeatureProbe core, making it flexible and easier to use. 29 | Development of FeatureProbe happens in the open on GitHub, and we are grateful to the 30 | community for contributing bugfixes and improvements. 31 | 32 | Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md) 33 | for details on our code of conduct, and the process for taking part in improving FeatureProbe. 34 | 35 | 36 | ## License 37 | 38 | This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details. 39 | -------------------------------------------------------------------------------- /craco.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [{ plugin: require('@semantic-ui-react/craco-less') }], 3 | webpack: { 4 | configure: (webpackConfig, { env, paths }) => { 5 | webpackConfig.output = { 6 | ...webpackConfig.output, 7 | publicPath: '/demo/' 8 | } 9 | return webpackConfig 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "feature-probe-demo-ui", 3 | "version": "1.0.1", 4 | "description": "FeatureProbe Demo UI", 5 | "license": "Apache-2.0", 6 | "keywords": [ 7 | "FeatureProbe", 8 | "demo" 9 | ], 10 | "repository": { 11 | "type": "git", 12 | "url": "git@github.com:FeatureProbe/feature-probe-demo-ui.git" 13 | }, 14 | "engines": { 15 | "node": "16.x" 16 | }, 17 | "dependencies": { 18 | "classnames": "^2.3.1", 19 | "dayjs": "^1.11.4", 20 | "featureprobe-client-sdk-js": "^2.1.1", 21 | "jsonlint-mod": "^1.7.6", 22 | "less-loader": "^7.3.0", 23 | "node-sass": "^7.0.1", 24 | "react": "^17.0.0", 25 | "react-dom": "^17.0.0", 26 | "react-ga4": "^1.4.1", 27 | "react-hook-form": "^7.34.0", 28 | "react-intl": "^5.25.1", 29 | "react-router-dom": "^5.3.0", 30 | "sass-loader": "^13.0.0", 31 | "semantic-ui-less": "^2.4.1", 32 | "semantic-ui-react": "^2.1.2", 33 | "typescript": "^4.4.2", 34 | "unstated-next": "^1.1.0" 35 | }, 36 | "scripts": { 37 | "start": "semantic-ui-css-patch && craco start", 38 | "build": "semantic-ui-css-patch && craco build", 39 | "test": "craco test", 40 | "eject": "craco eject" 41 | }, 42 | "eslintConfig": { 43 | "extends": [ 44 | "react-app", 45 | "react-app/jest" 46 | ] 47 | }, 48 | "browserslist": { 49 | "production": [ 50 | ">0.2%", 51 | "not dead", 52 | "not op_mini all" 53 | ], 54 | "development": [ 55 | "last 1 chrome version", 56 | "last 1 firefox version", 57 | "last 1 safari version" 58 | ] 59 | }, 60 | "devDependencies": { 61 | "@craco/craco": "^5.9.0", 62 | "@semantic-ui-react/craco-less": "^2.0.2", 63 | "@semantic-ui-react/css-patch": "^1.0.0", 64 | "@types/dom-inputevent": "^1.0.7", 65 | "@types/jest": "^27.0.1", 66 | "@types/node": "^16.7.13", 67 | "@types/qs": "^6.9.7", 68 | "@types/react": "^17.0.43", 69 | "@types/react-dom": "^17.0.9", 70 | "@types/react-router-dom": "^5.3.3", 71 | "eslint": "^8.20.0", 72 | "eslint-config-prettier": "^8.5.0", 73 | "eslint-plugin-check-file": "^1.2.2", 74 | "eslint-plugin-import": "^2.26.0", 75 | "http-proxy-middleware": "^2.0.6", 76 | "prettier": "^2.7.1", 77 | "react-scripts": "^5.0.1", 78 | "webpack": "^5.76.0" 79 | }, 80 | "resolutions": { 81 | "@types/react": "17.0.43" 82 | }, 83 | "proxy": "https://featureprobe.io" 84 | } 85 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | FeatureProbe demo 13 | 14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /src/components/Button/index.tsx: -------------------------------------------------------------------------------- 1 | import { useRef, MouseEvent, useCallback } from 'react'; 2 | import { Button, ButtonProps } from 'semantic-ui-react'; 3 | 4 | const CustomButton = ({children, ...props}: ButtonProps) => { 5 | const { onClick } = props; 6 | const buttonRef = useRef(null); 7 | 8 | const handleOnClick = useCallback((e: MouseEvent, {...props}) => { 9 | // // @ts-ignore 10 | // buttonRef.current.ref?.current.blur(); 11 | 12 | if (onClick) { 13 | onClick(e, props); 14 | } 15 | }, [onClick]); 16 | 17 | return ( 18 | 21 | ); 22 | }; 23 | 24 | export default CustomButton; -------------------------------------------------------------------------------- /src/components/EventTracker/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { SyntheticEvent, ReactElement } from 'react'; 2 | import { EventTrack } from 'utils/track'; 3 | 4 | interface IProps { 5 | category: string; 6 | action: string; 7 | children: ReactElement; 8 | } 9 | 10 | const EventTracker = (props: IProps) => { 11 | const { category, action, children } = props; 12 | const onClick = (e: SyntheticEvent) => { 13 | EventTrack.track(category, action); 14 | 15 | if (typeof children.props.onClick === 'function') { 16 | children.props.onClick(e); 17 | } 18 | }; 19 | 20 | const onlychildren = React.Children.only(children); 21 | 22 | return React.cloneElement( 23 | onlychildren, 24 | { 25 | ...props, 26 | onClick: onClick, 27 | }, 28 | children.props.children 29 | ); 30 | }; 31 | 32 | export default EventTracker; 33 | -------------------------------------------------------------------------------- /src/components/Header/index.module.scss: -------------------------------------------------------------------------------- 1 | .container { 2 | position: sticky; 3 | position: -webkit-sticky; 4 | top: 0; 5 | z-index: 100; 6 | background: rgba(235, 81, 87, 0.8); 7 | box-shadow: none; 8 | color: #ffffff; 9 | } 10 | 11 | .container-scroll { 12 | background: #ffffff; 13 | color: rgba(0, 0, 0, 0.84); 14 | box-shadow: 0 2px 4px 0 rgba(0,0,0,0.01), 0 3px 6px 3px rgba(0,0,0,0.01), 0 2px 6px 0 rgba(0,0,0,0.03); 15 | } 16 | 17 | .header { 18 | height: 98px; 19 | font-size: 16px; 20 | max-width: 1200px; 21 | padding: 36px 20px 0; 22 | margin: 0 auto; 23 | display: flex; 24 | justify-content: space-between; 25 | } 26 | 27 | .logo { 28 | margin-right: 134px; 29 | } 30 | 31 | .logo-image { 32 | width: 158px; 33 | margin-top: 13px; 34 | } 35 | 36 | .navs { 37 | flex: 1; 38 | display: block; 39 | height: 48px; 40 | line-height: 48px; 41 | } 42 | 43 | .btns { 44 | display: none; 45 | } 46 | 47 | .nav-item { 48 | font-family: PingFangSC-Medium; 49 | margin-right: 60px; 50 | cursor: pointer; 51 | } 52 | 53 | .btn-login { 54 | font-family: PingFangSC-Medium; 55 | font-size: 16px; 56 | color: #000000; 57 | margin-right: 24px; 58 | display: inline-block; 59 | vertical-align: middle; 60 | line-height: 40px; 61 | cursor: pointer; 62 | } 63 | 64 | .btn-register { 65 | width: 100px; 66 | height: 40px !important; 67 | font-size: 16px !important; 68 | font-family: PingFangSC-Medium !important; 69 | border-radius: 8px !important; 70 | cursor: pointer; 71 | } 72 | 73 | .icon { 74 | font-size: 24px !important; 75 | vertical-align: middle; 76 | cursor: pointer; 77 | } 78 | 79 | .menu-btn { 80 | display: none; 81 | } 82 | 83 | .menu-item { 84 | font-size: 17px; 85 | color: rgba(0, 0, 0, 0.84); 86 | line-height: 60px; 87 | margin-left: 16px; 88 | border-bottom: 1px solid #eee; 89 | cursor: pointer; 90 | } 91 | 92 | .menu-item:last-child { 93 | border-bottom: none; 94 | } 95 | 96 | .menus { 97 | display: none; 98 | } 99 | 100 | .popup { 101 | padding: 4px 0 !important; 102 | margin-top: 0 !important; 103 | } 104 | 105 | .language-popup { 106 | cursor: pointer; 107 | margin-right: 10px; 108 | line-height: 48px; 109 | } 110 | 111 | .dropdown-menu { 112 | min-width: 120px; 113 | color: #212529; 114 | } 115 | 116 | .dropdown-menu-item { 117 | height: 28px; 118 | line-height: 28px; 119 | cursor: pointer; 120 | font-size: 12px; 121 | padding: 0 12px; 122 | } 123 | 124 | .dropdown-menu-item:hover { 125 | background-color: #F8F9FA; 126 | } 127 | 128 | @media (max-width: 1100px) { 129 | .container { 130 | opacity: 1; 131 | } 132 | 133 | .header { 134 | height: 60px; 135 | padding: 0 20px; 136 | } 137 | 138 | .logo { 139 | flex: 1; 140 | margin-right: 0; 141 | padding-top: 15px; 142 | } 143 | 144 | .logo-image { 145 | margin-top: 7px; 146 | } 147 | 148 | .navs { 149 | display: none; 150 | } 151 | 152 | .btns { 153 | display: none; 154 | } 155 | 156 | .menu-btn { 157 | display: block; 158 | line-height: 60px; 159 | } 160 | 161 | .menus { 162 | position: fixed; 163 | top: 60px; 164 | left: 0; 165 | bottom: 0; 166 | right: 0; 167 | background-color: #ffffff; 168 | display: block; 169 | } 170 | 171 | .language-popup { 172 | line-height: 60px; 173 | } 174 | } -------------------------------------------------------------------------------- /src/components/Header/index.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useState, useEffect, SyntheticEvent } from 'react'; 2 | import { FormattedMessage } from 'react-intl'; 3 | import { useHistory } from 'react-router-dom'; 4 | import { Popup } from 'semantic-ui-react'; 5 | import classNames from 'classnames'; 6 | import Icon from 'components/Icon'; 7 | import { I18NContainer } from 'hooks'; 8 | import styles from './index.module.scss'; 9 | 10 | interface IProps { 11 | isScroll?: boolean 12 | isLogin: boolean; 13 | } 14 | 15 | const Header = (props: IProps) => { 16 | const { isScroll, isLogin } = props; 17 | const [ showMenus, setShowMenus ] = useState(false); 18 | const [ i18nMenuOpen, setI18nMenuOpen ] = useState(false); 19 | const history = useHistory(); 20 | const { i18n, setI18n } = I18NContainer.useContainer(); 21 | 22 | useEffect(() => { 23 | const handler = () => { 24 | if (i18nMenuOpen) { 25 | setI18nMenuOpen(false); 26 | } 27 | }; 28 | window.addEventListener('click', handler); 29 | return () => window.removeEventListener('click', handler); 30 | }, [i18nMenuOpen]); 31 | 32 | const gotoStart = useCallback(() => { 33 | window.scrollTo(0, 0); 34 | setShowMenus(false); 35 | }, [history]); 36 | 37 | const gotoFirstTask = useCallback(() => { 38 | const firstTask = document.getElementById('firstTask')?.offsetTop || 0; 39 | const header = document.getElementById('header')?.clientHeight || 0; 40 | setTimeout(() => { 41 | window.scrollTo(0, firstTask - header); 42 | }, 400); 43 | }, [history]); 44 | 45 | const gotoSecondtTask = useCallback(() => { 46 | const firstTask = document.getElementById('secondTask')?.offsetTop || 0; 47 | const header = document.getElementById('header')?.clientHeight || 0; 48 | setTimeout(() => { 49 | window.scrollTo(0, firstTask - header); 50 | }, 400); 51 | }, [history]); 52 | 53 | const gotoThirdTask = useCallback(() => { 54 | const firstTask = document.getElementById('thirdTask')?.offsetTop || 0; 55 | const header = document.getElementById('header')?.clientHeight || 0; 56 | setTimeout(() => { 57 | window.scrollTo(0, firstTask - header); 58 | }, 400); 59 | }, [history]); 60 | 61 | const gotoFourthTask = useCallback(() => { 62 | const firstTask = document.getElementById('fourthTask')?.offsetTop || 0; 63 | const header = document.getElementById('header')?.clientHeight || 0; 64 | setTimeout(() => { 65 | window.scrollTo(0, firstTask - header); 66 | }, 400); 67 | }, [history]); 68 | 69 | const cls = classNames(styles.container, { 70 | [styles['container-scroll']]: isScroll 71 | }); 72 | 73 | return ( 74 |
75 | 123 | } 124 | > 125 |
{ setI18nMenuOpen(false); }}> 126 |
{ setI18n('en-US'); }}> 127 | English 128 |
129 |
{ setI18n('zh-CN'); }}> 130 | 中文 131 |
132 |
133 | 134 |
{ setShowMenus(!showMenus); }}> 135 | { showMenus ? : } 136 |
137 | { 138 | showMenus && ( 139 |
140 |
{ 141 | gotoStart(); 142 | setShowMenus(false); 143 | }}> 144 | 145 |
146 |
{ 147 | gotoFirstTask(); 148 | setShowMenus(false); 149 | }}> 150 | 151 |
152 |
{ 153 | gotoSecondtTask(); 154 | setShowMenus(false); 155 | }}> 156 | 157 |
158 |
{ 159 | gotoThirdTask(); 160 | setShowMenus(false); 161 | }}> 162 | 163 |
164 |
{ 165 | gotoFourthTask(); 166 | setShowMenus(false); 167 | }}> 168 | 169 |
170 |
171 | ) 172 | } 173 |
174 | 175 | ); 176 | }; 177 | 178 | export default Header; -------------------------------------------------------------------------------- /src/components/Icon/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | interface IProps extends React.HTMLProps { 4 | type: string; 5 | customClass?: string; 6 | } 7 | 8 | const Icon = (props: IProps) => { 9 | const { type, customClass } = props; 10 | 11 | return ( 12 | 13 | ); 14 | }; 15 | 16 | export default Icon; -------------------------------------------------------------------------------- /src/constants/api/content_type.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line check-file/filename-naming-convention 2 | export const ApplicationJson = () => { 3 | return { 4 | 'Content-Type': 'application/json', 5 | 'Accept-Language': localStorage.getItem('i18n')?.replaceAll('"', '') || 'en-US', 6 | Authorization: 'Bearer ' + localStorage.getItem('token'), 7 | 'X-OrganizeID': localStorage.getItem('organizeId') || '', 8 | }; 9 | }; -------------------------------------------------------------------------------- /src/constants/api/index.ts: -------------------------------------------------------------------------------- 1 | const origin = '/api'; 2 | 3 | const APIS = { 4 | getProjectListURI: `${origin}/projects`, 5 | loginURI: `${origin}/guestLogin`, 6 | }; 7 | 8 | export default APIS; 9 | -------------------------------------------------------------------------------- /src/hooks.ts: -------------------------------------------------------------------------------- 1 | import { createContainer } from 'unstated-next'; 2 | import { useLocalStorage } from 'utils/hooks'; 3 | 4 | export const useI18N = () => { 5 | const [ i18n, setI18n ] = useLocalStorage('i18n', 'en-US'); 6 | 7 | return { 8 | i18n, 9 | setI18n, 10 | }; 11 | }; 12 | 13 | export const I18NContainer = createContainer(useI18N); 14 | -------------------------------------------------------------------------------- /src/iconfont/iconfont.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "iconfont"; /* Project id 3325204 */ 3 | src: url('iconfont.woff2?t=1667467360013') format('woff2'), 4 | url('iconfont.woff?t=1667467360013') format('woff'), 5 | url('iconfont.ttf?t=1667467360013') format('truetype'); 6 | } 7 | 8 | .iconfont { 9 | font-family: "iconfont" !important; 10 | font-size: 16px; 11 | font-style: normal; 12 | -webkit-font-smoothing: antialiased; 13 | -moz-osx-font-smoothing: grayscale; 14 | } 15 | 16 | .icon-enable:before { 17 | content: "\e77e"; 18 | } 19 | 20 | .icon-user:before { 21 | content: "\e77f"; 22 | } 23 | 24 | .icon-percentage:before { 25 | content: "\e780"; 26 | } 27 | 28 | .icon-group:before { 29 | content: "\e781"; 30 | } 31 | 32 | .icon-timeout:before { 33 | content: "\e77d"; 34 | } 35 | 36 | .icon-service:before { 37 | content: "\e77b"; 38 | } 39 | 40 | .icon-lock:before { 41 | content: "\e77a"; 42 | } 43 | 44 | .icon-toggle:before { 45 | content: "\e779"; 46 | } 47 | 48 | .icon-reject:before { 49 | content: "\e775"; 50 | } 51 | 52 | .icon-pending:before { 53 | content: "\e776"; 54 | } 55 | 56 | .icon-wait:before { 57 | content: "\e777"; 58 | } 59 | 60 | .icon-withdraw:before { 61 | content: "\e778"; 62 | } 63 | 64 | .icon-connect-sdk:before { 65 | content: "\e773"; 66 | } 67 | 68 | .icon-setting:before { 69 | content: "\e774"; 70 | } 71 | 72 | .icon-filter:before { 73 | content: "\e772"; 74 | } 75 | 76 | .icon-info:before { 77 | content: "\e771"; 78 | } 79 | 80 | .icon-back:before { 81 | content: "\e770"; 82 | } 83 | 84 | .icon-menu:before { 85 | content: "\e76a"; 86 | } 87 | 88 | .icon-email:before { 89 | content: "\e766"; 90 | } 91 | 92 | .icon-check-circle:before { 93 | content: "\e764"; 94 | } 95 | 96 | .icon-edit:before { 97 | content: "\e75f"; 98 | } 99 | 100 | .icon-view:before { 101 | content: "\e75e"; 102 | } 103 | 104 | .icon-search:before { 105 | content: "\e753"; 106 | } 107 | 108 | .icon-put-up:before { 109 | content: "\e752"; 110 | } 111 | 112 | .icon-put-away:before { 113 | content: "\e751"; 114 | } 115 | 116 | .icon-password:before { 117 | content: "\e750"; 118 | } 119 | 120 | .icon-reduce:before { 121 | content: "\e74f"; 122 | } 123 | 124 | .icon-more:before { 125 | content: "\e74e"; 126 | } 127 | 128 | .icon-angle-down:before { 129 | content: "\e74d"; 130 | } 131 | 132 | .icon-angle-left:before { 133 | content: "\e74b"; 134 | } 135 | 136 | .icon-angle-up:before { 137 | content: "\e74c"; 138 | } 139 | 140 | .icon-angle-right:before { 141 | content: "\e74a"; 142 | } 143 | 144 | .icon-avatar:before { 145 | content: "\e749"; 146 | } 147 | 148 | .icon-english:before { 149 | content: "\e747"; 150 | } 151 | 152 | .icon-info-circle:before { 153 | content: "\e743"; 154 | } 155 | 156 | .icon-warning-circle:before { 157 | content: "\e744"; 158 | } 159 | 160 | .icon-error-circle:before { 161 | content: "\e745"; 162 | } 163 | 164 | .icon-success-circle:before { 165 | content: "\e746"; 166 | } 167 | 168 | .icon-remove-circle:before { 169 | content: "\e742"; 170 | } 171 | 172 | .icon-code:before { 173 | content: "\e741"; 174 | } 175 | 176 | .icon-add:before { 177 | content: "\e740"; 178 | } 179 | 180 | .icon-close:before { 181 | content: "\e73f"; 182 | } 183 | 184 | .icon-check:before { 185 | content: "\e73d"; 186 | } 187 | 188 | .icon-question:before { 189 | content: "\e73c"; 190 | } 191 | 192 | .icon-archive:before { 193 | content: "\e73a"; 194 | } 195 | 196 | .icon-drag:before { 197 | content: "\e73b"; 198 | } 199 | 200 | .icon-minus:before { 201 | content: "\e739"; 202 | } 203 | 204 | .icon-evaluate:before { 205 | content: "\e738"; 206 | } 207 | 208 | .icon-member:before { 209 | content: "\e737"; 210 | } 211 | 212 | .icon-attribute:before { 213 | content: "\e735"; 214 | } 215 | 216 | .icon-switch:before { 217 | content: "\e733"; 218 | } 219 | 220 | .icon-debugger:before { 221 | content: "\e734"; 222 | } 223 | 224 | -------------------------------------------------------------------------------- /src/iconfont/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/iconfont/iconfont.ttf -------------------------------------------------------------------------------- /src/iconfont/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/iconfont/iconfont.woff -------------------------------------------------------------------------------- /src/iconfont/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/iconfont/iconfont.woff2 -------------------------------------------------------------------------------- /src/images/ball-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/ball-left.png -------------------------------------------------------------------------------- /src/images/ball-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/ball-right.png -------------------------------------------------------------------------------- /src/images/corn1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/corn1.png -------------------------------------------------------------------------------- /src/images/corn2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/corn2.png -------------------------------------------------------------------------------- /src/images/corn3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/corn3.png -------------------------------------------------------------------------------- /src/images/footer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/footer.png -------------------------------------------------------------------------------- /src/images/logo-text-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/logo-text-dark.png -------------------------------------------------------------------------------- /src/images/logo-text-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/logo-text-light.png -------------------------------------------------------------------------------- /src/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 编组 22 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/images/start-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/start-bg.png -------------------------------------------------------------------------------- /src/images/start-box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/start-box.png -------------------------------------------------------------------------------- /src/images/task-result-en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task-result-en.png -------------------------------------------------------------------------------- /src/images/task-result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task-result.png -------------------------------------------------------------------------------- /src/images/task1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task1.png -------------------------------------------------------------------------------- /src/images/task2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task2.png -------------------------------------------------------------------------------- /src/images/task3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task3.png -------------------------------------------------------------------------------- /src/images/task4-result-en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task4-result-en.png -------------------------------------------------------------------------------- /src/images/task4-result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task4-result.png -------------------------------------------------------------------------------- /src/images/task4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/images/task4.png -------------------------------------------------------------------------------- /src/index.scss: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: 'Helvetica Neue', Helvetica, Arial, 'PingFang SC', 'Heiti SC', 'Hiragino Sans GB', 'Microsoft YaHei', sanf-serif; 4 | -webkit-font-smoothing: antialiased; 5 | -moz-osx-font-smoothing: grayscale; 6 | } 7 | 8 | code { 9 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 10 | monospace; 11 | } 12 | 13 | html { 14 | scroll-behavior: smooth; 15 | } -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import Router from './router'; 4 | import { I18NContainer } from './hooks'; 5 | import Intl from './locales/intl'; 6 | import 'iconfont/iconfont.css'; 7 | import 'semantic-ui-less/semantic.less'; 8 | import 'dayjs/locale/zh-cn'; 9 | 10 | import './index.scss'; 11 | 12 | ReactDOM.render( 13 | 14 | 15 | 16 | 17 | 18 | 19 | , 20 | document.getElementById('root') 21 | ); 22 | -------------------------------------------------------------------------------- /src/interfaces/index.d.ts: -------------------------------------------------------------------------------- 1 | export interface IEnvironment { 2 | name: string; 3 | key: string; 4 | clientSdkKey: string; 5 | serverSdkKey: string; 6 | } 7 | 8 | export interface IProject { 9 | name: string; 10 | key: string; 11 | description: string; 12 | environments: IEnvironment[]; 13 | } -------------------------------------------------------------------------------- /src/layout/BasicLayout.tsx: -------------------------------------------------------------------------------- 1 | import { ReactElement } from 'react'; 2 | 3 | interface IProps { 4 | children: ReactElement 5 | } 6 | 7 | const BasicLayout = (props: IProps) => { 8 | return ( 9 |
10 | { props.children } 11 |
12 | ); 13 | }; 14 | 15 | export default BasicLayout; -------------------------------------------------------------------------------- /src/locales/en-US.json: -------------------------------------------------------------------------------- 1 | { 2 | "header.start": "Home", 3 | "header.status": "Enabled/disabled", 4 | "header.user": "For user", 5 | "header.percentage": "Percentage", 6 | "header.variation": "Variations", 7 | 8 | "demo.title": "Interactive experience", 9 | "demo.description": "Here is a SPA(Single Page Application). It updates its UI according to the toggle status configured on FeatureProbe platform. Click the link below to open FeatureProbe platform and follow the steps to run the demo.", 10 | "demo.userid": "Your userId is 00003", 11 | "demo.start.login.description": "Click the link below to open FeatureProbe platform and follow the steps to run the demo.", 12 | "demo.start.unlogin.description": "Here is a SPA(Single Page Application). It updates its UI according to the toggle status configured on FeatureProbe platform. Click 'Try Now' to experience~ 🎉", 13 | "demo.try.btn": "Try Now", 14 | "demo.welcome": "Welcome! {account}", 15 | 16 | "demo.task1.title": "Task 1: enable/disable a feature toggle.", 17 | "demo.task1.description": "We have launched a marketing promotion campaign. The basic use case is inviting all end users or not letting them know the campaign by toggling the toggle between “enable” and ”disable” status.", 18 | "demo.task1.task.left": "You will find the “", 19 | "demo.task1.task.right": "” toggle and “enable” it so that all end users will see the marketing campaign.", 20 | "demo.task1.status.on": "The entry page of the campaign is: ", 21 | "demo.task1.status.off": "Not showing the campaign entry page.", 22 | 23 | "demo.task2.title": "Task 2: enable a toggle for a group of specified users.", 24 | "demo.task2.description": "We have launched a marketing promotion campaign. We are going to invite some “internal users” in the first place and let them give it a try. If it goes smoothly, we will extend the invitation to the rest users.", 25 | "demo.task2.task.left": "You will find the “", 26 | "demo.task2.task.right": "” toggle first. Since you are one of the “internal users”, you will want to add your userId into the custom rules so that you will be invited to the marketing campaign. Remember that your userId is 00003.", 27 | "demo.task2.status.on": "The entry page of the campaign shown to userId 00003 is: ", 28 | "demo.task2.status.off": "Not showing the campaign entry page to userId 00003.", 29 | 30 | "demo.task3.title": "Task 3: enable a toggle to users by percentage.", 31 | "demo.task3.description": "To mitigate the risks, we will allow a proportional of end users to join the newly launched market campaign.", 32 | "demo.task3.task.left": "You will find the “", 33 | "demo.task3.task.right": "” toggle and modify the percentage setting. The current setting is 40% and it allow as many as 40% of total users to join. But you cannot see the campaign entry page because you are not one of the 40% users. Try to increase the percentage until you can see the entry page.", 34 | "demo.task3.status.on": "The entry page of the campaign shown to userId 00003 is: ", 35 | "demo.task3.status.off": "Not showing the campaign entry page to userId 00003.", 36 | 37 | "demo.task4.title": "Task 4: customize groups.", 38 | "demo.task4.description": "We decide to show different price tags to different users of a specific product which will be put on the rack shortly. It is not ideal to give a special discount to some users based on a true/false toggle, and we need more options. In FeatureProbe, you can customize pricing groups and specify toggles to each group to achieve rich settings.", 39 | "demo.task4.task.left": "You will find the “", 40 | "demo.task4.task.right": "” toggle and add a new pricing group. Set the group's name and value as “30” respectively. Select your userId(here is 00003) and set the return value as the newly added group 30.", 41 | "demo.task4.status": "The pricing format shown to userId 00003 is: $", 42 | 43 | "demo.ready": "You are now in the「feature」delivery new era.", 44 | 45 | "login.demo.text": "Access FeatureProbe demo instance", 46 | "login.demo.tip": "No further data required", 47 | "login.email.text": "Email", 48 | "login.email.placeholder.text": "Please input email address", 49 | "login.email.invalid.text": "Invalid email address", 50 | "login.signin": "Sign in", 51 | "login.error.message": "Login error, please retry!", 52 | "login.demo.password.tip": "The quick trial environment provides password free login, and the open source version supports password customization", 53 | 54 | "qrcode.title": "Scan WeChat QR code" 55 | } -------------------------------------------------------------------------------- /src/locales/intl.tsx: -------------------------------------------------------------------------------- 1 | import { ReactElement } from 'react'; 2 | import { IntlProvider } from 'react-intl'; 3 | import { I18NContainer } from 'hooks'; 4 | import dayjs from 'dayjs'; 5 | import zh_CN from './zh-CN.json'; 6 | import en_US from './en-US.json'; 7 | 8 | interface IProps { 9 | children: ReactElement 10 | } 11 | 12 | const Intl = (props: IProps) => { 13 | const { children } = props; 14 | 15 | const { 16 | i18n, 17 | } = I18NContainer.useContainer(); 18 | 19 | const chooseLocale = (val: string) => { 20 | const _val = val || navigator.language; 21 | switch (_val) { 22 | case 'en-US': 23 | dayjs.locale('en'); 24 | return en_US; 25 | case 'zh-CN': 26 | dayjs.locale('zh-CN'); 27 | return zh_CN; 28 | default: 29 | return en_US; 30 | } 31 | }; 32 | 33 | return ( 34 | 38 | {children} 39 | 40 | ); 41 | }; 42 | 43 | export default Intl; -------------------------------------------------------------------------------- /src/locales/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "header.start": "开始", 3 | "header.status": "启用/禁用", 4 | "header.user": "特定用户", 5 | "header.percentage": "百分比放量", 6 | "header.variation": "自定义分组", 7 | 8 | "demo.title": "交互式体验", 9 | "demo.description": "这是模拟一个使用了FeatureProbe功能开关的网页应用,通过FeatureProbe上的功能开关配置可以更新本页面行为。点击下方链接,可打开对应的FeatureProbe服务,免费体验控制本网页应用:", 10 | "demo.userid": "你的 userId:00003", 11 | "demo.start.login.description": "点击下方链接,可打开对应的FeatureProbe服务,免费体验控制本网页应用:", 12 | "demo.start.unlogin.description": "这是模拟一个使用了FeatureProbe功能开关的网页应用,通过FeatureProbe上的功能开关配置可以更新本页面行为。点击立即试用去体验吧~ 🎉", 13 | "demo.try.btn": "立即试用", 14 | "demo.welcome": "欢迎你!{account}", 15 | 16 | "demo.task1.title": "任务一:启用/禁用功能开关", 17 | "demo.task1.description": "我们新上线了一个运营活动,最简单的使用方式是为所有用户开放【启用】或关闭【禁用】它。", 18 | "demo.task1.task.left": "你的任务是进入到为“", 19 | "demo.task1.task.right": "”的功能开关,并尝试【启用】它。确保运营活动入口对所有用户开放。", 20 | "demo.task1.status.on": "运营活动入口展示为: ", 21 | "demo.task1.status.off": "运营活动入口不展示", 22 | 23 | "demo.task2.title": "任务二:为特定用户开启功能开关", 24 | "demo.task2.description": "我们上线了一个运营活动,计划先给部分「内部用户」开放并进行试用,试用没问题后,再将其开放给其他用户。", 25 | "demo.task2.task.left": "你的任务是进入功能开关“", 26 | "demo.task2.task.right": "”,你作为内部用户的一员,需要将自己的userId也添加到自定义规则中,确保运营活动入口对你是开放的。你的userId为:00003 ", 27 | "demo.task2.status.on": "运营活动入口对 userId 00003 展示为:", 28 | "demo.task2.status.off": "运营活动入口对 userId 00003 不展示", 29 | 30 | "demo.task3.title": "任务三:按百分比放量", 31 | "demo.task3.description": "我们希望只为一定比例的用户,开放一个新的运营活动,从而减少一定的发布风险。", 32 | "demo.task3.task.left": "你的任务是进入功能开关“", 33 | "demo.task3.task.right": "”,并调整放量的百分比。当放量比例较低时,运营活动入口对你不可见,尝试提高放量的百分比,确保你能看到运营活动入口。", 34 | "demo.task3.status.on": "运营活动入口对 userId 00003 展示为:", 35 | "demo.task3.status.off": "运营活动入口对 userId 00003 不展示", 36 | 37 | "demo.task4.title": "任务四:增加返回值分组", 38 | "demo.task4.description": "当我们想将一款商品对不同地区用户展示不同的定价。只用2个默认分组是不够的,在FeatureProbe中,你可以为功能开关增加自定义分组。", 39 | "demo.task4.task.left": "你的任务是进入功能开关“", 40 | "demo.task4.task.right": "”,并添加一个价格分组,给分组起个名称,并将值设为“30”,把含自己userId(00003)规则的返回值选择为该分组。", 41 | "demo.task4.status": "商品价格对 userId 00003 展示为:$", 42 | 43 | "demo.ready": "进入「功能」交付的全新时代", 44 | 45 | "login.demo.text": "访问 FeatureProbe 演示实例", 46 | "login.demo.tip": "无须进一步提供其它数据", 47 | "login.email.text": "邮箱", 48 | "login.email.placeholder.text": "请输入邮箱地址", 49 | "login.email.invalid.text": "无效的邮箱地址", 50 | "login.signin": "登录", 51 | "login.error.message": "登录错误,请重试!", 52 | "login.demo.password.tip": "快速试用环境提供免密登录,开源版支持密码自定义", 53 | 54 | "qrcode.title": "请扫描微信二维码" 55 | } -------------------------------------------------------------------------------- /src/pages/home/index.module.scss: -------------------------------------------------------------------------------- 1 | .home { 2 | min-width: 375px; 3 | } 4 | 5 | .start { 6 | background: url('images/start-bg.png'); 7 | background-size: cover; 8 | background-position: center; 9 | position: relative; 10 | padding-top: 230px; 11 | margin-top: -98px; 12 | padding-bottom: 54px; 13 | } 14 | 15 | .start-h { 16 | background: url('images/start-bg.png'); 17 | background-size: cover; 18 | background-position: center; 19 | position: relative; 20 | padding-top: 230px; 21 | margin-top: -98px; 22 | padding-bottom: 154px; 23 | } 24 | 25 | .start-box { 26 | width: 985px; 27 | margin: 0 auto; 28 | padding-top: 60px; 29 | text-align: center; 30 | background-color: rgba(255, 255, 255, 0.9); 31 | border-radius: 24px; 32 | padding-bottom: 50px; 33 | } 34 | 35 | .start-box-title { 36 | font-family: PingFangSC-Semibold; 37 | font-size: 60px; 38 | color: rgba(0, 0, 0, 0.84); 39 | line-height: 70px; 40 | font-weight: 600; 41 | padding: 0 20px; 42 | } 43 | 44 | .start-title-ball-left { 45 | width: 71px; 46 | margin-right: 17px; 47 | } 48 | 49 | .start-title-ball-right { 50 | width: 32px; 51 | margin-left: 13px; 52 | } 53 | 54 | .start-box-desc { 55 | font-size: 16px; 56 | color: rgba(0,0,0,0.70); 57 | padding: 0 120px; 58 | margin-top: 32px; 59 | line-height: 26px; 60 | } 61 | 62 | .start-box-link { 63 | font-size: 24px; 64 | text-align: center; 65 | line-height: 32px; 66 | margin-top: 32px; 67 | 68 | :global { 69 | a { 70 | color: #4F6DFF; 71 | } 72 | 73 | a:hover { 74 | color: #4F6DFF; 75 | } 76 | } 77 | } 78 | 79 | .start-box-user { 80 | font-family: PingFangSC-Regular; 81 | font-size: 40px; 82 | color: rgba(0, 0, 0, 0.84); 83 | font-weight: 400; 84 | margin-top: 30px; 85 | line-height: 56px; 86 | } 87 | 88 | .start-welcome { 89 | font-family: PingFangSC-Medium; 90 | font-size: 24px; 91 | color: #282323; 92 | margin-top: 15px; 93 | display: inline-flex; 94 | align-items: center; 95 | } 96 | 97 | .line-left { 98 | display: inline-block; 99 | width: 87px; 100 | height: 2px; 101 | background-image: linear-gradient(to right, #ffffff , #282323); 102 | margin-right: 20px; 103 | } 104 | 105 | .line-right { 106 | display: inline-block; 107 | width: 87px; 108 | height: 2px; 109 | background-image: linear-gradient(to right, #282323 , #ffffff); 110 | margin-left: 20px; 111 | } 112 | 113 | .down { 114 | text-align: center; 115 | width: 52px; 116 | height: 52px; 117 | background-color: #ffffff; 118 | margin: 0 auto; 119 | border-radius: 100%; 120 | color: #EB505C; 121 | line-height: 52px; 122 | margin-top: 50px; 123 | cursor: pointer; 124 | } 125 | 126 | .down-icon { 127 | font-size: 40px !important; 128 | } 129 | 130 | .navs { 131 | display: inline-flex; 132 | justify-content: center; 133 | height: 46px; 134 | background: rgba(255, 255, 255, 0.4); 135 | line-height: 46px; 136 | margin: 32px auto 0; 137 | border-radius: 8px; 138 | } 139 | 140 | .nav-icon { 141 | margin-right: 8px; 142 | } 143 | 144 | .nav-item { 145 | font-size: 16px; 146 | color: #282323; 147 | font-weight: 400; 148 | margin-right: 78px; 149 | } 150 | 151 | .nav-item:first-child { 152 | padding-left: 16px; 153 | } 154 | 155 | .nav-item:last-child { 156 | margin-right: 0; 157 | padding-right: 16px; 158 | } 159 | 160 | .start-btn { 161 | margin-top: 40px; 162 | } 163 | 164 | .try-btn { 165 | width: 380px; 166 | height: 52px !important; 167 | font-size: 20px !important; 168 | border-radius: 8px !important; 169 | background: #EB3148 !important; 170 | } 171 | 172 | .task-bg { 173 | background: #FFF6F2; 174 | position: relative; 175 | } 176 | 177 | .task { 178 | display: flex; 179 | padding-top: 120px; 180 | margin: 0 auto; 181 | max-width: 1150px; 182 | } 183 | 184 | .task-logo { 185 | width: 150px; 186 | } 187 | 188 | .task-left { 189 | margin-top: 24px; 190 | margin-bottom: 24px; 191 | } 192 | 193 | .task-right { 194 | flex: 1; 195 | margin-left: 100px; 196 | } 197 | 198 | .task-title { 199 | font-family: PingFangSC-Medium; 200 | font-size: 40px; 201 | color: rgba(0, 0, 0, 0.84); 202 | font-weight: 500; 203 | line-height: 56px; 204 | margin-bottom: 50px; 205 | } 206 | 207 | .task-desc { 208 | font-size: 18px; 209 | color: rgba(0, 0, 0, 0.6); 210 | margin-top: 24px; 211 | line-height: 25px; 212 | 213 | :global { 214 | a { 215 | color: #4F6DFF; 216 | } 217 | 218 | a:hover { 219 | color: #4F6DFF; 220 | } 221 | } 222 | } 223 | 224 | .task-result-off { 225 | font-size: 40px; 226 | color: rgba(0, 0, 0, 0.84); 227 | font-weight: 400; 228 | margin-top: 60px; 229 | line-height: 56px; 230 | padding-bottom: 204px; 231 | } 232 | 233 | .task-result-on { 234 | padding-bottom: 108px; 235 | font-size: 40px; 236 | color: rgba(0, 0, 0, 0.84); 237 | font-weight: 400; 238 | margin-top: 60px; 239 | line-height: 56px; 240 | position: relative; 241 | } 242 | 243 | .task-result-img { 244 | width: 470px; 245 | margin-top: 16px; 246 | } 247 | 248 | .price { 249 | position: absolute; 250 | bottom: 166px; 251 | font-size: 24px; 252 | color: #ffffff; 253 | left: 330px; 254 | } 255 | 256 | .footer { 257 | background: url('images/footer.png'); 258 | background-size: 100% 100%; 259 | height: 420px; 260 | text-align: center; 261 | padding-top: 120px; 262 | position: relative; 263 | } 264 | 265 | .footer-logo { 266 | width: 207px; 267 | } 268 | 269 | .footer-text { 270 | font-family: PingFangSC-Medium; 271 | font-size: 40px; 272 | color: #FFFFFF; 273 | font-weight: 500; 274 | margin-top: 40px; 275 | line-height: 56px; 276 | } 277 | 278 | .up { 279 | position: absolute; 280 | text-align: center; 281 | width: 52px; 282 | height: 52px; 283 | background-color: #ffffff; 284 | margin: 0 auto; 285 | border-radius: 100%; 286 | color: #EB505C; 287 | line-height: 52px; 288 | cursor: pointer; 289 | top: -26px; 290 | transform: translateX(-50%); 291 | left: 50%; 292 | } 293 | 294 | .up-icon { 295 | font-size: 40px !important; 296 | } 297 | 298 | .decoration-coin-first { 299 | width: 190px; 300 | position: absolute; 301 | right: 0; 302 | top: -150px 303 | } 304 | 305 | .decoration-coin-second { 306 | height: 292px; 307 | position: absolute; 308 | left: 0; 309 | bottom: -100px; 310 | } 311 | 312 | .decoration-coin-third { 313 | height: 292px; 314 | position: absolute; 315 | right: -20px; 316 | top: -150px 317 | } 318 | 319 | .modal-container { 320 | width: 460px !important; 321 | border-radius: 16px !important; 322 | } 323 | 324 | .modal { 325 | padding: 40px; 326 | } 327 | 328 | .demo-product { 329 | font-family: HelveticaNeue-Bold; 330 | font-size: 28px; 331 | color: rgba(0, 0, 0, 0.84); 332 | margin-top: 40px; 333 | } 334 | 335 | .demo-login-text { 336 | font-size: 22px; 337 | margin-top: 20px; 338 | } 339 | 340 | .demo-login-tip { 341 | font-size: 12px; 342 | color: #74788D; 343 | margin-top: 8px; 344 | } 345 | 346 | .demo-password-tip { 347 | background: #fffae0; 348 | line-height: 18px; 349 | font-size: 13px; 350 | color: #592d00; 351 | padding: 7px 20px; 352 | border-radius: 8px; 353 | } 354 | 355 | .demo-form { 356 | margin-top: 50px; 357 | 358 | :global { 359 | .iconfont { 360 | font-size: 20px; 361 | margin-right: 10px; 362 | } 363 | 364 | .ui.form .field { 365 | margin-bottom: 12px !important; 366 | } 367 | 368 | input { 369 | height: 42px !important; 370 | } 371 | } 372 | } 373 | 374 | .field { 375 | margin-bottom: 32px !important; 376 | } 377 | 378 | .label { 379 | margin-bottom: 11px !important; 380 | } 381 | 382 | .label-text { 383 | font-size: 20px; 384 | color: #495057; 385 | line-height: 20px; 386 | } 387 | 388 | .error-text { 389 | color: #F46A6A; 390 | font-size: 12px; 391 | margin-top: 12px; 392 | } 393 | 394 | .tip-text { 395 | color: #74788D; 396 | margin-bottom: 15px; 397 | font-size: 12px; 398 | transform-origin: left center; 399 | } 400 | 401 | .demo-footer { 402 | margin-top: 80px; 403 | margin-bottom: 22px; 404 | } 405 | 406 | .demo-btn { 407 | width: 100%; 408 | height: 52px !important; 409 | font-size: 20px !important; 410 | border-radius: 8px !important; 411 | background: #EB3148 !important; 412 | } 413 | 414 | .service { 415 | width: 44px; 416 | height: 44px; 417 | position: fixed; 418 | bottom: 40px; 419 | right: 10px; 420 | background: #FFFFFF; 421 | box-shadow: 0 -2px 4px 0 rgba(0,0,0,0.02), 0 2px 6px 6px rgba(0,0,0,0.02), 0 2px 6px 0 rgba(0,0,0,0.06); 422 | border-radius: 100%; 423 | text-align: center; 424 | line-height: 44px; 425 | cursor: pointer; 426 | } 427 | 428 | .icon-service { 429 | font-size: 24px!important; 430 | color: #3E76FF; 431 | } 432 | 433 | .qrcode-modal { 434 | position: fixed; 435 | right: 0; 436 | bottom: 92px; 437 | width: 240px; 438 | background: #FFFFFF; 439 | box-shadow: 0 0 6px 0 rgba(0,0,0,0.04), 0 4px 8px 8px rgba(0,0,0,0.04), 0 4px 6px 0 rgba(0,0,0,0.08); 440 | border-radius: 6.4px; 441 | padding: 16px 24px; 442 | } 443 | 444 | .qrcode-title { 445 | font-family: PingFangSC-Medium; 446 | font-size: 14px; 447 | color: #000000; 448 | font-weight: 500; 449 | text-align: center; 450 | } 451 | 452 | .qrcode-content { 453 | border: 1px solid #D7DAE0; 454 | border-radius: 6px; 455 | margin-top: 12px; 456 | } 457 | 458 | .qrcode-image { 459 | width: 190px; 460 | min-height: 302px; 461 | border-radius: 10px; 462 | } 463 | 464 | @media (max-width: 1100px) { 465 | .start { 466 | height: auto; 467 | background-size: cover; 468 | background-position: center; 469 | margin-top: -60px; 470 | } 471 | 472 | .start-box { 473 | width: 90%; 474 | height: auto; 475 | padding-bottom: 50px; 476 | } 477 | 478 | .start-box-title { 479 | font-size: 40px; 480 | line-height: 56px; 481 | } 482 | 483 | .start-title-ball-left { 484 | display: none; 485 | } 486 | 487 | .start-title-ball-right { 488 | display: none; 489 | } 490 | 491 | .start-box-desc { 492 | padding: 0 20px; 493 | font-size: 14px; 494 | } 495 | 496 | .start-box-link { 497 | font-size: 20px; 498 | } 499 | 500 | .start-box-user { 501 | font-size: 30px; 502 | } 503 | 504 | .down { 505 | width: 32px; 506 | height: 32px; 507 | line-height: 32px; 508 | } 509 | 510 | .down-icon { 511 | font-size: 32px !important; 512 | } 513 | 514 | .task { 515 | display: block; 516 | padding: 80px 10px 0; 517 | } 518 | 519 | .task-logo { 520 | width: 136px; 521 | } 522 | 523 | .task-title { 524 | font-size: 28px; 525 | line-height: 40px; 526 | margin-bottom: 30px; 527 | } 528 | 529 | .task-right { 530 | margin-left: 0; 531 | } 532 | 533 | .task-result-on { 534 | margin-top: 50px; 535 | font-size: 28px; 536 | padding-bottom: 80px; 537 | line-height: 40px; 538 | } 539 | 540 | .task-result-off { 541 | margin-top: 50px; 542 | font-size: 28px; 543 | padding-bottom: 80px; 544 | line-height: 40px; 545 | } 546 | 547 | .task-result-img { 548 | width: 350px; 549 | margin-top: 24px; 550 | } 551 | 552 | .price { 553 | bottom: 123px; 554 | font-size: 18px; 555 | color: #ffffff; 556 | left: 246px; 557 | } 558 | 559 | .decoration-coin-first { 560 | display: none; 561 | } 562 | 563 | .decoration-coin-second { 564 | display: none; 565 | } 566 | 567 | .decoration-coin-third { 568 | display: none; 569 | } 570 | 571 | .up { 572 | width: 32px; 573 | height: 32px; 574 | line-height: 32px; 575 | top: -16px; 576 | } 577 | 578 | .up-icon { 579 | font-size: 32px !important; 580 | } 581 | 582 | .footer { 583 | background-size: cover; 584 | background-position: center; 585 | } 586 | 587 | .footer-text { 588 | font-size: 32px; 589 | width: 90%; 590 | margin: 24px auto; 591 | line-height: 45px; 592 | } 593 | 594 | .modal-container { 595 | width: 350px !important; 596 | } 597 | } -------------------------------------------------------------------------------- /src/pages/home/index.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useEffect, useState, useRef, SyntheticEvent } from 'react'; 2 | import { FormattedMessage, useIntl } from 'react-intl'; 3 | import { FeatureProbe, FPUser } from 'featureprobe-client-sdk-js'; 4 | import { Modal, Form, InputOnChangeData } from 'semantic-ui-react'; 5 | import { useForm } from 'react-hook-form'; 6 | import { getProjectList, login } from 'services'; 7 | import { IProject } from 'interfaces'; 8 | import Icon from 'components/Icon'; 9 | import Header from 'components/Header'; 10 | import Button from 'components/Button'; 11 | import logo from 'images/logo.svg'; 12 | import { EventTrack } from 'utils/track'; 13 | import styles from './index.module.scss'; 14 | import EventTracker from 'components/EventTracker'; 15 | 16 | interface ILoginData { 17 | account: string; 18 | organizeId: number; 19 | role: string; 20 | token: string; 21 | } 22 | 23 | const Home = () => { 24 | const [ isScroll, setIsScroll ] = useState(false); 25 | const [ isLogin, setIsLogin ] = useState(false); 26 | const [ firstTaskStatusOn, saveFirstTaskStatus ] = useState(false); 27 | const [ secondTaskStatusOn, saveSecondTaskStatus ] = useState(false); 28 | const [ thirdTaskStatusOn, saveThirdTaskStatus ] = useState(false); 29 | const [ fourthTaskStatusOn, saveFourthTaskStatus ] = useState(0); 30 | const [ fourthTaskResultShow, saveFourthTaskResult ] = useState(false); 31 | 32 | const [ loginOpen, setLoginOpen ] = useState(false); 33 | const [ isShow, showQrCode ] = useState(false); 34 | const intl = useIntl(); 35 | const INTERVAVL_TIME = 1000; 36 | 37 | const { 38 | formState: { errors }, 39 | register, 40 | handleSubmit, 41 | setValue, 42 | trigger, 43 | } = useForm(); 44 | 45 | let FP: FeatureProbe; 46 | const timer: { current: NodeJS.Timeout | null } = useRef(null); 47 | 48 | const getTaskStatus = useCallback(() => { 49 | const fisrtTaskResult = FP.boolValue('campaign_enable', false); 50 | const secondTaskResult = FP.boolValue('campaign_allow_list', false); 51 | const thirdTaskResult = FP.boolValue('campaign_percentage_rollout', false); 52 | const fourthTaskResult = FP.numberValue('promotion_campaign', 0); 53 | 54 | saveFirstTaskStatus(fisrtTaskResult); 55 | saveSecondTaskStatus(secondTaskResult); 56 | saveThirdTaskStatus(thirdTaskResult); 57 | saveFourthTaskStatus(fourthTaskResult); 58 | saveFourthTaskResult(true); 59 | }, []); 60 | 61 | const initSDK = useCallback((sdkKey: string) => { 62 | const user = new FPUser('featureprobe'); 63 | user.with('userId', '00003'); 64 | FP = new FeatureProbe({ 65 | remoteUrl: 'https://featureprobe.io/server', 66 | clientSdkKey: sdkKey, 67 | user, 68 | refreshInterval: INTERVAVL_TIME, 69 | }); 70 | 71 | FP.start(); 72 | 73 | FP.on('ready', () => { 74 | if (timer.current) { 75 | clearInterval(timer.current); 76 | } 77 | getTaskStatus(); 78 | timer.current = setInterval(getTaskStatus, INTERVAVL_TIME); 79 | return () => { 80 | clearInterval(timer.current as NodeJS.Timeout); 81 | }; 82 | }); 83 | }, []); 84 | 85 | const init = useCallback(async () => { 86 | const res = await getProjectList(); 87 | const { data, code, success } = res; 88 | if (('' + code) === '401') { 89 | return; 90 | } 91 | if (success && data) { 92 | setIsLogin(true); 93 | if (data && data[0] && data[0].environments && data[0].environments[0]) { 94 | initSDK(data[0].environments[0].clientSdkKey); 95 | } 96 | } 97 | }, [intl]); 98 | 99 | useEffect(() => { 100 | init(); 101 | EventTrack.init(); 102 | EventTrack.pageView('/'); 103 | }, [init]); 104 | 105 | const scrollChange = useCallback(() => { 106 | const top = document.getElementById('start')?.getBoundingClientRect().top; 107 | 108 | if (top === 0) { 109 | setIsScroll(false); 110 | } else { 111 | setIsScroll(true); 112 | } 113 | }, []); 114 | 115 | useEffect(() => { 116 | window.addEventListener('scroll', scrollChange, false); 117 | scrollChange(); 118 | 119 | return () => { 120 | window.removeEventListener('scroll', scrollChange, false); 121 | }; 122 | }, [scrollChange]); 123 | 124 | const gotoStart = useCallback(() => { 125 | window.scrollTo(0, 0); 126 | }, []); 127 | 128 | const gotoFirstTask = useCallback(() => { 129 | const firstTask = document.getElementById('firstTask')?.offsetTop || 0; 130 | const header = document.getElementById('header')?.clientHeight || 0; 131 | setTimeout(() => { 132 | window.scrollTo(0, firstTask - header); 133 | }, 400); 134 | }, []); 135 | 136 | const onSubmit = useCallback(async (params) => { 137 | const res = await login({ 138 | source: 'demo', 139 | ...params 140 | }); 141 | const { success, data } = res; 142 | if (success && data) { 143 | console.log(data); 144 | localStorage.setItem('token', data.token); 145 | localStorage.setItem('organizeId', String(data.organizeId)); 146 | localStorage.setItem('account', String(data.account)); 147 | setLoginOpen(false); 148 | init(); 149 | EventTrack.setUserId(data.account); 150 | } 151 | }, []); 152 | 153 | return ( 154 |
155 |
159 | 160 | {/* start task */} 161 |
162 |
163 |
164 | ball 165 | 166 | ball 167 |
168 | 169 | { 170 | isLogin ? ( 171 |
172 | 173 | { 174 | intl.formatMessage({ 175 | id: 'demo.welcome' 176 | }, { 177 | account: localStorage.getItem('account') 178 | }) 179 | } 180 | 181 |
182 | ) : ( 183 |
184 |
185 |
186 | 187 | 188 |
189 |
190 | 191 | 192 |
193 |
194 | 195 | 196 |
197 |
198 | 199 | 200 |
201 |
202 |
203 | ) 204 | } 205 | 206 |
207 | { isLogin ? : } 208 |
209 | { 210 | isLogin && ( 211 | <> 212 | 219 |
220 | 221 |
222 | 223 | ) 224 | } 225 | { 226 | !isLogin && ( 227 |
228 | 231 |
232 | ) 233 | } 234 |
235 | { 236 | isLogin && ( 237 |
238 | 239 |
240 | ) 241 | } 242 |
243 | 244 | {/* first task */} 245 | { 246 | isLogin && ( 247 |
248 |
249 |
250 | task 251 |
252 |
253 |
254 | 255 |
256 |
257 | 258 |
259 |
260 | 261 | 262 | 263 | Campaign Enable 264 | 265 | 266 | 267 |
268 | { 269 | firstTaskStatusOn ? ( 270 |
271 |
272 | 273 |
274 |
275 | { 276 | localStorage.getItem('i18n')?.replaceAll('"', '') === 'en-US' 277 | ? result 278 | : result 279 | } 280 |
281 |
282 | ) : ( 283 |
284 | 285 |
286 | ) 287 | } 288 |
289 |
290 |
291 | ) 292 | } 293 | 294 | {/* second task */} 295 | { 296 | isLogin && ( 297 |
298 |
299 |
300 | task 301 |
302 |
303 |
304 | 305 |
306 |
307 | 308 |
309 |
310 | 311 | 312 | 313 | Campaign Allow List 314 | 315 | 316 | 317 |
318 | { 319 | secondTaskStatusOn ? ( 320 |
321 |
322 | 323 |
324 |
325 | { 326 | localStorage.getItem('i18n')?.replaceAll('"', '') === 'en-US' 327 | ? result 328 | : result 329 | } 330 |
331 |
332 | ) : ( 333 |
334 | 335 |
336 | ) 337 | } 338 |
339 |
340 | 341 | 342 |
343 | ) 344 | } 345 | 346 | {/* third task */} 347 | { 348 | isLogin && ( 349 |
350 |
351 |
352 | task 353 |
354 |
355 |
356 | 357 |
358 |
359 | 360 |
361 |
362 | 363 | 364 | 365 | Campaign Percentage Rollout 366 | 367 | 368 | 369 |
370 | { 371 | thirdTaskStatusOn ? ( 372 |
373 |
374 | 375 |
376 |
377 | { 378 | localStorage.getItem('i18n')?.replaceAll('"', '') === 'en-US' 379 | ? result 380 | : result 381 | } 382 |
383 |
384 | ) : ( 385 |
386 | 387 |
388 | ) 389 | } 390 |
391 |
392 |
393 | ) 394 | } 395 | 396 | {/* fourth task */} 397 | { 398 | isLogin && ( 399 |
400 |
401 |
402 | task 403 |
404 |
405 |
406 | 407 |
408 |
409 | 410 |
411 |
412 | 413 | 414 | 415 | Promotion Campaign 416 | 417 | 418 | 419 |
420 |
421 |
422 | { 423 | intl.formatMessage({ id: 'demo.task4.status' }) 424 | } 425 | { 426 | fourthTaskResultShow && { fourthTaskStatusOn } 427 | } 428 |
429 |
430 | { 431 | localStorage.getItem('i18n')?.replaceAll('"', '') === 'en-US' 432 | ? result 433 | : result 434 | } 435 | { 436 | fourthTaskResultShow && ( 437 |
438 | { fourthTaskStatusOn } 439 |
440 | ) 441 | } 442 |
443 |
444 |
445 |
446 | 447 |
448 | ) 449 | } 450 | { 451 | isLogin && ( 452 |
453 |
454 | 455 |
456 |
457 | logo 458 |
459 |
460 | 461 |
462 |
463 | ) 464 | } 465 | 466 | {/* login modal */} 467 | setLoginOpen(false)} 472 | onOpen={() => setLoginOpen(true)} 473 | className={styles['modal-container']} 474 | > 475 |
476 |
477 |
478 | 479 |
480 |
481 | 482 |
483 |
484 |
488 | 489 | 495 | { 515 | setValue(detail.name, detail.value); 516 | await trigger('account'); 517 | }} 518 | /> 519 | { errors.account &&
{ errors.account.message }
} 520 |
521 | 522 |
523 | 524 |
525 | 526 |
527 | 528 | 531 | 532 |
533 |
534 |
535 |
536 |
537 |
538 | 539 | {/* qr code */} 540 | { 541 | isShow && ( 542 |
543 |
544 | 545 |
546 |
547 | qrcode 552 |
553 |
554 | ) 555 | } 556 |
{ showQrCode(true); }} onMouseLeave={() => { showQrCode(false); }}> 557 | 558 |
559 |
560 | ); 561 | }; 562 | 563 | export default Home; 564 | -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | 5 | declare namespace NodeJS { 6 | interface ProcessEnv { 7 | readonly NODE_ENV: 'development' | 'production' | 'test'; 8 | readonly PUBLIC_URL: string; 9 | } 10 | } 11 | 12 | declare module '*.avif' { 13 | const src: string; 14 | export default src; 15 | } 16 | 17 | declare module '*.bmp' { 18 | const src: string; 19 | export default src; 20 | } 21 | 22 | declare module '*.gif' { 23 | const src: string; 24 | export default src; 25 | } 26 | 27 | declare module '*.jpg' { 28 | const src: string; 29 | export default src; 30 | } 31 | 32 | declare module '*.jpeg' { 33 | const src: string; 34 | export default src; 35 | } 36 | 37 | declare module '*.png' { 38 | const src: string; 39 | export default src; 40 | } 41 | 42 | declare module '*.webp' { 43 | const src: string; 44 | export default src; 45 | } 46 | 47 | declare module '*.svg' { 48 | import * as React from 'react'; 49 | 50 | export const ReactComponent: React.FunctionComponent & { title?: string }>; 53 | 54 | const src: string; 55 | export default src; 56 | } 57 | 58 | declare module '*.module.css' { 59 | const classes: { readonly [key: string]: string }; 60 | export default classes; 61 | } 62 | 63 | declare module '*.module.scss' { 64 | const classes: { readonly [key: string]: string }; 65 | export default classes; 66 | } 67 | 68 | declare module '*.module.sass' { 69 | const classes: { readonly [key: string]: string }; 70 | export default classes; 71 | } 72 | -------------------------------------------------------------------------------- /src/router/index.tsx: -------------------------------------------------------------------------------- 1 | import { BrowserRouter, Switch, Route } from 'react-router-dom'; 2 | import BasicLayout from '../layout/BasicLayout'; 3 | import { blankRoutes } from './routes'; 4 | 5 | const Router = () => { 6 | return ( 7 | 8 | 9 | 10 | { 11 | blankRoutes.map(route => { 12 | return ( 13 | ( 18 | 19 | )} 20 | /> 21 | ); 22 | }) 23 | } 24 | 25 | 26 | 27 | ); 28 | }; 29 | 30 | export default Router; 31 | -------------------------------------------------------------------------------- /src/router/routes.ts: -------------------------------------------------------------------------------- 1 | import Home from '../pages/home'; 2 | 3 | export const blankRoutes = [ 4 | { 5 | path: '/demo', 6 | exact: true, 7 | component: Home 8 | }, 9 | ]; 10 | -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/breadcrumb.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.breadcrumb a { 6 | color: #74788D; 7 | } 8 | .ui.breadcrumb a:hover { 9 | color: @linkHoverColor; 10 | } 11 | 12 | .ui.breadcrumb { 13 | font-size: 12px; 14 | } 15 | 16 | .ui.breadcrumb .active.section { 17 | color: #495057; 18 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/breadcrumb.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | @linkHoverColor: #556ee6; -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/form.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.form .fields { 6 | display: flex; 7 | flex-direction: row; 8 | margin: 0; 9 | } 10 | 11 | .ui.form .field.disabled :disabled { 12 | opacity: 1; 13 | background: #EFF2F7; 14 | border: 1px solid #CED4DA; 15 | color: #ADB5BC; 16 | } 17 | 18 | .ui.form .field { 19 | clear: both; 20 | margin: 0 0 16px 0; 21 | } 22 | 23 | .ui.form .field > label { 24 | margin: 0; 25 | } 26 | 27 | .ui.form .disabled.fields .field, 28 | .ui.form .disabled.field, 29 | .ui.form .field :disabled { 30 | pointer-events: inherit; 31 | cursor: not-allowed; 32 | } 33 | 34 | .ui.form .fields .wide.field { 35 | padding-left: 4px; 36 | padding-right: 4px; 37 | } 38 | 39 | .ui.form .fields > .field { 40 | padding-left: 4px; 41 | padding-right: 4px; 42 | } 43 | 44 | 45 | .ui.form input:not([type]), 46 | .ui.form input[type="date"], 47 | .ui.form input[type="datetime-local"], 48 | .ui.form input[type="email"], 49 | .ui.form input[type="number"], 50 | .ui.form input[type="password"], 51 | .ui.form input[type="search"], 52 | .ui.form input[type="tel"], 53 | .ui.form input[type="time"], 54 | .ui.form input[type="text"], 55 | .ui.form input[type="file"], 56 | .ui.form input[type="url"] { 57 | height: 32px; 58 | padding: 0 12px; 59 | } 60 | 61 | .ui.form textarea { 62 | min-height: 90px; 63 | } 64 | 65 | 66 | .ui.form .field.field input:-webkit-autofill { 67 | box-shadow: none !important; 68 | border-color: transparent !important; 69 | background-color: transparent !important; 70 | background-image: none !important; 71 | transition: background-color 50000s ease-in-out 0s !important; 72 | } 73 | 74 | /* Focus */ 75 | .ui.form .field.field input:-webkit-autofill:focus { 76 | box-shadow: none !important; 77 | background-color: transparent !important; 78 | background-image: none !important; 79 | border-color: #74788D !important; 80 | transition: background-color 50000s ease-in-out 0s !important; 81 | } 82 | -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/form.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | 5 | @inputBackground: rgba(33, 37, 41, 0.04); 6 | @inputBorderRadius: 6px; 7 | @inputBorder: 1px solid transparent; 8 | @labelColor: #74788D; 9 | @labelFontWeight: 'normal'; 10 | @inputFocusBorderColor: #74788D; 11 | 12 | @disabledLabelOpacity: 1; 13 | @disabledOpacity: 1; 14 | 15 | @formErrorBackground: #FFFAFA; 16 | @formErrorBorder: #FF7066; 17 | @formErrorColor: #495057; 18 | 19 | @labelFontSize: 13px; 20 | @labelColor: #495057; -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/grid.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.grid { 6 | margin-top: 0; 7 | margin-bottom: 0; 8 | } 9 | 10 | .ui.grid > .row { 11 | padding-top: 0; 12 | padding-bottom: 0; 13 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/grid.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/menu.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | 6 | 7 | .ui.pagination.menu { 8 | margin: 0em; 9 | display: inline-flex; 10 | vertical-align: middle; 11 | border: none; 12 | box-shadow: none; 13 | min-height: 0; 14 | } 15 | 16 | .ui.pagination.menu .item::before{ 17 | background: transparent 18 | } 19 | 20 | .ui.pagination.menu .item:last-child { 21 | border-radius: 0 22 | } 23 | .ui.compact.menu .item:last-child { 24 | border-radius: 0 25 | } 26 | .ui.pagination.menu .item:last-child:before { 27 | display: none; 28 | } 29 | 30 | .ui.pagination.menu .item { 31 | min-width: 0; 32 | text-align: center; 33 | padding: 0; 34 | width: 24px; 35 | height: 24px; 36 | display: inline-flex; 37 | justify-content: center; 38 | align-items: center; 39 | margin-right: 10px 40 | } 41 | 42 | .ui.link.menu .item:hover, 43 | .ui.menu .dropdown.item:hover, 44 | .ui.menu .link.item:hover, 45 | .ui.menu a.item:hover { 46 | cursor: pointer; 47 | background: #556ee6; 48 | color: #ffffff; 49 | border-radius: 100%; 50 | } 51 | 52 | .ui.pagination.menu .icon.item i.icon { 53 | vertical-align: top; 54 | } 55 | 56 | .ui.pagination.menu .item:last-child { 57 | border-radius: 100%; 58 | } 59 | 60 | /* Active */ 61 | .ui.pagination.menu .active.item { 62 | box-shadow: none; 63 | background: #556EE6; 64 | border: 1px solid #556EE6; 65 | border-radius: 100%; 66 | color: #fff; 67 | padding: 0; 68 | } 69 | 70 | 71 | .ui.secondary.pointing.menu { 72 | border-bottom: none; 73 | } 74 | 75 | .ui.secondary.pointing.menu .active.item { 76 | background-color: transparent; 77 | box-shadow: none; 78 | border-color: #556ee6; 79 | color: #556ee6; 80 | border-bottom-width: 2px; 81 | } 82 | 83 | .ui.secondary.menu .item { 84 | padding: 12px 0 !important; 85 | margin-right: 24px !important; 86 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/menu.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/message.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/message.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/table.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.table tr td { 6 | border-bottom: @rowBorder; 7 | border-top: none; 8 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/collections/table.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | 5 | @headerBorder: 2px solid rgba(34, 36, 38, 0.1); 6 | @headerColor: #212529; -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/button.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.button { 6 | min-height: 32px; 7 | height: 32px; 8 | font-size: 12px; 9 | border-radius: 6px; 10 | padding: 0 16px; 11 | margin: 0; 12 | } 13 | 14 | .ui.secondary.buttons .button, 15 | .ui.secondary.button { 16 | background-color: #ffffff; 17 | color: #556ee6; 18 | border: 1px solid #556EE6; 19 | } 20 | 21 | .ui.secondary.buttons .button:hover, 22 | .ui.secondary.button:hover { 23 | color: #556ee6; 24 | } 25 | 26 | .ui.secondary.buttons .button:active, 27 | .ui.secondary.button:active { 28 | background-color: @secondaryColorHover; 29 | color: #556ee6; 30 | } 31 | 32 | .ui.secondary.buttons .button:focus, 33 | .ui.secondary.button:focus { 34 | background-color: transparent; 35 | color: #556ee6; 36 | } 37 | 38 | .ui.basic.buttons .button, 39 | .ui.basic.button { 40 | background: #ffffff !important; 41 | color: #353A40 !important; 42 | box-shadow: none; 43 | border: 1px solid #CED4DA; 44 | } 45 | 46 | .ui.basic.buttons .button:hover, 47 | .ui.basic.button:hover { 48 | background: #ffffff !important; 49 | color: #556EE6 !important; 50 | border: 1px solid #556EE6; 51 | box-shadow: none; 52 | } 53 | .ui.basic.buttons .button:focus, 54 | .ui.basic.button:focus { 55 | background: #ffffff !important; 56 | color: #556EE6 !important; 57 | box-shadow: none; 58 | } 59 | .ui.basic.buttons .button:active, 60 | .ui.basic.button:active { 61 | background: #ffffff !important; 62 | color: #556EE6 !important; 63 | box-shadow: none; 64 | } 65 | .ui.basic.buttons .active.button, 66 | .ui.basic.active.button { 67 | background: #ffffff !important; 68 | color: #556EE6 !important; 69 | box-shadow: none; 70 | } 71 | 72 | .ui.mini.buttons .button, 73 | .ui.mini.buttons .or, 74 | .ui.mini.button { 75 | font-size: 13px; 76 | height: 27px; 77 | padding: 0 8px; 78 | min-height: 27px; 79 | } 80 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/button.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | 5 | @basicBorderRadius: 6px; 6 | @primaryColorFocus: #556ee6; -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/container.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/container.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/divider.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/divider.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/flag.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/flag.variables: -------------------------------------------------------------------------------- 1 | /*------------------- 2 | Flag Variables 3 | --------------------*/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/header.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/header.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/icon.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/icon.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/image.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/image.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/input.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.mini.input { 6 | font-size: 13px; 7 | } 8 | 9 | .ui.mini.input > input { 10 | height: 27px !important; 11 | padding: 0 12px; 12 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/input.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | 5 | @disabledOpacity: 1; -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/label.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.labeled.input > .label:not(.corner) { 6 | padding-top: 0; 7 | padding-bottom: 0; 8 | line-height: 30px; 9 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/label.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/list.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/list.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/loader.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/loader.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/rail.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/rail.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/reveal.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/reveal.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/segment.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | .ui.segment { 6 | padding: 0 24px; 7 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/segment.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/step.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/elements/step.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/globals/reset.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/globals/reset.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Global Variables 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/globals/site.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/globals/site.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Global Variables 3 | *******************************/ 4 | @importGoogleFonts: false; 5 | @pageFont: Helvetica Neue, Helvetica, Arial, PingFang SC, Heiti SC, Hiragino Sans GB, Microsoft YaHei, sanf-serif; 6 | @primaryColor: #556ee6; 7 | @primaryColorHover: #4458B8; 8 | @primaryColorDown: #4458B8; 9 | @pageBackground: #FFFFFF; 10 | @secondaryColorHover: rgba(85, 110, 230, 0.10); 11 | @trackBackground: transparent; 12 | @inputPlaceholderColor: #ADB5BC; -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/accordion.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/accordion.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/chatroom.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/chatroom.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/checkbox.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/checkbox.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | 5 | @toggleLaneWidth: 28px; 6 | @toggleHandleSize: 16px; 7 | 8 | @radioActiveBulletColor: #ffffff; 9 | @checkboxActiveBorderColor: #556ee6; 10 | @radioActiveBackground: #556ee6; 11 | @checkboxBorder: 1px solid #ADB5BD; 12 | @checkboxActiveFocusBorderColor: #556ee6; 13 | @checkboxActiveFocusBackground: #ffffff; 14 | @radioActiveFocusBackground: #556ee6; 15 | @radioActiveFocusBulletColor: #ffffff; 16 | @toggleOnFocusLaneColor: #556ee6; 17 | 18 | @checkboxActiveBackground: #556eef; 19 | @checkboxActiveCheckColor: #ffffff; 20 | @checkboxBorder: 1px solid #ADB5BD; 21 | @checkboxFocusBackground: #ffffff; 22 | @checkboxFocusBorderColor: #ADB5BD; 23 | @checkboxActiveFocusBackground: #556eef; 24 | @checkboxActiveFocusBorderColor: transparent; 25 | @checkboxActiveFocusCheckColor: ffffff; -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/dimmer.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | 5 | .ui.dimmer { 6 | background: rgba(0, 0, 0, 0.5); 7 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/dimmer.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/dropdown.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | 5 | .ui.disabled.dropdown, 6 | .ui.dropdown .menu > .disabled.item { 7 | background: #EFF2F7; 8 | border: 1px solid #CED4DA; 9 | opacity: 1; 10 | pointer-events: inherit; 11 | cursor: not-allowed; 12 | color: #ADB5BC; 13 | } 14 | 15 | .ui.multiple.dropdown > .label { 16 | background: rgba(33, 37, 41, 0.08); 17 | border-radius: 4px; 18 | box-shadow: none; 19 | color: #495057; 20 | font-size: 12px; 21 | margin: 2px 4px 3px 0 !important; 22 | height: 20px; 23 | vertical-align: middle; 24 | line-height: 20px; 25 | padding: 0 4px; 26 | font-weight: normal; 27 | min-width: 50px; 28 | position: relative; 29 | display: inline-flex; 30 | justify-content: space-between; 31 | } 32 | 33 | .ui.selection.dropdown { 34 | padding: 3px 12px 2px; 35 | min-height: 32px; 36 | } 37 | 38 | .ui.dropdown > .text { 39 | vertical-align: middle; 40 | width: 95%; 41 | overflow: hidden; 42 | text-overflow: ellipsis; 43 | white-space: nowrap; 44 | line-height: 25px; 45 | } 46 | 47 | .ui.multiple.search.dropdown > input.search { 48 | position: inherit; 49 | margin: 0; 50 | height: 25px; 51 | } 52 | 53 | .ui.multiple.search.dropdown > .text { 54 | margin: 0 !important; 55 | line-height: 27px; 56 | } 57 | 58 | .ui.floating.dropdown > .menu { 59 | border: none; 60 | border-radius: 8px !important; 61 | margin-top: 4px !important; 62 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/dropdown.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | 5 | @selectionBackground: rgba(33,37,41,0.04); 6 | @selectionBorder: 1px solid transparent; 7 | @selectionHoverBorderColor: transparent; 8 | @selectionFocusBorderColor: #74788D; 9 | @selectionVisibleBorderColor: #74788D; 10 | @selectionActiveHoverBorderColor: #74788D; 11 | @disabledOpacity: 1; 12 | @multipleSelectionChildMargin: 5px 0; 13 | @errorTextColor: #495057; 14 | @searchSelectionInputPadding: 0 12px; 15 | @selectionVisibleConnectingBorder: 6px; 16 | @selectionBorderRadius: 6px; 17 | @selectedBackground: #F1F3FF; 18 | @selectedColor: #556EE6; 19 | @hoveredItemBackground: #F8F9FA; 20 | @hoveredItemColor: #212529; 21 | @selectionItemDivider: 1px solid transparent; 22 | @upwardSelectionVisibleBorderRadius: 6px; -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/embed.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/embed.variables: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FeatureProbe/feature-probe-demo-ui/1ee90fab92f8d1f15a00be74256fe24a46afc9ad/src/semantic-ui/site/modules/embed.variables -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/modal.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/modal.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | 5 | @miniHeaderSize: 16px; 6 | @contentPadding: 16px; 7 | @borderRadius: 10px; -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/nag.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/nag.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/popup.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | 5 | 6 | .ui.popup { 7 | border: none; 8 | box-shadow: 0 -2px 4px 0 rgba(0,0,0,0.02), 0 2px 6px 6px rgba(0,0,0,0.02), 0 2px 6px 0 rgba(0,0,0,0.06); 9 | font-size: 13px; 10 | color: #495057; 11 | padding: 8px 14px; 12 | border-radius: 6px; 13 | } 14 | 15 | .ui.popup:before { 16 | box-shadow: none; 17 | } -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/popup.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | 5 | @invertedBackground: #212B36; 6 | @invertedColor: #EFF2F7; -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/progress.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/progress.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/rating.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/rating.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/search.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/search.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/shape.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/shape.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/sidebar.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/sidebar.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/sticky.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/sticky.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/tab.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/tab.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/transition.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | Site Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/modules/transition.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/ad.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/ad.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/card.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/card.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/comment.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/comment.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/feed.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/feed.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/item.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/item.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/statistic.overrides: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/site/views/statistic.variables: -------------------------------------------------------------------------------- 1 | /******************************* 2 | User Variable Overrides 3 | *******************************/ 4 | -------------------------------------------------------------------------------- /src/semantic-ui/theme.config: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | ████████╗██╗ ██╗███████╗███╗ ███╗███████╗███████╗ 4 | ╚══██╔══╝██║ ██║██╔════╝████╗ ████║██╔════╝██╔════╝ 5 | ██║ ███████║█████╗ ██╔████╔██║█████╗ ███████╗ 6 | ██║ ██╔══██║██╔══╝ ██║╚██╔╝██║██╔══╝ ╚════██║ 7 | ██║ ██║ ██║███████╗██║ ╚═╝ ██║███████╗███████║ 8 | ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝ 9 | 10 | */ 11 | 12 | /******************************* 13 | Theme Selection 14 | *******************************/ 15 | 16 | /* To override a theme for an individual element 17 | specify theme name below 18 | */ 19 | 20 | /* Global */ 21 | @site : 'default'; 22 | @reset : 'default'; 23 | 24 | /* Elements */ 25 | @button : 'default'; 26 | @container : 'default'; 27 | @divider : 'default'; 28 | @flag : 'default'; 29 | @header : 'default'; 30 | @icon : 'default'; 31 | @image : 'default'; 32 | @input : 'default'; 33 | @label : 'default'; 34 | @list : 'default'; 35 | @loader : 'default'; 36 | @placeholder : 'default'; 37 | @rail : 'default'; 38 | @reveal : 'default'; 39 | @segment : 'default'; 40 | @step : 'default'; 41 | 42 | /* Collections */ 43 | @breadcrumb : 'default'; 44 | @form : 'default'; 45 | @grid : 'default'; 46 | @menu : 'default'; 47 | @message : 'default'; 48 | @table : 'default'; 49 | 50 | /* Modules */ 51 | @accordion : 'default'; 52 | @checkbox : 'default'; 53 | @dimmer : 'default'; 54 | @dropdown : 'default'; 55 | @embed : 'default'; 56 | @modal : 'default'; 57 | @nag : 'default'; 58 | @popup : 'default'; 59 | @progress : 'default'; 60 | @rating : 'default'; 61 | @search : 'default'; 62 | @shape : 'default'; 63 | @sidebar : 'default'; 64 | @sticky : 'default'; 65 | @tab : 'default'; 66 | @transition : 'default'; 67 | 68 | /* Views */ 69 | @ad : 'default'; 70 | @card : 'default'; 71 | @comment : 'default'; 72 | @feed : 'default'; 73 | @item : 'default'; 74 | @statistic : 'default'; 75 | 76 | /******************************* 77 | Folders 78 | *******************************/ 79 | 80 | @themesFolder : 'themes'; 81 | @siteFolder : '../../src/semantic-ui/site'; 82 | 83 | /******************************* 84 | Import Theme 85 | *******************************/ 86 | 87 | @import (multiple) '~semantic-ui-less/theme.less'; 88 | @fontPath : '../../../themes/@{theme}/assets/fonts'; 89 | -------------------------------------------------------------------------------- /src/services/index.ts: -------------------------------------------------------------------------------- 1 | import request from '../utils/request'; 2 | import API from '../constants/api'; 3 | import { ApplicationJson } from 'constants/api/content_type'; 4 | 5 | interface ILoginParams { 6 | account: string; 7 | password?: string; 8 | } 9 | 10 | export const getProjectList = async () => { 11 | const url = API.getProjectListURI; 12 | 13 | return request(url, { 14 | method: 'GET', 15 | headers: { 16 | ...ApplicationJson() 17 | }, 18 | }); 19 | }; 20 | 21 | export const login = async (data: ILoginParams) => { 22 | const url = `${API.loginURI}`; 23 | 24 | return request(url, { 25 | method: 'POST', 26 | headers: { 27 | 'Content-Type': 'application/json', 28 | 'Accept-Language': localStorage.getItem('i18n')?.replaceAll('"', '') || 'en-US', 29 | }, 30 | body: JSON.stringify(data), 31 | }); 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /src/setupProxy.ts: -------------------------------------------------------------------------------- 1 | import { createProxyMiddleware } from 'http-proxy-middleware'; 2 | 3 | module.exports = function(app: any) { 4 | app.use( 5 | '/server', 6 | createProxyMiddleware({ 7 | target: window.location.protocol + '//' + window.location.hostname + ':4007/', 8 | changeOrigin: false, 9 | cookiePathRewrite: false, 10 | }) 11 | ); 12 | }; -------------------------------------------------------------------------------- /src/utils/hooks.ts: -------------------------------------------------------------------------------- 1 | 2 | import { useState } from 'react'; 3 | 4 | export const useLocalStorage = (key: string, initialValue: boolean | string) => { 5 | const [storedValue, setStoredValue] = useState(() => { 6 | if (typeof window === 'undefined') { 7 | return initialValue; 8 | } 9 | 10 | try { 11 | const item = window.localStorage.getItem(key); 12 | return item ? JSON.parse(item) : initialValue; 13 | } catch (error) { 14 | return initialValue; 15 | } 16 | }); 17 | 18 | const setValue = (value: object) => { 19 | try { 20 | const valueToStore = value instanceof Function ? value(storedValue) : value; 21 | setStoredValue(valueToStore); 22 | 23 | if (typeof window !== 'undefined') { 24 | window.localStorage.setItem(key, JSON.stringify(valueToStore)); 25 | } 26 | } catch (error) { 27 | console.log(error); 28 | } 29 | }; 30 | return [storedValue, setValue]; 31 | }; 32 | -------------------------------------------------------------------------------- /src/utils/request.ts: -------------------------------------------------------------------------------- 1 | function parseJSON (response: Response) { 2 | return response.json(); 3 | } 4 | 5 | function checkStatus(response: Response) { 6 | if (response.status >= 200 && response.status < 300) { 7 | return response; 8 | } 9 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 10 | const error: any = new Error(response.statusText); 11 | error.response = response; 12 | throw error; 13 | } 14 | 15 | type IResponse = { 16 | success: boolean; 17 | code?: string; 18 | message?: string; 19 | data?: T; 20 | } 21 | 22 | function handleCode(res: IResponse, resolve: (value: IResponse | PromiseLike>) => void) { 23 | if (res.code) { 24 | resolve({ 25 | success: false, 26 | code: res.code, 27 | message: res.message, 28 | }); 29 | } 30 | } 31 | 32 | export default function request(url: string, options?: RequestInit): Promise> { 33 | options = options || { 34 | headers:{ 35 | 'Accept-Language': 'en-US' 36 | } 37 | }; 38 | 39 | return new Promise(resolve => { 40 | return fetch(url, options) 41 | .then(response => checkStatus(response)) 42 | .then(response => parseJSON(response)) 43 | .then(response => { 44 | handleCode, T>(response, resolve); 45 | resolve({ 46 | success: true, 47 | data: response, 48 | }); 49 | }) 50 | .catch(err => { 51 | resolve({ 52 | code: err.response.status, 53 | success: false, 54 | message: err.message, 55 | }); 56 | }); 57 | }); 58 | } 59 | -------------------------------------------------------------------------------- /src/utils/track.ts: -------------------------------------------------------------------------------- 1 | import ReactGA from 'react-ga4'; 2 | 3 | export const EventTrack = { 4 | init() { 5 | ReactGA.initialize('G-3NE3REQG2T'); 6 | }, 7 | 8 | setUserId(userId: string) { 9 | ReactGA.set({ userId }); 10 | }, 11 | 12 | pageView(pathName: string) { 13 | ReactGA.send({ hitType: 'pageview', page: pathName }); 14 | }, 15 | 16 | track(category: string, action: string) { 17 | ReactGA.event({ 18 | category, 19 | action, 20 | }); 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx", 22 | "baseUrl": "src" 23 | }, 24 | "include": [ 25 | "src" 26 | ], 27 | "exclude": [ 28 | "./node_modules/**/*" 29 | ] 30 | } 31 | --------------------------------------------------------------------------------