commit dbf400f9be4b3ec66c4d2c8a30ec06d04d8b2ee1 Author: Flatlogic Bot Date: Mon May 11 17:18:27 2026 +0200 Initial import diff --git a/.env b/.env new file mode 100644 index 0000000..d785839 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_BACKEND=false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9735fb4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + validate: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [20.x, 22.x] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: npm + + - name: Install + run: npm ci + + - name: Lint + run: npm run lint + + - name: Build + run: npm run build + + - name: Test + run: npm test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ecc71ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +.idea diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0041883 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 FLATLOGIC.COM + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a0198b --- /dev/null +++ b/README.md @@ -0,0 +1,131 @@ +# 🚀 Light Blue React - A Free Transparent React Admin Template! + +[View Demo](https://flatlogic.com/templates/light-blue-react/demo) | [Download](https://github.com/flatlogic/light-blue-react/archive/refs/heads/master.zip) | [More Templates](https://flatlogic.com/templates) | [Discord Community](https://discord.gg/flatlogic-community) | [Support Forum](https://flatlogic.com/forum) + +**Originally a premium product priced at $69+, made available for free in January 2025!** 🎉 + +Looking for a perfect codebase generator for your Startup? Try [Flatlogic AI Web App Generator](https://flatlogic.com/generator) - our new tool, sort of a template++. + +--- + +## 🎯 Why Light Blue React? +- **Ex-Premium**: This template was previously paid. Enjoy it for free now. 😉 +- **Tons of components**: Hundreds of ready-to-use UI elements, charts, and more. +- **Join the Community**: [Flatlogic Discord](https://discord.gg/flatlogic-community) is where the action happens. +- **Free Node.js Backend**: Pair it up with [this backend](https://github.com/flatlogic/nodejs-backend) to go full-stack. + +--- + +## 🚀 Quick Start + +1. **Clone the repo** + ```bash + git clone https://github.com/flatlogic/light-blue-react.git + cd light-blue-react + ``` +2. **Install dependencies** + ```bash + npm install --force + ``` + This repository is maintained with npm lockfile (`package-lock.json`). + Peer override is currently required because several legacy demo dependencies still declare React 18 peer ranges. +3. **Run the app** + ```bash + npm run dev + ``` + Navigate to http://localhost:3000/. + +4. **Backend Support** + ```bash + npm run start:backend + ``` + +5. **Build for production** + ```bash + npm run build + ``` + +6. **Preview production build locally** + ```bash + npm run preview + ``` + +7. **Run tests** + ```bash + npm test + ``` + +--- + +## đŸ§© Features + +- Easily customizable styling & themes +- Over 30 Unique Pages +- Fully Responsive +- React 19 +- React Router 7 +- Bootstrap 5 +- Developer-Oriented Dashboard +- Fully Documented Codebase + +--- + +## 🛠 Built With +- React 19 +- Bootstrap 5 +- Node.js +- Vite 7 + SWC +- Vitest +- SASS +- JavaScript (ES6) + +Node engine target in `package.json`: `^20.19.0 || >=22.12.0`. + +--- + +## 📩 Components +- UI Elements (Badge, Card, Carousel, Modal, etc.) +- Charts (Flot, Morris, Rickshaw, Sparkline, Easy Pie Charts) +- Forms (Validation, Wizard, Elements) +- Dashboards (Analytics, Visits) +- Pages (Profile, E-commerce, Calendar, Chat, Error) +- Maps (Google, Vector) + +--- + +## 🌍 Available Variants + +| | **Material** | **Transparent** | **Classic** | **Sofia** | **Flatlogic** | +|---------------|-----------------------------------------------------------|---------------------------------------------------------|-------------------------------------------------------|-----------------------------------------------------|----------------------------------------------------| +| **React** | [React Material Admin](https://github.com/flatlogic/react-material-admin-full) | [Light Blue React](https://github.com/flatlogic/light-blue-react) | [Sing App React](https://github.com/flatlogic/sing-app-react) | [Sofia React](https://github.com/flatlogic/sofia-react) | [One React](https://github.com/flatlogic/one-react) | +| **Angular** | [Angular Material Admin](https://github.com/flatlogic/angular-material-admin-full) | [Light Blue Angular](https://github.com/flatlogic/light-blue-angular) | [Sing App Angular](https://github.com/flatlogic/sing-app-angular) | - | - | +| **Vue** | [Material Vue](https://github.com/flatlogic/material-vue-full) | [Light Blue Vue](https://github.com/flatlogic/light-blue-vue) | [Sing App Vue](https://github.com/flatlogic/sing-app-vue) | - | - | +| **Bootstrap** | - | [Light Blue HTML5](https://github.com/flatlogic/light-blue-html5) | [Sing App HTML5](https://github.com/flatlogic/sing-app-html5) | - | [One Bootstrap](https://github.com/flatlogic/one-bootstrap-template-full) | + +Additionally, these templates are tailored for specific business needs: + +- [E-Commerce Frontend (React)](https://github.com/flatlogic/ecommerce-frontend) - A complete e-commerce solution. +- [Bookkeeper UI (React)](https://github.com/flatlogic/bookkeeper-ui) - Accounting dashboard for finance management. +- [User Management Template (React)](https://github.com/flatlogic/user-management-template) - User authentication and management. + +--- + +## đŸ‘šâ€đŸ’» How to Contribute +- **Star this repo ⭐** - show some love. +- **Report bugs** - but be nice. +- **Join the [Discord]()** - meet fellow devs. + +--- + +## đŸ”„ About Flatlogic +[Flatlogic AI Software Engineer](https://flatlogic.com/ai-software-development-agent) builds modern business software so you don't have to. Our AI Software Development Agent helps you generate, deploy, and maintain enterprise applications with minimal effort. + +--- + +## 📜 License +This template is free to use. Modify it, break it, make it your own. Just don’t try to sell it back to us. 😎 + +--- + +> **Questions or feedback?** +> Join our [Flatlogic Community Discord](https://discord.gg/flatlogic-community) or visit our [support forum](https://flatlogic.com/forum). We might even reply! diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..7856b94 --- /dev/null +++ b/changelog.md @@ -0,0 +1,334 @@ +# Changelog + +## [Unreleased] + +## [8.3.3] - 2026-02-23 +- Dependency and runtime cleanup: + - removed Vite Node polyfill plugin and legacy browserify/polyfill packages (`assert`, `crypto-browserify`, `os-browserify`, `process`, `stream-browserify`, `stream-http`, `url`, `vm-browserify`); + - removed direct `lodash` usage from app code paths and replaced it with local utility helpers in form/user formatters; + - pinned transitive `lodash` to a safe version via npm override (`^4.17.23`). +- Lockfile update: + - added `yarn.lock` for Yarn install parity while keeping npm lockfile in place. + +## [8.3.2] - 2026-02-23 +- Phase 1 modernization baseline fixes: + - fixed dead fallback redirect in app shell (`/app/main/visits` -> `/app/main/dashboard`); + - hardened `AuthRoute` against missing `location.state`; + - normalized login/register/forgot links to absolute auth routes; + - replaced obsolete layout test with route-guard smoke tests; + - removed conflicting project-level `babel.config.js` to align with CRA toolchain. +- Tooling baseline updates: + - added explicit `ajv@^8.18.0` dev dependency to fix webpack/schema-utils `ajv` resolution during build; + - documented working install path (`npm install --force`) in README. +- Phase 2 modernization updates: + - migrated build/dev/preview workflow to Vite + SWC (`vite.config.js`, root `index.html`); + - removed CRA/rewired build overrides (`config-overrides.js`, `public/index.html`, `react-app-rewired`, `react-scripts`); + - migrated test runner to Vitest and retained route-guard smoke coverage; + - migrated runtime env handling to Vite-compatible app env bridge (`VITE_BACKEND` + `__APP_ENV__`); + - kept build output compatibility (`build/`) and added Node memory guard for large production bundle builds; + - standardized lockfile strategy to npm (`package-lock.json`). +- Dependency refresh batch 1: + - low-risk update: `bootstrap` upgraded within major (`5.2.3` -> `5.3.8`); + - major update block A: `axios` (`0.27.2` -> `1.13.5`), `jsonwebtoken` (`8.5.1` -> `9.0.3`), `cross-env` (`7.0.3` -> `10.1.0`); + - adjusted SCSS override to keep build compatibility with Bootstrap 5.3 variable changes. +- Dependency refresh batch 2: + - updated `react-slick` (`0.30.3` -> `0.31.0`), `showdown` (`1.9.1` -> `2.1.0`), and `uuid` (`8.3.2` -> `13.0.0`); + - fixed `redux-thunk` import usage for v3 named export (`ReduxThunk` -> `thunk`) to restore production build compatibility. +- Dependency refresh batch 3: + - updated form/data libs: `formik` (`1.5.8` -> `2.4.9`), `yup` (`0.32.11` -> `1.7.1`), `react-toastify` (`6.2.0` -> `11.0.5`), `react-select` (`3.2.0` -> `5.10.2`), `filesize` (`6.4.0` -> `11.0.13`); + - updated utility libs: `formsy-react` (`0.19.5` -> `2.3.2`) and `styled-components` (`5.3.11` -> `6.3.11`). +- Dependency refresh batch 4: + - updated UI/demo libs: `react-dropzone` (`11.7.1` -> `15.0.0`), `react-autosize-textarea` (`5.0.1` -> `7.1.0`), `react-syntax-highlighter` (`13.5.3` -> `16.1.0`), `react-animate-height` (`2.1.2` -> `3.2.3`), `rc-slider` (`9.7.5` -> `11.1.9`), `react-bootstrap-table-next` (`3.3.5` -> `4.0.3`), `react-bootstrap-table2-toolkit` (`1.4.2` -> `2.1.3`); + - migrated removed `rc-slider` tooltip helper API usage to v11-compatible slider usage in documentation/forms pages. +- Dependency refresh batch 5: + - updated chart libs: `highcharts` (`10.3.3` -> `12.5.0`), `apexcharts` (`3.54.1` -> `5.6.0`), `react-apexcharts` (`1.9.0` -> `2.0.1`); + - updated calendar stack to `@fullcalendar/*` `6.1.20` and adapted calendar config for v6 (`initialView`, list view target `listWeek`, removed deprecated plugin CSS imports). +- Dependency refresh batch 6: + - removed React-16/17-locked dependencies: `connected-react-router`, `react-bootstrap-table-next`, `react-bootstrap-table2-toolkit`, `react-bootstrap-table2-paginator`, `react-google-maps`, `react-images`, `react-maskedinput`, `react-mde`, `react-shuffle`, `react-sortable-hoc`, `react-sortable-tree`, `react-table`; + - replaced dependency-driven implementations with local/runtime-safe equivalents: + - custom navigation action boundary + shared history singleton (no `connected-react-router`); + - native/Reactstrap tables in users/management/dynamic pages (search + pagination preserved); + - iframe-based map component for maps/timeline pages; + - modal-based gallery image viewer; + - local masked input and auto-resize textarea components; + - local markdown editor (write/preview with Showdown); + - native drag-and-drop sortable list implementation for list groups demo; + - removed stale third-party CSS imports tied to deleted packages. +- Dependency refresh batch 7: + - migrated router runtime to `react-router-dom` v7 (`Routes`/`Route`/`Navigate`) across app shell, main layout, and documentation layout; + - removed deprecated router dependencies: `react-router`, `history`, `react-router-hash-link`; + - replaced route guard implementation (`AdminRoute`, `UserRoute`, `AuthRoute`) with v7-compatible wrapper components and refreshed route smoke tests; + - introduced local `withRouter` bridge (`src/components/withRouter.js`) to keep class-component routes working during phased hooks migration; + - replaced hash-link usage in docs scrollspy with `react-router-dom` `Link`. +- Dependency refresh batch 8: + - upgraded framework/tooling stack: `react`/`react-dom` (`18.3.1` -> `19.2.4`), `eslint` (`9.39.x` -> `10.0.1`); + - upgraded chart/sortable stack: `echarts` (`4.9.0` -> `6.0.0`), `echarts-for-react` (`2.0.16` -> `3.0.6`), `react-sortablejs` (`1.5.1` -> `6.1.4`); + - removed obsolete CRA-era dependencies no longer used under Vite: `react-app-polyfill`, `react-dev-utils`, `sass-loader`; + - migrated ECharts imports to modular `echarts/core` registration compatible with ECharts 6. +- Phase 5 legacy cleanup batch: + - migrated app shell entry and docs shell from `class`/`connect`/`withRouter` to hooks (`App`, `DocumentationLayout`, `DocumentationHeader`, `DocumentationSidebar`); + - completed migration away from `react-redux` `connect(...)` HOC to hooks across app-level screens/components; + - converted all header/sidebar icon components to functional React components; + - migrated ecommerce pages/components (`Products`, `Product`, `ProductCard`) to hooks and removed router HOC usage; + - migrated ecommerce management flows (`Management`, `ProductEdit`) to hooks and `useNavigate`/`useLocation` adapter for existing product thunks; + - migrated legacy auth pages (`/pages/login`, `/pages/register`) and users form page to hooks-based implementation; + - migrated users view and rickshaw-based widgets/charts (`UsersViewItem`, `ChangesChart`, `RealtimeTraffic`, dashboard `Rickshaw`) away from `connect` classes; + - replaced sidebar `LinksGroup` HOC routing dependency with native `useLocation` hook and removed obsolete local `withRouter` bridge. +- Phase 4 state modernization: + - moved auth/users side effects to reusable service layer (`src/services/authService.js`, `src/services/usersService.js`); + - migrated users auth-domain thunks to `async/await` with safer shared error-message handling; + - consolidated registration state ownership in `auth` reducer and removed duplicated legacy `register` reducer/actions; + - cleaned users state compatibility fields (`findLoading`/`loading`, list modal/delete metadata) and removed stale empty `dashboard` reducer. +- Phase 5 progress: + - removed deprecated lifecycle methods from source components (`componentWillMount`, `componentWillReceiveProps`); + - migrated users route-level pages (`UsersListPage`, `UsersViewPage`, `ChangePasswordFormPage`) from class components to hooks-based functional components; + - migrated auth route-level pages (`Login`, `Register`, `Forgot`, `Reset`, `Verify`) from class components to hooks-based functional components; + - migrated app shell components (`Layout`, `Header`, `Sidebar`) from class components to hooks-based functional components. +- Phase 6 quality hardening: + - introduced repository lint gate with ESLint flat config and `npm run lint` command; + - added GitHub Actions CI workflow (`.github/workflows/ci.yml`) for `npm ci`, `npm run lint`, `npm run build`, and `npm test`. +- Dependency cleanup and release docs: + - removed unused direct dependencies from runtime manifest: `buffer`, `https-browserify`, `jsonwebtoken`, `md5`, `rc-hammerjs`; + - removed `yarn.lock` to keep npm as the single package manager lock source; + - added migration and release docs (`docs/migration-notes.md`, `docs/adr/0001-routing-and-runtime-baseline.md`, `docs/release-checklist.md`, `docs/rollback-recovery.md`). +- Runtime/tooling compatibility: + - aligned Node engine range to `^20.19.0 || >=22.12.0` to support current Node 22 environments and Vite 7 requirements. + - React 19 is active; some legacy demo dependencies still declare React 18 peer ranges, so install currently uses npm peer override behavior (`npm install --force`) until those packages are replaced. + +## [8.3.1] - 26.11.2024 +- Update dependencies + +## [8.3.0] - 05/09/2024 + +- Added react-scripts version 5 along with webpack version 5 support. +- Added support for node.js version > 20 +- Removed old webpack configs. +- Removed unnecessary dev dependencies. +- Replaced deprecated glyphicons-halflings icon library with bootstrap-icons + +## [8.2.3] - 21.12.2023 +- Update dependencies + +## [8.2.2] - 18.05.2023 +- Update dependencies +- Update react version +- Corrected minor errors + +## [8.2.1] - 01.07.2022 +- UI Adjust + +## [8.2.0] - 17.06.2022 +- Updated Bootstrap/Reactstrap +- Add theme swicther +- Updated dependencies + +## [8.1.6] - 13.05.2021 +- Updated blocks position in Typography, Form Validations, LB Packages, +- Products Grid: Customize dropdowns in E-Commerce +- Alerts: Customize alerts notifications +- Dashboard: Fixed position pop-up alert in header +- Add function LoginOut in Login Page, +- Following dependencies and devDependencies was updated to the recent versions +###Dependencies: + "@fullcalendar/core": "5.3.0" -> "5.6.0", + "@fullcalendar/daygrid": "5.3.0" -> "5.6.0", + "@fullcalendar/interaction": "5.3.0" -> "5.6.0", + "@fullcalendar/list": "5.3.0" -> "5.6.0", + "@fullcalendar/react": "5.3.0" -> "5.6.0", + "@fullcalendar/timegrid": "5.3.0" -> "5.6.0", + "axios": "^0.19.2" -> "^0.21.1", + "bootstrap": "4.5.0" -> "4.6.0",` + "classnames": "^2.2.6" -> "^2.3.1", + "connected-react-router": "^6.8.0" -> "6.9.1", + "draft-js": "^0.11.6" -> "^0.11.7", + "echarts-for-react": "^2.0.16", + "file-saver": "^2.0.2" -> "^2.0.5", + "filesize": "^6.1.0" -> "^6.3.0", + "md5": "^2.2.1" -> "^2.3.0", + "rc-slider": "^9.5.1" -> "^9.7.2", + "react": "^16.13.1" -> "^16.14.0", + "react-animate-height": "^2.0.21" -> "^2.0.23", + "react-animated-number": "^0.4.4", + "react-apexcharts": "^1.3.7" -> "^1.3.9", + "react-app-polyfill": "^0.1.3" -> "^0.2.0", + "react-dev-utils": "^6.0.5" -> "^6.1.1", + "react-dom": "^16.5.2" -> "^16.14.0", + "react-draft-wysiwyg": "1.10.12" -> "1.14.7", + "react-dropzone": "^11.2.0" -> "^11.3.2", + "react-mde": "^11.0.0" -> "^11.5.0", + "react-redux": "7.2.0" -> "7.2.4", + "react-router-hash-link": "^2.1.0" -> "^2.4.1", + "react-scrollspy": "^3.4.2" -> "^3.4.3", + "react-select": "^3.1.0" -> "^3.2.0", + "react-slick": "^0.26.1" -> "^0.28.1", + "react-sortable-tree": "^2.7.1" -> "^2.8.0", + "react-toastify": "^6.0.8" -> "^6.2.0", + "react-transition-group": "^4.4.1", + "redux": "^4.0.5" -> "^4.1.0", + "sortablejs": "1.10.2" -> "1.13.0", + "styled-components": "^5.1.1" -> "^5.3.0", + "uuid": "^8.3.0" -> "^8.3.2", + "yup": "^0.29.1" -> "^0.32.9" + + ###DevDependencies: + "@babel/core": "7.4.4" -> "7.14.0", + "@babel/plugin-proposal-class-properties": "7.4.4" -> "7.13.0", + "@babel/plugin-proposal-optional-chaining": "7.2.0" -> "^7.13.12", + "@svgr/webpack": "4.2.0" ->"4.3.3", + "babel-core": "7.0.0-bridge.0", + "babel-eslint": "10.0.1" -> "10.1.0", + "babel-jest": "24.8.0" -> "24.9.0", + "babel-loader": "8.0.5" -> "8.2.2", + "babel-plugin-named-asset-import": "1.0.0-next.103" -> "1.0.0-next.154", + "babel-preset-react-app": "9.0.0" -> "9.1.2", + "bfj": "6.1.1" -> "6.1.2", + "case-sensitive-paths-webpack-plugin": "2.2.0" -> "2.4.0", + "cross-env": "^7.0.2" -> "^7.0.3", + "dotenv": "8.5.1" -> "8.5.1", + "eslint-plugin-flowtype": "3.8.1" -> "3.13.0", + "eslint-plugin-import": "2.17.2" -> "2.22.1", + "eslint-plugin-jsx-a11y": "6.2.1" -> "6.4.1", + "eslint-plugin-react": "7.13.0" -> "7.23.2", + "eslint-plugin-react-hooks": "1.6.0" -> "1.7.0", + "jest": "24.8.0" -> "24.9.0", + "jest-pnp-resolver": "1.2.1" -> "1.2.2", + "jest-resolve": "24.8.0" -> "24.9.0", + "mini-css-extract-plugin": "0.6.0" -> "0.12.0", + "node-sass": "4.14.0" -> "4.14.1", + "optimize-css-assets-webpack-plugin": "5.0.1" -> "5.0.4", + "pnp-webpack-plugin": "1.4.3" -> "1.6.4", + "postcss-flexbugs-fixes": "4.1.0" -> "4.2.1", + "postcss-preset-env": "6.6.0" -> "6.7.0", + "postcss-safe-parser": "4.0.1" -> "4.0.2", + "resolve": "1.10.1" -> "1.20.0", + "sass-loader": "7.1.0" -> "7.3.1", + "style-loader": "0.23.0" -> "0.23.1", + "terser-webpack-plugin": "1.2.3" -> "1.4.4", + "webpack": "4.31.0" -> "4.44.0", + "webpack-dev-server": "3.3.1" -> "3.11.2", + "webpack-manifest-plugin": "2.0.4" -> "2.2.0", + +## [8.1.5] + +- Updated documentation + +## [8.1.4] + +### Updated + +- Updated sidebar and header icons +- Updated sidebar and header layout + +## [8.1.3] + +### Fixed + +- Change badge text in the sidebar +- Change alert text in the usermanager/ecommerce + +## [8.1.2] + +### Fixed bugs and layout issues + +- Add new images to Documentation and LB Package pages +- Change progress bars bg color +- Update main colors +- Badges and buttons: fix margins, change font colors +- Dropdowns: change paddings +- Header component: change dropdown hover states +- Charts: fix charts issues +- Fix adaptive and layout issues on pages +- Charts: fix label colors, apex dropdown text + +## [8.1.1] + +- Added link to flatlogic on login page + +## [8.1.0] + +- Updated all dependencies, cleaned up dependency tree + +## [8.0.5] + +- Updated fullcalendar package to v5.3.0 + +## [8.0.4] + +- Add animation to alert in header +- Fix animated classes +- Fix colors in notifications, chart dropdown menu, tables + +## [8.0.3] + +- Updated line-awesome package + +## [8.0.2] + +### Fixed bug + +- Fixed sidebar caret for Safari + +## [8.0.1] + +### New Features + +- Added sample formik widget + +## [8.0.0] + +### New Features + +- Added brand new Backend +- New tab to mange users +- Social login +- Manage users functionality +- Update password route +- Reset password route +- Upload avatar +- Refactored architecture + +## [7.2.0] + +### New Features + +- Added re-usable breadcrumbs component + +## [7.1.2] + +### Fixed + +- Fixed small calendar events + +## [7.1.1] + +### Fixed + +- Added css fixes + +## [7.1.0] + +### New Features + +- New color scheme + +## [7.0.1] + +### Fixed + +- Fix bugs and css improvements + +## [7.0.0] + +### Updated + +- Removed Jquery from core layout + +### New Features + +- New charts + +## [6.1.0] + +### New Features + +- Make an api stub for non-backend mode diff --git a/commonGuide.md b/commonGuide.md new file mode 100644 index 0000000..d151212 --- /dev/null +++ b/commonGuide.md @@ -0,0 +1,2568 @@ +# Light Blue React + +Our React version follows latest industry best practices and uses Redux as a state manager. This version is a great choice when you want to be in control of your own codebase and decide on development approaches that are the best for your project. Webpack Module Bundler and Yarn as a package manager are under the hood. + +Below you will find some information on how to perform common tasks.
+ +## Table of Contents + +- [Updating to New Releases](#updating-to-new-releases) +- [Sending Feedback](#sending-feedback) +- [Folder Structure](#folder-structure) +- [Available Scripts](#available-scripts) + - [yarn start](#yarn-start) + - [yarn test](#yarn-test) + - [yarn build](#yarn-run-build) + - [yarn eject](#yarn-run-eject) +- [Supported Browsers](#supported-browsers) +- [Supported Language Features](#supported-language-features) +- [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) +- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) +- [Debugging in the Editor](#debugging-in-the-editor) +- [Formatting Code Automatically](#formatting-code-automatically) +- [Changing the Page ``](#changing-the-page-title) +- [Installing a Dependency](#installing-a-dependency) +- [Importing a Component](#importing-a-component) +- [Code Splitting](#code-splitting) +- [Adding a Stylesheet](#adding-a-stylesheet) +- [Adding a CSS Modules Stylesheet](#adding-a-css-modules-stylesheet) +- [Adding a Sass Stylesheet](#adding-a-sass-stylesheet) +- [Post-Processing CSS](#post-processing-css) +- [Adding Images, Fonts, and Files](#adding-images-fonts-and-files) +- [Adding SVGs](#adding-svgs) +- [Using the `public` Folder](#using-the-public-folder) + - [Changing the HTML](#changing-the-html) + - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system) + - [When to Use the `public` Folder](#when-to-use-the-public-folder) +- [Using Global Variables](#using-global-variables) +- [Adding Bootstrap](#adding-bootstrap) + - [Using a Custom Theme](#using-a-custom-theme) +- [Adding Flow](#adding-flow) +- [Adding Relay](#adding-relay) +- [Adding a Router](#adding-a-router) +- [Adding Custom Environment Variables](#adding-custom-environment-variables) + - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html) + - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) + - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env) +- [Can I Use Decorators?](#can-i-use-decorators) +- [Fetching Data with AJAX Requests](#fetching-data-with-ajax-requests) +- [Integrating with an API Backend](#integrating-with-an-api-backend) + - [Node](#node) + - [Ruby on Rails](#ruby-on-rails) +- [Proxying API Requests in Development](#proxying-api-requests-in-development) + - ["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy) + - [Configuring the Proxy Manually](#configuring-the-proxy-manually) +- [Using HTTPS in Development](#using-https-in-development) +- [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) +- [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files) +- [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page) +- [Running Tests](#running-tests) + - [Filename Conventions](#filename-conventions) + - [Command Line Interface](#command-line-interface) + - [Version Control Integration](#version-control-integration) + - [Writing Tests](#writing-tests) + - [Testing Components](#testing-components) + - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) + - [Initializing Test Environment](#initializing-test-environment) + - [Focusing and Excluding Tests](#focusing-and-excluding-tests) + - [Coverage Reporting](#coverage-reporting) + - [Continuous Integration](#continuous-integration) + - [Disabling jsdom](#disabling-jsdom) + - [Snapshot Testing](#snapshot-testing) + - [Editor Integration](#editor-integration) +- [Debugging Tests](#debugging-tests) + - [Debugging Tests in Chrome](#debugging-tests-in-chrome) + - [Debugging Tests in Visual Studio Code](#debugging-tests-in-visual-studio-code) +- [Developing Components in Isolation](#developing-components-in-isolation) + - [Getting Started with Storybook](#getting-started-with-storybook) + - [Getting Started with Styleguidist](#getting-started-with-styleguidist) +- [Publishing Components to yarn](#publishing-components-to-yarn) +- [Making a Progressive Web App](#making-a-progressive-web-app) + - [Why Opt-in?](#why-opt-in) + - [Offline-First Considerations](#offline-first-considerations) + - [Progressive Web App Metadata](#progressive-web-app-metadata) +- [Analyzing the Bundle Size](#analyzing-the-bundle-size) +- [Deployment](#deployment) + - [Static Server](#static-server) + - [Other Solutions](#other-solutions) + - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) + - [Building for Relative Paths](#building-for-relative-paths) + - [Customizing Environment Variables for Arbitrary Build Environments](#customizing-environment-variables-for-arbitrary-build-environments) + - [Azure](#azure) + - [Firebase](#firebase) + - [GitHub Pages](#github-pages) + - [Heroku](#heroku) + - [Netlify](#netlify) + - [Now](#now) + - [S3 and CloudFront](#s3-and-cloudfront) + - [Surge](#surge) +- [Advanced Configuration](#advanced-configuration) +- [Troubleshooting](#troubleshooting-1) + - [`yarn start` doesn’t detect changes](#yarn-start-doesnt-detect-changes) + - [`yarn test` hangs or crashes on macOS Sierra](#yarn-test-hangs-or-crashes-on-macos-sierra) + - [`yarn build` exits too early](#yarn-run-build-exits-too-early) + - [`yarn build` fails on Heroku](#yarn-run-build-fails-on-heroku) + - [`yarn build` fails to minify](#yarn-run-build-fails-to-minify) + - [Moment.js locales are missing](#momentjs-locales-are-missing) +- [Alternatives to Ejecting](#alternatives-to-ejecting) +- [Something Missing?](#something-missing) + +## Updating to New Releases + +Create React App is divided into two packages: + +- `create-react-app` is a global command-line utility that you use to create new projects. +- `react-scripts` is a development dependency in the generated projects (including this one). + +You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`. + +When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. + +To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. + +In most cases bumping the `react-scripts` version in `package.json` and running `yarn install` (or `yarn install`) in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. + +We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. + +## Sending Feedback + +We are always open to [your feedback](https://github.com/facebook/create-react-app/issues). + +## Folder Structure + +After creation, your project should look like this: + +``` +my-app/ + README.md + node_modules/ + package.json + public/ + index.html + favicon.ico + src/ + App.css + App.js + App.test.js + index.css + index.js + logo.svg +``` + +For the project to build, **these files must exist with exact filenames**: + +- `public/index.html` is the page template; +- `src/index.js` is the JavaScript entry point. + +You can delete or rename the other files. + +You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.<br> +You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them. + +Only files inside `public` can be used from `public/index.html`.<br> +Read instructions below for using assets from JavaScript and HTML. + +You can, however, create more top-level directories.<br> +They will not be included in the production build so you can use them for things like documentation. + +If you have Git installed and your project is not part of a larger repository, then a new repository will be initialized resulting in an additional `.git/` top-level directory. + +## Available Scripts + +In the project directory, you can run: + +### `yarn start` + +Runs the app in the development mode.<br> +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.<br> +You will also see any lint errors in the console. + +### `yarn test` + +Launches the test runner in the interactive watch mode.<br> +See the section about [running tests](#running-tests) for more information. + +### `yarn build` + +Builds the app for production to the `build` folder.<br> +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.<br> +Your app is ready to be deployed! + +See the section about [deployment](#deployment) for more information. + +### `yarn eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Supported Browsers + +By default, the generated project supports all modern browsers.<br> +Support for Internet Explorer 9, 10, and 11 requires [polyfills](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md). + +### Supported Language Features + +This project supports a superset of the latest JavaScript standard.<br> +In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports: + +- [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016). +- [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017). +- [Object Rest/Spread Properties](https://github.com/tc39/proposal-object-rest-spread) (ES2018). +- [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal) +- [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal). +- [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flow.org/) syntax. + +Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-). + +While we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future. + +Note that **this project includes no [polyfills](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md)** by default. + +If you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are [including the appropriate polyfills manually](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md), or that the browsers you are targeting already support them. + +## Syntax Highlighting in the Editor + +To configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered. + +## Displaying Lint Output in the Editor + +> Note: this feature is available with `react-scripts@0.2.0` and higher.<br> +> It also only works with yarn 3 or higher. + +Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. + +They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. + +You would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root: + +```js +{ + "extends": "react-app" +} +``` + +Now your editor should report the linting warnings. + +Note that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes. + +If you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules. + +## Debugging in the Editor + +**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).** + +Visual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools. + +### Visual Studio Code + +You would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed. + +Then add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory. + +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Chrome", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000", + "webRoot": "${workspaceRoot}/src", + "sourceMapPathOverrides": { + "webpack:///src/*": "${webRoot}/*" + } + } + ] +} +``` + +> Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `yarn start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. + +Having problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting). + +### WebStorm + +You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjkyarnjagkdomcpobmllji) Chrome extension installed. + +In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration. + +> Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `yarn start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm. + +The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine. + +## Formatting Code Automatically + +Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). + +To format our code whenever we make a commit in git, we need to install the following dependencies: + +```sh +yarn install --save husky lint-staged prettier +``` + +Alternatively you may use `yarn`: + +```sh +yarn add husky lint-staged prettier +``` + +- `husky` makes it easy to use githooks as if they are yarn scripts. +- `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8). +- `prettier` is the JavaScript formatter we will run before commits. + +Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root. + +Add the following field to the `package.json` section: + +```diff ++ "husky": { ++ "hooks": { ++ "pre-commit": "lint-staged" ++ } ++ } +``` + +Next we add a 'lint-staged' field to the `package.json`, for example: + +```diff + "dependencies": { + // ... + }, ++ "lint-staged": { ++ "src/**/*.{js,jsx,json,css}": [ ++ "prettier --single-quote --write", ++ "git add" ++ ] ++ }, + "scripts": { +``` + +Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx}"` to format your entire project for the first time. + +Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://prettier.io/docs/en/editors.html) on the Prettier GitHub page. + +## Changing the Page `<title>` + +You can find the source HTML file in the `public` folder of the generated project. You may edit the `<title>` tag in it to change the title from “React App” to anything else. + +Note that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML. + +If you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library. + +If you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files). + +## Installing a Dependency + +The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `yarn`: + +```sh +yarn install --save react-router-dom +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-router-dom +``` + +This works for any library, not just `react-router-dom`. + +## Importing a Component + +This project setup supports ES6 modules thanks to Webpack.<br> +While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. + +For example: + +### `Button.js` + +```js +import React, { Component } from 'react'; + +class Button extends Component { + render() { + // ... + } +} + +export default Button; // Don’t forget to use export default! +``` + +### `DangerButton.js` + +```js +import React, { Component } from 'react'; +import Button from './Button'; // Import a component from another file + +class DangerButton extends Component { + render() { + return <Button color="red" />; + } +} + +export default DangerButton; +``` + +Be aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes. + +We suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`. + +Named exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like. + +Learn more about ES6 modules: + +- [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281) +- [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html) +- [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules) + +## Code Splitting + +Instead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand. + +This project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module. + +Here is an example: + +### `moduleA.js` + +```js +const moduleA = 'Hello'; + +export { moduleA }; +``` + +### `App.js` + +```js +import React, { Component } from 'react'; + +class App extends Component { + handleClick = () => { + import('./moduleA') + .then(({ moduleA }) => { + // Use moduleA + }) + .catch(err => { + // Handle failure + }); + }; + + render() { + return ( + <div> + <button onClick={this.handleClick}>Load</button> + </div> + ); + } +} + +export default App; +``` + +This will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button. + +You can also use it with `async` / `await` syntax if you prefer it. + +### With React Router + +If you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app). + +Also check out the [Code Splitting](https://reactjs.org/docs/code-splitting.html) section in React documentation. + +## Adding a Stylesheet + +This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**: + +### `Button.css` + +```css +.Button { + padding: 20px; +} +``` + +### `Button.js` + +```js +import React, { Component } from 'react'; +import './Button.css'; // Tell Webpack that Button.js uses these styles + +class Button extends Component { + render() { + // You can use them as regular CSS styles + return <div className="Button" />; + } +} +``` + +**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-blog/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack. + +In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output. + +If you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool. + +## Adding a CSS Modules Stylesheet + +> Note: this feature is available with `react-scripts@2.0.0` and higher. + +This project supports [CSS Modules](https://github.com/css-modules/css-modules) alongside regular stylesheets using the `[name].module.css` file naming convention. CSS Modules allows the scoping of CSS by automatically creating a unique classname of the format `[filename]\_[classname]\_\_[hash]`. + +> **Tip:** Should you want to preprocess a stylesheet with Sass then make sure to [follow the installation instructions](#adding-a-sass-stylesheet) and then change the stylesheet file extension as follows: `[name].module.scss` or `[name].module.sass`. + +CSS Modules let you use the same CSS class name in different files without worrying about naming clashes. Learn more about CSS Modules [here](https://css-tricks.com/css-modules-part-1-need/). + +### `Button.module.css` + +```css +.error { + background-color: red; +} +``` + +### `another-stylesheet.css` + +```css +.error { + color: red; +} +``` + +### `Button.js` + +```js +import React, { Component } from 'react'; +import styles from './Button.module.css'; // Import css modules stylesheet as styles +import './another-stylesheet.css'; // Import regular stylesheet + +class Button extends Component { + render() { + // reference as a js object + return <button className={styles.error}>Error Button</button>; + } +} +``` + +### Result + +No clashes from other `.error` class names + +```html +<!-- This button has red background but not red text --> +<button class="Button_error_ax7yz"></div> +``` + +**This is an optional feature.** Regular `<link>` stylesheets and CSS files are fully supported. CSS Modules are turned on for files ending with the `.module.css` extension. + +## Adding a Sass Stylesheet + +> Note: this feature is available with `react-scripts@2.0.0` and higher. + +Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)). + +Following this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable. + +To use Sass, first install `node-sass`: + +```bash +$ yarn install node-sass --save +$ # or +$ yarn add node-sass +``` + +Now you can rename `src/App.css` to `src/App.scss` and update `src/App.js` to import `src/App.scss`. +This file and any other file will be automatically compiled if imported with the extension `.scss` or `.sass`. + +To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions. + +This will allow you to do imports like + +```scss +@import 'styles/_colors.scss'; // assuming a styles directory under src/ +@import '~nprogress/nprogress'; // importing a css file from the nprogress node module +``` + +> **Tip:** You can opt into using this feature with [CSS modules](#adding-a-css-modules-stylesheet) too! + +> **Note:** You must prefix imports from `node_modules` with `~` as displayed above. + +> **Note:** If you're using Flow, add the following to your `.flowconfig` so it'll recognize the `.sass` or `.scss` imports. + +``` +[options] +module.file_ext=.sass +module.file_ext=.scss +``` + +## Post-Processing CSS + +This project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it. + +Support for new CSS features like the [`all` property](https://developer.mozilla.org/en-US/docs/Web/CSS/all), [`break` properties](https://www.w3.org/TR/css-break-3/#breaking-controls), [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables), and [media query ranges](https://www.w3.org/TR/mediaqueries-4/#range-context) are automatically polyfilled to add support for older browsers. + +You can customize your target support browsers by adjusting the `browserslist` key in `package.json` according to the [Browserslist specification](https://github.com/browserslist/browserslist#readme). + +For example, this: + +```css +.App { + display: flex; + flex-direction: row; + align-items: center; +} +``` + +becomes this: + +```css +.App { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} +``` + +If you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling). + +[CSS Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout) prefixing is disabled by default, but it will **not** strip manual prefixing. +If you'd like to opt-in to CSS Grid prefixing, [first familiarize yourself about its limitations](https://github.com/postcss/autoprefixer#does-autoprefixer-polyfill-grid-layout-for-ie).<br> +To enable CSS Grid prefixing, add `/* autoprefixer grid: on */` to the top of your CSS file. + +## Adding Images, Fonts, and Files + +With Webpack, using static assets like images and fonts works similarly to CSS. + +You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. + +To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebook/create-react-app/issues/1153). + +Here is an example: + +```js +import React from 'react'; +import logo from './logo.png'; // Tell Webpack this JS file uses this image + +console.log(logo); // /logo.84287d09.png + +function Header() { + // Import result is the URL of your image + return <img src={logo} alt="Logo" />; +} + +export default Header; +``` + +This ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths. + +This works in CSS too: + +```css +.Logo { + background-image: url(./logo.png); +} +``` + +Webpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, just like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets. + +Please be advised that this is also a custom feature of Webpack. + +**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br> +An alternative way of handling static assets is described in the next section. + +### Adding SVGs + +> Note: this feature is available with `react-scripts@2.0.0` and higher. + +One way to add SVG files was described in the section above. You can also import SVGs directly as React components. You can use either of the two approaches. In your code it would look like this: + +```js +import { ReactComponent as Logo } from './logo.svg'; +const App = () => ( + <div> + {/* Logo is an actual React component */} + <Logo /> + </div> +); +``` + +This is handy if you don't want to load SVG as a separate file. Don't forget the curly braces in the import! The `ReactComponent` import name is special and tells Create React App that you want a React component that renders an SVG, rather than its filename. + +## Using the `public` Folder + +> Note: this feature is available with `react-scripts@0.5.0` and higher. + +### Changing the HTML + +The `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title). +The `<script>` tag with the compiled code will be added to it automatically during the build process. + +### Adding Assets Outside of the Module System + +You can also add other assets to the `public` folder. + +Note that we normally encourage you to `import` assets in JavaScript files instead. +For example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files). +This mechanism provides a number of benefits: + +- Scripts and stylesheets get minified and bundled together to avoid extra network requests. +- Missing files cause compilation errors instead of 404 errors for your users. +- Result filenames include content hashes so you don’t need to worry about browsers caching their old versions. + +However there is an **escape hatch** that you can use to add an asset outside of the module system. + +If you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`. + +Inside `index.html`, you can use it like this: + +```html +<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> +``` + +Only files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build. + +When you run `yarn build`, Create React App will substitute `%PUBLIC_URL%` with a correct absolute path so your project works even if you use client-side routing or host it at a non-root URL. + +In JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes: + +```js +render() { + // Note: this is an escape hatch and should be used sparingly! + // Normally we recommend using `import` for getting asset URLs + // as described in “Adding Images and Fonts” above this section. + return <img src={process.env.PUBLIC_URL + '/img/logo.png'} />; +} +``` + +Keep in mind the downsides of this approach: + +- None of the files in `public` folder get post-processed or minified. +- Missing files will not be called at compilation time, and will cause 404 errors for your users. +- Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change. + +### When to Use the `public` Folder + +Normally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript. +The `public` folder is useful as a workaround for a number of less common cases: + +- You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest). +- You have thousands of images and need to dynamically reference their paths. +- You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code. +- Some library may be incompatible with Webpack and you have no other option but to include it as a `<script>` tag. + +Note that if you add a `<script>` that declares global variables, you also need to read the next section on using them. + +## Using Global Variables + +When you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable. + +You can avoid this by reading the global variable explicitly from the `window` object, for example: + +```js +const $ = window.$; +``` + +This makes it obvious you are using a global variable intentionally rather than because of a typo. + +Alternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it. + +## Adding Bootstrap + +You don’t have to use [reactstrap](https://reactstrap.github.io/) together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps: + +Install reactstrap and Bootstrap from yarn. reactstrap does not include Bootstrap CSS so this needs to be installed as well: + +```sh +yarn install --save reactstrap bootstrap@4 +``` + +Alternatively you may use `yarn`: + +```sh +yarn add bootstrap@4 reactstrap +``` + +Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your `src/index.js` file: + +```js +import 'bootstrap/dist/css/bootstrap.css'; +// Put any other imports below so that CSS from your +// components takes precedence over default styles. +``` + +Import required reactstrap components within `src/App.js` file or your custom component files: + +```js +import { Button } from 'reactstrap'; +``` + +Now you are ready to use the imported reactstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/zx6658/d9f128cd57ca69e583ea2b5fea074238/raw/a56701c142d0c622eb6c20a457fbc01d708cb485/App.js) redone using reactstrap. + +### Using a Custom Theme + +> Note: this feature is available with `react-scripts@2.0.0` and higher. + +Sometimes you might need to tweak the visual styles of Bootstrap (or equivalent package).<br> +As of `react-scripts@2.0.0` you can import `.scss` files. This makes it possible to use a package's built-in Sass variables for global style preferences. + +To customize Bootstrap, create a file called `src/custom.scss` (or similar) and import the Bootstrap source stylesheet. Add any overrides _before_ the imported file(s). You can reference [Bootstrap's documentation](http://getbootstrap.com/docs/4.1/getting-started/theming/#css-variables) for the names of the available variables. + +```scss +// Override default variables before the import +$body-bg: #000; + +// Import Bootstrap and its default variables +@import '~bootstrap/scss/bootstrap.scss'; +``` + +> **Note:** You must prefix imports from `node_modules` with `~` as displayed above. + +Finally, import the newly created `.scss` file instead of the default Bootstrap `.css` in the beginning of your `src/index.js` file, for example: + +```javascript +import './custom.scss'; +``` + +## Adding Flow + +Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept. + +Recent versions of [Flow](https://flow.org/) work with Create React App projects out of the box. + +To add Flow to a Create React App project, follow these steps: + +1. Run `yarn install --save flow-bin` (or `yarn add flow-bin`). +2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. +3. Run `yarn flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flow.org/en/docs/config/) in the root directory. +4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). + +Now you can run `yarn flow` (or `yarn flow`) to check the files for type errors. +You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience. +In the future we plan to integrate it into Create React App even more closely. + +To learn more about Flow, check out [its documentation](https://flow.org/). + +## Adding Relay + +Relay is a framework for building data-driven React applications powered by GraphQL. The current release candidate of Relay works with Create React App projects out of the box using Babel Macros. Simply set up your project as laid out in the [Relay documentation](https://facebook.github.io/relay/), then make sure you have a version of the babel plugin providing the macro. + +To add it, run: + +```sh +yarn install --save --dev babel-plugin-relay@dev +``` + +Alternatively you may use `yarn`: + +```sh +yarn upgrade babel-plugin-relay@dev +``` + +Then, wherever you use the `graphql` template tag, import the macro: + +```js +import graphql from 'babel-plugin-relay/macro'; +// instead of: +// import { graphql } from "babel-plugin-relay" + +graphql` + query UserQuery { + viewer { + id + } + } +`; +``` + +To learn more about Relay, check out [its documentation](https://facebook.github.io/relay/). + +## Adding a Router + +Create React App doesn't prescribe a specific routing solution, but [React Router](https://reacttraining.com/react-router/web/) is the most popular one. + +To add it, run: + +```sh +yarn install --save react-router-dom +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-router-dom +``` + +To try it, delete all the code in `src/App.js` and replace it with any of the examples on its website. The [Basic Example](https://reacttraining.com/react-router/web/example/basic) is a good place to get started. + +Note that [you may need to configure your production server to support client-side routing](#serving-apps-with-client-side-routing) before deploying your app. + +## Adding Custom Environment Variables + +> Note: this feature is available with `react-scripts@0.2.3` and higher. + +Your project can consume variables declared in your environment as if they were declared locally in your JS files. By +default you will have `NODE_ENV` defined for you, and any other environment variables starting with +`REACT_APP_`. + +**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them. + +> Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebook/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running. + +These environment variables will be defined for you on `process.env`. For example, having an environment +variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`. + +There is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `yarn start`, it is always equal to `'development'`, when you run `yarn test` it is always equal to `'test'`, and when you run `yarn build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production. + +These environment variables can be useful for displaying information conditionally based on where the project is +deployed or consuming sensitive data that lives outside of version control. + +First, you need to have environment variables defined. For example, let’s say you wanted to consume a secret defined +in the environment inside a `<form>`: + +```jsx +render() { + return ( + <div> + <small>You are running this application in <b>{process.env.NODE_ENV}</b> mode.</small> + <form> + <input type="hidden" defaultValue={process.env.REACT_APP_SECRET_CODE} /> + </form> + </div> + ); +} +``` + +During the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically. + +When you load the app in the browser and inspect the `<input>`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `yarn start`: + +```html +<div> + <small>You are running this application in <b>development</b> mode.</small> + <form> + <input type="hidden" value="abcdef" /> + </form> +</div> +``` + +The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this +value, we need to have it defined in the environment. This can be done using two ways: either in your shell or in +a `.env` file. Both of these ways are described in the next few sections. + +Having access to the `NODE_ENV` is also useful for performing actions conditionally: + +```js +if (process.env.NODE_ENV !== 'production') { + analytics.disable(); +} +``` + +When you compile the app with `yarn build`, the minification step will strip out this condition, and the resulting bundle will be smaller. + +### Referencing Environment Variables in the HTML + +> Note: this feature is available with `react-scripts@0.9.0` and higher. + +You can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example: + +```html +<title>%REACT_APP_WEBSITE_NAME% +``` + +Note that the caveats from the above section apply: + +- Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work. +- The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server). + +### Adding Temporary Environment Variables In Your Shell + +Defining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the +life of the shell session. + +#### Windows (cmd.exe) + +```cmd +set "REACT_APP_SECRET_CODE=abcdef" && yarn start +``` + +(Note: Quotes around the variable assignment are required to avoid a trailing whitespace.) + +#### Windows (Powershell) + +```Powershell +($env:REACT_APP_SECRET_CODE = "abcdef") -and (yarn start) +``` + +#### Linux, macOS (Bash) + +```bash +REACT_APP_SECRET_CODE=abcdef yarn start +``` + +### Adding Development Environment Variables In `.env` + +> Note: this feature is available with `react-scripts@0.5.0` and higher. + +To define permanent environment variables, create a file called `.env` in the root of your project: + +``` +REACT_APP_SECRET_CODE=abcdef +``` + +> Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid [accidentally exposing a private key on the machine that could have the same name](https://github.com/facebook/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running. + +`.env` files **should be** checked into source control (with the exclusion of `.env*.local`). + +#### What other `.env` files can be used? + +> Note: this feature is **available with `react-scripts@1.0.0` and higher**. + +- `.env`: Default. +- `.env.local`: Local overrides. **This file is loaded for all environments except test.** +- `.env.development`, `.env.test`, `.env.production`: Environment-specific settings. +- `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings. + +Files on the left have more priority than files on the right: + +- `yarn start`: `.env.development.local`, `.env.development`, `.env.local`, `.env` +- `yarn build`: `.env.production.local`, `.env.production`, `.env.local`, `.env` +- `yarn test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing) + +These variables will act as the defaults if the machine does not explicitly set them.
+Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details. + +> Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need +> these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars). + +#### Expanding Environment Variables In `.env` + +> Note: this feature is available with `react-scripts@1.1.0` and higher. + +Expand variables already on your machine for use in your `.env` file (using [dotenv-expand](https://github.com/motdotla/dotenv-expand)). + +For example, to get the environment variable `yarn_package_version`: + +``` +REACT_APP_VERSION=$yarn_package_version +# also works: +# REACT_APP_VERSION=${yarn_package_version} +``` + +Or expand variables local to the current `.env` file: + +``` +DOMAIN=www.example.com +REACT_APP_FOO=$DOMAIN/foo +REACT_APP_BAR=$DOMAIN/bar +``` + +## Can I Use Decorators? + +Some popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.
+Create React App intentionally doesn’t support decorator syntax at the moment because: + +- It is an experimental proposal and is subject to change (in fact, it has already changed once, and will change again). +- Most libraries currently support only the old version of the proposal — which will never be a standard. + +However in many cases you can rewrite decorator-based code without decorators just as fine.
+Please refer to these two threads for reference: + +- [#214](https://github.com/facebook/create-react-app/issues/214) +- [#411](https://github.com/facebook/create-react-app/issues/411) + +Create React App will add decorator support when the specification advances to a stable stage. + +## Fetching Data with AJAX Requests + +React doesn't prescribe a specific approach to data fetching, but people commonly use either a library like [axios](https://github.com/axios/axios) or the [`fetch()` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) provided by the browser. + +The global `fetch` function allows you to easily make AJAX requests. It takes in a URL as an input and returns a `Promise` that resolves to a `Response` object. You can find more information about `fetch` [here](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). + +A Promise represents the eventual result of an asynchronous operation, you can find more information about Promises [here](https://www.promisejs.org/) and [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Both axios and `fetch()` use Promises under the hood. You can also use the [`async / await`](https://davidwalsh.name/async-await) syntax to reduce the callback nesting. + +Make sure the [`fetch()` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) are available in your target audience's browsers. +For example, support in Internet Explorer requires a [polyfill](https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md). + +You can learn more about making AJAX requests from React components in [the FAQ entry on the React website](https://reactjs.org/docs/faq-ajax.html). + +## Integrating with an API Backend + +These tutorials will help you to integrate your app with an API backend running on another port, +using `fetch()` to access it. + +### Node + +Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo). + +### Ruby on Rails + +Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails). + +### API Platform (PHP and Symfony) + +[API Platform](https://api-platform.com) is a framework designed to build API-driven projects. +It allows to create hypermedia and GraphQL APIs in minutes. +It is shipped with an official Progressive Web App generator as well as a dynamic administration interface, both built for Create React App. +Check out [this tutorial](https://api-platform.com/docs/distribution). + +## Proxying API Requests in Development + +> Note: this feature is available with `react-scripts@0.2.3` and higher. + +People often serve the front-end React app from the same host and port as their backend implementation.
+For example, a production setup might look like this after the app is deployed: + +``` +/ - static server returns index.html with React app +/todos - static server returns index.html with React app +/api/todos - server handles any /api/* requests using the backend implementation +``` + +Such setup is **not** required. However, if you **do** have a setup like this, it is convenient to write requests like `fetch('/api/todos')` without worrying about redirecting them to another host or port during development. + +To tell the development server to proxy any unknown requests to your API server in development, add a `proxy` field to your `package.json`, for example: + +```js + "proxy": "http://localhost:4000", +``` + +This way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will **only** attempt to send requests without `text/html` in its `Accept` header to the proxy. + +Conveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development: + +``` +Fetch API cannot load http://localhost:4000/api/todos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. +``` + +Keep in mind that `proxy` only has effect in development (with `yarn start`), and it is up to you to ensure that URLs like `/api/todos` point to the right thing in production. You don’t have to use the `/api` prefix. Any unrecognized request without a `text/html` accept header will be redirected to the specified `proxy`. + +The `proxy` option supports HTTP, HTTPS and WebSocket connections.
+If the `proxy` option is **not** flexible enough for you, alternatively you can: + +- [Configure the proxy yourself](#configuring-the-proxy-manually) +- Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)). +- Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app. + +### "Invalid Host Header" Errors After Configuring Proxy + +When you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887). + +This shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebook/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option: + +> Invalid Host header + +To work around it, you can specify your public development host in a file called `.env.development` in the root of your project: + +``` +HOST=mypublicdevhost.com +``` + +If you restart the development server now and load the app from the specified host, it should work. + +If you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:** + +``` +# NOTE: THIS IS DANGEROUS! +# It exposes your machine to attacks from the websites you visit. +DANGEROUSLY_DISABLE_HOST_CHECK=true +``` + +We don’t recommend this approach. + +### Configuring the Proxy Manually + +> Note: this feature is available with `react-scripts@2.0.0` and higher. + +If the `proxy` option is **not** flexible enough for you, you can get direct access to the Express app instance and hook up your own proxy middleware. + +You can use this feature in conjunction with the `proxy` property in `package.json`, but it is recommended you consolidate all of your logic into `src/setupProxy.js`. + +First, install `http-proxy-middleware` using yarn or Yarn: + +```bash +$ yarn install http-proxy-middleware --save +$ # or +$ yarn add http-proxy-middleware +``` + +Next, create `src/setupProxy.js` and place the following contents in it: + +```js +const proxy = require('http-proxy-middleware'); + +module.exports = function(app) { + // ... +}; +``` + +You can now register proxies as you wish! Here's an example using the above `http-proxy-middleware`: + +```js +const proxy = require('http-proxy-middleware'); + +module.exports = function(app) { + app.use(proxy('/api', { target: 'http://localhost:5000/' })); +}; +``` + +> **Note:** You do not need to import this file anywhere. It is automatically registered when you start the development server. + +> **Note:** This file only supports Node's JavaScript syntax. Be sure to only use supported language features (i.e. no support for Flow, ES Modules, etc). + +> **Note:** Passing the path to the proxy function allows you to use globbing and/or pattern matching on the path, which is more flexible than the express route matching. + +## Using HTTPS in Development + +> Note: this feature is available with `react-scripts@0.4.0` and higher. + +You may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the "proxy" feature](#proxying-api-requests-in-development) to proxy requests to an API server when that API server is itself serving HTTPS. + +To do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `yarn start`: + +#### Windows (cmd.exe) + +```cmd +set HTTPS=true&&yarn start +``` + +(Note: the lack of whitespace is intentional.) + +#### Windows (Powershell) + +```Powershell +($env:HTTPS = "true") -and (yarn start) +``` + +#### Linux, macOS (Bash) + +```bash +HTTPS=true yarn start +``` + +Note that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page. + +## Generating Dynamic `` Tags on the Server + +Since Create React App doesn’t support server rendering, you might be wondering how to make `` tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this: + +```html + + + + + +``` + +Then, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML! + +If you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases. + +## Pre-Rendering into Static HTML Files + +If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.yarnjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. + +There are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes. + +The primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines. + +You can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319). + +## Injecting Data from the Server into the Page + +Similarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example: + +```js + + + + +``` + +Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.** + +## Running Tests + +> Note: this feature is available with `react-scripts@0.3.0` and higher.
+ +> [Read the migration guide to learn how to enable it in older projects!](https://github.com/facebook/create-react-app/blob/master/CHANGELOG.md#migrating-from-023-to-030) + +Create React App uses [Jest](https://facebook.github.io/jest/) as its test runner. To prepare for this integration, we did a [major revamp](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html) of Jest so if you heard bad things about it years ago, give it another try. + +Jest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This lets us enable fast iteration speed and prevent flakiness. + +While Jest provides browser globals such as `window` thanks to [jsdom](https://github.com/tmpvar/jsdom), they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks. + +We recommend that you use a separate tool for browser end-to-end tests if you need them. They are beyond the scope of Create React App. + +### Filename Conventions + +Jest will look for test files with any of the following popular naming conventions: + +- Files with `.js` suffix in `__tests__` folders. +- Files with `.test.js` suffix. +- Files with `.spec.js` suffix. + +The `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder. + +We recommend to put the test files (or `__tests__` folders) next to the code they are testing so that relative imports appear shorter. For example, if `App.test.js` and `App.js` are in the same folder, the test just needs to `import App from './App'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects. + +### Command Line Interface + +When you run `yarn test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `yarn start` recompiles the code. + +The watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run: + +![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif) + +### Version Control Integration + +By default, when you run `yarn test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests. + +Jest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests. + +Jest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository. + +### Writing Tests + +To create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended. + +Jest provides a built-in `expect()` global function for making assertions. A basic test could look like this: + +```js +import sum from './sum'; + +it('sums numbers', () => { + expect(sum(1, 2)).toEqual(3); + expect(sum(2, 2)).toEqual(4); +}); +``` + +All `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).
+You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](https://facebook.github.io/jest/docs/en/expect.html#tohavebeencalled) to create “spies” or mock functions. + +### Testing Components + +There is a broad spectrum of component testing techniques. They range from a “smoke test” verifying that a component renders without throwing, to shallow rendering and testing some of the output, to full rendering and testing component lifecycle and state changes. + +Different projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components: + +```js +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); +``` + +This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot of value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`. + +When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. + +If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: + +```sh +yarn install --save enzyme enzyme-adapter-react-16 react-test-renderer +``` + +Alternatively you may use `yarn`: + +```sh +yarn add enzyme enzyme-adapter-react-16 react-test-renderer +``` + +As of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.) + +The adapter will also need to be configured in your [global setup file](#initializing-test-environment): + +#### `src/setupTests.js` + +```js +import { configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; + +configure({ adapter: new Adapter() }); +``` + +> Note: Keep in mind that if you decide to "eject" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it. [Read here](#initializing-test-environment) to learn how to add this after ejecting. + +Now you can write a smoke test with it: + +```js +import React from 'react'; +import { shallow } from 'enzyme'; +import App from './App'; + +it('renders without crashing', () => { + shallow(); +}); +``` + +Unlike the previous smoke test using `ReactDOM.render()`, this test only renders `` and doesn’t go deeper. For example, even if `` itself renders a ` + + + + diff --git a/public/demo/grid/default.php b/public/demo/grid/default.php new file mode 100644 index 0000000..c42f9d3 --- /dev/null +++ b/public/demo/grid/default.php @@ -0,0 +1,4 @@ + +

Simulating latency with tiny php block on the server-side.

+

A timestamp this widget was created: Apr 24, 19:07:07

+

A timestamp this widget was updated:

\ No newline at end of file diff --git a/public/demo/grid/news.php b/public/demo/grid/news.php new file mode 100644 index 0000000..5ea9f91 --- /dev/null +++ b/public/demo/grid/news.php @@ -0,0 +1,55 @@ + +
    +
  • + + + +
    +
    Just now! Check update time
    +

    + Check this news item timestamp. There is a small server part that generates current timestamp so it + would be easier for you to see ajax widgets in action +

    + +
    +
  • +
  • + + + +
    +
    First Human Colony on Mars
    +

    + First 700 people will take part in building first human settlement outside of Earth. + That's awesome, right? +

    + +
    +
  • +
  • + + + +
    +
    Light Blue reached $300
    +

    + Light Blue Inc. shares just hit $300 price. "This was inevitable. It should + have happen sooner or later" - says NYSE expert. +

    + +
    +
  • +
  • + + + +
    +
    No more spying
    +

    + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor + incididunt ut labore et dolore magna aliqua. +

    + +
    +
  • +
diff --git a/public/demo/grid/shares.php b/public/demo/grid/shares.php new file mode 100644 index 0000000..8cab92a --- /dev/null +++ b/public/demo/grid/shares.php @@ -0,0 +1,53 @@ + + diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000..01303cc Binary files /dev/null and b/public/favicon.png differ diff --git a/public/images/people/a1.jpg b/public/images/people/a1.jpg new file mode 100644 index 0000000..cd178e1 Binary files /dev/null and b/public/images/people/a1.jpg differ diff --git a/public/images/people/a2.jpg b/public/images/people/a2.jpg new file mode 100644 index 0000000..e6175c2 Binary files /dev/null and b/public/images/people/a2.jpg differ diff --git a/public/images/people/a3.jpg b/public/images/people/a3.jpg new file mode 100644 index 0000000..06a95ca Binary files /dev/null and b/public/images/people/a3.jpg differ diff --git a/public/images/people/a4.jpg b/public/images/people/a4.jpg new file mode 100644 index 0000000..41f4f1c Binary files /dev/null and b/public/images/people/a4.jpg differ diff --git a/public/images/people/a5.jpg b/public/images/people/a5.jpg new file mode 100644 index 0000000..cb46523 Binary files /dev/null and b/public/images/people/a5.jpg differ diff --git a/public/images/people/a6.jpg b/public/images/people/a6.jpg new file mode 100644 index 0000000..a49b350 Binary files /dev/null and b/public/images/people/a6.jpg differ diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..21ff039 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "Light Blue 5.0.0 - Isomorphic React Dashboard", + "name": "Create React App Sample", + "icons": [ + { + "src": "/favicon.png", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/src/actions/README.md b/src/actions/README.md new file mode 100644 index 0000000..be6bb8f --- /dev/null +++ b/src/actions/README.md @@ -0,0 +1,3 @@ +# Action creators + +Action Creators should go there diff --git a/src/actions/alerts.js b/src/actions/alerts.js new file mode 100644 index 0000000..6398703 --- /dev/null +++ b/src/actions/alerts.js @@ -0,0 +1,8 @@ +export const DISMISS_ALERT = 'DISMISS_ALERT'; + +export function dismissAlert(id) { + return { + type: DISMISS_ALERT, + id, + }; +} diff --git a/src/actions/analytics.js b/src/actions/analytics.js new file mode 100644 index 0000000..45189a4 --- /dev/null +++ b/src/actions/analytics.js @@ -0,0 +1,44 @@ +import axios from 'axios'; +import mock from '../pages/analytics/mock'; +import config from '../config'; + +export const RECEIVED_DATA_SUCCESS = 'RECEIVED_DATA_SUCCESS'; +export const RECEIVING_DATA = 'RECEIVING_DATA'; + +export function receiveDataRequest() { + return (dispatch) => { + // We check if app runs with backend mode + if (!config.isBackend) { + dispatch(receivingData()); + new Promise((resolve) => { + resolve(mock.backendData) + }).then(data => { + dispatch(receiveDataSuccess(mock.backendData)); + }) + } + + else { + dispatch(receivingData()); + axios.get('/analytics').then(res => { + dispatch(receiveDataSuccess(res.data)); + }) + } + }; +} + +export function receiveDataSuccess(payload) { + return { + type: RECEIVED_DATA_SUCCESS, + payload + } +} + +export function receivingData() { + return { + type: RECEIVING_DATA + } +} + + + + diff --git a/src/actions/auth.js b/src/actions/auth.js new file mode 100644 index 0000000..129aebb --- /dev/null +++ b/src/actions/auth.js @@ -0,0 +1,241 @@ +import axios from 'axios'; +import { toast } from 'react-toastify'; + +import config from '../config'; +import { push } from 'actions/navigation'; +import Errors from '../components/FormItems/error/errors'; +import { mockUser } from './mock'; +import { decodeJwt } from '../core/jwt'; +import { + fetchCurrentUser, + requestPasswordReset, + resetPasswordWithToken, + signInLocal, + signUp, + verifyEmailToken, +} from '../services/authService'; + +export const AUTH_FAILURE = 'AUTH_FAILURE'; +export const LOGIN_REQUEST = 'LOGIN_REQUEST'; +export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'; +export const LOGOUT_REQUEST = 'LOGOUT_REQUEST'; +export const LOGOUT_SUCCESS = 'LOGOUT_SUCCESS'; +export const RESET_REQUEST = 'RESET_REQUEST'; +export const RESET_SUCCESS = 'RESET_SUCCESS'; +export const PASSWORD_RESET_EMAIL_REQUEST = 'PASSWORD_RESET_EMAIL_REQUEST'; +export const PASSWORD_RESET_EMAIL_SUCCESS = 'PASSWORD_RESET_EMAIL_SUCCESS'; +export const AUTH_INIT_SUCCESS = 'AUTH_INIT_SUCCESS'; +export const AUTH_INIT_ERROR = 'AUTH_INIT_ERROR'; +export const REGISTER_REQUEST = 'REGISTER_REQUEST'; +export const REGISTER_SUCCESS = 'REGISTER_SUCCESS'; + +function getAuthErrorMessage(error) { + return Errors.selectMessage(error); +} + +export function authError(payload) { + return { + type: AUTH_FAILURE, + payload, + }; +} + +export function doInit() { + return async (dispatch) => { + if (!config.isBackend) { + dispatch({ + type: AUTH_INIT_SUCCESS, + payload: { + currentUser: mockUser, + }, + }); + return; + } + + try { + let currentUser = null; + const token = localStorage.getItem('token'); + if (token) { + currentUser = await fetchCurrentUser(); + } + dispatch({ + type: AUTH_INIT_SUCCESS, + payload: { + currentUser, + }, + }); + } catch (error) { + Errors.handle(error); + + dispatch({ + type: AUTH_INIT_ERROR, + payload: error, + }); + } + }; +} + +export function logoutUser() { + return (dispatch) => { + dispatch({ + type: LOGOUT_REQUEST, + }); + localStorage.removeItem('token'); + localStorage.removeItem('user'); + axios.defaults.headers.common.Authorization = ''; + dispatch({ + type: LOGOUT_SUCCESS, + }); + + dispatch(push('/login')); + }; +} + +export function receiveToken(token) { + return (dispatch) => { + const user = config.isBackend + ? decodeJwt(token) + : { + email: config.auth.email, + user: { + id: 'default_no_connection_id_444', + }, + }; + + localStorage.setItem('token', token); + localStorage.setItem('user', JSON.stringify(user)); + axios.defaults.headers.common.Authorization = `Bearer ${token}`; + dispatch({ + type: LOGIN_SUCCESS, + }); + + dispatch(push('/app')); + }; +} + +export function loginUser(creds) { + return async (dispatch) => { + if (!config.isBackend) { + dispatch(receiveToken('token')); + dispatch(doInit()); + return; + } + + dispatch({ + type: LOGIN_REQUEST, + }); + + if (creds.social) { + window.location.href = `${config.baseURLApi}/auth/signin/${creds.social}?app=${config.redirectUrl}`; + return; + } + + if (!creds.email || !creds.password) { + dispatch(authError('Something was wrong. Try again')); + return; + } + + try { + const token = await signInLocal(creds); + dispatch(receiveToken(token)); + dispatch(doInit()); + } catch (error) { + dispatch(authError(getAuthErrorMessage(error))); + } + }; +} + +export function verifyEmail(token) { + return async (dispatch) => { + if (!config.isBackend) { + dispatch(push('/login')); + return; + } + + try { + await verifyEmailToken(token); + toast.success('Your email was verified'); + } catch (error) { + toast.error(getAuthErrorMessage(error)); + } finally { + dispatch(push('/login')); + } + }; +} + +export function resetPassword(token, password) { + return async (dispatch) => { + if (!config.isBackend) { + dispatch(push('/login')); + return; + } + + dispatch({ + type: RESET_REQUEST, + }); + + try { + await resetPasswordWithToken(token, password); + dispatch({ + type: RESET_SUCCESS, + }); + toast.success('Password has been updated'); + dispatch(push('/login')); + } catch (error) { + dispatch(authError(getAuthErrorMessage(error))); + } + }; +} + +export function sendPasswordResetEmail(email) { + return async (dispatch) => { + if (!config.isBackend) { + dispatch(push('/login')); + return; + } + + dispatch({ + type: PASSWORD_RESET_EMAIL_REQUEST, + }); + + try { + await requestPasswordReset(email); + dispatch({ + type: PASSWORD_RESET_EMAIL_SUCCESS, + }); + toast.success('Email with resetting instructions has been sent'); + dispatch(push('/login')); + } catch (error) { + dispatch(authError(getAuthErrorMessage(error))); + } + }; +} + +export function registerUser(creds) { + return async (dispatch) => { + if (!config.isBackend) { + dispatch(push('/login')); + return; + } + + dispatch({ + type: REGISTER_REQUEST, + }); + + if (!creds.email || !creds.password) { + dispatch(authError('Something was wrong. Try again')); + return; + } + + try { + await signUp(creds); + dispatch({ + type: REGISTER_SUCCESS, + }); + toast.success("You've been registered successfully. Please check your email for verification link"); + dispatch(push('/login')); + } catch (error) { + dispatch(authError(getAuthErrorMessage(error))); + } + }; +} diff --git a/src/actions/layout.js b/src/actions/layout.js new file mode 100644 index 0000000..26e4e50 --- /dev/null +++ b/src/actions/layout.js @@ -0,0 +1,41 @@ +export const CHANGE_THEME = 'CHANGE_THEME'; +export const CHANGE_SIDEBAR_COLOR = 'CHANGE_SIDEBAR_COLOR'; +export const CHANGE_THEME_COLOR = 'CHANGE_THEME_COLOR'; +export const NAVBAR_TYPE_TOGGLE = 'NAVBAR_TYPE_TOGGLE'; +export const SIDEBAR_TYPE_TOGGLE = 'SIDEBAR_TYPE_TOGGLE'; + +export function changeTheme(payload) { + return { + type: CHANGE_THEME, + payload, + }; +} + +export function changeSidebarColor(payload) { + return { + type: CHANGE_SIDEBAR_COLOR, + payload, + }; +} + +export function changeThemeColor(payload) { + return { + type: CHANGE_THEME_COLOR, + payload, + }; +} + +export function navbarTypeToggle(value) { + return { + type: NAVBAR_TYPE_TOGGLE, + payload: value + } +} + +export function sidebarTypeToggle(value) { + return { + type: SIDEBAR_TYPE_TOGGLE, + payload: value + } +} + diff --git a/src/actions/mock.js b/src/actions/mock.js new file mode 100644 index 0000000..5a6dad7 --- /dev/null +++ b/src/actions/mock.js @@ -0,0 +1,24 @@ +export const mockUser = { + id: "98cea92c-84e5-4c0d-ac21-9998f4b23883", + firstName: "Admin", + authenticationUid: null, + avatar: null, + createdAt: "2020-05-12T11:04:00.864Z", + createdById: null, + deletedAt: null, + disabled: false, + email: "admin@flatlogic.com", + emailVerificationToken: null, + emailVerificationTokenExpiresAt: null, + emailVerified: true, + importHash: null, + lastName: null, + password: "$2b$12$EFuj2XoxivlGr.oiIvnvDulsE5iIBTngrLlrXMM/PkO//iInslWNW", + passwordResetToken: null, + passwordResetTokenExpiresAt: null, + phoneNumber: null, + provider: "local", + role: "admin", + updatedAt: "2020-05-12T11:04:00.864Z", + updatedById: null, +} \ No newline at end of file diff --git a/src/actions/navigation.js b/src/actions/navigation.js new file mode 100644 index 0000000..f4ae1fc --- /dev/null +++ b/src/actions/navigation.js @@ -0,0 +1,53 @@ +export const OPEN_SIDEBAR = 'OPEN_SIDEBAR'; +export const CLOSE_SIDEBAR = 'CLOSE_SIDEBAR'; +export const CHANGE_ACTIVE_SIDEBAR_ITEM = 'CHANGE_ACTIVE_SIDEBAR_ITEM'; +export const CHANGE_SIDEBAR_POSITION = 'CHANGE_SIDEBAR_POSITION'; +export const CHANGE_SIDEBAR_VISIBILITY = 'CHANGE_SIDEBAR_VISIBILITY'; + +export function openSidebar() { + return { + type: OPEN_SIDEBAR, + }; +} + +export function changeSidebarPosition(nextPosition) { + return { + type: CHANGE_SIDEBAR_POSITION, + payload: nextPosition, + }; +} + +export function closeSidebar() { + return { + type: CLOSE_SIDEBAR, + }; +} + +export function changeActiveSidebarItem(activeItem) { + return { + type: CHANGE_ACTIVE_SIDEBAR_ITEM, + activeItem, + }; +} + +export function changeSidebarVisibility(nextVisibility) { + return { + type: CHANGE_SIDEBAR_VISIBILITY, + payload: nextVisibility, + }; +} + +export function push(path) { + return () => { + if (!path) { + return; + } + + const normalizedPath = path.startsWith('/') ? path : `/${path}`; + + if (window.location.pathname !== normalizedPath) { + window.history.pushState({}, '', normalizedPath); + window.dispatchEvent(new PopStateEvent('popstate')); + } + }; +} diff --git a/src/actions/products.js b/src/actions/products.js new file mode 100644 index 0000000..ddda8e9 --- /dev/null +++ b/src/actions/products.js @@ -0,0 +1,184 @@ +import axios from 'axios'; +import { toast } from 'react-toastify'; +import mock from "../pages/products/backendMock"; +import config from "../config"; + +export const RECEIVED_PRODUCTS = 'RECEIVED_PRODUCTS'; +export const RECEIVING_PRODUCTS = 'RECEIVING_PRODUCTS'; +export const RECEIVED_PRODUCT = 'RECEIVED_PRODUCT'; +export const RECEIVING_PRODUCT = 'RECEIVING_PRODUCT'; +export const UPDATED_PRODUCT = 'UPDATED_PRODUCT'; +export const UPDATING_PRODUCT = 'UPDATING_PRODUCT'; +export const DELETED_PRODUCT = 'DELETED_PRODUCT'; +export const DELETING_PRODUCT = 'DELETING_PRODUCT'; +export const RECEIVED_IMAGES = 'RECEIVED_IMAGES'; + +const toSerializable = (value) => { + if (value instanceof Date) { + return value.toISOString(); + } + + if (Array.isArray(value)) { + return value.map(toSerializable); + } + + if (value && typeof value === 'object') { + return Object.entries(value).reduce((acc, [key, nestedValue]) => ({ + ...acc, + [key]: toSerializable(nestedValue), + }), {}); + } + + return value; +}; + +export function getProductsRequest() { + return (dispatch) => { + // We check if app runs with backend mode + if (!config.isBackend) { + dispatch(receiveProducts(mock)); + } + + else { + dispatch(receivingProducts()); + axios.get('/products').then(res => { + dispatch(receiveProducts(res.data)); + }) + } + }; +} + +export function loadProductRequest(id) { + return (dispatch) => { + // We check if app runs with backend mode + if (!config.isBackend) { + dispatch(receiveProduct(mock.find(arr => arr.id === id))); + } + + else { + dispatch(receivingProduct()); + axios.get('/products/' + id).then(res => { + dispatch(receiveProduct(res.data)); + }) + } + }; +} + +export function updateProductRequest(product) { + return (dispatch) => { + // We check if app runs with backend mode + if (!config.isBackend) return; + + dispatch(updatingProduct()); + axios.put('/products/' + product.id, product).then(res => { + dispatch(updateProduct(res.data)); + toast.success("Product has been Updated!"); + }) + }; +} + +export function createProductRequest(payload) { + return (dispatch) => { + // We check if app runs with backend mode + if (!config.isBackend) return; + + dispatch(updatingProduct()); + axios.post('/products', payload.product).then(res => { + dispatch(updateProduct(res.data)); + payload.history.push('/app/ecommerce/management'); + toast.success("Product has been Created!"); + }) + }; +} + +export function deleteProductRequest(payload) { + return (dispatch) => { + // We check if app runs with backend mode + if (!config.isBackend) return; + + dispatch(deletingProduct(payload)); + axios.delete('/products/' + payload.id).then(res => { + dispatch(deleteProduct({id: payload.id})); + if (payload.history.location.pathname !== '/app/ecommerce/management') { + payload.history.push('/app/ecommerce/management'); + } + toast.success("Product has been Deleted!"); + }) + }; +} + +export function getProductsImagesRequest(payload) { + return (dispatch) => { + // We check if app runs with backend mode + if (!config.isBackend) return; + + axios.get('/products/images-list').then(res => { + dispatch(receiveProductImages(res.data)); + if (!payload.img && res.data.length) { + dispatch(updateProduct({id: payload.id, img: res.data[0]})); + } + }) + }; +} + +export function receiveProductImages(payload) { + return { + type: RECEIVED_IMAGES, + payload + } +} + + +export function receiveProducts(payload) { + return { + type: RECEIVED_PRODUCTS, + payload: toSerializable(payload), + } +} + +export function receivingProducts() { + return { + type: RECEIVING_PRODUCTS + } +} + +export function receiveProduct(payload) { + return { + type: RECEIVED_PRODUCT, + payload: toSerializable(payload), + } +} + +export function receivingProduct() { + return { + type: RECEIVING_PRODUCT + } +} + +export function updateProduct(payload) { + return { + type: UPDATED_PRODUCT, + payload: toSerializable(payload), + } +} + +export function updatingProduct() { + return { + type: UPDATING_PRODUCT + } +} + +export function deleteProduct(payload) { + return { + type: DELETED_PRODUCT, + payload + } +} + +export function deletingProduct(payload) { + return { + type: DELETING_PRODUCT, + payload + } +} + diff --git a/src/actions/usersFormActions.js b/src/actions/usersFormActions.js new file mode 100644 index 0000000..d275325 --- /dev/null +++ b/src/actions/usersFormActions.js @@ -0,0 +1,134 @@ +import Errors from 'components/FormItems/error/errors'; +import { push } from 'actions/navigation'; +import { doInit } from 'actions/auth'; +import { toast } from 'react-toastify'; +import config from '../config'; +import { mockUser } from '../actions/mock'; +import { updatePassword } from '../services/authService'; +import { createUser, findUser, updateUser } from '../services/usersService'; + +const actions = { + doNew: () => { + return { + type: 'USERS_FORM_RESET', + }; + }, + + doFind: (id) => async (dispatch) => { + if (!config.isBackend) { + dispatch({ + type: 'USERS_FORM_FIND_SUCCESS', + payload: mockUser, + }); + return; + } + + try { + dispatch({ + type: 'USERS_FORM_FIND_STARTED', + }); + + const record = await findUser(id); + + dispatch({ + type: 'USERS_FORM_FIND_SUCCESS', + payload: record, + }); + } catch (error) { + Errors.handle(error); + + dispatch({ + type: 'USERS_FORM_FIND_ERROR', + }); + + dispatch(push('/admin/users')); + } + }, + + doCreate: (values) => async (dispatch) => { + try { + dispatch({ + type: 'USERS_FORM_CREATE_STARTED', + }); + + if (config.isBackend) { + await createUser(values); + } + + dispatch({ + type: 'USERS_FORM_CREATE_SUCCESS', + }); + + toast.success('User created'); + dispatch(push('/admin/users')); + } catch (error) { + Errors.handle(error); + + dispatch({ + type: 'USERS_FORM_CREATE_ERROR', + }); + } + }, + + doUpdate: (id, values, isProfile) => async (dispatch) => { + try { + dispatch({ + type: 'USERS_FORM_UPDATE_STARTED', + }); + + if (config.isBackend) { + await updateUser(id, values); + } + + dispatch(doInit()); + + dispatch({ + type: 'USERS_FORM_UPDATE_SUCCESS', + }); + + if (isProfile) { + toast.success('Profile updated'); + } else { + toast.success('User updated'); + dispatch(push('/admin/users')); + } + } catch (error) { + Errors.handle(error); + + dispatch({ + type: 'USERS_FORM_UPDATE_ERROR', + }); + } + }, + + doChangePassword: ({newPassword, currentPassword}) => async (dispatch) => { + try { + dispatch({ + type: 'USERS_FORM_UPDATE_STARTED', + }); + + if (config.isBackend) { + await updatePassword({newPassword, currentPassword}); + } + + dispatch({ + type: 'USERS_PASSWORD_UPDATE_SUCCESS', + }); + dispatch({ + type: 'USERS_FORM_UPDATE_SUCCESS', + }); + + toast.success('Password has been updated'); + dispatch(push('/app/main')); + + } catch (error) { + Errors.handle(error); + + dispatch({ + type: 'USERS_FORM_UPDATE_ERROR', + }); + } + }, +}; + +export default actions; diff --git a/src/actions/usersListActions.js b/src/actions/usersListActions.js new file mode 100644 index 0000000..11e355a --- /dev/null +++ b/src/actions/usersListActions.js @@ -0,0 +1,107 @@ +import Errors from 'components/FormItems/error/errors'; +import config from '../config'; +import { mockUser } from '../actions/mock'; +import { deleteUser, listUsers } from '../services/usersService'; + +function normalizeUsersPayload(response) { + if (Array.isArray(response)) { + return { + rows: response, + count: response.length, + }; + } + + const rows = Array.isArray(response && response.rows) ? response.rows : []; + const count = typeof (response && response.count) === 'number' ? response.count : rows.length; + + return { + rows, + count, + }; +} + +const actions = { + + doFetch: (filter, keepPagination = false) => async (dispatch) => { + if (!config.isBackend) { + dispatch({ + type: 'USERS_LIST_FETCH_SUCCESS', + payload: { + rows: [mockUser], + count: 1, + }, + }); + } else { + try { + dispatch({ + type: 'USERS_LIST_FETCH_STARTED', + payload: { filter, keepPagination }, + }); + + const response = await listUsers(); + const payload = normalizeUsersPayload(response); + + dispatch({ + type: 'USERS_LIST_FETCH_SUCCESS', + payload, + }); + } catch (error) { + Errors.handle(error); + + dispatch({ + type: 'USERS_LIST_FETCH_ERROR', + }); + } + } + }, + + doDelete: (id) => async (dispatch) => { + if (!config.isBackend) { + dispatch({ + type: 'USERS_LIST_DELETE_ERROR', + }); + } else { + try { + dispatch({ + type: 'USERS_LIST_DELETE_STARTED', + }); + + await deleteUser(id); + + dispatch({ + type: 'USERS_LIST_DELETE_SUCCESS', + }); + + const response = await listUsers(); + const payload = normalizeUsersPayload(response); + dispatch({ + type: 'USERS_LIST_FETCH_SUCCESS', + payload, + }); + + } catch (error) { + Errors.handle(error); + + dispatch({ + type: 'USERS_LIST_DELETE_ERROR', + }); + } + } + }, + doOpenConfirm: (id) => async (dispatch) => { + dispatch({ + type: 'USERS_LIST_OPEN_CONFIRM', + payload: { + id: id + }, + }); + }, + doCloseConfirm: () => async (dispatch) => { + dispatch({ + type: 'USERS_LIST_CLOSE_CONFIRM', + }); + }, +}; + + +export default actions; diff --git a/src/components/AnimatedNumber.js b/src/components/AnimatedNumber.js new file mode 100644 index 0000000..5ba5aa5 --- /dev/null +++ b/src/components/AnimatedNumber.js @@ -0,0 +1,81 @@ +import React, { useEffect, useRef, useState } from 'react'; +import PropTypes from 'prop-types'; + +function AnimatedNumber({ + value, + initialValue, + duration, + stepPrecision, + formatValue, +}) { + const initial = Number.isFinite(initialValue) ? initialValue : Number(value) || 0; + const [displayValue, setDisplayValue] = useState(initial); + const previousValueRef = useRef(initial); + const frameRef = useRef(null); + + useEffect(() => { + const to = Number(value); + const from = Number(previousValueRef.current) || 0; + + if (!Number.isFinite(to)) { + setDisplayValue(value); + previousValueRef.current = value; + return undefined; + } + + if (!duration || duration <= 0) { + setDisplayValue(to); + previousValueRef.current = to; + return undefined; + } + + let startTime = null; + const tick = (timestamp) => { + if (!startTime) { + startTime = timestamp; + } + + const progress = Math.min((timestamp - startTime) / duration, 1); + const next = from + (to - from) * progress; + const rounded = Number(next.toFixed(stepPrecision)); + setDisplayValue(rounded); + + if (progress < 1) { + frameRef.current = requestAnimationFrame(tick); + } else { + previousValueRef.current = to; + } + }; + + frameRef.current = requestAnimationFrame(tick); + + return () => { + if (frameRef.current) { + cancelAnimationFrame(frameRef.current); + } + }; + }, [duration, stepPrecision, value]); + + if (typeof formatValue === 'function') { + return <>{formatValue(displayValue)}; + } + + return <>{displayValue}; +} + +AnimatedNumber.defaultProps = { + duration: 300, + formatValue: null, + initialValue: 0, + stepPrecision: 0, +}; + +AnimatedNumber.propTypes = { + duration: PropTypes.number, + formatValue: PropTypes.func, + initialValue: PropTypes.number, + stepPrecision: PropTypes.number, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, +}; + +export default AnimatedNumber; diff --git a/src/components/App.js b/src/components/App.js new file mode 100644 index 0000000..9ace929 --- /dev/null +++ b/src/components/App.js @@ -0,0 +1,120 @@ +import React from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { + BrowserRouter, + Navigate, + Route, + Routes, +} from 'react-router-dom'; +import { ToastContainer } from 'react-toastify'; +import { AdminRoute, UserRoute, AuthRoute } from './RouteComponents'; + +/* eslint-disable */ +import ErrorPage from '../pages/error'; +/* eslint-enable */ + +import '../styles/theme.scss'; +import LayoutComponent from '../components/Layout'; +import DocumentationLayoutComponent from '../documentation/DocumentationLayout'; +import Login from '../pages/auth/login'; +import Verify from '../pages/auth/verify'; +import Register from '../pages/auth/register'; +import Reset from '../pages/auth/reset'; +import Forgot from '../pages/auth/forgot'; + +const CloseButton = ({ closeToast }) => ( + +); + +const App = () => { + const dispatch = useDispatch(); + const currentUser = useSelector((store) => store.auth.currentUser); + + return ( +
+ } + /> + + + } /> + } /> + + + + )} + /> + + + + )} + /> + } + /> + } /> + + + + )} + /> + + + + )} + /> + + + + )} + /> + + + + )} + /> + + + + )} + /> + } /> + } /> + + +
+ ); +}; + +export default App; diff --git a/src/components/AutoResizeTextarea.js b/src/components/AutoResizeTextarea.js new file mode 100644 index 0000000..77451d5 --- /dev/null +++ b/src/components/AutoResizeTextarea.js @@ -0,0 +1,48 @@ +import React, { useLayoutEffect, useRef } from 'react'; + +function resizeTextarea(textarea, minRows) { + if (!textarea) { + return; + } + + textarea.style.height = 'auto'; + const lineHeight = parseInt(window.getComputedStyle(textarea).lineHeight, 10) || 20; + const minHeight = minRows * lineHeight; + const nextHeight = Math.max(textarea.scrollHeight, minHeight); + textarea.style.height = `${nextHeight}px`; +} + +function AutoResizeTextarea({ + rows = 2, + onChange, + style, + ...rest +}) { + const textareaRef = useRef(null); + + useLayoutEffect(() => { + resizeTextarea(textareaRef.current, rows); + }, [rows, rest.value]); + + const handleChange = (event) => { + resizeTextarea(textareaRef.current, rows); + if (onChange) { + onChange(event); + } + }; + + return ( + + ); + } + + if (resolvedType === 'select' || tag === 'select') { + return ( + + ); + } + + if (resolvedType === 'checkbox' || resolvedType === 'radio') { + return ( + + ); + } + + if (resolvedType === 'range') { + return ; + } + + const Tag = resolveTag(tag, 'input'); + + return ( + + {Tag === 'input' ? undefined : children} + + ); +}); + +Input.displayName = 'Input'; + +export const InputGroup = ({ className, size, children, ...rest }) => ( + + {children} + +); + +export const InputGroupText = ({ className, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'span'); + return ( + + {children} + + ); +}; + +export const Alert = ({ className, color, isOpen = true, fade, toggle, children, ...rest }) => { + if (!isOpen) { + return null; + } + + return ( + + {children} + + ); +}; + +export const UncontrolledAlert = ({ toggle, ...props }) => { + const [isOpen, setIsOpen] = useState(true); + + return ( + { + setIsOpen(false); + if (toggle) { + toggle(); + } + }} + /> + ); +}; + +export const Badge = ({ className, color, pill, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'span'); + + return ( + + {children} + + ); +}; + +const TabContext = createContext({ activeTab: null }); + +export const TabContent = ({ className, activeTab, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'div'); + + return ( + + + {children} + + + ); +}; + +export const TabPane = ({ className, tabId, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'div'); + const { activeTab } = useContext(TabContext); + const isActive = String(activeTab) === String(tabId); + + return ( + + {children} + + ); +}; + +export const Nav = ({ className, tabs, pills, vertical, horizontal, justified, fill, navbar, children, tag, ...rest }) => { + const Tag = resolveTag(tag, 'ul'); + return ( + + {children} + + ); +}; + +export const NavItem = ({ className, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'li'); + return ( + + {children} + + ); +}; + +export const NavLink = ({ className, active, disabled, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'a'); + + return ( + + {children} + + ); +}; + +export const Navbar = ({ className, color, dark, light, expand, fixed, sticky, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'nav'); + + return ( + + {children} + + ); +}; + +export const NavbarBrand = ({ className, tag, children, ...rest }) => { + const Tag = tag; + return ( + + {children} + + ); +}; + +export const NavbarToggler = ({ className, children, ...rest }) => ( + + {children || } + +); + +export const Collapse = ({ className, isOpen, navbar, horizontal, children, ...rest }) => ( + +
+ {children} +
+
+); + +const DropdownContext = createContext(null); + +const DropdownBase = ({ + className, + isOpen, + toggle, + nav, + inNavbar, + direction, + group, + children, + tag, + ...rest +}) => { + const { value: internalOpen, setValue: setInternalOpen, isControlled } = useControlledState(isOpen, false); + const open = internalOpen; + + const toggleOpen = useCallback((event) => { + if (toggle) { + toggle(event); + } + if (!isControlled) { + setInternalOpen((prev) => !prev); + } + }, [toggle, isControlled, setInternalOpen]); + + const close = useCallback((event) => { + if (!open) { + return; + } + + if (toggle) { + toggle(event); + } + + if (!isControlled) { + setInternalOpen(false); + } + }, [open, toggle, isControlled, setInternalOpen]); + + const Tag = resolveTag(tag, 'div'); + + return ( + + + {children} + + + ); +}; + +export const Dropdown = (props) => ; + +export const ButtonDropdown = (props) => ; + +export const UncontrolledDropdown = ({ defaultOpen = false, ...props }) => { + const [isOpen, setIsOpen] = useState(defaultOpen); + + return setIsOpen((prev) => !prev)} />; +}; + +export const UncontrolledButtonDropdown = ({ defaultOpen = false, ...props }) => { + const [isOpen, setIsOpen] = useState(defaultOpen); + + return setIsOpen((prev) => !prev)} />; +}; + +export const DropdownToggle = ({ + className, + color, + caret, + split, + nav, + tag, + onClick, + children, + ...rest +}) => { + const ctx = useContext(DropdownContext); + const Tag = resolveTag(tag, nav ? 'a' : 'button'); + + const handleClick = (event) => { + if (onClick) { + onClick(event); + } + + if (!event.defaultPrevented && ctx) { + ctx.toggle(event); + } + }; + + const isButton = Tag === 'button'; + + return ( + + {children} + + ); +}; + +export const DropdownMenu = ({ className, end, right, tag, children, ...rest }) => { + const ctx = useContext(DropdownContext); + const Tag = resolveTag(tag, 'div'); + + return ( + + {children} + + ); +}; + +export const DropdownItem = ({ + className, + active, + disabled, + divider, + header, + toggle = true, + tag, + onClick, + children, + ...rest +}) => { + const ctx = useContext(DropdownContext); + + if (divider) { + return
; + } + + if (header) { + return ( +
+ {children} +
+ ); + } + + const Tag = resolveTag(tag, 'button'); + + return ( + { + if (disabled) { + event.preventDefault(); + return; + } + + if (onClick) { + onClick(event); + } + + if (toggle && ctx) { + ctx.close(event); + } + }} + {...rest} + > + {children} + + ); +}; + +export const Table = ({ className, bordered, borderless, striped, dark, hover, responsive, size, children, ...rest }) => { + return ( + + {children} + + ); +}; + +export const Progress = ({ + className, + value = 0, + max = 100, + color, + striped, + animated, + bar, + multi, + children, + ...rest +}) => { + if (bar) { + return ( +
+ {children} +
+ ); + } + + return ( +
+ {multi ? children : ( + + {children} + + )} +
+ ); +}; + +export const Card = ({ className, body, color, inverse, outline, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'div'); + return ( + + {children} + + ); +}; + +export const CardBody = ({ className, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'div'); + return ( + + {children} + + ); +}; + +export const CardTitle = ({ className, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'h5'); + return ( + + {children} + + ); +}; + +export const CardText = ({ className, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'p'); + return ( + + {children} + + ); +}; + +export const CardImg = ({ className, top, bottom, ...rest }) => ( + +); + +export const ListGroup = ({ className, flush, horizontal, numbered, children, tag, ...rest }) => { + const Tag = resolveTag(tag, numbered ? 'ol' : 'ul'); + + return ( + + {children} + + ); +}; + +export const ListGroupItem = ({ className, active, disabled, color, action, tag, children, ...rest }) => { + const Tag = resolveTag(tag, action ? 'button' : 'li'); + + return ( + + {children} + + ); +}; + +export const Breadcrumb = ({ className, tag, listTag, children, ...rest }) => { + const Tag = resolveTag(tag, 'nav'); + const ListTag = resolveTag(listTag, 'ol'); + + return ( + + + {children} + + + ); +}; + +export const BreadcrumbItem = ({ className, active, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'li'); + + return ( + + {children} + + ); +}; + +export const Pagination = ({ className, size, children, tag, ...rest }) => { + const Tag = resolveTag(tag, 'ul'); + return ( + + {children} + + ); +}; + +export const PaginationItem = ({ className, active, disabled, children, tag, ...rest }) => { + const Tag = resolveTag(tag, 'li'); + return ( + + {children} + + ); +}; + +export const PaginationLink = ({ className, children, tag, ...rest }) => { + const Tag = resolveTag(tag, 'a'); + return ( + + {children} + + ); +}; + +const ModalContext = createContext({ toggle: noop }); + +export const Modal = ({ + className, + isOpen, + toggle, + backdrop = true, + centered, + scrollable, + size, + fullscreen, + modalClassName, + contentClassName, + wrapClassName, + children, + ...rest +}) => { + useBodyClass(Boolean(isOpen), 'modal-open'); + + if (!isOpen || typeof document === 'undefined') { + return null; + } + + return createPortal( + <> +
{ + if (event.target !== event.currentTarget) { + return; + } + if (backdrop === true && toggle) { + toggle(event); + } + }}> +
+ +
+ {children} +
+
+
+
+ {backdrop !== false ?
: null} + , + document.body, + ); +}; + +export const ModalHeader = ({ className, toggle, close, tag, children, ...rest }) => { + const Tag = resolveTag(tag, 'div'); + const context = useContext(ModalContext); + const onClose = toggle || context.toggle; + + return ( + +
{children}
+ {close || (onClose ? + + ); +}; + +TasksContainer.propTypes = { + data: PropTypes.arrayOf( + PropTypes.shape({ + type: PropTypes.string, + title: PropTypes.string, + date: PropTypes.string, + }), + ).isRequired, +}; + +export default TasksContainer; diff --git a/src/pages/analytics/mock.js b/src/pages/analytics/mock.js new file mode 100644 index 0000000..96af59c --- /dev/null +++ b/src/pages/analytics/mock.js @@ -0,0 +1,349 @@ +export default { + serverOverview: [ + { + data: [{ + data: [4, 6, 5, 7, 5], + }], + width: '100%', + height: 30, + options: { + stroke: { + width: 1 + }, + markers: { + size: 4, + colors: '#57B955', + shape: "circle", + strokeWidth: 0, + hover: { + size: 5, + colors: '#fff', + } + }, + colors: [ + '#4E85BD' + ], + grid: { + padding: { + left: 10, + right: 10, + top: 10, + bottom: 10 + } + } + } + }, + { + data: [{ + data: [2, 3, 1, 4, 4], + }], + width: '100%', + height: 30, + options: { + stroke: { + width: 1 + }, + markers: { + size: 4, + colors: '#57B955', + shape: "circle", + strokeWidth: 0, + hover: { + size: 5, + colors: '#fff', + } + }, + colors: [ + '#4E85BD' + ], + grid: { + padding: { + left: 10, + right: 10, + top: 10, + bottom: 10 + } + } + } + } + ], + tasks: [ + { + id: 0, + type: 'Meeting', + title: 'Meeting with Andrew Piker', + time: '9:00', + }, + { + id: 1, + type: 'Call', + title: 'Call with HT Company', + time: '12:00', + }, + { + id: 2, + type: 'Meeting', + title: 'Meeting with Zoe Alison', + time: '14:00', + }, + { + id: 3, + type: 'Interview', + title: 'Interview with HR', + time: '15:00', + }, + ], + bigStat: [ + { + product: 'Light Blue', + total: '4,232', + color: 'primary', + registrations: { + value: 830, + profit: true, + }, + bounce: { + value: 4.5, + profit: false, + }, + }, + { + product: 'Sing App', + total: '754', + color: 'success', + registrations: { + value: 30, + profit: true, + }, + bounce: { + value: 2.5, + profit: true, + }, + }, + { + product: 'RNS', + total: '1,025', + color: 'danger', + registrations: { + value: 230, + profit: true, + }, + bounce: { + value: 21.5, + profit: false, + }, + }, + ], + notifications: [ + { + id: 0, + icon: 'thumbs-up', + color: 'primary', + content: 'Ken accepts your invitation', + }, + { + id: 1, + icon: 'file', + color: 'success', + content: 'Report from LT Company', + }, + { + id: 2, + icon: 'envelope', + color: 'danger', + content: '4 Private Mails', + }, + { + id: 3, + icon: 'comment', + color: 'success', + content: '3 Comments to your Post', + }, + { + id: 4, + icon: 'cog', + color: 'light', + content: 'New Version of RNS app', + }, + { + id: 5, + icon: 'bell', + color: 'info', + content: '15 Notifications from Social Apps', + }, + ], + table: [ + { + id: 0, + name: 'Mark Otto', + email: 'ottoto@wxample.com', + product: 'ON the Road', + price: '$25 224.2', + date: '11 May 2017', + city: 'Otsego', + status: 'Sent', + }, + { + id: 1, + name: 'Jacob Thornton', + email: 'thornton@wxample.com', + product: 'HP Core i7', + price: '$1 254.2', + date: '4 Jun 2017', + city: 'Fivepointville', + status: 'Sent', + }, + { + id: 2, + name: 'Larry the Bird', + email: 'bird@wxample.com', + product: 'Air Pro', + price: '$1 570.0', + date: '27 Aug 2017', + city: 'Leadville North', + status: 'Pending', + }, + { + id: 3, + name: 'Joseph May', + email: 'josephmay@wxample.com', + product: 'Version Control', + price: '$5 224.5', + date: '19 Feb 2018', + city: 'Seaforth', + status: 'Declined', + }, + { + id: 4, + name: 'Peter Horadnia', + email: 'horadnia@wxample.com', + product: 'Let\'s Dance', + price: '$43 594.7', + date: '1 Mar 2018', + city: 'Hanoverton', + status: 'Sent', + }, + ], + backendData: { + visits: { + count: 4.332, + logins: 830, + sign_out_pct: 0.5, + rate_pct: 4.5 + }, + performance: { + sdk: { + this_period_pct: 60, + last_period_pct: 30, + }, + integration: { + this_period_pct: 40, + last_period_pct: 55, + } + }, + server: { + 1: { + pct: 60, + temp: 37, + frequency: 3.3 + }, + 2: { + pct: 54, + temp: 31, + frequency: 3.3 + } + }, + revenue: getRevenueData(), + mainChart: getMainChartData() + } +}; + +function getRevenueData() { + const data = []; + const seriesCount = 3; + const accessories = ['SMX', 'Direct', 'Networks']; + + for (let i = 0; i < seriesCount; i += 1) { + data.push({ + label: accessories[i], + data: Math.floor(Math.random() * 100) + 1, + }); + } + + return data; +} + +function getMainChartData() { + function generateRandomPicks(minPoint, maxPoint, picksAmount, xMax) { + let x = 0; + let y = 0; + const result = []; + const xStep = 1; + const smoothness = 0.3; + const pointsPerPick = Math.ceil(xMax / ((picksAmount * 2) + 1) / 2); + + const maxValues = []; + const minValues = []; + + for (let i = 0; i < picksAmount; i += 1) { + const minResult = minPoint + Math.random(); + const maxResult = maxPoint - Math.random(); + + minValues.push(minResult); + maxValues.push(maxResult); + } + + let localMax = maxValues.shift(0); + let localMin = 0; + let yStep = parseFloat(((localMax - localMin) / pointsPerPick).toFixed(2)); + + for (let j = 0; j < Math.ceil(xMax); j += 1) { + result.push([x, y]); + + if ((y + yStep >= localMax) || (y + yStep <= localMin)) { + y += yStep * smoothness; + } else if ((result[result.length - 1][1] === localMax) || (result[result.length - 1][1] === localMin)) { + y += yStep * smoothness; + } else { + y += yStep; + } + + if (y > localMax) { + y = localMax; + } else if (y < localMin) { + y = localMin; + } + + if (y === localMin) { + localMax = maxValues.shift(0) || localMax; + + const share = (localMax - localMin) / localMax; + const p = share > 0.5 ? Math.round(pointsPerPick * 1.2) : Math.round(pointsPerPick * share); + + yStep = parseFloat(((localMax - localMin) / p).toFixed(2)); + yStep *= Math.abs(yStep); + } + + if (y === localMax) { + localMin = minValues.shift(0) || localMin; + + const share = (localMax - localMin) / localMax; + const p = share > 0.5 ? Math.round(pointsPerPick * 1.5) : Math.round(pointsPerPick * 0.5); + + yStep = parseFloat(((localMax - localMin) / p).toFixed(2)); + yStep *= -1; + } + + x += xStep; + } + + return result; + } + + const d1 = generateRandomPicks(0.2, 3, 4, 90); + const d2 = generateRandomPicks(0.4, 3.8, 4, 90); + const d3 = generateRandomPicks(0.2, 4.2, 3, 90); + + return [d1, d2, d3]; +} + diff --git a/src/pages/analytics/package.json b/src/pages/analytics/package.json new file mode 100644 index 0000000..cd501dd --- /dev/null +++ b/src/pages/analytics/package.json @@ -0,0 +1,6 @@ +{ + "name": "Analytics", + "version": "0.0.0", + "private": true, + "main": "./Analytics.js" +} diff --git a/src/pages/auth/forgot/Forgot.js b/src/pages/auth/forgot/Forgot.js new file mode 100644 index 0000000..fdf5554 --- /dev/null +++ b/src/pages/auth/forgot/Forgot.js @@ -0,0 +1,70 @@ +import React, { useState } from 'react'; +import { Link } from 'react-router-dom'; +import { useDispatch, useSelector } from 'react-redux'; +import { Container, Alert, Button, FormGroup, InputGroup, Input, InputGroupText } from 'reactstrap'; + +import Widget from '../../../components/Widget'; +import { sendPasswordResetEmail } from '../../../actions/auth'; + +function Forgot() { + const dispatch = useDispatch(); + const isFetching = useSelector((state) => state.auth.isFetching); + const errorMessage = useSelector((state) => state.auth.errorMessage); + const [email, setEmail] = useState(''); + + const doSendResetEmail = (e) => { + e.preventDefault(); + dispatch(sendPasswordResetEmail(email)); + }; + + return ( +
+ + Forgot password?}> +

+ Please fill your email below +

+
+ { + errorMessage && ( + + {errorMessage} + + ) + } + + + + + + + + setEmail(event.target.value)} + type="email" + required + name="email" + placeholder="Email" + /> + + + + +

+ Need to Login? +

+ Enter the account +
+
+
+ {new Date().getFullYear()} © Light Blue - React Admin Dashboard Template. Made by Flatlogic LLC +
+
+ ); +} + +export default Forgot; diff --git a/src/pages/auth/forgot/package.json b/src/pages/auth/forgot/package.json new file mode 100644 index 0000000..e306490 --- /dev/null +++ b/src/pages/auth/forgot/package.json @@ -0,0 +1,7 @@ +{ + "name": "forgot", + "version": "0.0.0", + "private": true, + "main": "Forgot.js" + +} diff --git a/src/pages/auth/login/Login.js b/src/pages/auth/login/Login.js new file mode 100644 index 0000000..a4b1ab9 --- /dev/null +++ b/src/pages/auth/login/Login.js @@ -0,0 +1,119 @@ +import React, { useEffect, useState } from 'react'; +import { Link, useLocation } from 'react-router-dom'; +import { useDispatch, useSelector } from 'react-redux'; +import { Container, Alert, Button, FormGroup, Label, InputGroup, Input, InputGroupText } from 'reactstrap'; + +import Widget from '../../../components/Widget'; +import { loginUser, receiveToken, doInit } from '../../../actions/auth'; +import microsoft from '../../../images/microsoft.png'; + +function Login() { + const dispatch = useDispatch(); + const location = useLocation(); + const isFetching = useSelector((state) => state.auth.isFetching); + const errorMessage = useSelector((state) => state.auth.errorMessage); + const [email, setEmail] = useState('admin@flatlogic.com'); + const [password, setPassword] = useState('password'); + + useEffect(() => { + const params = new URLSearchParams(location.search); + const token = params.get('token'); + + if (token) { + dispatch(receiveToken(token)); + dispatch(doInit()); + } + }, [dispatch, location.search]); + + const doLogin = (e) => { + e.preventDefault(); + dispatch(loginUser({ email, password })); + }; + + const googleLogin = () => { + dispatch(loginUser({ social: 'google' })); + }; + + const microsoftLogin = () => { + dispatch(loginUser({ social: 'microsoft' })); + }; + + return ( +
+ + Login to your Web App}> +

+ Use your email to sign in. +

+ + This is a real app with Node.js backend - use +
+ "admin@flatlogic.com / password" +
+ to login! +
+
+ { + errorMessage && ( + + {errorMessage} + + ) + } + + + + + + + setEmail(event.target.value)} type="email" + required name="email" placeholder="Email" /> + + + + + + + + + setPassword(event.target.value)} type="password" + required name="password" placeholder="Password" /> + + +
+ + Forgot password? +

+ Don't have an account? Sign up now! +

+ Create an Account +
+ + +
+
+ +
+
+
+ {new Date().getFullYear()} © Light Blue - React Admin Dashboard Template. Made by Flatlogic LLC +
+
+ ); +} + +export default Login; diff --git a/src/pages/auth/login/package.json b/src/pages/auth/login/package.json new file mode 100644 index 0000000..bc43daf --- /dev/null +++ b/src/pages/auth/login/package.json @@ -0,0 +1,7 @@ +{ + "name": "login", + "version": "0.0.0", + "private": true, + "main": "Login.js" + +} diff --git a/src/pages/auth/register/Register.js b/src/pages/auth/register/Register.js new file mode 100644 index 0000000..f5d32c6 --- /dev/null +++ b/src/pages/auth/register/Register.js @@ -0,0 +1,179 @@ +import React, { useEffect, useRef, useState } from 'react'; +import { Link } from 'react-router-dom'; +import { useDispatch, useSelector } from 'react-redux'; +import { Container, Alert, Button, FormGroup, InputGroup, Input, InputGroupText } from 'reactstrap'; + +import Widget from '../../../components/Widget'; +import { registerUser, authError, loginUser } from '../../../actions/auth'; +import microsoft from '../../../images/microsoft.png'; + +function Register() { + const dispatch = useDispatch(); + const isFetching = useSelector((state) => state.auth.isFetching); + const errorMessage = useSelector((state) => state.auth.errorMessage); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const clearErrorTimerRef = useRef(null); + + useEffect(() => { + return () => { + if (clearErrorTimerRef.current) { + clearTimeout(clearErrorTimerRef.current); + } + }; + }, []); + + const clearAuthErrorWithDelay = () => { + if (clearErrorTimerRef.current) { + clearTimeout(clearErrorTimerRef.current); + } + + clearErrorTimerRef.current = setTimeout(() => { + dispatch(authError()); + }, 3 * 1000); + }; + + const isPasswordValid = () => { + return password && password === confirmPassword; + }; + + const checkPassword = () => { + if (!isPasswordValid()) { + if (!password) { + dispatch(authError('Password field is empty')); + } else { + dispatch(authError('Passwords are not equal')); + } + clearAuthErrorWithDelay(); + return false; + } + + return true; + }; + + const doRegister = (e) => { + e.preventDefault(); + if (!checkPassword()) { + return; + } + + dispatch(registerUser({ + email, + password, + })); + }; + + const googleLogin = () => { + dispatch(loginUser({ social: 'google' })); + }; + + const microsoftLogin = () => { + dispatch(loginUser({ social: 'microsoft' })); + }; + + return ( +
+ + Create an account}> +

+ Please fill all fields below +

+
+ { + errorMessage && ( + + {errorMessage} + + ) + } + + + + + + + + setEmail(event.target.value)} + type="email" + required + name="email" + placeholder="Email" + /> + + + + + + + + + + setPassword(event.target.value)} + type="password" + required + name="password" + placeholder="Password" + /> + + + + + + + + + + setConfirmPassword(event.target.value)} + onBlur={checkPassword} + type="password" + required + name="confirmPassword" + placeholder="Confirm Password" + /> + + + +
+

+ Already have the account? Login now! +

+ Enter the account +

+ Don't have an account? Sign up now! +

+
+ + +
+
+ +
+
+
+ {new Date().getFullYear()} © Light Blue - React Admin Dashboard Template. Made by Flatlogic LLC +
+
+ ); +} + +export default Register; diff --git a/src/pages/auth/register/package.json b/src/pages/auth/register/package.json new file mode 100644 index 0000000..9f6f33e --- /dev/null +++ b/src/pages/auth/register/package.json @@ -0,0 +1,6 @@ +{ + "name": "register", + "version": "0.0.0", + "private": true, + "main": "Register.js" +} diff --git a/src/pages/auth/reset/Reset.js b/src/pages/auth/reset/Reset.js new file mode 100644 index 0000000..3d0d929 --- /dev/null +++ b/src/pages/auth/reset/Reset.js @@ -0,0 +1,143 @@ +import React, { useEffect, useRef, useState } from 'react'; +import { Link, useLocation } from 'react-router-dom'; +import { useDispatch, useSelector } from 'react-redux'; +import { Container, Alert, Button, FormGroup, InputGroup, Input, InputGroupText } from 'reactstrap'; + +import Widget from '../../../components/Widget'; +import { authError, resetPassword } from '../../../actions/auth'; + +function Reset() { + const dispatch = useDispatch(); + const location = useLocation(); + const isFetching = useSelector((state) => state.auth.isFetching); + const errorMessage = useSelector((state) => state.auth.errorMessage); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const clearErrorTimerRef = useRef(null); + + useEffect(() => { + return () => { + if (clearErrorTimerRef.current) { + clearTimeout(clearErrorTimerRef.current); + } + }; + }, []); + + const clearAuthErrorWithDelay = () => { + if (clearErrorTimerRef.current) { + clearTimeout(clearErrorTimerRef.current); + } + + clearErrorTimerRef.current = setTimeout(() => { + dispatch(authError()); + }, 3 * 1000); + }; + + const isPasswordValid = () => { + return password && password === confirmPassword; + }; + + const checkPassword = () => { + if (!isPasswordValid()) { + if (!password) { + dispatch(authError('Password field is empty')); + } else { + dispatch(authError('Passwords are not equal')); + } + clearAuthErrorWithDelay(); + return false; + } + + return true; + }; + + const doReset = (e) => { + e.preventDefault(); + + const params = new URLSearchParams(location.search); + const token = params.get('token'); + + if (!token) { + dispatch(authError('There are no token')); + clearAuthErrorWithDelay(); + return; + } + + if (!checkPassword()) { + return; + } + + dispatch(resetPassword(token, password)); + }; + + return ( +
+ + Reset password}> +

+ Please fill all fields below +

+
+ { + errorMessage && ( + + {errorMessage} + + ) + } + + + + + + + + setPassword(event.target.value)} + type="password" + required + name="password" + placeholder="Password" + /> + + + + + + + + + + setConfirmPassword(event.target.value)} + onBlur={checkPassword} + type="password" + required + name="confirmPassword" + placeholder="Confirm Password" + /> + + + + +

+ or +

+ Enter the account +
+
+
+ {new Date().getFullYear()} © Light Blue - React Admin Dashboard Template. Made by Flatlogic LLC +
+
+ ); +} + +export default Reset; diff --git a/src/pages/auth/reset/package.json b/src/pages/auth/reset/package.json new file mode 100644 index 0000000..70fceea --- /dev/null +++ b/src/pages/auth/reset/package.json @@ -0,0 +1,7 @@ +{ + "name": "reset", + "version": "0.0.0", + "private": true, + "main": "Reset.js" + +} diff --git a/src/pages/auth/verify/Verify.js b/src/pages/auth/verify/Verify.js new file mode 100644 index 0000000..0c00ca9 --- /dev/null +++ b/src/pages/auth/verify/Verify.js @@ -0,0 +1,23 @@ +import { useEffect } from 'react'; +import { useDispatch } from 'react-redux'; +import { useLocation } from 'react-router-dom'; + +import { verifyEmail } from '../../../actions/auth'; + +function Verify() { + const dispatch = useDispatch(); + const location = useLocation(); + + useEffect(() => { + const params = new URLSearchParams(location.search); + const token = params.get('token'); + + if (token) { + dispatch(verifyEmail(token)); + } + }, [dispatch, location.search]); + + return null; +} + +export default Verify; diff --git a/src/pages/auth/verify/package.json b/src/pages/auth/verify/package.json new file mode 100644 index 0000000..155ae20 --- /dev/null +++ b/src/pages/auth/verify/package.json @@ -0,0 +1,7 @@ +{ + "name": "verify", + "version": "0.0.0", + "private": true, + "main": "Verify.js" + +} diff --git a/src/pages/charts/Charts.js b/src/pages/charts/Charts.js new file mode 100644 index 0000000..9a57963 --- /dev/null +++ b/src/pages/charts/Charts.js @@ -0,0 +1,205 @@ +import React, { useEffect } from 'react'; + +import { + Row, Col +} from 'reactstrap'; + +import Widget from '../../components/Widget'; +import ApexChart from 'react-apexcharts'; + +import s from './Charts.module.scss'; +import {chartData, liveChart, liveChartInterval} from './mock'; +import Sparklines from '../../components/Sparklines/Sparklines'; + +import ReactEchartsCore from 'echarts-for-react/lib/core'; +import * as echarts from 'echarts/core'; +import { LineChart, PieChart, ThemeRiverChart } from 'echarts/charts'; +import { + TooltipComponent, + LegendComponent, + GridComponent, + SingleAxisComponent, +} from 'echarts/components'; +import { CanvasRenderer } from 'echarts/renderers'; + +import Highcharts from 'highcharts'; +import HighchartsReact from 'highcharts-react-official' +import 'highcharts/modules/exporting'; +import 'highcharts/modules/export-data'; + +echarts.use([ + LineChart, + PieChart, + ThemeRiverChart, + TooltipComponent, + LegendComponent, + GridComponent, + SingleAxisComponent, + CanvasRenderer, +]); + + +const Charts = () => { + const cd = chartData; + const ld = liveChart; + const initEchartsOptions = { + renderer: 'canvas', + }; + const sparklineData = { + series: [{ data: [1, 7, 3, 5, 7, 8] }], + options1: { + colors: ['#2477ff'], + plotOptions: { + bar: { + columnWidth: '50%', + }, + }, + }, + options2: { + colors: ['#db2a34'], + plotOptions: { + bar: { + columnWidth: '50%', + }, + }, + }, + }; + + useEffect(() => () => { + clearInterval(liveChartInterval); + }, []); + + return ( +
+

Visual - Charts

+
+ + + Apex Column Chart} + close collapse + > + + + + + Echarts Line Chart} + close collapse + > + + + + + Highcharts Line Chart} + close collapse + > + +
Interactive Sparklines
+ + +
+
+

34 567

+
Overall Values
+
+
+ +
+
+ + +
+
+

34 567

+
Overall Values
+
+
+ +
+
+ +
+
+ + + + + Apex Monochrome Pie} + close collapse + > + + + + + Chart Donut Chart} + close collapse + > + + + + + Highcharts Live Chart} + close collapse + > + + + + + + + Echarts River Chart} + close collapse + > + + + +
+
+
+ ); +}; + +export default Charts; diff --git a/src/pages/charts/Charts.module.scss b/src/pages/charts/Charts.module.scss new file mode 100644 index 0000000..5a61624 --- /dev/null +++ b/src/pages/charts/Charts.module.scss @@ -0,0 +1,74 @@ +@import '../../styles/app'; + +.root { + :global { + /* NVD3 */ + .nvtooltip { + padding: $padding-small-vertical $padding-small-horizontal; + font-family: $font-family-base; + font-size: $font-size-sm; + text-align: center; + + p { + margin: 0; + padding: 0; + } + + h3 { + background: none; + border-bottom: 0; + } + } + + svg text { + font: $font-weight-base $font-size-sm $font-family-base; + fill: $text-color; + } + + svg .title { + font: $font-weight-bold $font-size-base $font-family-base; + } + + .nvd3.nv-noData { + font-size: $font-size-lg; + font-weight: $font-weight-bold; + } + + .nvd3 .nv-axis path.domain { + stroke-opacity: 0; + } + + .nv-controlsWrap { + .nv-legend-symbol { + fill: #666 !important; + stroke: #666 !important; + } + } + + /* Flot */ + .chart-tooltip { + position: fixed; + padding: $padding-small-vertical $padding-small-horizontal; + border: 1px solid $gray-600; + font-size: $font-size-mini; + background-color: $white; + } + + /* Easy Pie Chart */ + .easy-pie-chart { + position: relative; + display: inline-block; + line-height: 120px; + height: 120px; + width: 120px; + text-align: center; + color: $gray-600; + + canvas { + position: absolute; + top: 0; + left: 0; + } + } + } +} diff --git a/src/pages/charts/apex/Apex.js b/src/pages/charts/apex/Apex.js new file mode 100644 index 0000000..f12af8f --- /dev/null +++ b/src/pages/charts/apex/Apex.js @@ -0,0 +1,149 @@ +import React from 'react'; +import { + Col, + Row, +} from 'reactstrap'; +import ApexChart from 'react-apexcharts'; +import './ApexChart.module.scss'; +import Widget from '../../../components/Widget'; +import chartsData from './mock'; + +const ApexCharts = () => { + const cd = chartsData; + + return ( +
+

Visual - Apex Charts

+

For more information please read full documentation

+ + + Apex Line Chart} + close collapse + > + + + + + Apex Area Chart} + close collapse + > + + + + + Apex Column Chart} + close collapse + > + + + + + Apex Bar Chart} + close collapse + > + + + + + Apex Mixed Chart} + close collapse + > + + + + + + + Apex Pie Chart} + close collapse + > + + + + + Apex Donut Chart} + close collapse + > + + + + + Apex Heat Map Chart} + close collapse + > + + + + + + + Apex Radial Chart} + close collapse + > + + + + +
+ ); +}; + +export default ApexCharts; diff --git a/src/pages/charts/apex/ApexChart.module.scss b/src/pages/charts/apex/ApexChart.module.scss new file mode 100644 index 0000000..8cba83d --- /dev/null +++ b/src/pages/charts/apex/ApexChart.module.scss @@ -0,0 +1,5 @@ +:global { + .apexcharts-menu-item { + color: #777777; + } +} \ No newline at end of file diff --git a/src/pages/charts/apex/mock.js b/src/pages/charts/apex/mock.js new file mode 100644 index 0000000..3031c63 --- /dev/null +++ b/src/pages/charts/apex/mock.js @@ -0,0 +1,735 @@ +import config from '../config'; +const colors = config.chartColors; + +var generateDayWiseTimeSeries = function (baseval, count, yrange) { + var i = 0; + var series = []; + while (i < count) { + var x = baseval; + var y = Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min; + + series.push([x, y]); + baseval += 86400000; + i++; + } + return series; +}; + +function generateHeatMapData(count, yrange) { + var i = 0; + var series = []; + while (i < count) { + var x = (i + 1).toString(); + var y = Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min; + + series.push({ + x: x, + y: y + }); + i++; + } + return series; +} + +const actualDate = new Date(); +const actualYear = actualDate.getFullYear(); + +export default { + line: { + series: [{ + name: "Desktops", + data: [10, 41, 35, 51, 49, 62, 69, 91, 148] + }], + options: { + chart: { + height: 350, + zoom: { + enabled: false + } + }, + dataLabels: { + enabled: false + }, + stroke: { + curve: 'straight' + }, + title: { + text: 'Product Trends by Month', + align: 'left', + style: { + color: colors.textColor + } + }, + xaxis: { + categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'], + labels: { + style: { + colors: colors.textColor + } + }, + axisBorder: { + show: false + }, + axisTicks: { + show: false + } + }, + yaxis: { + labels: { + style: { + colors: colors.textColor + } + } + }, + tooltip: { + theme: 'dark' + }, + grid: { + borderColor: colors.gridLineColor + }, + colors: [colors.blue] + } + }, + area: { + series: [{ + name: 'South', + data: generateDayWiseTimeSeries(new Date('11 Feb 2017 GMT').getTime(), 20, { + min: 10, + max: 60 + }) + }, + { + name: 'North', + data: generateDayWiseTimeSeries(new Date('11 Feb 2017 GMT').getTime(), 20, { + min: 10, + max: 20 + }) + }, + { + name: 'Central', + data: generateDayWiseTimeSeries(new Date('11 Feb 2017 GMT').getTime(), 20, { + min: 10, + max: 15 + }) + } + ], + options: { + chart: { + stacked: true, + }, + tooltip: { + theme: 'dark' + }, + colors: [colors.blue, colors.green, colors.red], + dataLabels: { + enabled: false + }, + stroke: { + curve: 'smooth' + }, + fill: { + type: 'solid', + opacity: 1, + // gradient: { + // opacityFrom: 0.6, + // opacityTo: 0.8, + // } + }, + legend: { + position: 'top', + horizontalAlign: 'left', + labels: { + colors: [colors.textColor] + } + }, + xaxis: { + type: 'datetime', + labels: { + style: { + colors: colors.textColor + } + }, + axisBorder: { + show: false + }, + axisTicks: { + show: false + } + }, + yaxis: { + labels: { + style: { + colors: colors.textColor + } + } + }, + grid: { + borderColor: colors.gridLineColor + } + } + }, + column: { + series: [{ + name: 'Inflation', + data: [2.3, 3.1, 4.0, 10.1, 4.0, 3.6, 3.2, 2.3, 1.4, 0.8, 0.5, 0.2] + }], + options: { + colors: [colors.blue], + chart: { + // height: 450, + height: 350, + type: 'bar', + }, + tooltip: { + theme: 'dark' + }, + plotOptions: { + bar: { + dataLabels: { + position: 'top', // top, center, bottom, + }, + } + }, + dataLabels: { + enabled: true, + formatter: function (val) { + return val + "%"; + }, + offsetY: -20, + style: { + fontSize: '12px', + colors: [colors.textColor] + } + }, + + xaxis: { + categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], + position: 'top', + labels: { + style: { + colors: colors.textColor, + offsetY: -18, + } + }, + axisBorder: { + show: false + }, + axisTicks: { + show: false + }, + crosshairs: { + fill: { + type: 'gradient', + } + }, + tooltip: { + enabled: true, + offsetY: -35, + + } + }, + fill: { + gradient: { + shade: 'light', + type: "horizontal", + shadeIntensity: 0.25, + gradientToColors: undefined, + inverseColors: true, + opacityFrom: 1, + opacityTo: 1, + stops: [50, 0, 100, 100] + }, + }, + yaxis: { + axisBorder: { + show: false + }, + axisTicks: { + show: false, + }, + labels: { + show: false, + formatter: function (val) { + return val + "%"; + } + } + + }, + title: { + text: 'Monthly Inflation in Argentina, 2002', + align: 'top', + style: { + color: colors.textColor + } + }, + grid: { + borderColor: colors.gridLineColor + } + } + }, + bar: { + series: [{ + name: 'Males', + data: [0.4, 0.65, 0.76, 0.88, 1.5, 2.1, 2.9, 3.8, 3.9, 4.2, 4, 4.3, 4.1, 4.2, 4.5, + 3.9, 3.5, 3 + ] + }, + { + name: 'Females', + data: [-0.8, -1.05, -1.06, -1.18, -1.4, -2.2, -2.85, -3.7, -3.96, -4.22, -4.3, -4.4, + -4.1, -4, -4.1, -3.4, -3.1, -2.8 + ] + } + ], + options: { + chart: { + stacked: true + }, + colors: [colors.blue, colors.red], + plotOptions: { + bar: { + horizontal: true, + barHeight: '80%', + + }, + }, + dataLabels: { + enabled: false + }, + legend: { + labels: { + colors: [colors.textColor] + } + }, + stroke: { + width: 0, + }, + + grid: { + borderColor: colors.gridLineColor, + xaxis: { + showLines: false + } + }, + yaxis: { + min: -5, + max: 5, + title: { + style: { + colors: colors.textColor + } + }, + labels: { + style: { + colors: colors.textColor + } + } + }, + tooltip: { + theme: 'dark', + shared: false, + x: { + formatter: function (val) { + return val + } + }, + y: { + formatter: function (val) { + return Math.abs(val) + "%" + } + } + }, + title: { + text: 'Mauritius population pyramid 2011', + style: { + color: colors.textColor + } + }, + xaxis: { + categories: ['85+', '80-84', '75-79', '70-74', '65-69', '60-64', '55-59', '50-54', + '45-49', '40-44', '35-39', '30-34', '25-29', '20-24', '15-19', '10-14', '5-9', + '0-4' + ], + labels: { + formatter: function (val) { + return Math.abs(Math.round(val)) + "%" + }, + style: { + colors: colors.textColor + } + }, + axisBorder: { + show: false + }, + axisTicks: { + show: false + } + }, + } + }, + mixed: { + series: [{ + name: 'Income', + type: 'column', + data: [1.4, 2, 2.5, 1.5, 2.5, 2.8, 3.8, 4.6] + }, { + name: 'Cashflow', + type: 'column', + data: [1.1, 3, 3.1, 4, 4.1, 4.9, 6.5, 8.5] + }, { + name: 'Revenue', + type: 'line', + data: [20, 29, 37, 36, 44, 45, 50, 58] + }], + options: { + dataLabels: { + enabled: false + }, + colors: [colors.blue, colors.green, colors.red], + stroke: { + width: [1, 1, 4] + }, + title: { + text: 'XYZ - Stock Analysis (2009 - 2016)', + align: 'left', + offsetX: 110, + style: { + color: colors.textColor + } + }, + xaxis: { + categories: [actualYear-7, actualYear-6, actualYear-5, actualYear-4, actualYear-3, actualYear-2, actualYear-1, actualYear], + labels: { + style: { + colors: colors.textColor + } + }, + axisBorder: { + show: false + }, + axisTicks: { + show: false + } + }, + yaxis: [{ + axisTicks: { + show: true, + }, + axisBorder: { + show: true, + color: colors.blue + }, + labels: { + style: { + colors: colors.blue, + } + }, + title: { + text: "Income (thousand crores)", + style: { + color: colors.blue, + } + }, + tooltip: { + enabled: true + } + }, + + { + seriesName: 'Income', + opposite: true, + axisTicks: { + show: true, + }, + axisBorder: { + show: true, + color: colors.green + }, + labels: { + style: { + colors: colors.green, + } + }, + title: { + text: "Operating Cashflow (thousand crores)", + style: { + color: colors.green, + } + }, + }, + { + seriesName: 'Revenue', + opposite: true, + axisTicks: { + show: true, + }, + axisBorder: { + show: true, + color: colors.orange + }, + labels: { + style: { + colors: colors.orange, + }, + }, + title: { + text: "Revenue (thousand crores)", + style: { + color: colors.orange, + } + } + }, + ], + tooltip: { + theme: 'dark', + fixed: { + enabled: true, + position: 'topLeft', // topRight, topLeft, bottomRight, bottomLeft + offsetY: 30, + offsetX: 60 + }, + }, + legend: { + horizontalAlign: 'left', + offsetX: 40, + labels: { + colors: [colors.textColor] + } + }, + grid: { + borderColor: colors.gridLineColor + } + } + }, + pie: { + series: [44, 55, 13, 43, 22], + options: { + tooltip: { + theme: 'dark' + }, + legend: { + labels: { + colors: [colors.textColor] + } + }, + labels: ['Team A', 'Team B', 'Team C', 'Team D', 'Team E'], + responsive: [{ + breakpoint: 480, + options: { + chart: { + width: 200 + }, + legend: { + position: 'bottom', + } + } + }], + stroke: { + show: false, + width: 0 + }, + colors: [colors.blue, colors.green, colors.orange, colors.red, colors.purple], + } + }, + donut: { + series: [44, 55, 41, 17, 15], + options: { + tooltip: { + theme: 'dark' + }, + legend: { + labels: { + colors: [colors.textColor] + } + }, + responsive: [{ + breakpoint: 480, + options: { + chart: { + width: 200 + }, + legend: { + position: 'bottom', + } + } + }], + stroke: { + show: false, + width: 0 + }, + colors: [colors.blue, colors.green, colors.orange, colors.red, colors.purple], + } + }, + radial: { + series: [76, 67, 61, 90], + options: { + labels: ['January', 'February', 'March', 'April', 'May', 'June'], + title: { + text: 'Basic Radial Chart', + style: { + color: colors.textColor + } + }, + colors: [colors.blue, colors.green, colors.orange, colors.red], + plotOptions: { + radialBar: { + dataLabels: { + value: { + color: colors.textColor + } + }, + track: { + background: '#000000', + opacity: 0.24 + } + } + } + } + }, + heatmap: { + series: [{ + name: 'Jan', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'Feb', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'Mar', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'Apr', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'May', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'Jun', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'Jul', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'Aug', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + }, + { + name: 'Sep', + data: generateHeatMapData(20, { + min: -30, + max: 55 + }) + } + ], + options: { + tooltip: { + theme: 'dark' + }, + legend: { + labels: { + colors: [colors.textColor] + } + }, + xaxis: { + labels: { + style: { + colors: colors.textColor + } + }, + axisBorder: { + show: false + }, + axisTicks: { + show: false + } + }, + yaxis: { + labels: { + style: { + color: colors.textColor + } + } + }, + plotOptions: { + heatmap: { + shadeIntensity: 0.5, + radius: 0, + colorScale: { + ranges: [{ + from: -30, + to: 5, + name: 'low', + color: colors.green + }, + { + from: 6, + to: 20, + name: 'medium', + color: colors.blue + }, + { + from: 21, + to: 45, + name: 'high', + color: colors.orange + }, + { + from: 46, + to: 55, + name: 'extreme', + color: colors.red + } + ] + } + } + }, + dataLabels: { + enabled: false + }, + + title: { + text: 'HeatMap Chart with Color Range', + style: { + color: colors.textColor + } + }, + stroke: { + show: false, + width: 0 + }, + grid: { + show: false + } + } + } +} \ No newline at end of file diff --git a/src/pages/charts/apex/package.json b/src/pages/charts/apex/package.json new file mode 100644 index 0000000..d15a0cd --- /dev/null +++ b/src/pages/charts/apex/package.json @@ -0,0 +1,6 @@ +{ + "name": "Apex", + "version": "0.0.0", + "private": true, + "main": "./Apex.js" +} diff --git a/src/pages/charts/config.js b/src/pages/charts/config.js new file mode 100644 index 0000000..b88a229 --- /dev/null +++ b/src/pages/charts/config.js @@ -0,0 +1,18 @@ +const chartColors = { + blue: '#2477ff', + green: '#2d8515', + orange: '#e49400', + red: '#db2a34', + purple: '#474D84', + dark: '#040620', + teal: '#4179cf', + pink: '#e671b8', + gray: '#d6dee5', + default: '#595d78', + textColor: '#e0e0e1', + gridLineColor: '#040620' +}; + +export default { + chartColors +} diff --git a/src/pages/charts/echarts/Echarts.js b/src/pages/charts/echarts/Echarts.js new file mode 100644 index 0000000..37b86e4 --- /dev/null +++ b/src/pages/charts/echarts/Echarts.js @@ -0,0 +1,130 @@ +import React from 'react'; +import { + Row, + Col, +} from 'reactstrap'; + +import Widget from '../../../components/Widget'; +import echartsData from './mock'; + +import ReactEchartsCore from 'echarts-for-react/lib/core'; +import * as echarts from 'echarts/core'; +import { BarChart, PieChart, LineChart, ScatterChart, GaugeChart } from 'echarts/charts'; +import { + DatasetComponent, + GridComponent, + LegendComponent, + PolarComponent, + TitleComponent, + ToolboxComponent, + TooltipComponent, +} from 'echarts/components'; +import { CanvasRenderer } from 'echarts/renderers'; + +import './Echarts.scss'; + +echarts.use([ + BarChart, + PieChart, + LineChart, + ScatterChart, + GaugeChart, + DatasetComponent, + GridComponent, + LegendComponent, + PolarComponent, + TitleComponent, + ToolboxComponent, + TooltipComponent, + CanvasRenderer, +]); + +const Echarts = () => { + const ed = echartsData; + const initOptions = { + renderer: 'canvas' + }; + + return ( +
+

Visual - Echarts

+

For more information please read full documentation

+ + + Echarts Bar Chart} + close collapse + > + + + + + Echarts Pie Chart} + close collapse + > + + + + + Echarts Polar Chart} + close collapse + > + + + + + Echarts Line Chart} + close collapse + > + + + + + Echarts Scatter Chart} + close collapse + > + + + + + Echarts Gauge Chart} + close collapse + > + + + + +
+ ); +}; + +export default Echarts; diff --git a/src/pages/charts/echarts/Echarts.scss b/src/pages/charts/echarts/Echarts.scss new file mode 100644 index 0000000..9deef5e --- /dev/null +++ b/src/pages/charts/echarts/Echarts.scss @@ -0,0 +1,3 @@ +.echarts-for-react { + width: 100%; +} \ No newline at end of file diff --git a/src/pages/charts/echarts/mock.js b/src/pages/charts/echarts/mock.js new file mode 100644 index 0000000..7206584 --- /dev/null +++ b/src/pages/charts/echarts/mock.js @@ -0,0 +1,335 @@ +import config from '../config'; +const colors = config.chartColors; + +var scatterData = [[0, 0, 5], [0, 1, 1], [0, 2, 0], [0, 3, 0], [0, 4, 0], [0, 5, 0], [0, 6, 0], [0, 7, 0], [0, 8, 0], [0, 9, 0], [0, 10, 0], [0, 11, 2], [0, 12, 4], [0, 13, 1], [0, 14, 1], [0, 15, 3], [0, 16, 4], [0, 17, 6], [0, 18, 4], [0, 19, 4], [0, 20, 3], [0, 21, 3], [0, 22, 2], [0, 23, 5], [1, 0, 7], [1, 1, 0], [1, 2, 0], [1, 3, 0], [1, 4, 0], [1, 5, 0], [1, 6, 0], [1, 7, 0], [1, 8, 0], [1, 9, 0], [1, 10, 5], [1, 11, 2], [1, 12, 2], [1, 13, 6], [1, 14, 9], [1, 15, 11], [1, 16, 6], [1, 17, 7], [1, 18, 8], [1, 19, 12], [1, 20, 5], [1, 21, 5], [1, 22, 7], [1, 23, 2], [2, 0, 1], [2, 1, 1], [2, 2, 0], [2, 3, 0], [2, 4, 0], [2, 5, 0], [2, 6, 0], [2, 7, 0], [2, 8, 0], [2, 9, 0], [2, 10, 3], [2, 11, 2], [2, 12, 1], [2, 13, 9], [2, 14, 8], [2, 15, 10], [2, 16, 6], [2, 17, 5], [2, 18, 5], [2, 19, 5], [2, 20, 7], [2, 21, 4], [2, 22, 2], [2, 23, 4], [3, 0, 7], [3, 1, 3], [3, 2, 0], [3, 3, 0], [3, 4, 0], [3, 5, 0], [3, 6, 0], [3, 7, 0], [3, 8, 1], [3, 9, 0], [3, 10, 5], [3, 11, 4], [3, 12, 7], [3, 13, 14], [3, 14, 13], [3, 15, 12], [3, 16, 9], [3, 17, 5], [3, 18, 5], [3, 19, 10], [3, 20, 6], [3, 21, 4], [3, 22, 4], [3, 23, 1], [4, 0, 1], [4, 1, 3], [4, 2, 0], [4, 3, 0], [4, 4, 0], [4, 5, 1], [4, 6, 0], [4, 7, 0], [4, 8, 0], [4, 9, 2], [4, 10, 4], [4, 11, 4], [4, 12, 2], [4, 13, 4], [4, 14, 4], [4, 15, 14], [4, 16, 12], [4, 17, 1], [4, 18, 8], [4, 19, 5], [4, 20, 3], [4, 21, 7], [4, 22, 3], [4, 23, 0], [5, 0, 2], [5, 1, 1], [5, 2, 0], [5, 3, 3], [5, 4, 0], [5, 5, 0], [5, 6, 0], [5, 7, 0], [5, 8, 2], [5, 9, 0], [5, 10, 4], [5, 11, 1], [5, 12, 5], [5, 13, 10], [5, 14, 5], [5, 15, 7], [5, 16, 11], [5, 17, 6], [5, 18, 0], [5, 19, 5], [5, 20, 3], [5, 21, 4], [5, 22, 2], [5, 23, 0], [6, 0, 1], [6, 1, 0], [6, 2, 0], [6, 3, 0], [6, 4, 0], [6, 5, 0], [6, 6, 0], [6, 7, 0], [6, 8, 0], [6, 9, 0], [6, 10, 1], [6, 11, 0], [6, 12, 2], [6, 13, 1], [6, 14, 3], [6, 15, 4], [6, 16, 0], [6, 17, 0], [6, 18, 0], [6, 19, 0], [6, 20, 1], [6, 21, 2], [6, 22, 2], [6, 23, 6]]; +var scatterHours = ['12a', '1a', '2a', '3a', '4a', '5a', '6a', + '7a', '8a', '9a', '10a', '11a', + '12p', '1p', '2p', '3p', '4p', '5p', + '6p', '7p', '8p', '9p', '10p', '11p']; +var scatterDays = ['Saturday', 'Friday', 'Thursday', + 'Wednesday', 'Tuesday', 'Monday', 'Sunday']; +export default { + bar: { + legend: { + textStyle: { + color: colors.textColor + } + }, + tooltip: {}, + dataset: { + source: [ + ['Product', '2015', '2016', '2017'], + ['Matcha Latte', ...randomize()], + ['Milk Tea', ...randomize()], + ['Cheese Cocoa', ...randomize()], + ['Walnut Brownie', ...randomize()] + ] + }, + xAxis: { + type: 'category', + axisLabel: { + color: colors.textColor + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + } + }, + yAxis: { + axisLabel: { + color: colors.textColor + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + } + }, + series: [{type: 'bar'}, {type: 'bar'}, {type: 'bar'}], + color: [colors.blue, colors.green, colors.red, colors.dark, ] + }, + pie: { + tooltip: { + trigger: 'item', + formatter: '{a}
{b} : {c} ({d}%)' + }, + legend: { + orient: 'vertical', + left: 'left', + data: ['Direct interview', 'Email marketing', 'Alliance advertising', 'Video ad', 'Search engine'], + textStyle: { + color: colors.textColor + } + }, + series: [ + { + name: 'Access source', + type: 'pie', + radius: '55%', + center: ['50%', '60%'], + color: [colors.blue, colors.red, colors.orange, colors.green, colors.purple], + data: [ + {value: 335, name: 'Direct interview'}, + {value: 310, name: 'Email marketing'}, + {value: 234, name: 'Alliance advertising'}, + {value: 135, name: 'Video ad'}, + {value: 1548, name: 'Search engine'} + ], + emphasis: { + itemStyle: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } + } + ] + }, + polar: { + legend: { + data: ['line'], + textStyle: { + color: colors.textColor + } + }, + polar: { + center: ['50%', '54%'] + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'cross' + } + }, + angleAxis: { + type: 'value', + startAngle: 0, + axisLabel: { + color: colors.textColor + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + } + }, + radiusAxis: { + min: 0, + axisLabel: { + color: colors.textColor + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + } + }, + series: [ + { + coordinateSystem: 'polar', + name: 'line', + type: 'line', + showSymbol: false, + data: polarData(), + color: [colors.red] + } + ], + animationDuration: 2000 + }, + line: { + tooltip: { + trigger: 'axis' + }, + legend: { + data: ['Step Start', 'Step Middle', 'Step End'], + textStyle: { + color: colors.textColor + } + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + outerBoundsMode: 'same', + outerBoundsContain: 'axisLabel' + }, + toolbox: { + feature: { + saveAsImage: {} + } + }, + xAxis: { + type: 'category', + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + axisLabel: { + color: colors.textColor + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + } + }, + yAxis: { + type: 'value', + axisLabel: { + color: colors.textColor + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + } + }, + series: [ + { + name: 'Step Start', + type: 'line', + step: 'start', + data: [120, 132, 101, 134, 90, 230, 210], + color: [colors.blue] + }, + { + name: 'Step Middle', + type: 'line', + step: 'middle', + data: [220, 282, 201, 234, 290, 430, 410], + color: [colors.red] + }, + { + name: 'Step End', + type: 'line', + step: 'end', + data: [450, 432, 401, 454, 590, 530, 510], + color: [colors.orange] + } + ] + }, + scatter: { + title: { + text: 'Punch Card of Github', + link: 'https://github.com/pissang/echarts-next/graphs/punch-card', + textStyle: { + color: colors.textColor + } + }, + legend: { + data: ['Punch Card'], + left: 'right', + textStyle: { + color: colors.textColor + } + }, + tooltip: { + position: 'top', + formatter: function (params) { + return params.value[2] + ' commits in ' + scatterHours[params.value[0]] + ' of ' + scatterDays[params.value[1]]; + } + }, + grid: { + left: 2, + bottom: 10, + right: 10, + outerBoundsMode: 'same', + outerBoundsContain: 'axisLabel' + }, + xAxis: { + type: 'category', + data: scatterHours, + boundaryGap: false, + splitLine: { + show: true, + lineStyle: { + color: colors.textColor, + type: 'dashed' + } + }, + axisLine: { + show: false, + lineStyle: { + color: colors.textColor + } + }, + axisLabel: { + color: colors.textColor + } + }, + yAxis: { + type: 'category', + data: scatterDays, + axisLine: { + show: false, + lineStyle: { + color: colors.textColor + } + }, + axisLabel: { + color: colors.textColor + } + }, + series: [{ + color: [colors.red], + name: 'Punch Card', + type: 'scatter', + symbolSize: function (val) { + return val[2] * 2; + }, + data: scatterData.map(function (item) { + return [item[1], item[0], item[2]]; + }), + animationDelay: function (idx) { + return idx * 5; + } + }] + }, + gauge: { + tooltip: { + formatter: "{a}
{b} : {c}%" + }, + toolbox: { + feature: { + restore: {}, + saveAsImage: {} + } + }, + series: [ + { + name: 'Business indicator', + type: 'gauge', + axisLabel: { + color: colors.textColor + }, + detail: { + formatter: '{value}%' + }, + title: { + color: colors.textColor + }, + data: [{value: 64, name: 'Rate'}], + axisLine: { + lineStyle: { + color: [[0.2,colors.green], [0.8,colors.blue], [1,colors.red]], + } + }, + } + ] + } +} + +function polarData() { + let data = []; + + for (let i = 0; i <= 360; i++) { + let t = (i / 180) * Math.PI; + let r = Math.sin(2 * t) * Math.cos(2 * t); + data.push([r, i]) + } + return data; +} + +function randomize() { + return [0, 0, 0].map(() => { + return Math.round(300 + Math.random() * 700) / 10 + }) +} diff --git a/src/pages/charts/echarts/package.json b/src/pages/charts/echarts/package.json new file mode 100644 index 0000000..3e62b85 --- /dev/null +++ b/src/pages/charts/echarts/package.json @@ -0,0 +1,6 @@ +{ + "name": "Echarts", + "version": "0.0.0", + "private": true, + "main": "./Echarts.js" +} diff --git a/src/pages/charts/highcharts/HighCharts.js b/src/pages/charts/highcharts/HighCharts.js new file mode 100644 index 0000000..ac15a9c --- /dev/null +++ b/src/pages/charts/highcharts/HighCharts.js @@ -0,0 +1,84 @@ +import React from 'react'; +import { + Row, + Col, +} from 'reactstrap'; +import Highcharts from 'highcharts'; +import HighchartsReact from 'highcharts-react-official' +import 'highcharts/modules/variable-pie'; +import 'highcharts/modules/exporting'; +import 'highcharts/modules/export-data'; +import 'highcharts/modules/accessibility'; +import 'highcharts/highcharts-3d'; +import 'highcharts/modules/sunburst'; +import 'highcharts/modules/vector'; +import 'highcharts/modules/wordcloud'; +import Widget from '../../../components/Widget'; +import chartsData from './mock'; + +const HighCharts = () => { + const cd = chartsData; + + return ( +
+

Visual - Highcharts

+

For more information please read full documentation

+ + + Highcharts Line Chart} + close collapse + > + + + + + Highcharts Pie Chart} + close collapse + > + + + + + Highcharts Column 3D Chart} + close collapse + > + + + + + + + Highcharts Vector Chart} + close collapse + > + + + + + Highcharts Sunburst Chart} + close collapse + > + + + + + + + Highcharts Sunburst Chart} + close collapse + > + + + + +
+ ); +}; + +export default HighCharts; diff --git a/src/pages/charts/highcharts/mock.js b/src/pages/charts/highcharts/mock.js new file mode 100644 index 0000000..4a6cf0e --- /dev/null +++ b/src/pages/charts/highcharts/mock.js @@ -0,0 +1,435 @@ +import Highcharts from 'highcharts'; +import usdeur from './usdeur'; +import sunburstData from './sunburstData'; + +import config from '../config'; +const colors = config.chartColors; +const hasTouchSupport = typeof document !== 'undefined' && 'ontouchstart' in document; + +let wordCloudText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean bibendum erat ac justo sollicitudin, quis lacinia ligula fringilla. Pellentesque hendrerit, nisi vitae posuere condimentum, lectus urna accumsan libero, rutrum commodo mi lacus pretium erat. Phasellus pretium ultrices mi sed semper.'; +let wordCloudLines = wordCloudText.split(/[,. ]+/g); +let wordCloudData = wordCloudLines.reduce((arr, word) => { + const found = arr.find((item) => item.name === word); + + if (found) { + found.weight += 1; + } else { + arr.push({ + name: word, + weight: 1, + }); + } + + return arr; +}, []); + +function generateVectorData() { + var data = [], + x, + y, + length, + direction; + + for (x = 5; x < 100; x += 5) { + for (y = 5; y < 100; y += 5) { + length = Math.round(200 - (x + y)); + direction = Math.round((x + y) / 200 * 360); + data.push([ + x, + y, + length, + direction + ]); + } + } + return data; +} + +export default { + line: { + credits: { + enabled: false + }, + colors: [colors.blue], + chart: { + zoomType: 'x', + backgroundColor: 'transparent' + }, + title: { + text: 'USD to EUR exchange rate over time', + style: { + color: colors.textColor + } + }, + exporting: { + enabled: false + }, + subtitle: { + text: !hasTouchSupport ? + 'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in', + style: { + color: colors.textColor + } + }, + xAxis: { + type: 'datetime', + labels: { + style: { + color: colors.textColor + } + }, + lineWidth: 0, + tickWidth: 0 + }, + yAxis: { + title: { + text: 'Exchange rate', + style: { + color: colors.textColor + } + }, + labels: { + style: { + color: colors.textColor + } + }, + gridLineColor: colors.gridLineColor + }, + legend: { + enabled: false + }, + plotOptions: { + area: { + fillColor: { + linearGradient: { + x1: 0, + y1: 0, + x2: 0, + y2: 1 + }, + stops: [ + [0, colors.blue], + [1, Highcharts.color(colors.blue).setOpacity(0).get('rgba')] + ] + }, + marker: { + radius: 2 + }, + lineWidth: 1, + states: { + hover: { + lineWidth: 1 + } + }, + threshold: null + } + }, + + series: [{ + type: 'area', + name: 'USD to EUR', + data: usdeur + }] + }, + pie: { + credits: { + enabled: false + }, + chart: { + type: 'variablepie', + backgroundColor: 'transparent' + }, + exporting: { + enabled: false + }, + accessibility: { + description: 'A variable radius pie chart compares the population density and total land mass for seven European nations: Spain, France, Poland, the Czech Republic, Italy, Switzerland and Germany. The chart visualizes the data by using the width of each section to represent total area and the depth of the section to represent population density. Each section is color-coded according to the country and the chart is interactive: by hovering over each section the data points are exposed in a call-out box. The chart is organized by population density in a counterclockwise direction. Germany has the highest population density at 235.6 people per square kilometer, followed by Switzerland, Italy, the Czech Republic, Poland, France and Spain. France has the largest land mass at 551,500 square kilometers. Spain is the second largest country at 505,370 square kilometers but has the lowest population density at 92.9 people per square kilometer. Switzerland is the smallest nation by land mass at 41,277 square kilometers but it has the second highest population density at 214.5 people per square kilometer.' + }, + title: { + text: 'Countries compared by population density and total area.', + style: { + color: colors.textColor + } + }, + tooltip: { + headerFormat: '', + pointFormat: '\u25CF {point.name}
' + + 'Area (square km): {point.y}
' + + 'Population density (people per square km): {point.z}
' + }, + plotOptions: { + variablepie: { + borderColor: null, + dataLabels: { + style: { + color: colors.textColor, + textOutline: null + } + } + } + }, + colors: [colors.blue, colors.green, colors.orange, colors.red, colors.purple, colors.pink, colors.teal], + series: [{ + minPointSize: 10, + innerSize: '20%', + zMin: 0, + name: 'countries', + data: [{ + name: 'Spain', + y: 505370, + z: 92.9 + }, { + name: 'France', + y: 551500, + z: 118.7 + }, { + name: 'Poland', + y: 312685, + z: 124.6 + }, { + name: 'Czech Republic', + y: 78867, + z: 137.5 + }, { + name: 'Italy', + y: 301340, + z: 201.8 + }, { + name: 'Switzerland', + y: 41277, + z: 214.5 + }, { + name: 'Germany', + y: 357022, + z: 235.6 + }] + }] + }, + column3D: { + credits: { + enabled: false + }, + colors: [colors.red], + chart: { + backgroundColor: 'transparent', + type: 'column', + options3d: { + enabled: true, + alpha: 10, + beta: 25, + depth: 70 + } + }, + exporting: { + enabled: false + }, + title: { + text: '3D chart with null values', + style: { + color: colors.textColor + } + }, + legend: { + itemStyle: { + color: colors.textColor + } + }, + subtitle: { + text: 'Notice the difference between a 0 value and a null point', + style: { + color: colors.textColor + } + }, + plotOptions: { + column: { + depth: 25 + } + }, + xAxis: { + categories: Highcharts.getOptions().lang.shortMonths, + labels: { + skew3d: true, + style: { + fontSize: '16px', + color: colors.textColor + } + }, + gridLineColor: colors.gridLineColor + }, + yAxis: { + labels: { + style: { + color: colors.textColor + } + }, + title: { + text: null + }, + gridLineColor: colors.gridLineColor + }, + series: [{ + name: 'Sales', + data: [2, 3, null, 4, 0, 5, 1, 4, 6, 3] + }] + }, + sunburst: { + credits: { + enabled: false + }, + chart: { + height: '100%', + backgroundColor: 'transparent' + }, + exporting: { + enabled: false + }, + title: { + text: 'World population 2017', + style: { + color: colors.textColor + } + }, + subtitle: { + text: 'Source: Wikipedia (United Nations)', + style: { + color: colors.textColor + } + }, + plotOptions: { + sunburst: { + dataLabels: { + style: { + color: colors.textColor, + textOutline: null + } + } + } + }, + colors: [colors.blue, colors.green, colors.orange, colors.red, colors.purple, colors.dark, colors.teal], + series: [{ + type: "sunburst", + data: sunburstData, + allowDrillToNode: true, + cursor: 'pointer', + dataLabels: { + format: '{point.name}', + filter: { + property: 'innerArcLength', + operator: '>', + value: 16 + } + }, + levels: [{ + level: 1, + levelIsConstant: false, + dataLabels: { + filter: { + property: 'outerArcLength', + operator: '>', + value: 64 + } + } + }, { + level: 2, + colorByPoint: true + }, + { + level: 3, + colorVariation: { + key: 'brightness', + to: -0.5 + } + }, { + level: 4, + colorVariation: { + key: 'brightness', + to: 0.5 + } + }] + + }], + tooltip: { + headerFormat: "", + pointFormat: 'The population of {point.name} is {point.value}' + } + }, + vector: { + chart: { + backgroundColor: 'transparent' + }, + credits: { + enabled: false + }, + title: { + text: 'Highcharts Vector plot', + style: { + color: colors.textColor + } + }, + exporting: { + enabled: false + }, + xAxis: { + min: 0, + max: 100, + gridLineWidth: 1, + labels: { + style: { + color: colors.textColor + } + }, + gridLineColor: colors.gridLineColor, + lineWidth: 0, + tickWidth: 0 + }, + yAxis: { + min: 0, + max: 100, + title: { + style: { + color: colors.textColor + } + }, + labels: { + style: { + color: colors.textColor + } + }, + gridLineColor: colors.gridLineColor + }, + legend: { + itemStyle: { + color: colors.textColor + } + }, + series: [{ + type: 'vector', + name: 'Sample vector field', + color: colors.textColor, + data: generateVectorData() + }] + }, + wordCloud: { + chart: { + backgroundColor: 'transparent' + }, + credits: { + enabled: false + }, + colors: [colors.blue, colors.green, colors.orange, colors.red, colors.purple, colors.pink, colors.teal], + exporting: { + enabled: false + }, + series: [{ + type: 'wordcloud', + data: wordCloudData, + name: 'Occurrences' + }], + title: { + text: 'Wordcloud of Lorem Ipsum', + style: { + color: colors.textColor + } + } + } +} diff --git a/src/pages/charts/highcharts/package.json b/src/pages/charts/highcharts/package.json new file mode 100644 index 0000000..6014c3f --- /dev/null +++ b/src/pages/charts/highcharts/package.json @@ -0,0 +1,6 @@ +{ + "name": "HighCharts", + "version": "0.0.0", + "private": true, + "main": "./HighCharts.js" +} diff --git a/src/pages/charts/highcharts/sunburstData.js b/src/pages/charts/highcharts/sunburstData.js new file mode 100644 index 0000000..ec22b5d --- /dev/null +++ b/src/pages/charts/highcharts/sunburstData.js @@ -0,0 +1,1376 @@ +export default [{ + id: '0.0', + parent: '', + name: 'The World' +}, { + id: '1.3', + parent: '0.0', + name: 'Asia' +}, { + id: '1.1', + parent: '0.0', + name: 'Africa' +}, { + id: '1.2', + parent: '0.0', + name: 'America' +}, { + id: '1.4', + parent: '0.0', + name: 'Europe' +}, { + id: '1.5', + parent: '0.0', + name: 'Oceanic' +}, + + /* Africa */ + { + id: '2.1', + parent: '1.1', + name: 'Eastern Africa' + }, + + { + id: '3.1', + parent: '2.1', + name: 'Ethiopia', + value: 104957438 + }, { + id: '3.2', + parent: '2.1', + name: 'Tanzania', + value: 57310019 + }, { + id: '3.3', + parent: '2.1', + name: 'Kenya', + value: 49699862 + }, { + id: '3.4', + parent: '2.1', + name: 'Uganda', + value: 42862958 + }, { + id: '3.5', + parent: '2.1', + name: 'Mozambique', + value: 29668834 + }, { + id: '3.6', + parent: '2.1', + name: 'Madagascar', + value: 25570895 + }, { + id: '3.7', + parent: '2.1', + name: 'Malawi', + value: 18622104 + }, { + id: '3.8', + parent: '2.1', + name: 'Zambia', + value: 17094130 + }, { + id: '3.9', + parent: '2.1', + name: 'Zimbabwe', + value: 16529904 + }, { + id: '3.10', + parent: '2.1', + name: 'Somalia', + value: 14742523 + }, { + id: '3.11', + parent: '2.1', + name: 'South Sudan', + value: 12575714 + }, { + id: '3.12', + parent: '2.1', + name: 'Rwanda', + value: 12208407 + }, { + id: '3.13', + parent: '2.1', + name: 'Burundi', + value: 10864245 + }, { + id: '3.14', + parent: '2.1', + name: 'Eritrea', + value: 5068831 + }, { + id: '3.15', + parent: '2.1', + name: 'Mauritius', + value: 1265138 + }, { + id: '3.16', + parent: '2.1', + name: 'Djibouti', + value: 956985 + }, { + id: '3.17', + parent: '2.1', + name: 'RĂ©union', + value: 876562 + }, { + id: '3.18', + parent: '2.1', + name: 'Comoros', + value: 813912 + }, { + id: '3.19', + parent: '2.1', + name: 'Mayotte', + value: 253045 + }, { + id: '3.20', + parent: '2.1', + name: 'Seychelles', + value: 94737 + }, + + { + id: '2.5', + parent: '1.1', + name: 'Western Africa' + }, + + { + id: '3.42', + parent: '2.5', + name: 'Nigeria', + value: 190886311 + }, { + id: '3.43', + parent: '2.5', + name: 'Ghana', + value: 28833629 + }, { + id: '3.44', + parent: '2.5', + name: 'CĂŽte Ivoire', + value: 24294750 + }, { + id: '3.45', + parent: '2.5', + name: 'Niger', + value: 21477348 + }, { + id: '3.46', + parent: '2.5', + name: 'Burkina Faso', + value: 19193382 + }, { + id: '3.47', + parent: '2.5', + name: 'Mali', + value: 18541980 + }, { + id: '3.48', + parent: '2.5', + name: 'Senegal', + value: 15850567 + }, { + id: '3.49', + parent: '2.5', + name: 'Guinea', + value: 12717176 + }, { + id: '3.50', + parent: '2.5', + name: 'Benin', + value: 11175692 + }, { + id: '3.51', + parent: '2.5', + name: 'Togo', + value: 7797694 + }, { + id: '3.52', + parent: '2.5', + name: 'Sierra Leone', + value: 7557212 + }, { + id: '3.53', + parent: '2.5', + name: 'Liberia', + value: 4731906 + }, { + id: '3.54', + parent: '2.5', + name: 'Mauritania', + value: 4420184 + }, { + id: '3.55', + parent: '2.5', + name: 'The Gambia', + value: 2100568 + }, { + id: '3.56', + parent: '2.5', + name: 'Guinea-Bissau', + value: 1861283 + }, { + id: '3.57', + parent: '2.5', + name: 'Cabo Verde', + value: 546388 + }, { + id: '3.58', + parent: '2.5', + name: 'Saint Helena, Ascension and Tristan da Cunha', + value: 4049 + }, + + { + id: '2.3', + parent: '1.1', + name: 'North Africa' + }, + + { + id: '3.30', + parent: '2.3', + name: 'Egypt', + value: 97553151 + }, { + id: '3.31', + parent: '2.3', + name: 'Algeria', + value: 41318142 + }, { + id: '3.32', + parent: '2.3', + name: 'Sudan', + value: 40533330 + }, { + id: '3.33', + parent: '2.3', + name: 'Morocco', + value: 35739580 + }, { + id: '3.34', + parent: '2.3', + name: 'Tunisia', + value: 11532127 + }, { + id: '3.35', + parent: '2.3', + name: 'Libya', + value: 6374616 + }, { + id: '3.36', + parent: '2.3', + name: 'Western Sahara', + value: 552628 + }, + + { + id: '2.2', + parent: '1.1', + name: 'Central Africa' + }, + + { + id: '3.21', + parent: '2.2', + name: 'Democratic Republic of the Congo', + value: 81339988 + }, { + id: '3.22', + parent: '2.2', + name: 'Angola', + value: 29784193 + }, { + id: '3.23', + parent: '2.2', + name: 'Cameroon', + value: 24053727 + }, { + id: '3.24', + parent: '2.2', + name: 'Chad', + value: 14899994 + }, { + id: '3.25', + parent: '2.2', + name: 'Congo', + value: 5260750 + }, { + id: '3.26', + parent: '2.2', + name: 'Central African Republic', + value: 4659080 + }, { + id: '3.27', + parent: '2.2', + name: 'Gabon', + value: 2025137 + }, { + id: '3.28', + parent: '2.2', + name: 'Equatorial Guinea', + value: 1267689 + }, { + id: '3.29', + parent: '2.2', + name: 'Sao Tome and Principe', + value: 204327 + }, + + { + id: '2.4', + parent: '1.1', + name: 'South America' + }, + + { + id: '3.37', + parent: '2.4', + name: 'South Africa', + value: 56717156 + }, { + id: '3.38', + parent: '2.4', + name: 'Namibia', + value: 2533794 + }, { + id: '3.39', + parent: '2.4', + name: 'Botswana', + value: 2291661 + }, { + id: '3.40', + parent: '2.4', + name: 'Lesotho', + value: 2233339 + }, { + id: '3.41', + parent: '2.4', + name: 'Swaziland', + value: 1367254 + }, + + /***********/ + + /* America */ + { + id: '2.9', + parent: '1.2', + name: 'South America' + }, + + { + id: '3.98', + parent: '2.9', + name: 'Brazil', + value: 209288278 + }, { + id: '3.99', + parent: '2.9', + name: 'Colombia', + value: 49065615 + }, { + id: '3.100', + parent: '2.9', + name: 'Argentina', + value: 44271041 + }, { + id: '3.101', + parent: '2.9', + name: 'Peru', + value: 32165485 + }, { + id: '3.102', + parent: '2.9', + name: 'Venezuela', + value: 31977065 + }, { + id: '3.103', + parent: '2.9', + name: 'Chile', + value: 18054726 + }, { + id: '3.104', + parent: '2.9', + name: 'Ecuador', + value: 16624858 + }, { + id: '3.105', + parent: '2.9', + name: 'Bolivia', + value: 11051600 + }, { + id: '3.106', + parent: '2.9', + name: 'Paraguay', + value: 6811297 + }, { + id: '3.107', + parent: '2.9', + name: 'Uruguay', + value: 3456750 + }, { + id: '3.108', + parent: '2.9', + name: 'Guyana', + value: 777859 + }, { + id: '3.109', + parent: '2.9', + name: 'Suriname', + value: 563402 + }, { + id: '3.110', + parent: '2.9', + name: 'French Guiana', + value: 282731 + }, { + id: '3.111', + parent: '2.9', + name: 'Falkland Islands', + value: 2910 + }, + + { + id: '2.8', + parent: '1.2', + name: 'Northern America' + }, + + { + id: '3.93', + parent: '2.8', + name: 'United States', + value: 324459463 + }, { + id: '3.94', + parent: '2.8', + name: 'Canada', + value: 36624199 + }, { + id: '3.95', + parent: '2.8', + name: 'Bermuda', + value: 61349 + }, { + id: '3.96', + parent: '2.8', + name: 'Greenland', + value: 56480 + }, { + id: '3.97', + parent: '2.8', + name: 'Saint Pierre and Miquelon', + value: 6320 + }, + + { + id: '2.7', + parent: '1.2', + name: 'Central America' + }, + + { + id: '3.85', + parent: '2.7', + name: 'Mexico', + value: 129163276 + }, { + id: '3.86', + parent: '2.7', + name: 'Guatemala', + value: 16913503 + }, { + id: '3.87', + parent: '2.7', + name: 'Honduras', + value: 9265067 + }, { + id: '3.88', + parent: '2.7', + name: 'El Salvador', + value: 6377853 + }, { + id: '3.89', + parent: '2.7', + name: 'Nicaragua', + value: 6217581 + }, { + id: '3.90', + parent: '2.7', + name: 'Costa Rica', + value: 4905769 + }, { + id: '3.91', + parent: '2.7', + name: 'Panama', + value: 4098587 + }, { + id: '3.92', + parent: '2.7', + name: 'Belize', + value: 374681 + }, + + { + id: '2.6', + parent: '1.2', + name: 'Caribbean' + }, + + { + id: '3.59', + parent: '2.6', + name: 'Cuba', + value: 11484636 + }, { + id: '3.60', + parent: '2.6', + name: 'Haiti', + value: 10981229 + }, { + id: '3.61', + parent: '2.6', + name: 'Dominican Republic', + value: 10766998 + }, { + id: '3.62', + parent: '2.6', + name: 'Puerto Rico', + value: 3663131 + }, { + id: '3.63', + parent: '2.6', + name: 'Jamaica', + value: 2890299 + }, { + id: '3.64', + parent: '2.6', + name: 'Trinidad and Tobago', + value: 1369125 + }, { + id: '3.65', + parent: '2.6', + name: 'Guadeloupe', + value: 449568 + }, { + id: '3.66', + parent: '2.6', + name: 'Bahamas', + value: 395361 + }, { + id: '3.67', + parent: '2.6', + name: 'Martinique', + value: 384896 + }, { + id: '3.68', + parent: '2.6', + name: 'Barbados', + value: 285719 + }, { + id: '3.69', + parent: '2.6', + name: 'Saint Lucia', + value: 178844 + }, { + id: '3.70', + parent: '2.6', + name: 'Curaçao', + value: 160539 + }, { + id: '3.71', + parent: '2.6', + name: 'Saint Vincent and the Grenadines', + value: 109897 + }, { + id: '3.72', + parent: '2.6', + name: 'Grenada', + value: 107825 + }, { + id: '3.73', + parent: '2.6', + name: 'Aruba', + value: 105264 + }, { + id: '3.74', + parent: '2.6', + name: 'United States Virgin Islands', + value: 104901 + }, { + id: '3.75', + parent: '2.6', + name: 'Antigua and Barbuda', + value: 102012 + }, { + id: '3.76', + parent: '2.6', + name: 'Dominica', + value: 73925 + }, { + id: '3.77', + parent: '2.6', + name: 'Cayman Islands', + value: 61559 + }, { + id: '3.78', + parent: '2.6', + name: 'Saint Kitts and Nevis', + value: 55345 + }, { + id: '3.79', + parent: '2.6', + name: 'Sint Maarten', + value: 40120 + }, { + id: '3.80', + parent: '2.6', + name: 'Turks and Caicos Islands', + value: 35446 + }, { + id: '3.81', + parent: '2.6', + name: 'British Virgin Islands', + value: 31196 + }, { + id: '3.82', + parent: '2.6', + name: 'Caribbean Netherlands', + value: 25398 + }, { + id: '3.83', + parent: '2.6', + name: 'Anguilla', + value: 14909 + }, { + id: '3.84', + parent: '2.6', + name: 'Montserrat', + value: 5177 + }, + /***********/ + + /* Asia */ + { + id: '2.13', + parent: '1.3', + name: 'Southern Asia' + }, + + { + id: '3.136', + parent: '2.13', + name: 'India', + value: 1339180127 + }, { + id: '3.137', + parent: '2.13', + name: 'Pakistan', + value: 197015955 + }, { + id: '3.138', + parent: '2.13', + name: 'Bangladesh', + value: 164669751 + }, { + id: '3.139', + parent: '2.13', + name: 'Iran', + value: 81162788 + }, { + id: '3.140', + parent: '2.13', + name: 'Afghanistan', + value: 35530081 + }, { + id: '3.141', + parent: '2.13', + name: 'Nepal', + value: 29304998 + }, { + id: '3.142', + parent: '2.13', + name: 'Sri Lanka', + value: 20876917 + }, { + id: '3.143', + parent: '2.13', + name: 'Bhutan', + value: 807610 + }, { + id: '3.144', + parent: '2.13', + name: 'Maldives', + value: 436330 + }, + + { + id: '2.11', + parent: '1.3', + name: 'Eastern Asia' + }, + + { + id: '3.117', + parent: '2.11', + name: 'China', + value: 1409517397 + }, { + id: '3.118', + parent: '2.11', + name: 'Japan', + value: 127484450 + }, { + id: '3.119', + parent: '2.11', + name: 'South Korea', + value: 50982212 + }, { + id: '3.120', + parent: '2.11', + name: 'North Korea', + value: 25490965 + }, { + id: '3.121', + parent: '2.11', + name: 'Taiwan', + value: 23626456 + }, { + id: '3.122', + parent: '2.11', + name: 'Hong Kong', + value: 7364883 + }, { + id: '3.123', + parent: '2.11', + name: 'Mongolia', + value: 3075647 + }, { + id: '3.124', + parent: '2.11', + name: 'Macau', + value: 622567 + }, + + { + id: '2.12', + parent: '1.3', + name: 'South-Eastern Asia' + }, + + { + id: '3.125', + parent: '2.12', + name: 'Indonesia', + value: 263991379 + }, { + id: '3.126', + parent: '2.12', + name: 'Philippines', + value: 104918090 + }, { + id: '3.127', + parent: '2.12', + name: 'Vietnam', + value: 95540800 + }, { + id: '3.128', + parent: '2.12', + name: 'Thailand', + value: 69037513 + }, { + id: '3.129', + parent: '2.12', + name: 'Myanmar', + value: 53370609 + }, { + id: '3.130', + parent: '2.12', + name: 'Malaysia', + value: 31624264 + }, { + id: '3.131', + parent: '2.12', + name: 'Cambodia', + value: 16005373 + }, { + id: '3.132', + parent: '2.12', + name: 'Laos', + value: 6858160 + }, { + id: '3.133', + parent: '2.12', + name: 'Singapore', + value: 5708844 + }, { + id: '3.134', + parent: '2.12', + name: 'Timor-Leste', + value: 1296311 + }, { + id: '3.135', + parent: '2.12', + name: 'Brunei', + value: 428697 + // 'color': '' + }, + + { + id: '2.14', + parent: '1.3', + name: 'Western Asia' + }, + + { + id: '3.145', + parent: '2.14', + name: 'Turkey', + value: 80745020 + }, { + id: '3.146', + parent: '2.14', + name: 'Iraq', + value: 38274618 + }, { + id: '3.147', + parent: '2.14', + name: 'Saudi Arabia', + value: 32938213 + }, { + id: '3.148', + parent: '2.14', + name: 'Yemen', + value: 28250420 + }, { + id: '3.149', + parent: '2.14', + name: 'Syria', + value: 18269868 + }, { + id: '3.150', + parent: '2.14', + name: 'Azerbaijan', + value: 9827589 + }, { + id: '3.151', + parent: '2.14', + name: 'Jordan', + value: 9702353 + }, { + id: '3.152', + parent: '2.14', + name: 'United Arab Emirates', + value: 9400145 + }, { + id: '3.153', + parent: '2.14', + name: 'Israel', + value: 8321570 + }, { + id: '3.154', + parent: '2.14', + name: 'Lebanon', + value: 6082357 + }, { + id: '3.155', + parent: '2.14', + name: 'Palestine', + value: 4920724 + }, { + id: '3.156', + parent: '2.14', + name: 'Oman', + value: 4636262 + }, { + id: '3.157', + parent: '2.14', + name: 'Kuwait', + value: 4136528 + }, { + id: '3.158', + parent: '2.14', + name: 'Georgia', + value: 3912061 + }, { + id: '3.159', + parent: '2.14', + name: 'Armenia', + value: 2930450 + }, { + id: '3.160', + parent: '2.14', + name: 'Qatar', + value: 2639211 + }, { + id: '3.161', + parent: '2.14', + name: 'Bahrain', + value: 1492584 + }, + + { + id: '2.10', + parent: '1.3', + name: 'Central Asia' + }, + + { + id: '3.112', + parent: '2.10', + name: 'Uzbekistan', + value: 31910641 + }, { + id: '3.113', + parent: '2.10', + name: 'Kazakhstan', + value: 18204499 + }, { + id: '3.114', + parent: '2.10', + name: 'Tajikistan', + value: 8921343 + }, { + id: '3.115', + parent: '2.10', + name: 'Kyrgyzstan', + value: 6045117 + }, { + id: '3.116', + parent: '2.10', + name: 'Turkmenistan', + value: 5758075 + }, + /***********/ + + /* Europe */ + { + id: '2.15', + parent: '1.4', + name: 'Eastern Europe' + }, + + { + id: '3.162', + parent: '2.15', + name: 'Russia', + value: 143989754 + }, { + id: '3.163', + parent: '2.15', + name: 'Ukraine', + value: 44222947 + }, { + id: '3.164', + parent: '2.15', + name: 'Poland', + value: 38170712 + }, { + id: '3.165', + parent: '2.15', + name: 'Romania', + value: 19679306 + }, { + id: '3.166', + parent: '2.15', + name: 'Czechia', + value: 10618303 + }, { + id: '3.167', + parent: '2.15', + name: 'Hungary', + value: 9721559 + }, { + id: '3.168', + parent: '2.15', + name: 'Belarus', + value: 9468338 + }, { + id: '3.169', + parent: '2.15', + name: 'Bulgaria', + value: 7084571 + }, { + id: '3.170', + parent: '2.15', + name: 'Slovakia', + value: 5447662 + }, { + id: '3.171', + parent: '2.15', + name: 'Moldova', + value: 4051212 + }, { + id: '3.172', + parent: '2.15', + name: 'Cyprus', + value: 1179551 + }, + + { + id: '2.16', + parent: '1.4', + name: 'Northern Europe' + }, + + { + id: '3.173', + parent: '2.16', + name: 'United Kingdom', + value: 66181585 + }, { + id: '3.174', + parent: '2.16', + name: 'Sweden', + value: 9910701 + }, { + id: '3.175', + parent: '2.16', + name: 'Denmark', + value: 5733551 + }, { + id: '3.176', + parent: '2.16', + name: 'Finland', + value: 5523231 + }, { + id: '3.177', + parent: '2.16', + name: 'Norway', + value: 5305383 + }, { + id: '3.178', + parent: '2.16', + name: 'Ireland', + value: 4761657 + }, { + id: '3.179', + parent: '2.16', + name: 'Lithuania', + value: 2890297 + }, { + id: '3.180', + parent: '2.16', + name: 'Latvia', + value: 1949670 + }, { + id: '3.181', + parent: '2.16', + name: 'Estonia', + value: 1309632 + }, { + id: '3.182', + parent: '2.16', + name: 'Iceland', + value: 335025 + }, { + id: '3.183', + parent: '2.16', + name: 'Guernsey and Jersey', + value: 165314 + }, { + id: '3.184', + parent: '2.16', + name: 'Isle of Man', + value: 84287 + }, { + id: '3.185', + parent: '2.16', + name: 'Faroe Islands', + value: 49290 + }, + + { + id: '2.17', + parent: '1.4', + name: 'Southern Europe' + }, + + { + id: '3.186', + parent: '2.17', + name: 'Italy', + value: 59359900 + }, { + id: '3.187', + parent: '2.17', + name: 'Spain', + value: 46354321 + }, { + id: '3.188', + parent: '2.17', + name: 'Greece', + value: 11159773 + }, { + id: '3.189', + parent: '2.17', + name: 'Portugal', + value: 10329506 + }, { + id: '3.190', + parent: '2.17', + name: 'Serbia', + value: 8790574 + }, { + id: '3.191', + parent: '2.17', + name: 'Croatia', + value: 4189353 + }, { + id: '3.192', + parent: '2.17', + name: 'Bosnia and Herzegovina', + value: 3507017 + }, { + id: '3.193', + parent: '2.17', + name: 'Albania', + value: 2930187 + }, { + id: '3.194', + parent: '2.17', + name: 'Republic of Macedonia', + value: 2083160 + }, { + id: '3.195', + parent: '2.17', + name: 'Slovenia', + value: 2079976 + }, { + id: '3.196', + parent: '2.17', + name: 'Montenegro', + value: 628960 + }, { + id: '3.197', + parent: '2.17', + name: 'Malta', + value: 430835 + }, { + id: '3.198', + parent: '2.17', + name: 'Andorra', + value: 76965 + }, { + id: '3.199', + parent: '2.17', + name: 'Gibraltar', + value: 34571 + }, { + id: '3.200', + parent: '2.17', + name: 'San Marino', + value: 33400 + }, { + id: '3.201', + parent: '2.17', + name: 'Vatican City', + value: 792 + }, + + { + id: '2.18', + parent: '1.4', + name: 'Western Europe' + }, + + { + id: '3.202', + parent: '2.18', + name: 'Germany', + value: 82114224 + }, { + id: '3.203', + parent: '2.18', + name: 'France', + value: 64979548 + }, { + id: '3.204', + parent: '2.18', + name: 'Netherlands', + value: 17035938 + }, { + id: '3.205', + parent: '2.18', + name: 'Belgium', + value: 11429336 + }, { + id: '3.206', + parent: '2.18', + name: 'Austria', + value: 8735453 + }, { + id: '3.207', + parent: '2.18', + name: 'Switzerland', + value: 8476005 + }, { + id: '3.208', + parent: '2.18', + name: 'Luxembourg', + value: 583455 + }, { + id: '3.209', + parent: '2.18', + name: 'Monaco', + value: 38695 + }, { + id: '3.210', + parent: '2.18', + name: 'Liechtenstein', + value: 37922 + }, + /***********/ + + /* Oceania */ + { + id: '2.19', + parent: '1.5', + name: 'Australia and New Zealand' + }, + + { + id: '3.211', + parent: '2.19', + name: 'Australia', + value: 24450561 + }, { + id: '3.212', + parent: '2.19', + name: 'New Zealand', + value: 4705818 + }, + + { + id: '2.20', + parent: '1.5', + name: 'Melanesia' + }, + + { + id: '3.213', + parent: '2.20', + name: 'Papua New Guinea' + }, { + id: '3.214', + parent: '2.20', + name: 'Fiji', + value: 905502 + }, { + id: '3.215', + parent: '2.20', + name: 'Solomon Islands', + value: 611343 + }, { + id: '3.216', + parent: '2.20', + name: 'New Caledonia', + value: 276255 + }, { + id: '3.217', + parent: '2.20', + name: 'Vanuatu', + value: 276244 + }, + + { + id: '2.21', + parent: '1.5', + name: 'Micronesia' + }, + + { + id: '3.218', + parent: '2.21', + name: 'Guam', + value: 164229 + }, { + id: '3.219', + parent: '2.21', + name: 'Kiribati', + value: 116398 + }, { + id: '3.220', + parent: '2.21', + name: 'Federated States of Micronesia', + value: 105544 + }, { + id: '3.221', + parent: '2.21', + name: 'Northern Mariana Islands', + value: 55144 + }, { + id: '3.222', + parent: '2.21', + name: 'Marshall Islands', + value: 53127 + }, { + id: '3.223', + parent: '2.21', + name: 'Palau', + value: 21729 + }, { + id: '3.224', + parent: '2.21', + name: 'Nauru', + value: 11359 + }, + + { + id: '2.22', + parent: '1.5', + name: 'Polynesia' + }, + + { + id: '3.225', + parent: '2.22', + name: 'French Polynesia', + value: 283007 + }, { + id: '3.226', + parent: '2.22', + name: 'Samoa', + value: 196440 + }, { + id: '3.227', + parent: '2.22', + name: 'Tonga', + value: 108020 + }, { + id: '3.228', + parent: '2.22', + name: 'American Samoa', + value: 55641 + }, { + id: '3.229', + parent: '2.22', + name: 'Cook Islands', + value: 17380 + }, { + id: '3.230', + parent: '2.22', + name: 'Wallis and Futuna', + value: 11773 + }, { + id: '3.231', + parent: '2.22', + name: 'Tuvalu', + value: 11192 + }, { + id: '3.232', + parent: '2.22', + name: 'Niue', + value: 1618 + }, { + id: '3.233', + parent: '2.22', + name: 'Tokelau', + value: 1300 + }] \ No newline at end of file diff --git a/src/pages/charts/highcharts/usdeur.js b/src/pages/charts/highcharts/usdeur.js new file mode 100644 index 0000000..b5a4e4c --- /dev/null +++ b/src/pages/charts/highcharts/usdeur.js @@ -0,0 +1,518 @@ +export default [ + [ + 1167609600000, + 0.7537 + ], + [ + 1167696000000, + 0.7537 + ], + [ + 1167782400000, + 0.7559 + ], + [ + 1167868800000, + 0.7631 + ], + [ + 1167955200000, + 0.7644 + ], + [ + 1168214400000, + 0.769 + ], + [ + 1168300800000, + 0.7683 + ], + [ + 1168387200000, + 0.77 + ], + [ + 1168473600000, + 0.7703 + ], + [ + 1168560000000, + 0.7757 + ], + [ + 1168819200000, + 0.7728 + ], + [ + 1168905600000, + 0.7721 + ], + [ + 1168992000000, + 0.7748 + ], + [ + 1169078400000, + 0.774 + ], + [ + 1169164800000, + 0.7718 + ], + [ + 1169424000000, + 0.7731 + ], + [ + 1169510400000, + 0.767 + ], + [ + 1169596800000, + 0.769 + ], + [ + 1169683200000, + 0.7706 + ], + [ + 1169769600000, + 0.7752 + ], + [ + 1170028800000, + 0.774 + ], + [ + 1170115200000, + 0.771 + ], + [ + 1170201600000, + 0.7721 + ], + [ + 1170288000000, + 0.7681 + ], + [ + 1170374400000, + 0.7681 + ], + [ + 1170633600000, + 0.7738 + ], + [ + 1170720000000, + 0.772 + ], + [ + 1170806400000, + 0.7701 + ], + [ + 1170892800000, + 0.7699 + ], + [ + 1170979200000, + 0.7689 + ], + [ + 1171238400000, + 0.7719 + ], + [ + 1171324800000, + 0.768 + ], + [ + 1171411200000, + 0.7645 + ], + [ + 1171497600000, + 0.7613 + ], + [ + 1171584000000, + 0.7624 + ], + [ + 1171843200000, + 0.7616 + ], + [ + 1171929600000, + 0.7608 + ], + [ + 1172016000000, + 0.7608 + ], + [ + 1172102400000, + 0.7631 + ], + [ + 1172188800000, + 0.7615 + ], + [ + 1172448000000, + 0.76 + ], + [ + 1172534400000, + 0.756 + ], + [ + 1172620800000, + 0.757 + ], + [ + 1172707200000, + 0.7562 + ], + [ + 1172793600000, + 0.7598 + ], + [ + 1173052800000, + 0.7645 + ], + [ + 1173139200000, + 0.7635 + ], + [ + 1173225600000, + 0.7614 + ], + [ + 1173312000000, + 0.7604 + ], + [ + 1173398400000, + 0.7603 + ], + [ + 1173657600000, + 0.7602 + ], + [ + 1173744000000, + 0.7566 + ], + [ + 1173830400000, + 0.7587 + ], + [ + 1173916800000, + 0.7562 + ], + [ + 1174003200000, + 0.7506 + ], + [ + 1174262400000, + 0.7518 + ], + [ + 1174348800000, + 0.7522 + ], + [ + 1174435200000, + 0.7524 + ], + [ + 1174521600000, + 0.7491 + ], + [ + 1174608000000, + 0.7505 + ], + [ + 1174867200000, + 0.754 + ], + [ + 1174953600000, + 0.7493 + ], + [ + 1175040000000, + 0.7493 + ], + [ + 1175126400000, + 0.7491 + ], + [ + 1175212800000, + 0.751 + ], + [ + 1175472000000, + 0.7483 + ], + [ + 1175558400000, + 0.7487 + ], + [ + 1175644800000, + 0.7491 + ], + [ + 1175731200000, + 0.7479 + ], + [ + 1175817600000, + 0.7479 + ], + [ + 1176076800000, + 0.7479 + ], + [ + 1176163200000, + 0.7449 + ], + [ + 1176249600000, + 0.7454 + ], + [ + 1176336000000, + 0.7427 + ], + [ + 1176422400000, + 0.7391 + ], + [ + 1176681600000, + 0.7381 + ], + [ + 1176768000000, + 0.7382 + ], + [ + 1176854400000, + 0.7366 + ], + [ + 1176940800000, + 0.7353 + ], + [ + 1177027200000, + 0.7351 + ], + [ + 1177286400000, + 0.7377 + ], + [ + 1177372800000, + 0.7364 + ], + [ + 1177459200000, + 0.7328 + ], + [ + 1177545600000, + 0.7356 + ], + [ + 1177632000000, + 0.7331 + ], + [ + 1177891200000, + 0.7351 + ], + [ + 1177977600000, + 0.7351 + ], + [ + 1178064000000, + 0.736 + ], + [ + 1178150400000, + 0.7347 + ], + [ + 1178236800000, + 0.7375 + ], + [ + 1178496000000, + 0.7346 + ], + [ + 1178582400000, + 0.7377 + ], + [ + 1178668800000, + 0.7389 + ], + [ + 1178755200000, + 0.7394 + ], + [ + 1178841600000, + 0.7416 + ], + [ + 1179100800000, + 0.7382 + ], + [ + 1179187200000, + 0.7388 + ], + [ + 1179273600000, + 0.7368 + ], + [ + 1179360000000, + 0.74 + ], + [ + 1179446400000, + 0.7421 + ], + [ + 1179705600000, + 0.7439 + ], + [ + 1179792000000, + 0.7434 + ], + [ + 1179878400000, + 0.7414 + ], + [ + 1179964800000, + 0.7437 + ], + [ + 1180051200000, + 0.7441 + ], + [ + 1180310400000, + 0.7434 + ], + [ + 1180396800000, + 0.7403 + ], + [ + 1180483200000, + 0.7453 + ], + [ + 1180569600000, + 0.7434 + ], + [ + 1180656000000, + 0.7444 + ], + [ + 1180915200000, + 0.7418 + ], + [ + 1181001600000, + 0.7391 + ], + [ + 1181088000000, + 0.7401 + ], + [ + 1181174400000, + 0.7425 + ], + [ + 1181260800000, + 0.7492 + ], + [ + 1181520000000, + 0.7489 + ], + [ + 1181606400000, + 0.7494 + ], + [ + 1181692800000, + 0.7527 + ], + [ + 1181779200000, + 0.7518 + ], + [ + 1181865600000, + 0.7512 + ], + [ + 1182124800000, + 0.7461 + ], + [ + 1182211200000, + 0.7462 + ], + [ + 1182297600000, + 0.7449 + ], + [ + 1182384000000, + 0.7465 + ], + [ + 1182470400000, + 0.7441 + ], + [ + 1182729600000, + 0.743 + ], + [ + 1182816000000, + 0.743 + ], + [ + 1182902400000, + 0.7443 + ], + [ + 1182988800000, + 0.7427 + ] +] \ No newline at end of file diff --git a/src/pages/charts/mock.js b/src/pages/charts/mock.js new file mode 100644 index 0000000..c583b30 --- /dev/null +++ b/src/pages/charts/mock.js @@ -0,0 +1,613 @@ +import Highcharts from 'highcharts'; +import config from './config'; +const colors = config.chartColors; + +let columnColors = [colors.blue, colors.green, colors.orange, colors.red, colors.default, colors.gray, colors.teal, colors.pink]; +let lineColors = [colors.blue, colors.green, colors.orange]; + +export const chartData = { + apex: { + column: { + series: [{ + data: [21, 22, 10, 28, 16, 21, 13, 30] + }], + options: { + chart: { + height: 350, + type: 'bar' + }, + legend: { + show: true, + labels: { + colors: colors.textColor, + }, + itemMargin: { + horizontal: 10, + vertical: 5 + }, + }, + colors: columnColors, + plotOptions: { + bar: { + columnWidth: '45%', + distributed: true + } + }, + dataLabels: { + enabled: false, + }, + xaxis: { + categories: ['John', 'Joe', 'Jake', 'Amber', 'Peter', 'Mary', 'David', 'Lily'], + labels: { + style: { + colors: columnColors, + fontSize: '14px' + } + }, + axisBorder: { + show: false + }, + axisTicks: { + show: false + } + }, + yaxis: { + labels: { + style: { + color: colors.textColor, + } + } + }, + tooltip: { + theme: 'dark' + }, + grid: { + borderColor: colors.gridLineColor + } + } + }, + pie: { + series: [25, 15, 44, 55, 41, 17], + options: { + labels: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + theme: { + monochrome: { + enabled: true, + color: colors.blue, + } + }, + stroke: { + show: false, + width: 0 + }, + legend: false, + responsive: [{ + breakpoint: 480, + options: { + chart: { + width: 200 + }, + legend: { + position: 'bottom' + } + } + }] + } + } + }, + echarts: { + line: { + color: lineColors, + tooltip: { + trigger: 'none', + axisPointer: { + type: 'cross' + } + }, + legend: { + data: ['2015 Precipitation', '2016 Precipitation'], + textStyle: { + color: colors.textColor + } + }, + grid: { + top: 70, + bottom: 50, + }, + xAxis: [ + { + type: 'category', + axisTick: { + alignWithLabel: true + }, + axisLine: { + onZero: false, + lineStyle: { + color: lineColors[1] + } + }, + axisPointer: { + label: { + formatter: function (params) { + return 'Precipitation ' + params.value + + (params.seriesData.length ? '' + params.seriesData[0].data : ''); + } + } + }, + data: ["2020-1", "2020-2", "2020-3", "2020-4", "2020-5", "2020-6", "2020-7", "2020-8", "2020-9", "2020-10", "2020-11", "2020-12"] + }, + { + type: 'category', + axisTick: { + alignWithLabel: true + }, + axisLine: { + onZero: false, + lineStyle: { + color: lineColors[0] + } + }, + axisPointer: { + label: { + formatter: function (params) { + return 'Precipitation ' + params.value + + (params.seriesData.length ? '' + params.seriesData[0].data : ''); + } + } + }, + data: ["2019-1", "2019-2", "2019-3", "2019-4", "2019-5", "2019-6", "2019-7", "2019-8", "2019-9", "2019-10", "2019-11", "2019-12"] + } + ], + yAxis: [ + { + type: 'value', + axisLabel: { + color: colors.textColor + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + }, + splitLine: { + lineStyle: { + color: colors.gridLineColor + } + }, + axisPointer: { + label: { + color: colors.dark + } + } + } + ], + series: [ + { + name: '2015 Precipitation', + type: 'line', + xAxisIndex: 1, + smooth: true, + data: [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3] + }, + { + name: '2016 Precipitation', + type: 'line', + smooth: true, + data: [3.9, 5.9, 11.1, 18.7, 48.3, 69.2, 231.6, 46.6, 55.4, 18.4, 10.3, 0.7] + } + ] + }, + donut: { + tooltip: { + trigger: 'item', + formatter: "{a}
{b}: {c} ({d}%)" + }, + legend: { + show: false + }, + color: [colors.blue, colors.green, colors.orange, colors.red, colors.purple], + series: [ + { + name: 'Access source', + type: 'pie', + radius: ['50%', '70%'], + avoidLabelOverlap: false, + label: { + show: false, + position: 'center' + }, + emphasis: { + label: { + show: true, + fontSize: 30, + fontWeight: 'bold' + } + }, + labelLine: { + show: false + }, + data: [ + {value: 335, name: 'Direct interview'}, + {value: 310, name: 'Email marketing'}, + {value: 234, name: 'Alliance advertising'}, + {value: 135, name: 'Video ad'}, + {value: 1548, name: 'Search engine'} + ] + } + ] + }, + river: { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'line', + lineStyle: { + color: 'rgba(0,0,0,0.2)', + width: 1, + type: 'solid' + } + } + }, + + legend: { + data: ['DQ', 'TY', 'SS', 'QG', 'SY', 'DD'], + textStyle: { + color: colors.textColor + } + }, + color: [colors.blue, colors.green, colors.orange, colors.red, colors.purple, colors.gray], + singleAxis: { + top: 50, + bottom: 50, + axisTick: {}, + axisLabel: { + color: colors.textColor + }, + type: 'time', + axisPointer: { + animation: true, + label: { + show: true, + color: colors.dark + } + }, + splitLine: { + show: true, + lineStyle: { + color: [colors.gridLineColor], + type: 'dashed', + opacity: 0.2 + } + }, + axisLine: { + lineStyle: { + color: colors.textColor + } + }, + }, + + series: [ + { + type: 'themeRiver', + emphasis: { + itemStyle: { + shadowBlur: 20, + shadowColor: 'rgba(0, 0, 0, 0.8)' + } + }, + data: [['2015/11/08', 10, 'DQ'], ['2015/11/09', 15, 'DQ'], ['2015/11/10', 35, 'DQ'], + ['2015/11/11', 38, 'DQ'], ['2015/11/12', 22, 'DQ'], ['2015/11/13', 16, 'DQ'], + ['2015/11/14', 7, 'DQ'], ['2015/11/15', 2, 'DQ'], ['2015/11/16', 17, 'DQ'], + ['2015/11/17', 33, 'DQ'], ['2015/11/18', 40, 'DQ'], ['2015/11/19', 32, 'DQ'], + ['2015/11/20', 26, 'DQ'], ['2015/11/21', 35, 'DQ'], ['2015/11/22', 40, 'DQ'], + ['2015/11/23', 32, 'DQ'], ['2015/11/24', 26, 'DQ'], ['2015/11/25', 22, 'DQ'], + ['2015/11/26', 16, 'DQ'], ['2015/11/27', 22, 'DQ'], ['2015/11/28', 10, 'DQ'], + ['2015/11/08', 35, 'TY'], ['2015/11/09', 36, 'TY'], ['2015/11/10', 37, 'TY'], + ['2015/11/11', 22, 'TY'], ['2015/11/12', 24, 'TY'], ['2015/11/13', 26, 'TY'], + ['2015/11/14', 34, 'TY'], ['2015/11/15', 21, 'TY'], ['2015/11/16', 18, 'TY'], + ['2015/11/17', 45, 'TY'], ['2015/11/18', 32, 'TY'], ['2015/11/19', 35, 'TY'], + ['2015/11/20', 30, 'TY'], ['2015/11/21', 28, 'TY'], ['2015/11/22', 27, 'TY'], + ['2015/11/23', 26, 'TY'], ['2015/11/24', 15, 'TY'], ['2015/11/25', 30, 'TY'], + ['2015/11/26', 35, 'TY'], ['2015/11/27', 42, 'TY'], ['2015/11/28', 42, 'TY'], + ['2015/11/08', 21, 'SS'], ['2015/11/09', 25, 'SS'], ['2015/11/10', 27, 'SS'], + ['2015/11/11', 23, 'SS'], ['2015/11/12', 24, 'SS'], ['2015/11/13', 21, 'SS'], + ['2015/11/14', 35, 'SS'], ['2015/11/15', 39, 'SS'], ['2015/11/16', 40, 'SS'], + ['2015/11/17', 36, 'SS'], ['2015/11/18', 33, 'SS'], ['2015/11/19', 43, 'SS'], + ['2015/11/20', 40, 'SS'], ['2015/11/21', 34, 'SS'], ['2015/11/22', 28, 'SS'], + ['2015/11/23', 26, 'SS'], ['2015/11/24', 37, 'SS'], ['2015/11/25', 41, 'SS'], + ['2015/11/26', 46, 'SS'], ['2015/11/27', 47, 'SS'], ['2015/11/28', 41, 'SS'], + ['2015/11/08', 10, 'QG'], ['2015/11/09', 15, 'QG'], ['2015/11/10', 35, 'QG'], + ['2015/11/11', 38, 'QG'], ['2015/11/12', 22, 'QG'], ['2015/11/13', 16, 'QG'], + ['2015/11/14', 7, 'QG'], ['2015/11/15', 2, 'QG'], ['2015/11/16', 17, 'QG'], + ['2015/11/17', 33, 'QG'], ['2015/11/18', 40, 'QG'], ['2015/11/19', 32, 'QG'], + ['2015/11/20', 26, 'QG'], ['2015/11/21', 35, 'QG'], ['2015/11/22', 40, 'QG'], + ['2015/11/23', 32, 'QG'], ['2015/11/24', 26, 'QG'], ['2015/11/25', 22, 'QG'], + ['2015/11/26', 16, 'QG'], ['2015/11/27', 22, 'QG'], ['2015/11/28', 10, 'QG'], + ['2015/11/08', 10, 'SY'], ['2015/11/09', 15, 'SY'], ['2015/11/10', 35, 'SY'], + ['2015/11/11', 38, 'SY'], ['2015/11/12', 22, 'SY'], ['2015/11/13', 16, 'SY'], + ['2015/11/14', 7, 'SY'], ['2015/11/15', 2, 'SY'], ['2015/11/16', 17, 'SY'], + ['2015/11/17', 33, 'SY'], ['2015/11/18', 40, 'SY'], ['2015/11/19', 32, 'SY'], + ['2015/11/20', 26, 'SY'], ['2015/11/21', 35, 'SY'], ['2015/11/22', 4, 'SY'], + ['2015/11/23', 32, 'SY'], ['2015/11/24', 26, 'SY'], ['2015/11/25', 22, 'SY'], + ['2015/11/26', 16, 'SY'], ['2015/11/27', 22, 'SY'], ['2015/11/28', 10, 'SY'], + ['2015/11/08', 10, 'DD'], ['2015/11/09', 15, 'DD'], ['2015/11/10', 35, 'DD'], + ['2015/11/11', 38, 'DD'], ['2015/11/12', 22, 'DD'], ['2015/11/13', 16, 'DD'], + ['2015/11/14', 7, 'DD'], ['2015/11/15', 2, 'DD'], ['2015/11/16', 17, 'DD'], + ['2015/11/17', 33, 'DD'], ['2015/11/18', 4, 'DD'], ['2015/11/19', 32, 'DD'], + ['2015/11/20', 26, 'DD'], ['2015/11/21', 35, 'DD'], ['2015/11/22', 40, 'DD'], + ['2015/11/23', 32, 'DD'], ['2015/11/24', 26, 'DD'], ['2015/11/25', 22, 'DD'], + ['2015/11/26', 16, 'DD'], ['2015/11/27', 22, 'DD'], ['2015/11/28', 10, 'DD']] + } + ] + } + }, + highcharts: { + mixed: { + chart: { + type: 'spline', + height: 350, + backgroundColor: 'transparent' + }, + exporting: { + enabled: false + }, + title: { + text: 'Snow depth at Vikjafjellet, Norway', + style: { + color: colors.textColor + } + }, + credits: { + enabled: false + }, + xAxis: { + type: 'datetime', + dateTimeLabelFormats: { // don't display the dummy year + month: '%e. %b', + year: '%b' + }, + labels: { + style: { + color: colors.textColor + } + } + }, + yAxis: { + min: 0, + title: { + enabled: false + }, + labels: { + style: { + color: colors.textColor + } + }, + gridLineColor: colors.gridLineColor + }, + tooltip: { + headerFormat: '{series.name}
', + pointFormat: '{point.x:%e. %b}: {point.y:.2f} m' + }, + legend: { + enabled: false + }, + plotOptions: { + series: { + marker: { + enabled: false, + symbol: 'circle' + } + } + }, + colors: [colors.green, colors.blue, colors.red], + + series: [{ + name: "Winter 2014-2015", + data: [ + [Date.UTC(1970, 10, 25), 0], + [Date.UTC(1970, 11, 6), 0.25], + [Date.UTC(1970, 11, 20), 1.41], + [Date.UTC(1970, 11, 25), 1.64], + [Date.UTC(1971, 0, 4), 1.6], + [Date.UTC(1971, 0, 17), 2.55], + [Date.UTC(1971, 0, 24), 2.62], + [Date.UTC(1971, 1, 4), 2.5], + [Date.UTC(1971, 1, 14), 2.42], + [Date.UTC(1971, 2, 6), 2.74], + [Date.UTC(1971, 2, 14), 2.62], + [Date.UTC(1971, 2, 24), 2.6], + [Date.UTC(1971, 3, 1), 2.81], + [Date.UTC(1971, 3, 11), 2.63], + [Date.UTC(1971, 3, 27), 2.77], + [Date.UTC(1971, 4, 4), 2.68], + [Date.UTC(1971, 4, 9), 2.56], + [Date.UTC(1971, 4, 14), 2.39], + [Date.UTC(1971, 4, 19), 2.3], + [Date.UTC(1971, 5, 4), 2], + [Date.UTC(1971, 5, 9), 1.85], + [Date.UTC(1971, 5, 14), 1.49], + [Date.UTC(1971, 5, 19), 1.27], + [Date.UTC(1971, 5, 24), 0.99], + [Date.UTC(1971, 5, 29), 0.67], + [Date.UTC(1971, 6, 3), 0.18], + [Date.UTC(1971, 6, 4), 0] + ] + }, { + name: "Winter 2015-2016", + type: 'areaspline', + data: [ + [Date.UTC(1970, 10, 9), 0], + [Date.UTC(1970, 10, 15), 0.23], + [Date.UTC(1970, 10, 20), 0.25], + [Date.UTC(1970, 10, 25), 0.23], + [Date.UTC(1970, 10, 30), 0.39], + [Date.UTC(1970, 11, 5), 0.41], + [Date.UTC(1970, 11, 10), 0.59], + [Date.UTC(1970, 11, 15), 0.73], + [Date.UTC(1970, 11, 20), 0.41], + [Date.UTC(1970, 11, 25), 1.07], + [Date.UTC(1970, 11, 30), 0.88], + [Date.UTC(1971, 0, 5), 0.85], + [Date.UTC(1971, 0, 11), 0.89], + [Date.UTC(1971, 0, 17), 1.04], + [Date.UTC(1971, 0, 20), 1.02], + [Date.UTC(1971, 0, 25), 1.03], + [Date.UTC(1971, 0, 30), 1.39], + [Date.UTC(1971, 1, 5), 1.77], + [Date.UTC(1971, 1, 26), 2.12], + [Date.UTC(1971, 3, 19), 2.1], + [Date.UTC(1971, 4, 9), 1.7], + [Date.UTC(1971, 4, 29), 0.85], + [Date.UTC(1971, 5, 7), 0] + ] + }, { + name: "Winter 2016-2017", + type: 'areaspline', + data: [ + [Date.UTC(1970, 9, 15), 0], + [Date.UTC(1970, 9, 31), 0.09], + [Date.UTC(1970, 10, 7), 0.17], + [Date.UTC(1970, 10, 10), 0.1], + [Date.UTC(1970, 11, 10), 0.1], + [Date.UTC(1970, 11, 13), 0.1], + [Date.UTC(1970, 11, 16), 0.11], + [Date.UTC(1970, 11, 19), 0.11], + [Date.UTC(1970, 11, 22), 0.08], + [Date.UTC(1970, 11, 25), 0.23], + [Date.UTC(1970, 11, 28), 0.37], + [Date.UTC(1971, 0, 16), 0.68], + [Date.UTC(1971, 0, 19), 0.55], + [Date.UTC(1971, 0, 22), 0.4], + [Date.UTC(1971, 0, 25), 0.4], + [Date.UTC(1971, 0, 28), 0.37], + [Date.UTC(1971, 0, 31), 0.43], + [Date.UTC(1971, 1, 4), 0.42], + [Date.UTC(1971, 1, 7), 0.39], + [Date.UTC(1971, 1, 10), 0.39], + [Date.UTC(1971, 1, 13), 0.39], + [Date.UTC(1971, 1, 16), 0.39], + [Date.UTC(1971, 1, 19), 0.35], + [Date.UTC(1971, 1, 22), 0.45], + [Date.UTC(1971, 1, 25), 0.62], + [Date.UTC(1971, 1, 28), 0.68], + [Date.UTC(1971, 2, 4), 0.68], + [Date.UTC(1971, 2, 7), 0.65], + [Date.UTC(1971, 2, 10), 0.65], + [Date.UTC(1971, 2, 13), 0.75], + [Date.UTC(1971, 2, 16), 0.86], + [Date.UTC(1971, 2, 19), 1.14], + [Date.UTC(1971, 2, 22), 1.2], + [Date.UTC(1971, 2, 25), 1.27], + [Date.UTC(1971, 2, 27), 1.12], + [Date.UTC(1971, 2, 30), 0.98], + [Date.UTC(1971, 3, 3), 0.85], + [Date.UTC(1971, 3, 6), 1.04], + [Date.UTC(1971, 3, 9), 0.92], + [Date.UTC(1971, 3, 12), 0.96], + [Date.UTC(1971, 3, 15), 0.94], + [Date.UTC(1971, 3, 18), 0.99], + [Date.UTC(1971, 3, 21), 0.96], + [Date.UTC(1971, 3, 24), 1.15], + [Date.UTC(1971, 3, 27), 1.18], + [Date.UTC(1971, 3, 30), 1.12], + [Date.UTC(1971, 4, 3), 1.06], + [Date.UTC(1971, 4, 6), 0.96], + [Date.UTC(1971, 4, 9), 0.87], + [Date.UTC(1971, 4, 12), 0.88], + [Date.UTC(1971, 4, 15), 0.79], + [Date.UTC(1971, 4, 18), 0.54], + [Date.UTC(1971, 4, 21), 0.34], + [Date.UTC(1971, 4, 25), 0] + ] + }] + }, + } +}; + +export let liveChartInterval = null; + +export const liveChart = { + liveChartInterval: null, + colors: [colors.blue], + chart: { + backgroundColor: 'transparent', + height: 170, + type: 'spline', + animation: Highcharts.svg, // don't animate in old IE + marginRight: 10, + events: { + load: function () { + + // set up the updating of the chart each second + var series = this.series[0]; + liveChartInterval = setInterval(function () { + var x = (new Date()).getTime(), // current time + y = Math.random(); + series.addPoint([x, y], true, true); + }, 1000); + } + } + }, + + time: { + useUTC: false + }, + credits: { + enabled: false + }, + title: false, + xAxis: { + type: 'datetime', + tickPixelInterval: 150, + labels: { + style: { + color: colors.textColor + } + }, + lineWidth: 0, + tickWidth: 0 + }, + yAxis: { + title: { + enabled: false + }, + plotLines: [{ + value: 0, + width: 1, + color: colors.textColor + }], + labels: { + style: { + color: colors.textColor + } + }, + gridLineColor: colors.gridLineColor + }, + tooltip: { + headerFormat: '{series.name}
', + pointFormat: '{point.x:%Y-%m-%d %H:%M:%S}
{point.y:.2f}' + }, + legend: { + enabled: false + }, + exporting: { + enabled: false + }, + series: [{ + name: 'Random data', + data: (function () { + // generate an array of random data + var data = [], + time = (new Date()).getTime(), + i; + + for (i = -19; i <= 0; i += 1) { + data.push({ + x: time + i * 1000, + y: Math.random() + }); + } + return data; + }()) + }] +}; diff --git a/src/pages/charts/package.json b/src/pages/charts/package.json new file mode 100644 index 0000000..19793aa --- /dev/null +++ b/src/pages/charts/package.json @@ -0,0 +1,6 @@ +{ + "name": "Charts", + "version": "0.0.0", + "private": true, + "main": "./Charts.js" +} diff --git a/src/pages/core/colors/Colors.js b/src/pages/core/colors/Colors.js new file mode 100644 index 0000000..5596f91 --- /dev/null +++ b/src/pages/core/colors/Colors.js @@ -0,0 +1,117 @@ +import React from 'react'; +import { + Row, + Col, + Table, + Button, +} from 'reactstrap'; + +import Widget from '../../../components/Widget'; + +const tableData = [ + { + id: 0, + state: 'Success', + usage: ['text-success', 'btn-success'], + }, + { + id: 1, + state: 'Warning', + usage: ['badge-warning', 'bg-warning'], + }, + { + id: 2, + state: 'Danger', + usage: ['btn-danger', 'text-danger'], + }, + { + id: 3, + state: 'Info', + usage: ['alert-info', 'badge-info'], + }, + { + id: 4, + state: 'Primary', + usage: ['bg-primary', 'text-primary'], + }, + { + id: 5, + state: 'Secondary', + usage: ['bg-secondary'], + }, +]; + +const Colors = () => ( +
+

Colors

+ + + States Colors} + close collapse + > +

Light Blue comes with a number of state colors that can be applied to + the most of elements and components. It reuses Bootstrap's original 6 states:

+ + + + + + + + + + + {tableData.map(({ state, usage, id }) => + + + + + + , + )} + +
STATEPREVIEWCLASS POSTFIXUSAGE EXAMPLE
{state} *-{state.toLowerCase()}{usage.map(item => {item})}
+
+ +
+ + + Text Colors} + close collapse + > +

Convey meaning through color with a handful of color utility classes. + Includes support for styling links with hover states, too. Use text-* class to fill text.

+
+

h1. Heading

+

h2. Heading

+

h3. Heading

+

h4. Heading

+
h5. Heading
+
h6. Heading
+
+
+ + + Example Buttons} + close collapse + > +

Use any of the available button classes to quickly create a styled button. + Semantically distinguishable beauty.

+ + + + + + + + +
+ +
+
+); + +export default Colors; diff --git a/src/pages/core/colors/package.json b/src/pages/core/colors/package.json new file mode 100644 index 0000000..687bc55 --- /dev/null +++ b/src/pages/core/colors/package.json @@ -0,0 +1,6 @@ +{ + "name": "Colors", + "version": "0.0.0", + "main": "./Colors.js", + "private": true +} diff --git a/src/pages/core/grid/Grid.js b/src/pages/core/grid/Grid.js new file mode 100644 index 0000000..63a63a3 --- /dev/null +++ b/src/pages/core/grid/Grid.js @@ -0,0 +1,311 @@ +import React from 'react'; +import { + Row, + Col, + Table, +} from 'reactstrap'; + +import Widget from '../../../components/Widget'; + +const Typography = () => ( +
+

Grid System

+ + + How it works} + close collapse + > +

+ Bootstrap’s grid system uses a series of containers, rows, and columns to layout + and align content. It’s built with flexbox and is fully responsive. Below is an + example and an in-depth look at how the grid comes together. +

+
+ + +
+ One of three columns +
+ + +
+ One of three columns +
+ + +
+ One of three columns +
+ +
+
+              {'\n'}
+              {'  \n'}
+              {'    \n'}
+              {'      One of three columns\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      One of three columns\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      One of three columns\n'}
+              {'    \n'}
+              {'  \n'}
+              {''}
+            
+
+
+ + + Equal width} + close collapse + > +

+ For example, here are two grid layouts that apply to every device and viewport, + from xs to xxl. Add any number of unit-less classes for each breakpoint you + need and every column will be the same width. +

+
+ + +
+ 1 of 2 +
+ + +
+ 2 of 2 +
+ +
+
+              {'\n'}
+              {'  \n'}
+              {'    \n'}
+              {'      1 of 2\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      2 of 2\n'}
+              {'    \n'}
+              {'  \n'}
+              {''}
+            
+
+
+ +
+ + + Grid options} + close collapse + > +

+ While Bootstrap uses ems or rems for defining + most sizes, pxs are used for + grid breakpoints and container widths. This is because the viewport width is in + pixels and does not change with the font size. See how aspects of the Bootstrap grid + system work across multiple devices with a handy table. +

+ + + + + + + + + + + + + + + + + + + + + + + + '} + '} + '} + '} + '} + '} + + + + + + + + + + + + + + + + + + +
+ + Extra small
+ <576px +
+ Small
+ ≄576px +
+ Medium
+ ≄768px +
+ Large
+ ≄992px +
+ Extra large
+ ≄1200px +
+ Extra extra large
+ ≄1400px +
Max container widthNone (auto)540px720px960px1140px1320px
Component property{'
{'
{'
{'
{'
{'
# of columns12
Gutter width1.5rem (0.75rem on each side of a column)
NestableYes
Column orderingYes
+
+ +
+ + + Vertical Alignment} + close collapse + > +

Use flexbox alignment utilities to vertically and horizontally align columns.

+
+ + +
+ Start +
+ + +
+ Center +
+ + +
+ End +
+ +
+
+              {'\n'}
+              {'  \n'}
+              {'    \n'}
+              {'      Start\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      Center\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      End\n'}
+              {'    \n'}
+              {'  \n'}
+              {''}
+            
+
+
+ + + Horizontal Alignment} + close collapse + > +

Use flexbox alignment utilities to vertically and horizontally align columns.

+
+ + +
+ 1 +
+ + +
+ 2 +
+ +
+ + +
+ 1 +
+ + +
+ 2 +
+ +
+ + +
+ 1 +
+ + +
+ 2 +
+ + +
+ 3 +
+ +
+
+              {'\n'}
+              {'  \n'}
+              {'    \n'}
+              {'      1\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      2\n'}
+              {'    \n'}
+              {'  \n'}
+              {'  \n'}
+              {'    \n'}
+              {'      1\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      2\n'}
+              {'    \n'}
+              {'  \n'}
+              {'  \n'}
+              {'    \n'}
+              {'      1\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      2\n'}
+              {'    \n'}
+              {'    \n'}
+              {'      3\n'}
+              {'    \n'}
+              {'  \n'}
+              {''}
+            
+
+
+ +
+
+); + +export default Typography; diff --git a/src/pages/core/grid/package.json b/src/pages/core/grid/package.json new file mode 100644 index 0000000..6171343 --- /dev/null +++ b/src/pages/core/grid/package.json @@ -0,0 +1,6 @@ +{ + "name": "Grid", + "version": "0.0.0", + "main": "./Grid.js", + "private": true +} diff --git a/src/pages/core/typography/Typography.js b/src/pages/core/typography/Typography.js new file mode 100644 index 0000000..4d35696 --- /dev/null +++ b/src/pages/core/typography/Typography.js @@ -0,0 +1,112 @@ +import React from 'react'; +import { + Row, + Col, +} from 'reactstrap'; + +import Widget from '../../../components/Widget'; + +const Typography = () => ( +
+

Typography - Texts & Display

+ + + Headings Default and customized} + close collapse + > +

Default headings

+

Basic headings for everyday use

+
+ + +

h1. Heading

+

h2. Heading

+

h3. Heading

+

h4. Heading

+
h5. Heading
+
h6. Heading
+ + +

h1. Heading

+

h2. Heading

+

h3. Heading

+

h4. Heading

+
h5. Heading
+
h6. Heading
+ +
+
+

Customized headings

+

Enhanced with additional text

+
+

+ Headings And some clarification text +

+
+

Display

+

Headings to stand out

+
+

Display 1

+

Display 2

+

Display 3

+

Display 4

+
+

Lead

+

Make a paragraph stand out by adding .lead.

+
+

Light Blue is admin dashboard template built with Bootstrap

+
+
+ + + Body texts Variations} + close collapse + > +

Basic texts

+

Styling for common texts

+
+

You can use the mark tag to highlight text.

+

This line of text is meant to be treated as deleted text.

+

This line of text is meant to be treated as an addition to the document.

+

This line of text is meant to be treated as fine print.

+

This line rendered as italicized text.

+

This line rendered as bold text.

+
+

Font weights

+

Various font weights supported

+
+

Thin (default) font weight

+

Normal font weight

+

Semi bold to empasize important thing

+

Bold font as a high priority

+
+

Colors

+

Bootstrap state colors can be applied to texts too

+
+

Some danger text

+

Some warning text

+

Some succes text

+

Some primary text

+

Some info text

+
+

Blockquotes

+

Citing someone is really easy

+
+
+

Don't get set into one form, adapt it and build your own, and let + it grow, be like water. Empty your mind, be formless, shapeless — like water. + Now you put water in a cup, it becomes the cup; You put water into a bottle it + becomes the bottle; You put it in a teapot it becomes the teapot. Now water can + flow or it can crash. Be water, my friend.

+
Bruce Lee in A Warrior's Journey
+
+
+
+ +
+
+); + +export default Typography; diff --git a/src/pages/core/typography/package.json b/src/pages/core/typography/package.json new file mode 100644 index 0000000..8c934da --- /dev/null +++ b/src/pages/core/typography/package.json @@ -0,0 +1,6 @@ +{ + "name": "Typography", + "version": "0.0.0", + "main": "./Typography.js", + "private": true +} diff --git a/src/pages/dashboard/Dashboard.js b/src/pages/dashboard/Dashboard.js new file mode 100644 index 0000000..69584c6 --- /dev/null +++ b/src/pages/dashboard/Dashboard.js @@ -0,0 +1,379 @@ +import React, { useState } from 'react'; +import { + Row, + Col, + Progress, + Table, + Label, + Input, +} from 'reactstrap'; + +import Widget from '../../components/Widget'; + +import Calendar from './components/calendar/Calendar'; +import Map from './components/am4chartMap/am4chartMap'; +import Rickshaw from './components/rickshaw/Rickshaw'; + +import AnimateNumber from '../../components/AnimatedNumber'; + +import s from './Dashboard.module.scss'; + +import peopleA1 from '../../images/people/a1.jpg'; +import peopleA2 from '../../images/people/a2.jpg'; +import peopleA5 from '../../images/people/a5.jpg'; +import peopleA4 from '../../images/people/a4.jpg'; + +const Dashboard = () => { + const [checkedArr, setCheckedArr] = useState([false, false, false]); + + const checkTable = (id) => { + let arr = []; + if (id === 0) { + const val = !checkedArr[0]; + for (let i = 0; i < checkedArr.length; i += 1) { + arr[i] = val; + } + } else { + arr = [...checkedArr]; + arr[id] = !arr[id]; + } + if (arr[0]) { + let count = 1; + for (let i = 1; i < arr.length; i += 1) { + if (arr[i]) { + count += 1; + } + } + if (count !== arr.length) { + arr[0] = !arr[0]; + } + } + setCheckedArr(arr); + }; + + return ( +
+

Dashboard   + + The Lucky One + +

+ + + + + + + + + + + Map +  Statistics} settings refresh close + > +

Status: Live

+

+   + 146 Countries, 2759 Cities +

+
+
+
Foreign Visits
+

Some Cool Text

+ +
+
+ + % + +
+
+
+
+
Local Visits
+

P. to C. Conversion

+ +
+
+ + % + +
+
+
+
+
Sound Frequencies
+

Average Bitrate

+ +
+
+ + % + +
+
+
Map Distributions
+

Tracking: Active

+

+ +   391 elements installed, 84 sets +

+
+ + + + +
+ +
+ + +
+ + + + USERBASE GROWTH } + close settings + > +
+
+
Overall Growth
+

76.38%

+
+
+
Montly
+

10.38%

+
+
+
24h
+

3.38%

+
+
+ +

+ + + + + +  17% higher +  than last month +

+
+ + + TRAFFIC VALUES } + close settings + > +
+
+
Overall Values
+

17 567 318

+
+
+
Montly
+

55 120

+
+
+
24h
+

9 695

+
+
+ +

+ +  8% lower +  than last month +

+
+ + + RANDOM VALUES } + close settings + > +
+
+
Overcome T.
+

104.85%

+
+
+
Takeoff Angle
+

14.29°

+
+
+
World Pop.
+

7,211M

+
+
+ +

+ +  8 734 higher +  than last month +

+
+ + +
+ + + + New Messages} + refresh close + > +
+
+ + + + +
+
+
+ +
+ +
+ + + + Market Stats} close + > + +
+

$720 Earned

+

+ Target $820 day earnings + is 96% reached. +

+
+
+ + + + + + + + + + + + + + + + + + + + +
+
+ checkTable(0)} + checked={checkedArr[0]} + readOnly + />{' '} +
+
  
+
+ checkTable(1)} + checked={checkedArr[1]} + readOnly + />{' '} +
+
HP Core i7$346.1
+
+ checkTable(2)} type="checkbox" + checked={checkedArr[2]} + readOnly + />{' '} +
+
Air Pro$533.1
+
+ +
+ +
+ +
+ + + + Calendar} settings close bodyClass={"pt-2 px-0 py-0"}> + +
+ + +
+
+ + +
+ +
+ ); +}; + +export default Dashboard; diff --git a/src/pages/dashboard/Dashboard.module.scss b/src/pages/dashboard/Dashboard.module.scss new file mode 100644 index 0000000..6c0e4be --- /dev/null +++ b/src/pages/dashboard/Dashboard.module.scss @@ -0,0 +1,62 @@ +@import '../../styles/app'; + +.root { + :global { + .post-comments footer { + margin: 0 (-$widget-padding-horizontal) (-$widget-padding-vertical); + padding: $widget-padding-vertical $widget-padding-horizontal; + } + + .stat-item .name { + margin-top: 10px; + } + + .list-group-item:hover { + background-color: $bg-addition; + } + + .detail { + .x_label { + background: $widget-bg-color !important; + } + } + } +} + +.table { + :global(.table.table-sm) { + --bs-table-bg: transparent; + --bs-table-color: #fff; + --bs-table-border-color: rgba(255, 255, 255, 0.14); + --bs-table-striped-color: #fff; + --bs-table-striped-bg: rgba(199, 208, 255, 0.08); + margin-bottom: 0; + + th, + td { + background-color: transparent; + color: #fff; + border-color: rgba(255, 255, 255, 0.14); + } + + tbody tr:nth-of-type(odd) > * { + background-color: rgba(199, 208, 255, 0.08); + } + + tbody tr:nth-of-type(even) > * { + background-color: transparent; + } + } + + :global(.table.table-sm.table-striped) { + td { + font-size: 1rem; + vertical-align: middle; + } + } +} + +.searchBtn { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; +} diff --git a/src/pages/dashboard/components/am4chartMap/am4chartMap.js b/src/pages/dashboard/components/am4chartMap/am4chartMap.js new file mode 100644 index 0000000..316e65c --- /dev/null +++ b/src/pages/dashboard/components/am4chartMap/am4chartMap.js @@ -0,0 +1,107 @@ +import React, { useEffect, useRef } from 'react'; + +import * as am4core from '@amcharts/amcharts4/core'; +import * as am4maps from '@amcharts/amcharts4/maps'; +import cities from './mock'; +import am4geodata_usaHigh from '@amcharts/amcharts4-geodata/usaHigh'; + +import AnimateNumber from '../../../../components/AnimatedNumber'; +import s from './am4chartMap.module.scss'; + +const Am4chartMap = () => { + const mapRef = useRef(null); + const mapContainerRef = useRef(null); + + useEffect(() => { + if (!mapContainerRef.current) { + return undefined; + } + + try { + const map = am4core.create(mapContainerRef.current, am4maps.MapChart); + mapRef.current = map; + map.geodata = am4geodata_usaHigh; + map.percentHeight = 90; + map.dy = 10; + map.projection = new am4maps.projections.AlbersUsa(); + const polygonSeries = map.series.push(new am4maps.MapPolygonSeries()); + polygonSeries.useGeodata = true; + map.homeZoomLevel = 1.2; + map.zoomControl = new am4maps.ZoomControl(); + map.zoomControl.layout = 'horizontal'; + map.zoomControl.align = 'left'; + map.zoomControl.valign = 'bottom'; + map.zoomControl.dy = -10; + map.zoomControl.contentHeight = 20; + map.zoomControl.minusButton.background.fill = am4core.color('#C7D0FF'); + map.zoomControl.minusButton.background.stroke = am4core.color('#6979C9'); + map.zoomControl.minusButton.label.fontWeight = 600; + map.zoomControl.minusButton.label.fontSize = 22; + map.zoomControl.minusButton.scale = 0.75; + map.zoomControl.minusButton.label.scale = 0.75; + map.zoomControl.plusButton.background.fill = am4core.color('#C7D0FF'); + map.zoomControl.plusButton.background.stroke = am4core.color('#6979C9'); + map.zoomControl.plusButton.label.fontWeight = 600; + map.zoomControl.plusButton.label.fontSize = 22; + map.zoomControl.plusButton.label.align = 'center'; + map.zoomControl.plusButton.scale = 0.75; + map.zoomControl.plusButton.label.scale = 0.75; + map.zoomControl.plusButton.dx = 5; + const plusButtonHoverState = map.zoomControl.plusButton.background.states.create('hover'); + plusButtonHoverState.properties.fill = am4core.color('#354D84'); + const minusButtonHoverState = map.zoomControl.minusButton.background.states.create('hover'); + minusButtonHoverState.properties.fill = am4core.color('#354D84'); + const polygonTemplate = polygonSeries.mapPolygons.template; + polygonTemplate.tooltipText = '{name}'; + polygonTemplate.fill = am4core.color('#474D84'); + polygonTemplate.stroke = am4core.color('#6979C9'); + const hs = polygonTemplate.states.create('hover'); + hs.properties.fill = am4core.color('#354D84'); + const citySeries = map.series.push(new am4maps.MapImageSeries()); + citySeries.data = cities; + citySeries.dataFields.value = 'size'; + const city = citySeries.mapImages.template; + city.nonScaling = true; + city.propertyFields.latitude = 'latitude'; + city.propertyFields.longitude = 'longitude'; + const circle = city.createChild(am4core.Circle); + circle.fill = am4core.color('#C7D0FF'); + circle.strokeWidth = 0; + const circleHoverState = circle.states.create('hover'); + circleHoverState.properties.strokeWidth = 1; + circle.tooltipText = '{tooltip}'; + circle.propertyFields.radius = 'size'; + } catch { + mapRef.current = null; + } + + return () => { + mapRef.current?.dispose(); + mapRef.current = null; + }; + }, []); + + return ( +
+
+
GEO-LOCATIONS
+

+ + n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ')} + /> + +

+
+
+ Alternative content for the map +
+
+ ); +}; + +export default Am4chartMap; diff --git a/src/pages/dashboard/components/am4chartMap/am4chartMap.module.scss b/src/pages/dashboard/components/am4chartMap/am4chartMap.module.scss new file mode 100644 index 0000000..d6b96b6 --- /dev/null +++ b/src/pages/dashboard/components/am4chartMap/am4chartMap.module.scss @@ -0,0 +1,21 @@ +@import '../../../../styles/app'; + +.map { + position: relative; + height: 500px; + svg { + height: 500px; + } +} +.stats { + position: absolute; + z-index: 1; + top: 0; + left: 0; + margin: 5% 10%; +} + +.mapChart { + position: relative; + margin: (-$widget-padding-vertical) (-$widget-padding-horizontal) 0; +} diff --git a/src/pages/dashboard/components/am4chartMap/mock.js b/src/pages/dashboard/components/am4chartMap/mock.js new file mode 100644 index 0000000..1bbe8ba --- /dev/null +++ b/src/pages/dashboard/components/am4chartMap/mock.js @@ -0,0 +1,69 @@ +export default [ + { + latitude: 40.717079, + longitude: -74.00116, + size: 6, + tooltip: 'New York', + fill: "#F00" + }, + { + latitude: 33.145235, + longitude: -83.811834, + size: 7, + tooltip: 'Oconee National Forest', + }, + { + latitude: 37.792032, + longitude: -122.394613, + size: 4, + tooltip: 'San Francisco', + }, + { + latitude: 26.935080, + longitude: -80.851766, + size: 9, + tooltip: 'Lake Okeechobee', + }, + { + latitude: 36.331308, + longitude: -83.336050, + size: 4, + tooltip: 'Grainger County', + }, + { + latitude: 36.269356, + longitude: -76.587477, + size: 8, + tooltip: 'Chowan County', + }, + { + latitude: 30.700644, + longitude: -95.145249, + size: 6, + tooltip: 'Lake Livingston', + }, + { + latitude: 34.546708, + longitude: -90.211471, + size: 5, + tooltip: 'Tunica County', + }, + { + latitude: 32.628599, + longitude: -103.675115, + size: 5, + tooltip: 'Lea County', + }, + { + latitude: 40.456692, + longitude: -83.522688, + size: 5, + tooltip: 'Union County', + }, + { + latitude: 33.844630, + longitude: -118.157483, + size: 6, + tooltip: 'Lakewood Mutual', + } +] \ No newline at end of file diff --git a/src/pages/dashboard/components/calendar/Calendar.js b/src/pages/dashboard/components/calendar/Calendar.js new file mode 100644 index 0000000..74367d9 --- /dev/null +++ b/src/pages/dashboard/components/calendar/Calendar.js @@ -0,0 +1,113 @@ +import React, { useState } from 'react'; +import DayNames from './DayNames'; +import { v4 as uuid } from 'uuid'; +import Week from './Week'; +import dayjs from 'core/date'; +import s from './Calendar.module.scss'; + +const Calendar = () => { + const [selectedMonth, setSelectedMonth] = useState(dayjs()); + const [selectedDay] = useState(dayjs().startOf('day')); + const [selectedMonthEvents] = useState([ + { + title: 'The flower bed', + info: 'Contents here', + itemStyle: '#2477ff', + date: dayjs(`${dayjs().year()}-${dayjs().month() + 1}-02`), + }, + { + title: 'Stop world water pollution', + info: 'Have a kick off meeting with .inc company', + itemStyle: '#e49400', + date: dayjs(`${dayjs().year()}-${dayjs().month() + 1}-05`), + }, + { + title: 'Light Blue 2.2 release', + info: 'Some contents here', + itemStyle: '#2d8515', + date: dayjs(`${dayjs().year()}-${dayjs().month() + 1}-18`), + }, + { + title: 'A link', + info: '', + itemStyle: '#f45722', + link: 'http://www.flatlogic.com', + date: dayjs(`${dayjs().year()}-${dayjs().month() + 1}-29`), + }, + ]); + + const previous = () => { + setSelectedMonth((prevMonth) => prevMonth.clone().subtract(1, 'month')); + }; + + const next = () => { + setSelectedMonth((prevMonth) => prevMonth.clone().add(1, 'month')); + }; + + const renderMonthLabel = () => ( + + {selectedMonth.format('MMMM YYYY')} + + ); + + const renderWeeks = () => { + const currentMonthView = selectedMonth; + const currentSelectedDay = selectedDay; + + const weeks = []; + let done = false; + let previousCurrentNextView = currentMonthView + .clone() + .startOf('month') + .subtract(1, 'd') + .day(0); + let count = 0; + let monthIndex = previousCurrentNextView.month(); + + while (!done) { + weeks.push( + + ); + previousCurrentNextView = previousCurrentNextView.add(1, 'w'); + done = count++ > 2 && monthIndex !== previousCurrentNextView.month(); + monthIndex = previousCurrentNextView.month(); + } + return weeks; + }; + + return ( +
+
+
+
+
+ +
+ {renderMonthLabel()} +
+ +
+ +
+
+ {renderWeeks()} +
+
+
+
+ ); +}; + +export default Calendar; diff --git a/src/pages/dashboard/components/calendar/Calendar.module.scss b/src/pages/dashboard/components/calendar/Calendar.module.scss new file mode 100644 index 0000000..f114ef2 --- /dev/null +++ b/src/pages/dashboard/components/calendar/Calendar.module.scss @@ -0,0 +1,170 @@ +@import '../../../../styles/app'; + +.calendarRectangle { + width: 100%; + position: relative; + margin-left: auto; + margin-right: auto; + color: $content-color; + font-size: .9rem; + overflow: visible; + +} + +.calendarRow { + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} + +.mainCalendar { + height: 100%; + display: flex; + flex-wrap: wrap; + + .calendarHeader { + display: flex; + flex-wrap: wrap; + width: 100%; + color: $content-color; + + .titleHeader { + width: 100%; + height: 70%; + white-space: nowrap; + font-size: 1.2em; + background-color: transparent; + + @media (min-width: 992px) { + font-size: 1.4em; + } + + @media (min-width: 1200px) { + font-size: 1.2em; + } + + .headerText { + flex: 5; + display: flex; + + .todayLabel { + flex: 1; + font-size: 0.8em; + } + .monthLabel { + flex: 3; + color: $content-color; + font-size: 0.9rem; + } + } + } + + .daysHeader { + width: 100%; + padding: 5px 0; + background-color: transparent; + + .dayName { + color: $content-color; + } + } + + .buttonContainer { + width: 100%; + height: 30%; + .eventButton { + flex-grow: 1; + display: flex; + height: 100%; + align-items: center; + justify-content: center; + } + } + } + + .daysContainer { + width: 100%; + background: transparent; + height: inherit; + padding: 15px 0; + .week { + height: 15%; + } + } +} + + +.calendarItemContainer { + flex-grow: 1; + display: flex; + justify-content: center; + align-items: center; + flex: 1; + height: 100%; + transition: all 0.4s ease-in-out 0s; + +} + +.calendarItem-container.arrow { + cursor: pointer; + font-size: 0.9rem; + color: #d6dee5; +} + +.day { + display: flex; + justify-content: center; + align-items: center; + flex: 1; + height: 30px; + width: 30px; + + .dayNumber { + width: 28px; + height: 28px; + cursor: pointer; + display: flex; + margin: 3px 0; + color: $content-color; + justify-content: center; + align-items: center; + box-sizing: border-box; + } + + + + &.hasEvents { + .dayNumber { + position: relative; + color: $content-color; + background-color: rgba(0,0,0,.15); + border-radius: 50%; + font-weight: bold; + } + } + + &.differentMonth { + visibility: hidden; + height: 0; + } +} + +@media(max-width: 810px) { + .day .dayNumber { + width: 25px; + height: 25px; + } +} +.day.selected.hasEvents { + position: relative; +} + +.calendarDot { + position: absolute; + top: -2px; + width: 6px; + height: 6px; + border-radius: 6px; + background-color: inherit; +} diff --git a/src/pages/dashboard/components/calendar/Day.js b/src/pages/dashboard/components/calendar/Day.js new file mode 100644 index 0000000..16b6283 --- /dev/null +++ b/src/pages/dashboard/components/calendar/Day.js @@ -0,0 +1,82 @@ +import React, { useState } from 'react'; +import { Popover, PopoverHeader, PopoverBody, Tooltip } from 'reactstrap'; +import s from './Calendar.module.scss'; + +const Day = ({ day, selected }) => { + const [popoverShow, setPopoverShow] = useState(false); + const [tooltipShow, setTooltipShow] = useState(false); + + const togglePopover = () => { + setPopoverShow((prevState) => !prevState); + }; + + const toggleTooltip = () => { + setTooltipShow((prevState) => !prevState); + }; + + return ( +
+ + {!day.hasEvents ? +
{day.number}
+ : (day.hasEvents && day.link) + ? + + {day.number} + {day.itemStyle ? + + : '' } + + + {day.title} + + + : (day.hasEvents && !day.link) + ? + +
{day.number} + {day.itemStyle ? + + : '' } +
+ + {day.title} + {day.info} + +
+ : '' } + +
+ ); +}; +export default Day; diff --git a/src/pages/dashboard/components/calendar/DayNames.js b/src/pages/dashboard/components/calendar/DayNames.js new file mode 100644 index 0000000..59628c8 --- /dev/null +++ b/src/pages/dashboard/components/calendar/DayNames.js @@ -0,0 +1,16 @@ +import React from 'react'; +import s from './Calendar.module.scss'; + +const DayNames = () => ( +
+ S + M + T + W + T + F + S +
+); + +export default DayNames; diff --git a/src/pages/dashboard/components/calendar/Week.js b/src/pages/dashboard/components/calendar/Week.js new file mode 100644 index 0000000..d79ab3a --- /dev/null +++ b/src/pages/dashboard/components/calendar/Week.js @@ -0,0 +1,57 @@ +import React from 'react'; +import Day from './Day'; +import { v4 as uuid } from 'uuid'; +import s from './Calendar.module.scss'; + +const Week = ({ previousCurrentNextView, selectedMonthEvents, selected, currentMonthView }) => { + const days = []; + let date = previousCurrentNextView; + + for (let i = 0; i < 7; i += 1) { + let dayHasEvents = false; + let title = ''; + let info = ''; + let itemStyle = ''; + let link = ''; + + for (let j = 0; j < selectedMonthEvents.length; j += 1) { + if (selectedMonthEvents[j].date.isSame(date, 'day')) { + dayHasEvents = true; + title = selectedMonthEvents[j].title ? selectedMonthEvents[j].title : ''; + info = selectedMonthEvents[j].info ? selectedMonthEvents[j].info : ''; + itemStyle = selectedMonthEvents[j].itemStyle ? selectedMonthEvents[j].itemStyle : ''; + link = selectedMonthEvents[j].link ? selectedMonthEvents[j].link : ''; + } + } + + const day = { + name: date.format('dd').substring(0, 1), + number: date.date(), + isCurrentMonth: date.month() === currentMonthView.month(), + isToday: date.isSame(new Date(), 'day'), + date, + hasEvents: dayHasEvents, + title, + info, + itemStyle, + link, + }; + + days.push( + + ); + date = date.clone().add(1, 'd'); + } + + return ( +
+ {days} +
+ ); +}; + +export default Week; diff --git a/src/pages/dashboard/components/rickshaw/Rickshaw.js b/src/pages/dashboard/components/rickshaw/Rickshaw.js new file mode 100644 index 0000000..20a962c --- /dev/null +++ b/src/pages/dashboard/components/rickshaw/Rickshaw.js @@ -0,0 +1,89 @@ +import React, { useEffect, useMemo, useState } from 'react'; +import PropTypes from 'prop-types'; +import Chart from 'react-apexcharts'; + +const POINTS_COUNT = 30; + +const generatePoints = () => + Array.from({ length: POINTS_COUNT }, () => Math.round(Math.random() * 60) + 20); + +const RickshawGraph = ({ height }) => { + const [series, setSeries] = useState([ + { name: 'Uploads', data: generatePoints() }, + { name: 'Downloads', data: generatePoints() }, + ]); + + const options = useMemo(() => ({ + chart: { + animations: { + enabled: false, + }, + sparkline: { + enabled: true, + }, + toolbar: { + show: false, + }, + }, + stroke: { + width: 2.5, + curve: 'smooth', + }, + colors: ['#2477ff', '#2d8515'], + legend: { + show: false, + }, + xaxis: { + labels: { + show: false, + }, + axisBorder: { + show: false, + }, + axisTicks: { + show: false, + }, + }, + yaxis: { + show: false, + }, + grid: { + show: false, + }, + tooltip: { + theme: 'dark', + }, + }), []); + + useEffect(() => { + const intervalId = setInterval(() => { + setSeries((prev) => prev.map((entry) => ({ + ...entry, + data: [...entry.data.slice(1), Math.round(Math.random() * 60) + 20], + }))); + }, 1000); + + return () => { + clearInterval(intervalId); + }; + }, []); + + return ( + + ); +}; + +RickshawGraph.propTypes = { + height: PropTypes.number, +}; + +RickshawGraph.defaultProps = { + height: 100, +}; + +export default RickshawGraph; diff --git a/src/pages/dashboard/package.json b/src/pages/dashboard/package.json new file mode 100644 index 0000000..2360b6a --- /dev/null +++ b/src/pages/dashboard/package.json @@ -0,0 +1,6 @@ +{ + "name": "dashboard", + "version": "0.0.0", + "private": true, + "main": "./Dashboard.js" +} diff --git a/src/pages/email/Email.js b/src/pages/email/Email.js new file mode 100644 index 0000000..ed3796f --- /dev/null +++ b/src/pages/email/Email.js @@ -0,0 +1,86 @@ +import React, { useEffect, useState } from 'react'; +import cx from 'classnames'; +import { Alert } from 'reactstrap'; + +import Filters from './components/Filters/Filters'; +import MessageTable from './components/MessageTable/MessageTable'; + +import s from './Email.module.scss'; + +const Email = () => { + const [isNotificationOpen, setIsNotificationOpen] = useState(true); + const [filter, setFilter] = useState(null); + const [openedMessage, setOpenedMessage] = useState(null); + const [compose, setCompose] = useState(false); + const [composeData, setComposeData] = useState(null); + const [alertAfter, setAlertAfter] = useState(false); + + useEffect(() => { + const timeoutId = setTimeout(() => { + setAlertAfter(true); + }, 0); + + return () => { + clearTimeout(timeoutId); + }; + }, []); + + const onFilter = (nextFilter) => { + setFilter(nextFilter); + setCompose(false); + setComposeData(null); + }; + + const closeNotification = () => { + setIsNotificationOpen(false); + }; + + const openMessage = (id) => { + setOpenedMessage(id); + if (id === null) { + setCompose(false); + setComposeData(null); + } + }; + + const changeCompose = (nextCompose, data) => { + setCompose(nextCompose); + + if (data) { + setComposeData(data); + } + }; + + return ( +
+
+

Email - Inbox

+ + Hey! This is a real app with CRUD and Search functions. Have fun! + +
+
+ + +
+
+ ); +}; + +export default Email; diff --git a/src/pages/email/Email.module.scss b/src/pages/email/Email.module.scss new file mode 100644 index 0000000..7b5ca2d --- /dev/null +++ b/src/pages/email/Email.module.scss @@ -0,0 +1,28 @@ +.pageTopLine { + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: wrap; + + & :global .close { + margin-left: 25px; + } +} + +.view { + display: flex; + + @media screen and (max-width: 1125px) { + flex-direction: column; + } +} + +.alert { + transition: 0.6s; + transition-timing-function: ease; + transform: translateX(-130vw); +} + +.alertAfter { + transform: translateX(0); +} diff --git a/src/pages/email/components/Compose/Compose.js b/src/pages/email/components/Compose/Compose.js new file mode 100644 index 0000000..88538de --- /dev/null +++ b/src/pages/email/components/Compose/Compose.js @@ -0,0 +1,44 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import RichTextEditor from 'components/RichTextEditor/RichTextEditor'; +import { Input, Button } from 'reactstrap'; + +import Widget from '../../../../components/Widget'; + +import s from './Compose.module.scss'; + +const Compose = ({ data }) => ( + +
+

Compose New

+ + + +
+ + + +
+
+
+); + +Compose.propTypes = { + data: PropTypes.shape({ + from: PropTypes.string, + to: PropTypes.string, + }), +}; + +Compose.defaultProps = { + data: { + from: null, + to: null, + }, +}; + +export default Compose; diff --git a/src/pages/email/components/Compose/Compose.module.scss b/src/pages/email/components/Compose/Compose.module.scss new file mode 100644 index 0000000..02f663b --- /dev/null +++ b/src/pages/email/components/Compose/Compose.module.scss @@ -0,0 +1,50 @@ +@import '../../../../styles/app'; + +.compose { + h4 { + margin-bottom: 20px; + } + + input { + margin-bottom: 15px; + } + + button { + margin-left: 7.5px; + } +} + +.wysiwygWrapper { + border: 1px solid #ccc !important; + overflow: visible; + height: 270px; + margin-bottom: 15px; +} + +.wysiwygToolbar { + color: $gray-800 !important; + background-color: #ddd !important; + border-color: transparent !important; + + :global { + .rdw-option-wrapper { + font-family: 'Open Sans', sans-serif; + font-size: 14px; + height: 30px; + min-width: 30px; + margin: 0; + background: #f8f8f8; + } + + .rdw-dropdown-wrapper { + background: #f8f8f8; + } + } +} + +.wysiwygEditor { + position: relative !important; + overflow: hidden !important; + height: 150px; + line-height: 0.1; +} diff --git a/src/pages/email/components/Filters/Filters.js b/src/pages/email/components/Filters/Filters.js new file mode 100644 index 0000000..a8bf43d --- /dev/null +++ b/src/pages/email/components/Filters/Filters.js @@ -0,0 +1,70 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import cx from 'classnames'; +import { Badge } from 'reactstrap'; + +import s from './Filters.module.scss'; + +const Filters = ({ filter, openMessage, compose }) => { + const [activeButtonId, setActiveButtonId] = useState(0); + + const handleButtonClick = (id, filterCond) => { + setActiveButtonId(id); + openMessage(null); + filter(filterCond); + }; + + const mainButtons = [ + { id: 0, title: 'Inbox', notifications: 2, filter: null }, + { id: 1, title: 'Starred', filter: 'starred' }, + { id: 2, title: 'Sent Mail', filter: 'sent' }, + { id: 3, title: 'Draft', notifications: 3, lable: 'danger', filter: 'draft' }, + { id: 4, title: 'Trash', filter: 'trash' }, + ]; + const quickViewButton = [ + { id: 0, title: 'Work', colour: 'danger' }, + { id: 1, title: 'Private', colour: 'success' }, + { id: 2, title: 'Saved', colour: 'primary' }, + ]; + + return ( +
+ +
+ {mainButtons.map((button) => + , + )} +
+
+
QUICK VIEW
+ {quickViewButton.map((button) => + , + )} +
+
+ ); +}; + +Filters.propTypes = { + filter: PropTypes.func.isRequired, + openMessage: PropTypes.func.isRequired, + compose: PropTypes.func.isRequired, +}; + +export default Filters; diff --git a/src/pages/email/components/Filters/Filters.module.scss b/src/pages/email/components/Filters/Filters.module.scss new file mode 100644 index 0000000..458a5f4 --- /dev/null +++ b/src/pages/email/components/Filters/Filters.module.scss @@ -0,0 +1,47 @@ +@import '../../../../styles/app'; + +.filters { + width: 16%; + padding-right: 15px; + + @media screen and (max-width: 1125px) { + width: 100%; + padding-right: 0; + } +} + +.mainFilterButtons { + margin: 15px 0; +} + +.button { + width: 100%; + padding: 10px 14px !important; + display: flex !important; + justify-content: space-between; + align-items: center; + font-weight: $font-weight-normal; + border-radius: 0.2rem; + color: $white; + background: transparent; + + &:hover { + background-color: $widget-bg-color; + // color: $gray-700; + } + + & :global .badge { + width: 20px; + height: 20px; + padding: 0; + display: flex; + align-items: center; + justify-content: center; + line-height: 10px; + } +} + +.buttonActive { + background-color: $widget-bg-color; + font-weight: bold; +} diff --git a/src/pages/email/components/Message/Message.js b/src/pages/email/components/Message/Message.js new file mode 100644 index 0000000..cce2637 --- /dev/null +++ b/src/pages/email/components/Message/Message.js @@ -0,0 +1,38 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import Widget from '../../../../components/Widget'; +import MessageHeader from '../MessageHeader/MessageHeader'; +import MessageAttachments from '../MessageAttachments/MessageAttachments'; + +const Message = ({ message, compose }) => ( + + + {/* eslint-disable */} +
+ {/* eslint-enable */} + {message.attachments && } + +); + +Message.propTypes = { + message: PropTypes.shape({ + theme: PropTypes.string, + from: PropTypes.string, + fromEmail: PropTypes.string, + to: PropTypes.string, + date: PropTypes.string, + }).isRequired, + compose: PropTypes.func.isRequired, +}; + +export default Message; diff --git a/src/pages/email/components/MessageAttachments/MessageAttachments.js b/src/pages/email/components/MessageAttachments/MessageAttachments.js new file mode 100644 index 0000000..89f4458 --- /dev/null +++ b/src/pages/email/components/MessageAttachments/MessageAttachments.js @@ -0,0 +1,36 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import s from './MessageAttachments.module.scss'; + +const MessageAttachments = ({ attachments }) => ( +
+
+
+ {attachments.length} attachments - + + +
+ {attachments.map(att => +
+ attachment +
{att.photoName}
+
+ {att.weight} + + +
+
, + )} +
+); + +MessageAttachments.propTypes = { + attachments: PropTypes.arrayOf(PropTypes.shape({ + photo: PropTypes.string, + photoName: PropTypes.string, + weight: PropTypes.string, + })).isRequired, +}; + +export default MessageAttachments; diff --git a/src/pages/email/components/MessageAttachments/MessageAttachments.module.scss b/src/pages/email/components/MessageAttachments/MessageAttachments.module.scss new file mode 100644 index 0000000..3ab381c --- /dev/null +++ b/src/pages/email/components/MessageAttachments/MessageAttachments.module.scss @@ -0,0 +1,37 @@ +@import '../../../../styles/app'; + +.messageAttachments { + width: 50%; + + @media screen and (max-width: 576px) { + width: 100%; + } +} + +.attachmentsInfo { + margin: -5px 0 10px; + + a { + margin-left: 5px; + } +} + +.attachment { + max-width: 100%; + + img { + width: 100%; + } + + h5 { + font-weight: $font-weight-semi-bold; + } +} + +.attachmentButtons { + margin: -5px 0 15px; + + a { + margin-left: 10px; + } +} diff --git a/src/pages/email/components/MessageHeader/MessageHeader.js b/src/pages/email/components/MessageHeader/MessageHeader.js new file mode 100644 index 0000000..1a9d2f3 --- /dev/null +++ b/src/pages/email/components/MessageHeader/MessageHeader.js @@ -0,0 +1,42 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +import ReplyDropdown from '../ReplyDropdown/ReplyDropdown'; + +import userPhoto from '../../../../images/people/a5.jpg'; +import s from './MessageHeader.module.scss'; + +const MessageHeader = ({ title, name, email, to, date, compose }) => ( +
+

{title}

+
+
+ user +
+ + {name} + + {`<${email}>`} + + + to {to} +
+
+
+ {date} + compose(true, { from: name, theme: title })} /> +
+
+
+); + +MessageHeader.propTypes = { + title: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + email: PropTypes.string.isRequired, + to: PropTypes.string.isRequired, + date: PropTypes.string.isRequired, + compose: PropTypes.func.isRequired, +}; + +export default MessageHeader; diff --git a/src/pages/email/components/MessageHeader/MessageHeader.module.scss b/src/pages/email/components/MessageHeader/MessageHeader.module.scss new file mode 100644 index 0000000..4c1dbe2 --- /dev/null +++ b/src/pages/email/components/MessageHeader/MessageHeader.module.scss @@ -0,0 +1,56 @@ +@import '../../../../styles/app'; + +.messageHeader { + width: 100%; +} + +.messageHeaderLine { + display: flex; + justify-content: space-between; + align-items: center; + margin: 15px 0; + flex-wrap: wrap; +} + +.messageFrom { + display: flex; + align-items: center; + + img { + height: 30px; + width: 30px; + margin-right: 5px; + } +} + +.messageFromInfo { + display: flex; + flex-direction: column; + line-height: 1.1; +} + +.email { + color: #868e96; + font-size: $font-size-mini; + margin-left: 5px; +} + +.to { + color: #868e96; +} + +.messageHeaderDate { + padding: 15px 0; + + & :global .btn-group { + margin-left: 10px; + + button { + font-size: 12px; + + i { + margin-right: 3px; + } + } + } +} diff --git a/src/pages/email/components/MessageTable/MessageTable.js b/src/pages/email/components/MessageTable/MessageTable.js new file mode 100644 index 0000000..efda6de --- /dev/null +++ b/src/pages/email/components/MessageTable/MessageTable.js @@ -0,0 +1,274 @@ +import React, { useEffect, useRef, useState } from 'react'; +import PropTypes from 'prop-types'; +import cx from 'classnames'; +import { Table, Input, FormGroup, Label } from 'reactstrap'; + +import Widget from '../../../../components/Widget'; +import MessageTableHeader from '../MessageTableHeader/MessageTableHeader'; +import Pagination from '../Pagination/Pagination'; +import Compose from '../Compose/Compose'; +import Message from '../Message/Message'; + +import mock from '../../mock'; +import s from './MessageTable.module.scss'; + +const MessageTable = ({ + filter, + openedMessage, + openMessage, + compose, + composeData, + changeCompose, +}) => { + const [messages, setMessages] = useState(mock); + const [checkedIds, setCheckedIds] = useState([]); + const [searchString, setSearchString] = useState(''); + const prevFilterRef = useRef(filter); + + const chooseNone = () => { + setCheckedIds([]); + }; + + useEffect(() => { + if (filter !== prevFilterRef.current) { + chooseNone(); + openMessage(null); + prevFilterRef.current = filter; + } + }, [filter, openMessage]); + + const chooseAll = () => { + const data = filter + ? messages.filter((message) => message[filter]) + : messages; + + setCheckedIds(data.map((message) => message.id)); + }; + + const chooseRead = () => { + const newCheckedIds = []; + + messages.forEach((message) => { + if (!message.unreaded) { + newCheckedIds.push(message.id); + } + }); + + setCheckedIds(newCheckedIds); + }; + + const chooseUnread = () => { + const newCheckedIds = []; + + messages.forEach((message) => { + if (message.unreaded) { + newCheckedIds.push(message.id); + } + }); + + setCheckedIds(newCheckedIds); + }; + + const choose = (id) => { + setCheckedIds((prevCheckedIds) => { + const indexOfId = prevCheckedIds.indexOf(id); + + if (indexOfId === -1) { + return [...prevCheckedIds, id]; + } + + const newCheckedIds = [...prevCheckedIds]; + newCheckedIds.splice(indexOfId, 1); + return newCheckedIds; + }); + }; + + const markUnread = () => { + setMessages((prevMessages) => prevMessages.map((message) => { + if (checkedIds.indexOf(message.id) !== -1) { + return { + ...message, + unreaded: true, + }; + } + return message; + })); + }; + + const markRead = () => { + setMessages((prevMessages) => prevMessages.map((message) => { + if (checkedIds.indexOf(message.id) !== -1) { + return { + ...message, + unreaded: false, + }; + } + return message; + })); + }; + + const deleteItems = () => { + setMessages((prevMessages) => prevMessages + .map((message) => { + if (checkedIds.indexOf(message.id) !== -1) { + return { + ...message, + deleted: true, + }; + } + return message; + }) + .filter((message) => !message.deleted)); + + setCheckedIds([]); + }; + + const starItem = (id) => { + setMessages((prevMessages) => prevMessages.map((message) => { + if (message.id === id) { + return { + ...message, + starred: !message.starred, + }; + } + + return message; + })); + }; + + const handleOpenMessage = (id) => { + setMessages((prevMessages) => prevMessages.map((message) => { + if (message.id === id) { + return { + ...message, + unreaded: false, + }; + } + + return message; + })); + + openMessage(id); + }; + + const search = (value) => { + setSearchString(value.toLowerCase()); + }; + + const isSearchable = (message) => { + if (searchString) { + return ( + message.content.toLowerCase().indexOf(searchString) !== -1 || + message.from.toLowerCase().indexOf(searchString) !== -1 || + message.theme.toLowerCase().indexOf(searchString) !== -1 + ); + } + + return true; + }; + + const filteredMessages = messages.filter((message) => message[filter]); + const dataToDisplay = filter ? filteredMessages : messages; + + return ( +
+ {openedMessage === null && !compose + ? + : + } + {/* eslint-disable */} + {openedMessage === null && !compose + ? + + + + + + + + + {dataToDisplay + .filter((message) => isSearchable(message)) + .map((message) => + ( + + + + + + + ), + )} + +
+ + {' '} + +
+ + choose(message.id)} + />{' '} + + starItem(message.id)}>{message.starred + ? + : } + handleOpenMessage(message.id)} + >{message.from} handleOpenMessage(message.id)}>{message.theme}{message.attachments && }{message.date}
+
+ : compose + ? + : + } + {/* eslint-enable */} +
+ ); +}; + +MessageTable.propTypes = { + filter: PropTypes.string, + openedMessage: PropTypes.number, + openMessage: PropTypes.func.isRequired, + compose: PropTypes.bool.isRequired, + composeData: PropTypes.shape({ + from: PropTypes.string, + theme: PropTypes.string, + }), + changeCompose: PropTypes.func.isRequired, +}; + +MessageTable.defaultProps = { + filter: null, + openedMessage: null, + composeData: null, +}; + +export default MessageTable; diff --git a/src/pages/email/components/MessageTable/MessageTable.module.scss b/src/pages/email/components/MessageTable/MessageTable.module.scss new file mode 100644 index 0000000..99e8f1a --- /dev/null +++ b/src/pages/email/components/MessageTable/MessageTable.module.scss @@ -0,0 +1,63 @@ +@import '../../../../styles/app'; + +.messages { + width: 84%; + border-radius: 0.2rem; + + @media screen and (max-width: 1125px) { + width: 100%; + } + + & :global .form-check-input { + margin: 0; + position: relative; + } + + & :global .table { + margin-bottom: 0; + } +} + +.unreadedMessage { + td { + font-weight: $font-weight-semi-bold; + } +} + +.messageCheckbox { + width: 50px; + padding-right: 0; + + :global .form-check { + margin-bottom: 0; + } +} + +.messageStar { + left: 25px; + margin-left: -10px; +} + +.messageStarred { + color: theme-color('warning'); +} + +.messageFrom, +.messageClip { + @media screen and (max-width: 768px) { + display: none; + } +} + +.messageDate { + display: flex; + justify-content: flex-end; + + @media screen and (max-width: 768px) { + width: 65px; + } +} + +.backButton { + margin-bottom: 15px; +} diff --git a/src/pages/email/components/MessageTableHeader/MessageTableHeader.js b/src/pages/email/components/MessageTableHeader/MessageTableHeader.js new file mode 100644 index 0000000..7544e45 --- /dev/null +++ b/src/pages/email/components/MessageTableHeader/MessageTableHeader.js @@ -0,0 +1,82 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { + UncontrolledButtonDropdown, + DropdownToggle, + DropdownMenu, + DropdownItem, + Input, +} from 'reactstrap'; + +import s from './MessageTableHeader.module.scss'; + +const MessageTableHeader = (props) => { + const { all, none, read, unread, markRead, markUnread, deleteItems, search } = props; + const select = [ + { id: 0, title: 'All', onClick: all }, + { id: 1, title: 'None', onClick: none }, + { id: 2 }, + { id: 3, title: 'Read', onClick: read }, + { id: 4, title: 'Unread', onClick: unread }, + ]; + const action = [ + { id: 1, title: 'Reply' }, + { id: 2, title: 'Forward' }, + { id: 3, title: 'Archive' }, + { id: 4 }, + { id: 5, title: 'Mark As Read', onClick: markRead }, + { id: 6, title: 'Mark As Unread', onClick: markUnread }, + { id: 7 }, + { id: 8, title: 'Delete', onClick: deleteItems }, + ]; + return ( +
+
+ + + Select + + + {select.map(item => + (Object.keys(item).length > 1 + ? {item.title} + : ), + )} + + + + + Actions + + + {action.map(item => + (Object.keys(item).length > 1 + ? {item.title} + : ), + )} + + +
+ search(e.target.value)} /> +
+ ); +}; + +MessageTableHeader.propTypes = { + all: PropTypes.func.isRequired, + none: PropTypes.func.isRequired, + read: PropTypes.func.isRequired, + unread: PropTypes.func.isRequired, + markRead: PropTypes.func.isRequired, + markUnread: PropTypes.func.isRequired, + deleteItems: PropTypes.func.isRequired, + search: PropTypes.func.isRequired, +}; + +export default MessageTableHeader; diff --git a/src/pages/email/components/MessageTableHeader/MessageTableHeader.module.scss b/src/pages/email/components/MessageTableHeader/MessageTableHeader.module.scss new file mode 100644 index 0000000..af00672 --- /dev/null +++ b/src/pages/email/components/MessageTableHeader/MessageTableHeader.module.scss @@ -0,0 +1,9 @@ +.messageTableHeader { + display: flex; + justify-content: space-between; + align-items: center; + + & :global .form-control { + width: auto; + } +} diff --git a/src/pages/email/components/Pagination/Pagination.js b/src/pages/email/components/Pagination/Pagination.js new file mode 100644 index 0000000..4e3ffbf --- /dev/null +++ b/src/pages/email/components/Pagination/Pagination.js @@ -0,0 +1,18 @@ +import React from 'react'; +import cx from 'classnames'; + +import s from './Pagination.module.scss'; + +const Pagination = () => ( +
+ Showing 1 - 10 of 96 messages +
+ + + + +
+
+); + +export default Pagination; diff --git a/src/pages/email/components/Pagination/Pagination.module.scss b/src/pages/email/components/Pagination/Pagination.module.scss new file mode 100644 index 0000000..7b57c36 --- /dev/null +++ b/src/pages/email/components/Pagination/Pagination.module.scss @@ -0,0 +1,52 @@ +@import '../../../../styles/app'; + +.pagination { + width: 100%; + display: flex; + justify-content: flex-end; + align-items: center; + margin-bottom: 15px; +} + +.paginationText { + color: #868e96; + font-size: $font-size-mini; +} + +.paginationPages { + border-left: 1px solid #868e96; + padding-left: 11px; + margin-left: 10px; + display: flex; + + button { + margin-left: 4px; + } +} + +.button { + transition: 0.3s; + padding: 0.45rem 0.75rem; + display: flex; + justify-content: space-between; + align-items: center; + font-weight: $font-weight-normal; + border-radius: 0.2rem; + color: #888; + background: #fff; + border: none; + + &:hover { + background-color: transparent; + } +} + +.buttonActive { + background: $gray-300; +} + +.buttonDisabled { + &:hover { + background-color: #fff; + } +} diff --git a/src/pages/email/components/ReplyDropdown/ReplyDropdown.js b/src/pages/email/components/ReplyDropdown/ReplyDropdown.js new file mode 100644 index 0000000..36aa531 --- /dev/null +++ b/src/pages/email/components/ReplyDropdown/ReplyDropdown.js @@ -0,0 +1,42 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import { + ButtonDropdown, + Button, + DropdownToggle, + DropdownMenu, + DropdownItem, +} from 'reactstrap'; + +const ReplyDropdown = ({ compose }) => { + const [open, setOpen] = useState(false); + + const toggle = () => { + setOpen((pvState) => !pvState); + }; + + return ( + + + + + + + Reply + Forward + Print + + Spam + Delete + + + ); +}; + +ReplyDropdown.propTypes = { + compose: PropTypes.func.isRequired, +}; + +export default ReplyDropdown; diff --git a/src/pages/email/mock.js b/src/pages/email/mock.js new file mode 100644 index 0000000..c211fe1 --- /dev/null +++ b/src/pages/email/mock.js @@ -0,0 +1,83 @@ +import photo1 from '../../images/tables/1.png'; +import photo2 from '../../images/tables/2.png'; +import photo3 from '../../images/tables/3.png'; + +export default [ + { + id: 0, + starred: true, + from: 'Philip Horbachuski', + fromEmail: 'philip.horbachuski@example.com', + to: 'Flatlogic LLC', + theme: 'Hi, Welcom to Google Mail', + date: '18:31', + unreaded: true, + content: `

Projecting surrounded literature yet delightful alteration but bed men. Open are from long why cold. + If must snug by upon sang loud left. As me do preference entreaties compliment motionless ye literature. + Day behaviour explained law remainder.

+

On then sake home is am leaf. Of suspicion do departure at extremely he believing. + Do know said mind do rent they oh hope of. General enquire picture letters + garrets on offices of no on.

+

All the best,

+

Vitaut the Great, CEO,
+ Fooby Inc.

`, + attachments: [ + { + photo: photo1, + photoName: 'some-cool-photo1.jpg', + weight: '568K', + id: 0, + }, + { + photo: photo2, + photoName: 'some-cool-photo2.jpg', + weight: '568K', + id: 1, + }, + ], + }, + { + id: 1, + starred: true, + from: 'StackExchange', + theme: 'New Python questions for this week', + fromEmail: 'stackexchange@example.com', + to: 'Flatlogic LLC', + date: 'Aug 14', + unreaded: false, + draft: true, + content: '

THIS IS HTML!!!!

', + attachments: [ + { + photo: photo3, + photoName: 'some-cool-photo1.jpg', + weight: '568K', + id: 0, + }, + ], + }, + { + id: 2, + starred: false, + from: 'Facebook', + theme: 'Someone just commented on your photo!', + fromEmail: 'notification@facebook.com', + to: 'Flatlogic LLC', + date: 'Aug 7', + unreaded: true, + sent: true, + content: 'Someone just commented on your photo!', + }, + { + id: 3, + starred: false, + from: 'Twitter', + theme: '@hackernews is now following you on Twitter', + fromEmail: 'notification@twitter.com', + to: 'Flatlogic LLC', + date: 'Jul 31', + unreaded: false, + sent: true, + content: '@hackernews is now following you on Twitter', + }, +]; diff --git a/src/pages/email/package.json b/src/pages/email/package.json new file mode 100644 index 0000000..a60dfa8 --- /dev/null +++ b/src/pages/email/package.json @@ -0,0 +1,6 @@ +{ + "name": "email", + "version": "0.0.0", + "private": true, + "main": "./Email.js" +} \ No newline at end of file diff --git a/src/pages/error/ErrorPage.js b/src/pages/error/ErrorPage.js new file mode 100644 index 0000000..1da87e1 --- /dev/null +++ b/src/pages/error/ErrorPage.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { + Container, + Form, + FormGroup, + Input, + InputGroup, + InputGroupText, + Button, +} from 'reactstrap'; +import { Link } from 'react-router-dom'; +import Widget from '../../components/Widget'; + +import s from './ErrorPage.module.scss'; + +const ErrorPage = () => ( +
+ + Page Not Found}> +
+

404

+

+ Oops, this page does not exist. +

+

+ You can search for content or go back to the dashboard. +

+
+ + + + + + + + +
+ + +
+ +
+
+
+ {new Date().getFullYear()} © Light Blue - React Admin Dashboard Template. Made by Flatlogic LLC +
+
+
+); + +export default ErrorPage; diff --git a/src/pages/error/ErrorPage.module.scss b/src/pages/error/ErrorPage.module.scss new file mode 100644 index 0000000..3afa4e5 --- /dev/null +++ b/src/pages/error/ErrorPage.module.scss @@ -0,0 +1,43 @@ +@import '../../styles/app'; + +.errorPage { + min-height: 100vh; +} + +.errorContainer { + text-align: center; +} + +.errorBtn { + min-width: 135px; +} + +.errorCode { + margin: 0 0 12px; + font-size: 84px; + font-weight: $font-weight-semi-bold; + color: $text-color; + line-height: 1; + + @include media-breakpoint-up(md) { + font-size: 130px; + } +} + +.errorInfo { + margin-bottom: 0.5rem; + font-size: 18px; + color: $text-color; +} + +.errorHelp { + color: $text-muted; + font-size: 14px; + margin-bottom: 1rem; +} + +.actions { + display: flex; + gap: 0.75rem; + justify-content: center; +} diff --git a/src/pages/error/package.json b/src/pages/error/package.json new file mode 100644 index 0000000..000c0a0 --- /dev/null +++ b/src/pages/error/package.json @@ -0,0 +1,6 @@ +{ + "name": "error", + "version": "0.0.0", + "private": true, + "main": "./ErrorPage.js" +} diff --git a/src/pages/extra/calendar/Calendar.js b/src/pages/extra/calendar/Calendar.js new file mode 100644 index 0000000..8c80f4a --- /dev/null +++ b/src/pages/extra/calendar/Calendar.js @@ -0,0 +1,449 @@ +import React, { useEffect, useRef, useState } from "react"; +import { + Row, + Col, + ButtonGroup, + Button, + Modal, + ModalHeader, + ModalBody, + ModalFooter, + Input, +} from "reactstrap"; + +import dayjs from "core/date"; + +import s from "./Calendar.module.scss"; +import Widget from "../../../components/Widget"; + +import FullCalendar from "@fullcalendar/react"; +import dayGridPlugin from "@fullcalendar/daygrid"; +import timeGridPlugin from "@fullcalendar/timegrid"; +import listPlugin from "@fullcalendar/list"; +import interactionPlugin, { Draggable } from "@fullcalendar/interaction"; + +const Calendar = () => { + const fullCalendarRef = useRef(null); + const externalEventsRef = useRef(null); + + const [state, setComponentState] = useState(() => { + const date = new Date(); + const d = date.getDate(); + const m = date.getMonth(); + const y = date.getFullYear(); + + return { + event: {}, + modal: false, + modalEvent: false, + calendarView: "dayGridMonth", + currentMonth: dayjs().format("MMM YYYY"), + currentDay: dayjs().format("dddd"), + calendarOptions: { + headerToolbar: { + left: "", + center: "title", + right: "", + }, + events: [ + { + title: "All Day Event", + start: new Date(y, m, 1), + color: "#F45722", + textColor: "#fff", + description: "Will be busy throughout the whole day", + }, + { + title: "Long Event", + start: new Date(y, m, d + 5), + end: new Date(y, m, d + 7), + color: "#58D777", + textColor: "#f4f4f5", + description: "This conference should be worse visiting", + }, + { + id: 999, + title: "Blah Blah Car", + start: new Date(y, m, d - 3, 16, 0), + allDay: false, + color: "#f0af03", + textColor: "#f4f4f5", + description: "Agree with this guy on arrival time", + }, + { + id: 1000, + title: "Buy this template", + start: new Date(y, m, d + 3, 12, 0), + allDay: false, + color: "#4ebfbb", + textColor: "#f4f4f5", + description: "Make sure everything is consistent first", + }, + { + title: "Got to school", + start: new Date(y, m, d + 16, 12, 0), + end: new Date(y, m, d + 16, 13, 0), + color: "#64bd63", + textColor: "#fff", + description: "Time to go back", + }, + { + title: "Study some Node", + start: new Date(y, m, d + 18, 12, 0), + end: new Date(y, m, d + 18, 13, 0), + color: "#79A5F0", + textColor: "#fff", + description: + "Node.js is a platform built " + + "on Chrome's JavaScript runtime for easily" + + " building fast, scalable network applications." + + " Node.js uses an event-driven, non-blocking" + + " I/O model that makes it lightweight and" + + " efficient, perfect for data-intensive real-time" + + " applications that run across distributed devices.", + }, + { + title: "Click for Flatlogic", + start: new Date(y, m, 28), + end: new Date(y, m, 29), + url: "http://flatlogic.com/", + backgroundColor: "#e5603b", + textColor: "#fff", + description: "Creative solutions", + }, + ], + selectable: true, + selectHelper: true, + editable: true, + droppable: true, + }, + calendarPlugins: [ + dayGridPlugin, + timeGridPlugin, + interactionPlugin, + listPlugin, + ], + dragOptions: { zIndex: 999, revert: true, revertDuration: 0 }, + }; + }); + + const setState = (value) => { + if (typeof value === "function") { + setComponentState((prevState) => ({ + ...prevState, + ...value(prevState), + })); + return; + } + + setComponentState((prevState) => ({ + ...prevState, + ...value, + })); + }; + + const getCalendarApi = () => { + return fullCalendarRef.current && fullCalendarRef.current.getApi(); + }; + + useEffect(() => { + if (!externalEventsRef.current) { + return undefined; + } + + const draggable = new Draggable(externalEventsRef.current, { + itemSelector: ".external-event", + }); + + return () => { + if (typeof draggable.destroy === "function") { + draggable.destroy(); + } + }; + }, []); + + const drop = (info) => { + info.draggedEl.parentNode.removeChild(info.draggedEl); + }; + + const handleChange = (e) => { + setState({ event: { ...state.event, title: e.target.value } }); + }; + + const toggleModal = () => { + setState({ modal: !state.modal }); + }; + + const toggleModalEvent = () => { + setState({ modalEvent: !state.modalEvent }); + }; + + const createEvent = () => { + const api = getCalendarApi(); + if (!api) { + return; + } + + api.addEvent(state.event); + api.unselect(); + toggleModal(); + }; + + const select = ({ start, end, allDay }) => { + setState({ + event: { + start, + end, + allDay, + backgroundColor: "#64bd63", + textColor: "#fff", + editable: true, + }, + }); + toggleModal(); + }; + + const eventClick = (e) => { + setState({ event: e.event }); + toggleModalEvent(); + }; + + const prev = () => { + const api = getCalendarApi(); + if (api) { + api.prev(); + } + }; + + const next = () => { + const api = getCalendarApi(); + if (api) { + api.next(); + } + }; + + const today = () => { + const api = getCalendarApi(); + if (api) { + api.today(); + } + }; + + const changeView = (view) => { + setState({ calendarView: view }); + const api = getCalendarApi(); + if (api) { + api.changeView(view); + } + }; + + const getFormattedDate = (date) => { + return dayjs(date).format("YYYY-MM-DD"); + }; + + const { + event, + currentMonth, + currentDay, + calendarOptions, + modal, + modalEvent, + calendarView, + calendarPlugins, + } = state; + + return ( +
+ + +

+ {currentMonth} -{" "} + {currentDay} +

+

+ Draggable Events +

+

+ Just drap and drop events from there directly into the calendar. +

+
+
+
+ + Make a tea +
+
+
+
+ + Open windows +
+
+
+
+ + Some stuff +
+
+
+
+ + Study UX engineering +
+
+
+
+ + Another stuff +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + Create New Event + + + Just enter event name to create a new one + + + + {" "} + + + + + + + {event.title} + + +

+ + {getFormattedDate(event.start)} +

+

{event.extendedProps && event.extendedProps.description}

+
+ + + +
+
+ ); +}; + +export default Calendar; diff --git a/src/pages/extra/calendar/Calendar.module.scss b/src/pages/extra/calendar/Calendar.module.scss new file mode 100644 index 0000000..29e77dc --- /dev/null +++ b/src/pages/extra/calendar/Calendar.module.scss @@ -0,0 +1,85 @@ +@import '../../../styles/app'; + +.calendarModalInput { + border: 1px solid #e9ecef; + margin-top: 10px; +} + +.root { + h4 { + font-size: 14px; + } + + :global { + a { + text-decoration: none; + } + .fc-grid th { + text-transform: uppercase; + } + + .fc-day-grid-event { + margin: 0; + padding: 0; + } + + .fc .fc-list-sticky .fc-list-day > * { + background: $gray-900; + } + + .fc .fc-list-event:hover td { + background-color: $violet_deep; + cursor: pointer; + } + + .fc-event { + font-weight: $font-weight-normal; + border: 1px solid $text-color; + color: $text-color; + margin-left: 0!important; + } + + .fc .fc-today { + background-color: rgba($subtle-blue, .6); + } + + a.fc-event { + height: auto; + line-height: $line-height-base; + width: 100%; + } + + /* **** Full Calendar Custom **** */ + .full-calendar { + margin-top: 10px; + } + + .calendar-controls { + .btn { + font-size: $font-size-mini; + } + } + + .calendar-external-events { + margin-top: 20px; + } + .external-event { + background-color: $widget-bg-color; + border-radius: $border-radius; + margin: 0.5rem 0; + padding: 0.5rem; + } + + .widget-calendar { + @include media-breakpoint-up(xl) { + margin-top: -100px; + } + } + } +} + +.customExternalEvent { + font-size: $font-size-mini; + cursor: pointer; + box-shadow: $widget-shadow; +} \ No newline at end of file diff --git a/src/pages/extra/calendar/package.json b/src/pages/extra/calendar/package.json new file mode 100644 index 0000000..100b054 --- /dev/null +++ b/src/pages/extra/calendar/package.json @@ -0,0 +1,6 @@ +{ + "name": "calendar", + "version": "0.0.0", + "private": true, + "main": "./Calendar.js" +} diff --git a/src/pages/extra/gallery/Gallery.js b/src/pages/extra/gallery/Gallery.js new file mode 100644 index 0000000..7535c4f --- /dev/null +++ b/src/pages/extra/gallery/Gallery.js @@ -0,0 +1,262 @@ +import React, { useMemo, useState } from 'react'; +import { + Button, + ButtonGroup, + Modal, + ModalBody, + ModalFooter, + ModalHeader, +} from 'reactstrap'; + +import s from './Gallery.module.scss'; + +import pic1 from '../../../images/pictures/1.jpg'; +import pic2 from '../../../images/pictures/2.jpg'; +import pic3 from '../../../images/pictures/3.jpg'; +import pic4 from '../../../images/pictures/4.jpg'; +import pic5 from '../../../images/pictures/5.jpg'; +import pic6 from '../../../images/pictures/6.jpg'; +import pic8 from '../../../images/pictures/8.jpg'; +import pic9 from '../../../images/pictures/9.jpg'; +import pic10 from '../../../images/pictures/10.jpg'; +import pic11 from '../../../images/pictures/11.jpg'; +import pic13 from '../../../images/pictures/13.jpg'; +import pic14 from '../../../images/pictures/14.jpg'; + +const items = [ + { + name: 'Mountains', + groups: [ + 'nature', + ], + src: pic1, + date: '10 mins', + }, + { + name: 'Empire State Pigeon', + groups: [ + 'people', + ], + src: pic2, + date: '1 hour', + like: true, + }, + { + name: 'Big Lake', + groups: [ + 'nature', + ], + src: pic3, + date: '2 mins', + like: true, + }, + { + name: 'Forest', + groups: [ + 'nature', + ], + src: pic4, + date: '2 mins', + like: true, + }, + { + name: 'Smile', + groups: [ + 'people', + ], + src: pic5, + date: '2 mins', + }, + { + name: 'Smile', + groups: [ + 'people', + ], + src: pic6, + date: '1 hour', + like: true, + }, + { + name: 'Fog', + groups: [ + 'nature', + ], + src: pic8, + date: '2 mins', + like: true, + }, + { + name: 'Beach', + groups: [ + 'people', + ], + src: pic9, + date: '2 mins', + }, + { + name: 'Pause', + groups: [ + 'people', + ], + src: pic10, + date: '3 hour', + like: true, + }, + { + name: 'Space', + groups: [ + 'space', + ], + src: pic11, + date: '3 hour', + like: true, + }, + { + name: 'Shuttle', + groups: [ + 'space', + ], + src: pic13, + date: '35 mins', + like: true, + }, + { + name: 'Sky', + groups: [ + 'space', + ], + src: pic14, + date: '2 mins', + }, +]; + +const Gallery = () => { + const [currentImage, setCurrentImage] = useState(0); + const [lightboxIsOpen, setLightboxIsOpen] = useState(false); + const [children, setChildren] = useState(items); + const [activeGroup, setActiveGroup] = useState('all'); + const [order, setOrder] = useState('asc'); + + const currentItem = useMemo(() => children[currentImage], [children, currentImage]); + + const openLightbox = (index, event) => { + event.preventDefault(); + setCurrentImage(index); + setLightboxIsOpen(true); + }; + + const gotoPrevious = () => { + setCurrentImage((prevImage) => Math.max(prevImage - 1, 0)); + }; + + const gotoNext = () => { + setCurrentImage((prevImage) => Math.min(prevImage + 1, children.length - 1)); + }; + + const closeLightbox = () => { + setCurrentImage(0); + setLightboxIsOpen(false); + }; + + const filterChildren = (type) => { + setChildren(type === 'all' ? items : items.filter((child) => { + const group = child.groups.find((itemGroup) => itemGroup === type); + return !!group; + })); + setActiveGroup(type); + setCurrentImage(0); + }; + + const orderChildren = (sortOrder) => { + const sortedChildren = [...children].sort((a, b) => { + const nameA = a.name.toLowerCase(); + const nameB = b.name.toLowerCase(); + + if (nameA < nameB) { + return sortOrder === 'asc' ? -1 : 1; + } + + if (nameA > nameB) { + return sortOrder === 'asc' ? 1 : -1; + } + return 0; + }); + + setChildren(sortedChildren); + setOrder(sortOrder); + setCurrentImage((prevImage) => Math.min(prevImage, sortedChildren.length - 1)); + }; + + return ( +
+

Media - Images +

+ +
+ + + + + + + + + + +
+
+ {children.map((item, index) => { + const key = item.name + index; + return ( +
+ openLightbox(index, e)}>... +
+
{item.name}
+
    +
  • +
  • +
  • +
+
+
+ ); + })} +
+ + + {currentItem ? currentItem.name : 'Image'} + + + {currentItem && ( + {currentItem.name} + )} + + + + + {children.length ? currentImage + 1 : 0} / {children.length} + + + + +
+ ); +}; + +export default Gallery; diff --git a/src/pages/extra/gallery/Gallery.module.scss b/src/pages/extra/gallery/Gallery.module.scss new file mode 100644 index 0000000..0af684e --- /dev/null +++ b/src/pages/extra/gallery/Gallery.module.scss @@ -0,0 +1,43 @@ +@import '../../../styles/app'; + +.root { + :global .tile { + display: inline-block; + } +} + +.galleryControls { + display: flex; + justify-content: space-between; + margin-bottom: $spacer; +} + +.gallery { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); + grid-gap: 15px; +} + +.picture { + padding: 3px; + border-radius: $border-radius; + + > a { + overflow: hidden; + } + + :global .figure-img { + width: 100%; + transition: $transition-base; + } + + &:hover { + :global .figure-img { + transform: scale(1.1, 1.1); + } + } +} + +.description { + padding: ($spacer * 0.85) ($spacer * 0.5); +} diff --git a/src/pages/extra/gallery/package.json b/src/pages/extra/gallery/package.json new file mode 100644 index 0000000..9da9586 --- /dev/null +++ b/src/pages/extra/gallery/package.json @@ -0,0 +1,6 @@ +{ + "name": "invoice", + "version": "0.0.0", + "private": true, + "main": "./Gallery.js" +} diff --git a/src/pages/extra/invoice/Invoice.js b/src/pages/extra/invoice/Invoice.js new file mode 100644 index 0000000..831e9e1 --- /dev/null +++ b/src/pages/extra/invoice/Invoice.js @@ -0,0 +1,186 @@ +/* eslint class-methods-use-this: ["error", { "exceptMethods": ["printInvoice"] }] */ +import React from 'react'; +import { + Row, + Col, + Table, + ButtonToolbar, + Button, +} from 'reactstrap'; + +import s from './Invoice.module.scss'; +import Widget from '../../../components/Widget'; +import iLogo from '../../../images/flatlogic-logo.jpg'; + +const Stats = () => { + const printInvoice = () => { + window.print(); + }; + + return ( + + + + + +
+
+ + + Logo + + +

+ #9.45613 / + 17 May 2014 +

+
+ Some Invoice number description or whatever +
+ +
+
+
+ + +
Company Information
+

+ Flatlogic LLC +

+
+ 2 Infinite Loop
+ Minsk, Belarus 220004
+ 088.253.5345
+ e-mail: email@example.com
+ phone: (012) 345-678-901
+ fax: (012) 678-132-901 +
+ + + +
Client Information
+

+ Veronica Niasvizhskaja +

+
+ Consultant at + {/* eslint-disable */} + Allspana
+ {/* eslint-enable */} + e-mail: maryna@allspana.by
+ phone: (012) 345-678-901
+ fax: (012) 678-132-901 +

Note:

+

Some nights I stay up cashing in my bad luck. + Some nights I call it a draw

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
#ItemDescriptionQuantityPrice per UnitTotal
1Brand-new 27 monitor2,560x1,440-pixel (WQHD) resolution supported!27001,400.00
2Domain: okendoken.com6-month registration110.9921.88
3Atlas ShruggedNovel by Ayn Rand, first published in 1957 in the + United + States + 535175.00
4New Song by Dr. PreLyrics: praesent blandit augue non sapien ornare + imperdiet + 122.00
+ + + +

+ Note: + Thank you for your business. Keep in mind, sometimes bad things happen. But it's just + sometimes. +

+ + + + + +

Subtotal

+

Tax(10%)

+

Total

+ + +

1,598.88

+

159.89

+

1,758.77

+ +
+ +
+

+ Marketing Consultant +

+

+ Bob Smith +

+ + + + +
+
+
+ +
+ +
+ ); +}; + +export default Stats; diff --git a/src/pages/extra/invoice/Invoice.module.scss b/src/pages/extra/invoice/Invoice.module.scss new file mode 100644 index 0000000..4b00957 --- /dev/null +++ b/src/pages/extra/invoice/Invoice.module.scss @@ -0,0 +1,19 @@ +@import '../../../styles/app'; + +.root { + .invoiceLogo { + max-height: 100px; + border-radius: $widget-border-radius; + } + + .invoiceBody { + margin-top: 70px; + } + + :global { + .widget { + padding: 10px 20px; + } + } +} + diff --git a/src/pages/extra/invoice/package.json b/src/pages/extra/invoice/package.json new file mode 100644 index 0000000..83c8482 --- /dev/null +++ b/src/pages/extra/invoice/package.json @@ -0,0 +1,6 @@ +{ + "name": "invoice", + "version": "0.0.0", + "private": true, + "main": "./Invoice.js" +} diff --git a/src/pages/extra/search/Search.js b/src/pages/extra/search/Search.js new file mode 100644 index 0000000..00b6acd --- /dev/null +++ b/src/pages/extra/search/Search.js @@ -0,0 +1,251 @@ +import React from 'react'; +import { + Row, + Col, + ButtonGroup, + Button, + Nav, + NavItem, + NavLink, + Pagination, + PaginationLink, + PaginationItem, + Badge, + UncontrolledButtonDropdown, + DropdownMenu, + DropdownToggle, + DropdownItem, +} from 'reactstrap'; + +import s from './Search.module.scss'; +import i1 from '../../../images/search/s1.jpg'; +import i2 from '../../../images/search/s5.jpg'; +import i3 from '../../../images/search/s3.jpg'; +import i4 from '../../../images/search/s13.jpg'; + +const Search = () => ( +
+

Matching - Results

+
+
+ + + Popular + + + All + Popular + Interesting + Latest + + + + + All Time + + + Last 24h + Last Month + Last Year + + +
+ + + + + +
+ + +
Results Filtering
+

Listed content is categorized by the following groups:

+ + + + +

About 94 700 000 (0.39 sec.) results

+
+ +
+ + +

+ +

+

+ New York, NY 20188 +

+

+ Not just usual Metro. But something bigger. Not just usual widgets, but real + widgets. Not just yet another admin template, + but next generation admin template. +

+ + +

+ $9, 700 +

+

+ PER WEEK +

+ + +
+
+
+
+ +
+ + +

+ + + + Best Deal! + + +

+

+ Los Angeles, NY 20188 +

+

+ You will never know exactly how something will go until you try it. You can + think three hundred times and still have no precise result. +

+ + +

+ $10, 300 +

+

+ PER WEEK +

+ + +
+
+
+
+ +
+ + +

+ +

+

+ New York, NY 20188 +

+

+ The Great Prince of the Grand Duchy of Lithuania he had stopped the invasion + to Europe of Timur (Tamerlan) from Asia heading a big Army + of Belarusians, Lithuanians. +

+ + +

+ $3, 200 +

+

+ PER WEEK +

+ + +
+
+
+
+ +
+ + +

+ +

+

+ Minsk, NY 20188 +

+

+ Yes you can! Further more, you should! + It let's you create really beautiful images + either for elements or for the entire background. +

+ + +

+ $2, 400 +

+

+ PER MONTH +

+ + +
+
+
+
+ + + Prev + + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + Next + + +
+ +
+
+); + +export default Search; diff --git a/src/pages/extra/search/Search.module.scss b/src/pages/extra/search/Search.module.scss new file mode 100644 index 0000000..d7716c8 --- /dev/null +++ b/src/pages/extra/search/Search.module.scss @@ -0,0 +1,109 @@ +@import '../../../styles/app'; + +.root { + .searchResultCategories { + > li > a { + color: $content-color; + font-weight: $font-weight-normal; + + &:hover { + color: $content-color; + background-color: $subtle-blue; + } + } + } + + .searchResultsCount { + margin-top: 10px; + } + + .searchResultItem { + padding: 20px; + background-color: $widget-bg-color; + border-radius: $border-radius; + box-shadow: $widget-shadow; + + &:first-of-type { + overflow: hidden; + } + + @include clearfix(); + + .imageLink { + display: block; + overflow: hidden; + border-top-left-radius: $border-radius; + border-bottom-left-radius: $border-radius; + + @include media-breakpoint-up(md) { + display: inline-block; + margin: -20px 0 -20px -20px; + float: left; + width: 200px; + } + + @include media-breakpoint-down(sm) { + max-height: 200px; + } + } + + .image { + max-width: 100%; + } + + .info { + margin-top: 2px; + font-size: $font-size-sm; + color: $text-muted; + } + + .description { + font-size: $font-size-mini; + } + + + .searchResultItem { + margin-top: 20px; + } + + .searchResultItemBody { + height: auto; + + @include media-breakpoint-down(sm) { + margin-top: 10px; + } + + @include media-breakpoint-up(md) { + margin-left: 200px; + } + } + + .searchResultItemHeading { + font-weight: $font-weight-normal; + + > a { + color: $text-color; + } + + @include media-breakpoint-up(md) { + margin: 0; + } + } + } +} + +:global { + .pagination { + .page-item a, .page-item.disabled a { + background-color: transparent; + border: 1px solid $subtle-blue !important; + color: $subtle-blue + } + .page-item:not(.disabled) a { + &:hover { + background-color: $subtle-blue; + color: $content-color; + transition: all .35s ease; + } + } + } +} \ No newline at end of file diff --git a/src/pages/extra/search/package.json b/src/pages/extra/search/package.json new file mode 100644 index 0000000..644ba8a --- /dev/null +++ b/src/pages/extra/search/package.json @@ -0,0 +1,6 @@ +{ + "name": "search", + "version": "0.0.0", + "private": true, + "main": "./Search.js" +} diff --git a/src/pages/extra/timeline/Timeline.js b/src/pages/extra/timeline/Timeline.js new file mode 100644 index 0000000..bd3496d --- /dev/null +++ b/src/pages/extra/timeline/Timeline.js @@ -0,0 +1,220 @@ +import React from 'react'; +import { + Input, +} from 'reactstrap'; +import GoogleMapFrame from '../../../components/GoogleMapFrame'; + +import s from './Timeline.module.scss'; + +import a1 from '../../../images/people/a1.jpg'; +import a2 from '../../../images/people/a2.jpg'; +import a3 from '../../../images/people/a3.jpg'; +import a4 from '../../../images/people/a4.jpg'; +import a5 from '../../../images/people/a5.jpg'; +import a6 from '../../../images/people/a6.jpg'; +import avatar from '../../../images/avatar.png'; +import img8 from '../../../images/search/s8.jpg'; + +const Timeline = () => ( +
+

Events - Feed

+ +
    +
  • + + + + +
    + + ... + +

    + @jess +

    +

    10:12 am - Publicly near Minsk

    +
    + +
    +
    +
      +
    • +
    • +
    • +
    • +
    +
      +
    • + + ... + +
      +
      Radrigo Gonzales + 7 mins ago +
      +

      {`Someone said they were the best people out there just few years ago. Don't know + better options.`}

      +
      +
    • +
    • + + ... + +
      +
      Ignacio Abad + 6 mins ago +
      +

      True. Heard absolutely the same.

      +
      +
    • +
    • + + ... + +
      + +
      +
    • +
    +
    +
    +
  • + +
  • + + + + +
    + + ... + +
    + +
    +

    February 22, 2014 at 01:59 PM

    +

    + There is no such thing as maturity. There is instead an ever-evolving process of maturing. + Because when there is a maturity, there is ... +

    +
    +
      +
    • +
    • +
    • +
    +
    +
    +
  • +
  • + + + + +
    +
    + @jess +
    +

    February 22, 2014 at 01:59 PM

    +

    + Check out this awesome photo I made in Italy last summer. Seems it was lost somewhere deep inside + my brand new HDD 40TB. Thanks god I found it! +

    +
    + + ... + +
    +
    +
    +
      +
    • +
    • +
    • +
    + + + + + + + + + + +
    +
      +
    • + + ... + +
      +
      Ignacio Abad + 6 mins ago +
      +

      Hey, have you heard anything about that?

      +
      +
    • +
    • + + ... + +
      + +
      +
    • +
    +
    +
    +
  • +
  • + + + + +
    + + ... + +
    + @jess +
    +

    9:03 am - Publicly near Minsk

    +
    New Project Launch
    +

    + {`Let's try something different this time. Hey, do you wanna join us tonight? + We're planning to a launch a new project soon. Want to discuss with all of you...`} +

    + +
    +
      +
    • +
    • +
    • +
    +
    +
    +
  • +
+
+); + +export default Timeline; diff --git a/src/pages/extra/timeline/Timeline.module.scss b/src/pages/extra/timeline/Timeline.module.scss new file mode 100644 index 0000000..bf4dc2c --- /dev/null +++ b/src/pages/extra/timeline/Timeline.module.scss @@ -0,0 +1,325 @@ +@import '../../../styles/app'; + +/* Post Comments */ +.postComments { + font-size: $font-size-sm; + padding-left: 0; + + @include clearfix(); + + .postLinks + & { + margin-top: $spacer / 2; + } + + > li { + padding: 10px; + border-top: 1px solid $bg-custom-dark; + list-style: none; + + @include clearfix(); + + &:last-child { + padding-bottom: 0; + } + } + + p:last-child { + margin-bottom: 0; + } + + .avatar { + margin-top: 1px; + } + + .author { + margin-top: 0; + margin-bottom: 2px; + color: #7ca9dd; + } + + .commentBody { + overflow: auto; + } + + h6.author > small { + font-size: 11px; + } + + :global { + .widget > footer & { + margin-left: -$widget-padding-horizontal; + margin-right: -$widget-padding-horizontal; + } + } +} + +/* Post Links */ +.postLinks { + margin-bottom: 0; + font-size: $font-size-sm; + padding-left: 0; + + @include clearfix(); + + > li { + float: left; + list-style: none; + + + li { + &::before { + color: #999; + content: '\25cf'; + padding: 0 8px; + } + } + + > a { + text-decoration: none; + color: $text-muted; + + :hover { + color: $text-muted; + } + } + } + + :global { + .no-separator > li + li { + margin-left: 12px; + + &::before { + content: normal; + } + } + } +} + +/* Time Line */ +.timeline { + position: relative; + min-height: 100%; + list-style: none; + padding-left: 0; + margin-bottom: -40px; /* content padding bottom */ + padding-bottom: 80px; + + > li { + @include clearfix(); + + + li { + margin-top: 30px; + } + } + + /* the time line :) */ + &::before { + position: absolute; + top: 0; + bottom: 0; + left: 24%; + width: 8px; + content: ' '; + margin-left: -4px; + background-color: $widget-bg-color; + + @include media-breakpoint-up(lg) { + left: 50%; + margin-left: -4px; + } + } +} + +.event { + background: $widget-bg-color; + border-radius: $border-radius; + padding: 20px 20px 0; + position: relative; + box-shadow: $widget-shadow; + + .timeline & { + float: right; + width: 68%; + + &::before { + right: 100%; + content: ' '; + height: 0; + width: 0; + position: absolute; + border: 10px solid rgba(0, 0, 0, 0); + border-right-color: $widget-bg-color; + top: 15px; + } + } + + .postComments { + margin-left: -20px; + margin-right: -20px; + } + + > footer { + margin: 20px -20px 0; + padding: 10px 20px; + border-bottom-left-radius: $border-radius; + border-bottom-right-radius: $border-radius; + background-color: $widget-bg-color; + + @include clearfix(); + + :global { + .thumb { + margin-left: 10px; + } + } + } + + @include media-breakpoint-up(lg) { + .timeline & { + width: 45%; + } + + .timeline > li.onLeft & { + float: left; + + &::before { + right: auto; + left: 100%; + border-right-color: rgba(0, 0, 0, 0); + border-left-color: $widget-bg-color; + } + } + } +} + +.eventTime { + .timeline & { + float: left; + width: 18%; + margin-top: 5px; + text-align: right; + + > .date { + display: block; + font-size: $font-size-larger; + } + + > .time { + display: block; + font-size: $font-size-lg; + font-weight: $font-weight-normal; + } + } + + @include media-breakpoint-up(lg) { + .timeline & { + width: 46%; + } + + .timeline > li.onLeft & { + float: right; + text-align: left; + } + } +} + +.eventIcon { + :global { + .glyphicon { + top: -2px; + } + } + + .timeline & { + position: absolute; + left: 24%; + width: 50px; + height: 50px; + line-height: 37px; + margin-left: -25px; + background-color: $white; + border: 7px solid $white; + border-radius: 50%; + text-align: center; + box-shadow: $widget-shadow; + + &.eventIconDanger { + background-color: theme-color('danger'); + border-color: lighten(theme-color('danger'), 7%); + } + + &.eventIconWarning { + background-color: theme-color('warning'); + border-color: lighten(theme-color('warning'), 7%); + } + + &.eventIconSuccess { + background-color: theme-color('success'); + border-color: lighten(theme-color('success'), 7%); + } + + &.eventIconInfo { + background-color: theme-color('info'); + border-color: lighten(theme-color('info'), 7%); + } + + &.eventIconPrimary { + background-color: theme-color('primary'); + border-color: lighten(theme-color('primary'), 7%); + } + + &.eventIconDanger, + &.eventIconWarning, + &.eventIconSuccess, + &.eventIconInfo, + &.eventIconPrimary { + color: $white; + } + + @include media-breakpoint-up(lg) { + left: 50%; + } + + > img { + width: 36px; + height: 36px; + margin-top: -4px; + } + } +} + +.eventHeading { + margin: 0 0 2px; + font-weight: $font-weight-semi-bold; + + > a { + text-decoration: none; + color: #7ca9dd; + } + + > small { + font-weight: $font-weight-semi-bold; + + > a { + text-decoration: none; + color: $text-muted; + } + } +} + +.eventMap { + display: block; + height: 200px; + margin: 0 -20px -20px; + overflow: visible !important; +} + +.eventImage { + margin: 0 -20px -20px; + max-height: 260px; + overflow: hidden; + + > img { + max-width: 100%; + } +} + diff --git a/src/pages/extra/timeline/package.json b/src/pages/extra/timeline/package.json new file mode 100644 index 0000000..a47a9c2 --- /dev/null +++ b/src/pages/extra/timeline/package.json @@ -0,0 +1,6 @@ +{ + "name": "timeline", + "version": "0.0.0", + "main": "./Timeline.js", + "private": true +} diff --git a/src/pages/forms/elements/Elements.js b/src/pages/forms/elements/Elements.js new file mode 100644 index 0000000..463c8d5 --- /dev/null +++ b/src/pages/forms/elements/Elements.js @@ -0,0 +1,1335 @@ +import React, { useState } from 'react'; +import { + Row, + Col, + Button, + Form, + FormGroup, + Label, + Input, + UncontrolledTooltip, + UncontrolledButtonDropdown, + InputGroup, + DropdownMenu, + DropdownItem, + DropdownToggle, InputGroupText, +} from 'reactstrap'; +import RichTextEditor from 'components/RichTextEditor/RichTextEditor'; +import MaskedInput from 'components/MaskedInputField'; +import Slider from 'rc-slider'; +import Dropzone from 'react-dropzone'; +import TextareaAutosize from 'components/AutoResizeTextarea'; +import Select from 'react-select'; + +import MarkdownEditorComp from './Markdown'; +import Widget from '../../../components/Widget'; + +import s from './Elements.module.scss'; + +import 'rc-slider/assets/index.css'; +import imageUpload from '../../../images/image-upload.svg'; + + + +const Elements = () => { + const [state, setComponentState] = useState({ + dropDownValue: 'Another type', + simpleSelectDropdownValue: 'Option one', + greenSelectDropdownValue: 'Hichi', + orangeSelectDropdownValue: 'Shi', + redSelectDropdownValue: 'Ichi', + bigSelectDropdownValue: 'Fourth Item', + editorState: '', + selectGroupData: [ + { + label: 'NFC EAST', + options: [ + { value: 'Dallas-Cowboys', label: 'Dallas Cowboys', rating: 'safe' }, + { value: 'New-York-Giants', label: 'New York Giants', rating: 'good' }, + { value: 'Philadelphia-Eagles', label: 'Philadelphia Eagles', rating: 'wild' }, + { value: 'Washington-Redskins', label: 'Washington Redskins', rating: 'crazy' }, + ], + }, + { + label: 'NFC NORTH', + options: [ + { value: 'Chicago-Bears', label: 'Chicago Bears', rating: 'safe' }, + { value: 'Detroit-Lions', label: 'Detroit Lions', rating: 'good' }, + { value: 'Green-Bay-Packers', label: 'Green Bay Packers', rating: 'wild' }, + { value: 'Minnesota-Vikings', label: 'Minnesota Vikings', rating: 'crazy' }, + ], + }, + { + label: 'NFC SOUTH', + options: [ + { value: 'Atlanta-Falcons', label: 'Atlanta Falcons', rating: 'safe' }, + { value: 'Carolina-Panthers', label: 'Carolina Panthers', rating: 'good' }, + { value: 'New-Orleans-Saints', label: 'New Orleans Saints', rating: 'wild' }, + { value: 'Tampa-Bay-Buccaneers', label: 'Tampa Bay Buccaneers', rating: 'crazy' }, + ], + }, + ], + selectDefaultData: [ + { value: 'Magellanic', label: 'Large Magellanic Cloud', rating: 'safe' }, + { value: 'Andromeda', label: 'Andromeda Galaxy', rating: 'good' }, + { value: 'Sextans', label: 'Sextans A', rating: 'wild' }, + ], + colorpickerValue: '#ff0000', + colorpickerInputValue: '#ff0000', + dropFiles: [], + inputFiles: [], + imageFiles: [], + }); + + const setState = (value) => { + if (typeof value === 'function') { + setComponentState((prevState) => ({ + ...prevState, + ...value(prevState), + })); + return; + } + + setComponentState((prevState) => ({ + ...prevState, + ...value, + })); + }; + + const onEditorStateChange = (editorState) => { + setState({ + editorState, + }); + }; + + const onDrop = (files) => { + setState({ + dropFiles: files, + }); + } + + const onChangeInputFiles = (e) => { + const files = []; + let i = 0; + for (i; i < e.target.files.length; i += 1) { + files.push(e.target.files[i]); + } + setState({ + inputFiles: files, + }); + } + + const onChangeInputImage = (e) => { + const files = []; + const reader = new FileReader(); + files.push(e.target.files[0]); + reader.onloadend = () => { + files[0].preview = reader.result; + files[0].toUpload = true; + setState({ + imageFiles: files, + }); + }; + reader.readAsDataURL(e.target.files[0]); + } + + const changeValueDropdown = (e) => { + setState({ dropDownValue: e.currentTarget.textContent }); + } + + const changeSelectDropdownGreen = (e) => { + setState({ greenSelectDropdownValue: e.currentTarget.textContent }); + } + + const changeSelectDropdownOrange = (e) => { + setState({ orangeSelectDropdownValue: e.currentTarget.textContent }); + } + + const changeSelectDropdownRed = (e) => { + setState({ redSelectDropdownValue: e.currentTarget.textContent }); + } + + const changeSelectDropdownBig = (e) => { + setState({ bigSelectDropdownValue: e.currentTarget.textContent }); + } + + const changeSelectDropdownSimple = (e) => { + setState({ simpleSelectDropdownValue: e.currentTarget.textContent }); + } + + const changeColorValue = (valueOrEvent) => { + const color = valueOrEvent && valueOrEvent.target + ? valueOrEvent.target.value + : valueOrEvent.color; + + setState({ + colorpickerValue: color, + colorpickerInputValue: color, + }); + } + + const changeColorInput = (e) => { + if (e.target.value.length > 3 && e.target.value.length < 8) { + setState({ + colorpickerInputValue: e.target.value, + colorpickerValue: e.target.value, + }); + } + if (e.target.value.length <= 3) { + setState({ + colorpickerInputValue: e.target.value, + }); + } + } + + const removeInputFiles = () => { + setState({ + inputFiles: [], + }); + } + + const valueFormatter = (v) => { + return `${v}`; + } + + return ( +
+

Form - Inputs & Controls +

+ + + {/* Horizontal form */} + + + Inputs } settings refresh close> + +
+ Horizontal form + + + + + + + + + + + + + + + + + + Some explanation text here + + + + + + + + + + + + + + + You cannot write more than 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .00 + + + + + + + + $ + + .00 + + + + + + + + + + + + + + + + +
+
+ + + {/* Default form */} + + + Prepended and appended inputs } settings refresh close> + +
+ Default Form + + + + + + + + + + + + + + + + + + + + + + + + + + + Action + + + Action + Another action + Something else here + + Separated link + + + + + + + + + + + + + + Action + Another action + Something else here + + Separated link + + + + Anything can be appended to the right + + + + + + + + + {state.dropDownValue}  + + + + Another type + + + Type one + + + Next type + + + + +

+ You can select some type of a field just right in the place. +

+
+ + + + +

+ With .bg-gray-lighter. White by default. +

+
+ +
+ + + + + + +
+
+ +
+ + + + + Form Options} + settingsInverse refresh close + > +
+ Control sizing +

+ Set input heights using parameters like size='lg' and + size='sm'. + Also works with type='search' inputs, input groups and + selects. +

+
+ + + + + + + + + +
+
+ + + + + Form Options} + settingsInverse refresh close + > +
+ Input Groups +

+ Different colors & sizes for any elements including input groups. Elements may be + easily styled with classes like .bg-primary or + .bg-transparent +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + Textareas} settings refresh close> +
+ Small form + + + + + + + + + + + + + + + + +
+ + +
+ +
+ + + + + + + + + +
+
+ + + + + Selects } refresh close + settings + > +
+ Default form with labels on left + + + + + + +
+ +
+ Dropdown based colored selects + + + + + + {state.simpleSelectDropdownValue}  + + + + Option One + + + Option Two + + + Option Three + + + + Auto size + + + + + + + + + {state.redSelectDropdownValue}  + + + + Ichi + + + Ni + + + San + + + + + + {state.orangeSelectDropdownValue}  + + + + Shi + + + Go + + + Roku + + + + + + {state.greenSelectDropdownValue}  + + + + Hichi + + + Hachi + + + Ku + + + Ju + + + + + + + + + + + + {state.bigSelectDropdownValue} + + + + Fourth Item + + + Fifth Item + + + Sixth Item + + + + + +
+
+ +
+ + + + + Checkbox Controls} settingsInverse refresh + close + > + + +
+ + Basic +

+ Supports bootstrap brand colors: .abc-checkbox-primary, + .abc-checkbox-info + etc. + Pure css solution with no + javascript. + Let your checkboxes shine! +

+ + + {' '} + + + + {' '} + + + + {' '} + + + + {' '} + + + + {' '} + + + + {' '} + + + +
+ + + + +
+ Circled +

+ .abc-checkbox-circle for roundness. No more sad controls + controls. + Check out this brand-new rounded checkboxes! +

+ + {' '} + + + + {' '} + + +
+ + + +
+ Disabled +

+ Disabled state also supported. Full stack checkbox functionality. +

+ + {' '} + + + + {' '} + + + + {' '} + + +
+ +
+

Built with awesome-bootstrap-checkbox. +

+
+ +
+ + + + + Radio Controls} close refresh settingsInverse> +
+ + + Basic +

+ Supports bootstrap brand colors: .abc-radio-primary, .abc-radio-danger + etc. + Pure css solution with no javascript. Let your radios shine! +

+ + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + +

+ Disabled state also supported. Full stack radios functionality. +

+ + + + + + + + + + + + Cool iOS-like switches + +

+ Simple component that helps you turn your default HTML checkbox inputs into + beautiful iOS 7 style switches in just few simple steps. +

+ + + + + + + +
+ +
+ +
+ + + + + Pickers} close refresh settingsInverse> +
+ Date & Time + + + + +
+ + + + + + +
+ + +
+ + + + + + +
+ +
+
+ + +
+ Colors + + + +
+
+ + + + + Input Masks} close settingsInverse refresh> +
+ Masked inputs + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + + Sliders} settingsInverse close refresh> + + +

Color Options

+

Light Blue extends rc-slider and provides different color options:

+
+ + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ + + +

Slider Orientation

+

+ Vertical orientation is also possible. Simply by adding + verical prop + to slider component. +

+ + + + + +       + + + +       + + + +       + + + +       + + + + + + + + +

Range Selector

+

Range selector, options specified via data-slider-value + attribute as + an array. Price range selector:

+ + + + +   + + + + + + +
+
+ +
+ + + + + + Simple file uploads} settingsInverse close + refresh + > +
+
+

The man who is really serious, with the urge to find out what truth is, has no + style at all. He lives only in what is.

+
Bruce Lee
+
+ + + + + + + + {state.inputFiles.length === 0 ? + + : + + + } + + + Awesome file input plugin allows you to create a visually appealing + file or image inputs. + + + + + + + +
+
+ {state.imageFiles.length > 0 ?
+ {state.imageFiles.map((file, idx) => ( + ...))} +
: ...} +
+
+
+ +
+ Showing a thumbnail instead of the filename when uploading an image. + +
+
+
+ + + + + Drop Zone} settingsInverse refresh close> +
+ console.log(acceptedFiles)}> + {({getRootProps, getInputProps}) => ( +
+
+ +

Drag 'n' drop some files here, or click to select files

+
+
+ )} +
+ +
+
+ + +
+
+ ); +}; + +export default Elements; diff --git a/src/pages/forms/elements/Elements.module.scss b/src/pages/forms/elements/Elements.module.scss new file mode 100644 index 0000000..1a22456 --- /dev/null +++ b/src/pages/forms/elements/Elements.module.scss @@ -0,0 +1,451 @@ +@import '../../../styles/app'; + +:global { + //@import '../../../../node_modules/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox'; +} + +.autogrow { + overflow: hidden; + resize: none; +} + +.markdownEditor { + border: 1px solid $subtle-blue; + border-radius: $border-radius; + overflow: hidden; +} + +.markdownToolbar { + display: flex; + gap: 0.5rem; + padding: 0.5rem; + background: $subtle-blue; +} + +.markdownTextarea { + min-height: 240px; + resize: vertical; + border: 0; + border-radius: 0; + background: $bg-custom-dark; + color: $gray; +} + +.markdownPreview { + min-height: 240px; + padding: 1rem; + border-top: 1px solid $subtle-blue; + background: $bg-custom-dark; + color: $gray; +} + +.wysiwygWrapper { + border: 1px solid $bg-custom-dark !important; + overflow: visible; + height: 270px; +} + +.wysiwygToolbar { + color: $gray-800 !important; + background-color: $subtle-blue !important; + border-color: transparent !important; + + :global { + .rdw-dropdown-optionwrapper { + background: $bg-custom-dark; + border: 1px solid $bg-custom-dark; + } + .rdw-dropdown-optionwrapper-highlighted { + background: $bg-custom-dark!important; + border: 1px solid $bg-custom-dark; + } + .rdw-dropdownoption-highlighted { + background: $subtle-blue; + } + .rdw-dropdownoption-active { + background: $subtle-blue; + } + .rdw-dropdown-optionwrapper:hover { + background: $bg-custom-dark; + } + .rdw-option-wrapper { + font-family: 'Open Sans', sans-serif; + font-size: 14px; + height: 30px; + min-width: 30px; + margin: 0 3px 0 0; + background: $subtle-blue; + color: $content-color; + box-shadow: none; + border: 1px solid $bg-custom-dark; + &:hover, &:focus { + box-shadow: none; + } + } + + .rdw-dropdown-wrapper { + background: $subtle-blue; + color: $content-color; + border: 1px solid $bg-custom-dark; + &:hover, &:focus { + background: $subtle-blue; + color: $content-color; + box-shadow: none; + } + } + } +} + +.wysiwygEditor { + position: relative !important; + overflow: hidden !important; + height: 150px; + line-height: 0.1; + padding: 0 1rem; +} + +.root { + :global { + /* + * Switchery. + */ + + .abc-checkbox, + .abc-radio { + .form-check-input { + position: relative; + margin: 0; + } + } + + .display-inline-block { + display: inline-block; + } + + .display-none { + display: none; + } + + .switch { + box-sizing: content-box; + } + + .switch input { + display: none; + } + + .switch i { + display: inline-block; + cursor: pointer; + padding-right: 20px; + transition: all ease 0.2s; + -webkit-transition: all ease 0.2s; + border-radius: 20px; + box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.5); + } + + .switch i::before { + display: block; + content: ''; + width: 30px; + height: 30px; + padding: 1px; + border-radius: 20px; + background: white; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); + } + + .switch :checked + i { + padding-right: 0; + padding-left: 20px; + background: rgb(100, 189, 99); + } + + /* Datepicker */ + + .datepicker { + .input-group-addon { + display: inline-block; + position: relative; + top: -2px; + left: -2px; + } + + i.glyphicon { + vertical-align: top; + } + + .rdt { + display: inline-block; + } + } + + /* file input */ + + .fileinput.fileinput-new { + .thumbnail { + padding: $thumbnail-padding; + line-height: $line-height-base; + background-color: $inverse; + border: $thumbnail-border-width solid $gray; + border-radius: $thumbnail-border-radius; + transition: all 0.2s ease-in-out; + + @include box-shadow(0 1px 2px rgba(0, 0, 0, 0.075)); + } + + &.fileinput-fix { + width: 200px; + height: 150px; + } + } + + .btn { + label { + margin-bottom: 0; + } + } + + .fileinput-preview.fileinput-exists { + border: 1px solid $input-border-color; + border-radius: $border-radius; + padding: 5px; + } + + .fileinput.input-group { + display: flex; + } + + .fileinput-new.input-group .btn-file, + .fileinput-new .input-group .btn-file { + border-radius: 0 $border-radius $border-radius 0; + + &.btn-xs, + &.btn-sm { + border-radius: 0 $border-radius-sm $border-radius-sm 0; + } + + &.btn-lg { + border-radius: 0 $border-radius-lg $border-radius-lg 0; + } + } + + .form-group.has-warning .fileinput { + .fileinput-preview { + color: #fff; + } + + .thumbnail { + border-color: theme-color('warning'); + } + } + + .form-group.has-error .fileinput { + .fileinput-preview { + color: #fff; + } + + .thumbnail { + border-color: theme-color('danger'); + } + } + + .form-group.has-success .fileinput { + .fileinput-preview { + color: #fff; + } + + .thumbnail { + border-color: theme-color('success'); + } + } + + .btn-label { + background: transparent; + left: 2px; + padding: 1px 6px; + } + + // Opposite alignment of blockquote + .blockquote { + padding: ($spacer / 2) $spacer; + margin-bottom: $spacer; + font-size: $blockquote-font-size; + border-left: 0.25rem solid $green; + } + + .blockquote footer { + display: block; + font-size: 80%; // back to default font-size + color: $blockquote-footer-color; + + &::before { + content: '\2014 \00A0'; // em dash, nbsp + } + } + + .blockquote-reverse { + padding-right: $spacer; + padding-left: 0; + text-align: right; + border-right: 0.25rem solid $green; + border-left: 0; + } + + .blockquote-reverse footer { + &::before { + content: ''; + } + + &::after { + content: '\00A0 \2014'; // nbsp, em dash + } + } + } +} + +.dropzone { + width: 100%; + text-align: center; + padding: 40px 10px; + height: 200px; + border: 2px dashed #ccc; + + @include border-radius($border-radius); + + img { + max-height: 100px; + max-width: 150px; + border-radius: 5px; + } +} + +/* rc-slider customization */ + +.sliderCustomization.verticalSlider { + height: 165px!important; + display: inline-block; + :global { + .rc-slider-handle { + margin-left: -11px!important; + } + } +} + +.sliderCustomization { + :global { + .rc-slider-rail { + background: #040620; + } + .rc-slider-handle { + position: absolute; + width: 26px; + height: 26px; + cursor: pointer; + cursor: -webkit-grab; + cursor: grab; + border-radius: 50%; + border: none; + background-color: #fff; + touch-action: pan-x; + box-shadow: inset 0 1px 0 hsla(0,0%,100%,.2), 0 1px 3px #000; + } + .rc-slider-handle:hover { + border-color: none; + } + } +} + +.horizontalSlider { + margin: 18px 0; + :global { + .rc-slider-handle { + margin-top: -11px; + } + } + +} + +.rangeSlider { + :global { + .rc-slider-handle { + margin-top: -11px; + } + } +} + +.sliderGrey { + :global { + .rc-slider-track { + background-color: $gray; + } + } +} +.sliderBlue { + :global { + .rc-slider-track { + background-color: $blue; + } + } +} +.sliderInfo { + :global { + .rc-slider-track { + background-color: $info; + } + } +} +.sliderRed { + :global { + .rc-slider-track { + background-color: $red; + } + } +} +.sliderYellow { + :global { + .rc-slider-track { + background-color: $yellow; + } + } +} +.sliderGreen { + :global { + .rc-slider-track { + background-color: $green; + } + } +} + +/* rc-slider customization end */ + +/* react-select customization */ + +:global { + .selectCustomization { + > div { + background: $bg-custom-dark; + border: 1px solid $bg-custom-dark; + } + .react-select__single-value { + color: $content-color; + } + .react-select__option--is-focused { + background: $subtle-blue; + } + .react-select__option--is-selected { + background: rgba($subtle-blue,.6); + } + } + .rc-slider-handle { + background: $subtle-blue !important; + } + legend { + border-bottom: 1px solid $bg-custom-dark; + } + .rdw-editor-main { + height: auto!important; + } +} + +/* react-select end */ diff --git a/src/pages/forms/elements/Markdown.js b/src/pages/forms/elements/Markdown.js new file mode 100644 index 0000000..febea64 --- /dev/null +++ b/src/pages/forms/elements/Markdown.js @@ -0,0 +1,50 @@ +import * as React from "react"; +import { Button } from "reactstrap"; +import * as Showdown from "showdown"; +import s from "./Elements.module.scss"; + +const converter = new Showdown.Converter({ + tables: true, + simplifiedAutoLink: true, + strikethrough: true, + tasklists: true +}); + +export default function MarkdownEditorComp() { + const [value, setValue] = React.useState("**Hello world!!!**"); + const [selectedTab, setSelectedTab] = React.useState("write"); + const previewHtml = React.useMemo(() => converter.makeHtml(value), [value]); + + return ( +
+
+ + +
+ {selectedTab === "write" ? ( +