├── .gitignore ├── src └── progress-bar.js ├── tea.yaml ├── test └── index.test.js ├── LICENSE ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories 2 | node_modules/ 3 | dist/ 4 | coverage/ 5 | .cache/ 6 | 7 | # Files 8 | .env 9 | .DS_Store -------------------------------------------------------------------------------- /src/progress-bar.js: -------------------------------------------------------------------------------- 1 | class ProgressBar { 2 | constructor(totalSteps) { 3 | this.totalSteps = totalSteps; 4 | this.currentStep = 0; 5 | } 6 | 7 | setProgress(currentStep) { 8 | if (currentStep < 0 || currentStep > this.totalSteps) { 9 | throw new Error('Invalid step value'); 10 | } 11 | this.currentStep = currentStep; 12 | } 13 | 14 | getProgress() { 15 | return (this.currentStep / this.totalSteps) * 100; 16 | } 17 | } 18 | 19 | module.exports = ProgressBar; 20 | -------------------------------------------------------------------------------- /tea.yaml: -------------------------------------------------------------------------------- 1 | # https://tea.xyz/what-is-this-file 2 | --- 3 | version: 1.0.0 4 | codeOwners: 5 | - '0x9BAac40A197bbb110ae5B2f31342D8d15D734832' 6 | - '0x5397A2eE6710509dABf0C61e02cC664323f0512B' 7 | - '0x8cd1467006632Bb4c8CB5516D46D7797C9296009' 8 | - '0x4F99644202e8E59cf135430Fe6F3BF248d208356' 9 | - '0x11B16058F2aC4f66Bdb13E6231005256CC57E063' 10 | - '0x4157c3d0fD3C93e105Ef733CE90faec7016F688E' 11 | - '0x7Bc2Ae4081f84d42A9697d2bd4697f51A0e7E73d' 12 | - '0xdb8f23F54714EEBE9F3035EB4410D17d4BE50662' 13 | - '0x6AC24Db99aE3B91218b7da88f0030FC5595489E2' 14 | - '0x9F363178e092E7114D7101B9Ff1501F85DDA6569' 15 | - '0x4D2d66063f88B5b2975ffee2Bf4D32B88eF850E8' 16 | quorum: 1 17 | -------------------------------------------------------------------------------- /test/index.test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const ProgressBar = require('../src/progress-bar'); 3 | 4 | describe('ProgressBar', function() { 5 | describe('#getProgress()', function() { 6 | it('should return 0 when no progress is set', function() { 7 | const progressBar = new ProgressBar(100); 8 | assert.strictEqual(progressBar.getProgress(), 0); 9 | }); 10 | 11 | it('should return correct progress value', function() { 12 | const progressBar = new ProgressBar(100); 13 | progressBar.setProgress(50); 14 | assert.strictEqual(progressBar.getProgress(), 50); 15 | }); 16 | 17 | it('should throw an error for invalid progress value', function() { 18 | const progressBar = new ProgressBar(100); 19 | assert.throws(() => { 20 | progressBar.setProgress(-1); 21 | }, Error); 22 | assert.throws(() => { 23 | progressBar.setProgress(101); 24 | }, Error); 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 ONE DIONYS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "onedionys-progress-bar-component", 3 | "version": "5.0.0", 4 | "description": "One Dionys (Progress Bar Component) - A component to display the progress or status of processes in the application.", 5 | "main": "src/progress-bar.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "mocha" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/onedionys/onedionys-progress-bar-component.git" 15 | }, 16 | "keywords": [ 17 | "onedionys", 18 | "tea", 19 | "package-manager", 20 | "progress-bar-component" 21 | ], 22 | "author": "One Dionys", 23 | "license": "ISC", 24 | "bugs": { 25 | "url": "https://github.com/onedionys/onedionys-progress-bar-component/issues" 26 | }, 27 | "homepage": "https://github.com/onedionys/onedionys-progress-bar-component#readme", 28 | "dependencies": { 29 | "@types/chai": "^4.3.12", 30 | "@types/mocha": "^10.0.6", 31 | "chai": "^5.1.0", 32 | "mocha": "^10.3.0" 33 | }, 34 | "devDependencies": { 35 | "chai": "^5.1.0", 36 | "mocha": "^10.3.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Welcome to One Dionys - Progress Bar Component! 👋

2 | 3 |

A component to display the progress or status of processes in the application. 💖

4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 | ## 💾 Requirements 16 | 17 | * `Web Browser` - Can be used as an emulator to build applications. Example [Chrome, Firefox, Safari & Opera]. 18 | * `Internet` - Because many use CDN and to make it easier to find solutions to all problems. 19 | 20 | ## 🎯 How To Use 21 | 22 | #### Example Syntax 23 | 24 | ```javascript 25 | const ProgressBar = require('./src/progress-bar'); 26 | 27 | // Create a new progress bar with 100 total steps 28 | const progressBar = new ProgressBar(100); 29 | 30 | // Set the progress to 50 steps 31 | progressBar.setProgress(50); 32 | 33 | // Get the current progress percentage 34 | console.log(progressBar.getProgress()); 35 | ``` 36 | 37 | #### Explanation 38 | 39 | * The Progress Bar Component allows you to create a progress bar with a specified total number of steps. You can then update the progress and retrieve the current progress percentage. 40 | 41 | #### Return Value 42 | 43 | * `setProgress(currentStep)`: Sets the progress to the specified step. Throws an error if the step value is invalid. 44 | * `getProgress()`: Returns the current progress percentage. 45 | 46 | ## 📆 Release Date 47 | 48 | * v1.0.0 : 08 March 2024 49 | * v1.0.1 : 11 March 2024 50 | * v4.0.0 : 11 March 2024 51 | * v4.0.1 : 13 March 2024 52 | * v4.0.2 : 18 March 2024 53 | * v5.0.0 : 31 March 2024 54 | 55 | ## 🧑 Author 56 | 57 | * Facebook : Oned Ionys 58 | * Instagram : @onedionys 59 | * Twitter : @onedionys 60 | * LinkedIn : @onedionys 61 | 62 | ## 📝 License 63 | 64 | * Copyright © 2024 One Dionys 65 | * **One Dionys - Progress Bar Component is an open source project licensed under the MIT license** 66 | 67 | ## ☕️ Suppport & Donation 68 | 69 | Love One Dionys - Progress Bar Component? Support this project by donating or sharing with others in need. 70 | 71 | 72 | 73 | **Made with ❤️ One Dionys** 74 | --------------------------------------------------------------------------------