├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.js ├── index.css ├── index.js └── widgets ├── pagination ├── Pagination.js └── styles.css ├── widget-1 ├── Widget.js └── styles.css └── widget-2 ├── Widget.js └── styles.css /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | 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. 37 | 38 | 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. 39 | 40 | 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. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-widgets", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "^18.2.0", 7 | "react-dom": "^18.2.0", 8 | "react-scripts": "5.0.1" 9 | }, 10 | "scripts": { 11 | "start": "react-scripts start", 12 | "build": "react-scripts build" 13 | }, 14 | "eslintConfig": { 15 | "extends": [ 16 | "react-app" 17 | ] 18 | }, 19 | "browserslist": { 20 | "production": [ 21 | ">0.2%", 22 | "not dead", 23 | "not op_mini all" 24 | ], 25 | "development": [ 26 | "last 1 chrome version", 27 | "last 1 firefox version", 28 | "last 1 safari version" 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frontend-joe/react-widgets/8c07524404adb2b09984057ff07a4195e0461192/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 28 | 29 | 33 | 37 | React App 38 | 39 | 40 | 41 |
42 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frontend-joe/react-widgets/8c07524404adb2b09984057ff07a4195e0461192/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frontend-joe/react-widgets/8c07524404adb2b09984057ff07a4195e0461192/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import { Widget } from "./widgets/pagination/Pagination"; 2 | 3 | function App() { 4 | return ; 5 | } 6 | 7 | export default App; 8 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | import "./index.css"; 4 | import App from "./App"; 5 | 6 | const root = ReactDOM.createRoot(document.getElementById("root")); 7 | root.render(); 8 | -------------------------------------------------------------------------------- /src/widgets/pagination/Pagination.js: -------------------------------------------------------------------------------- 1 | import { useEffect, useState, useCallback } from "react"; 2 | import "./styles.css"; 3 | 4 | export const Widget = () => { 5 | const [pages, setPages] = useState([]); 6 | const [activePage, setActivePage] = useState(0); 7 | const pageCount = 10; 8 | 9 | const buildPages = useCallback(() => { 10 | let start = 0, 11 | end = 5; 12 | 13 | if (activePage > 3 && activePage < pageCount - 3) { 14 | start = activePage - 1; 15 | end = activePage - 1 + 3; 16 | } 17 | 18 | if (pageCount > 5 && activePage > pageCount - 5) { 19 | start = pageCount - 5; 20 | end = pageCount - 1; 21 | } 22 | 23 | const newPages = []; 24 | for (let i = start; i < end; i++) { 25 | newPages.push(i); 26 | } 27 | 28 | setPages(newPages); 29 | }, [activePage]); 30 | 31 | const onChange = (page) => setActivePage(page); 32 | 33 | const isActive = (page) => (activePage === page ? "active" : ""); 34 | 35 | useEffect(() => { 36 | buildPages(); 37 | }, [activePage]); 38 | 39 | return ( 40 | 62 | ); 63 | }; 64 | -------------------------------------------------------------------------------- /src/widgets/pagination/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | display: grid; 3 | place-items: center; 4 | height: 100vh; 5 | background: #18202a; 6 | font-family: "Euclid Circular A"; 7 | } 8 | 9 | * { 10 | box-sizing: border-box; 11 | } 12 | 13 | button { 14 | font-family: inherit; 15 | } 16 | 17 | .pagination { 18 | list-style: none; 19 | padding: 0; 20 | display: flex; 21 | gap: 2px; 22 | } 23 | 24 | .pagination > :is(button, span) { 25 | display: grid; 26 | place-items: center; 27 | width: 34px; 28 | height: 34px; 29 | padding: 0; 30 | border: 0; 31 | background: #283445; 32 | color: #f9f9f9; 33 | font-size: 12px; 34 | cursor: default; 35 | } 36 | 37 | .pagination > button:first-child { 38 | border-top-left-radius: 4px; 39 | border-bottom-left-radius: 4px; 40 | } 41 | 42 | .pagination > button:last-child { 43 | border-top-right-radius: 4px; 44 | border-bottom-right-radius: 4px; 45 | } 46 | 47 | .pagination > button:not(span) { 48 | cursor: pointer; 49 | } 50 | 51 | .pagination > button.active { 52 | background: #1f6ff1; 53 | color: #f9f9f9; 54 | } 55 | 56 | .pagination > button:disabled { 57 | opacity: 0.25; 58 | cursor: default; 59 | } 60 | -------------------------------------------------------------------------------- /src/widgets/widget-1/Widget.js: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import "./styles.css"; 3 | 4 | const buttonWidth = 64; 5 | const tabWidth = 300; 6 | const tabHeaders = ["home", "lock", "settings"]; 7 | const tabContent = []; 8 | 9 | export const Widget = () => { 10 | const [activeIndex, setActiveIndex] = useState(0); 11 | 12 | return ( 13 |
14 |
15 | {tabHeaders.map((tab, index) => ( 16 | 25 | ))} 26 |
32 |
33 |
34 |
40 |
41 |

Home

42 |

43 | This is the tab content, you can put anything you like in here. 44 |

45 |
46 |
47 |

Account

48 |

49 | This is the tab content, you can put anything you like in here. 50 |

51 |
52 |
53 |

Settings

54 |

55 | This is the tab content, you can put anything you like in here. 56 |

57 |
58 |
59 |
60 |
61 | ); 62 | }; 63 | -------------------------------------------------------------------------------- /src/widgets/widget-1/styles.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --color-primary: #5644fd; 3 | --tab-width: 300px; 4 | --button-width: 64px; 5 | } 6 | 7 | * { 8 | box-sizing: border-box; 9 | } 10 | 11 | html, 12 | body, 13 | .wrapper { 14 | height: 100%; 15 | } 16 | 17 | body { 18 | display: grid; 19 | place-items: center; 20 | margin: 0; 21 | font-family: "Euclid Circular A", "Poppins"; 22 | line-height: 1.5; 23 | background: #f1f0ff; 24 | color: #58547b; 25 | } 26 | 27 | .widget { 28 | background: #ffffff; 29 | width: var(--tab-width); 30 | border-radius: 8px; 31 | } 32 | 33 | .widget > header { 34 | position: relative; 35 | display: flex; 36 | border-bottom: 1px solid #e2e1ef; 37 | } 38 | 39 | .widget > header > button { 40 | padding: 20px; 41 | font-size: 15px; 42 | width: var(--button-width); 43 | cursor: pointer; 44 | background: transparent; 45 | color: #918db7; 46 | border: 0; 47 | font-size: 24px; 48 | transition: 0.3s; 49 | } 50 | 51 | .widget > header > button:not(.active) { 52 | opacity: 0.7; 53 | } 54 | 55 | .widget > header > button:hover:not(.active) { 56 | opacity: 1; 57 | } 58 | 59 | .widget > header > button.active { 60 | color: var(--color-primary); 61 | } 62 | 63 | .content { 64 | position: relative; 65 | overflow: hidden; 66 | height: 140px; 67 | } 68 | 69 | .content-inner { 70 | position: absolute; 71 | top: 0; 72 | left: 0; 73 | display: flex; 74 | align-items: center; 75 | width: calc(var(--tab-width) * 3); 76 | transition: 0.3s; 77 | } 78 | 79 | .underline { 80 | position: absolute; 81 | left: 0; 82 | bottom: 0; 83 | width: 64px; 84 | height: 3px; 85 | background: var(--color-primary); 86 | transition: 0.2s; 87 | } 88 | 89 | h2 { 90 | margin: 0 0 10px; 91 | font-size: 18px; 92 | font-weight: 600; 93 | } 94 | 95 | p { 96 | margin: 0; 97 | font-size: 14px; 98 | } 99 | 100 | .content-inner > div { 101 | width: inherit; 102 | padding: 20px; 103 | } 104 | -------------------------------------------------------------------------------- /src/widgets/widget-2/Widget.js: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import "./styles.css"; 3 | 4 | const menuHeight = getComputedStyle(document.documentElement).getPropertyValue( 5 | "--menu-height" 6 | ); 7 | 8 | const buttons = ["Details", "Metrics", "Orders", "Insights"]; 9 | 10 | export const Widget = () => { 11 | const [activeBlock, setActiveBlock] = useState(0); 12 | 13 | const toggleMenuBlock = (index) => { 14 | setActiveBlock(index); 15 | }; 16 | 17 | return ( 18 |
19 |
20 | {buttons.map((button, index) => ( 21 | 27 | ))} 28 |
29 |
30 |
34 |
35 |

Details

36 |

37 | Vivamus volutpat ipsum ac ipsum feugiat, vel molestie elit 38 | vestibulum. Donec luctus commodo dictum. Aenean in turpis erat. 39 | Vestibulum imperdiet nibh. Ipsum ac ipsum feugiat, vel molestie. 40 |

41 |
42 |
43 |

Metrics

44 |

45 | Vivamus volutpat ipsum ac ipsum feugiat, vel molestie elit 46 | vestibulum. Donec luctus commodo dictum. Aenean in turpis erat. 47 | Vestibulum imperdiet nibh. Ipsum ac ipsum feugiat, vel molestie. 48 |

49 |
50 |
51 |

Orders

52 |

53 | Vivamus volutpat ipsum ac ipsum feugiat, vel molestie elit 54 | vestibulum. Donec luctus commodo dictum. Aenean in turpis erat. 55 | Vestibulum imperdiet nibh. Ipsum ac ipsum feugiat, vel molestie. 56 |

57 |
58 |
59 |

Insights

60 |

61 | Vivamus volutpat ipsum ac ipsum feugiat, vel molestie elit 62 | vestibulum. Donec luctus commodo dictum. Aenean in turpis erat. 63 | Vestibulum imperdiet nibh. Ipsum ac ipsum feugiat, vel molestie. 64 |

65 |
66 |
67 |
68 |
69 | ); 70 | }; 71 | -------------------------------------------------------------------------------- /src/widgets/widget-2/styles.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | html, 6 | body { 7 | height: 100%; 8 | } 9 | 10 | body { 11 | margin: 0; 12 | background: #f1f0fa; 13 | display: grid; 14 | place-items: center; 15 | font-family: "Euclid Circular A", "Poppins"; 16 | } 17 | 18 | :root { 19 | --color-primary: #6d63ff; 20 | --sidebar-width: 140px; 21 | --menu-height: 190px; 22 | } 23 | 24 | .card { 25 | display: flex; 26 | padding: 0 20px; 27 | width: 480px; 28 | height: var(--menu-height); 29 | border-radius: 10px; 30 | background: #ffffff; 31 | box-shadow: 0 20px 30px rgba(57, 76, 96, 0.06); 32 | transition: 0.3s; 33 | } 34 | 35 | .buttons { 36 | padding-top: 20px; 37 | width: var(--sidebar-width); 38 | } 39 | 40 | .buttons button { 41 | margin: 0; 42 | font-size: 14px; 43 | width: 100%; 44 | height: 36px; 45 | padding: 0 0 0 12px; 46 | background: transparent; 47 | border-radius: 6px; 48 | border: 0; 49 | display: flex; 50 | align-items: center; 51 | font-weight: 500; 52 | font-family: inherit; 53 | cursor: pointer; 54 | color: #a7a7a7; 55 | } 56 | 57 | .buttons button.active { 58 | background: var(--color-primary); 59 | color: #f9f9f9; 60 | } 61 | 62 | .wrapper { 63 | position: relative; 64 | overflow: hidden; 65 | flex: 1 1 auto; 66 | } 67 | 68 | .wrapper::before, 69 | .wrapper::after { 70 | content: ""; 71 | position: absolute; 72 | z-index: 2; 73 | left: 0; 74 | width: 100%; 75 | height: 36px; 76 | } 77 | 78 | .wrapper::before { 79 | top: 0; 80 | background: linear-gradient(#ffffff, rgb(255 255 255 / 0%)); 81 | } 82 | 83 | .wrapper::after { 84 | bottom: 0; 85 | background: linear-gradient(rgb(255 255 255 / 0%), #ffffff); 86 | } 87 | 88 | .content { 89 | position: absolute; 90 | z-index: 1; 91 | top: 0; 92 | left: 0; 93 | height: calc(var(----menu-height) * 3); 94 | transition: 0.6s; 95 | } 96 | 97 | .content p { 98 | display: flex; 99 | align-items: center; 100 | line-height: 1.6; 101 | font-size: 13px; 102 | margin: 0; 103 | color: #222222; 104 | opacity: 0.5; 105 | } 106 | 107 | .block { 108 | padding: 0 20px; 109 | height: var(--menu-height); 110 | } 111 | 112 | .block h2 { 113 | padding-top: 20px; 114 | margin: 0 0 6px; 115 | font-size: 18px; 116 | font-weight: 500; 117 | } 118 | --------------------------------------------------------------------------------