A guide on advancing the border like a progress bar in react.js

My goal is to progressively fill a border every minute, reaching full capacity after 60 minutes and then starting over.

This task is part of my practice with react.js. I attempted to create a variable using .getMinutes(); to track the current number of minutes, but I am struggling with how to incrementally fill the border each minute.

<body>
        <div className="progress_container">
            <div className="progressbar">
                <p className="innertext">
                    <h2>{playtime + '/60'}</h2>
                    min
                </p>
            </div>
        </div>
</body>
.progress_container{
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: white;
    position: absolute;
    right: calc(100% - 600px);
    left: auto;
    bottom: calc(100% - 350px);

}
.progressbar{
    width: 190px;
    height: 190px;
    border-radius: 50%;
    border: 30px solid orange;

}
.progressbar:after{
    content: '';

}
p{
    color: #000;
    font-size: 16px;
    position: relative;
    top: calc(95px - 3*16px);
}
let pb = document.getElementsByClassName('progressbar');

    var date = new Date (Date.now());
    const playtime = date.getMinutes();

I have searched for alternative solutions, but integrating them with react.js proved unsuccessful, resulting in numerous errors.

Answer №1

You may think that adjusting the width of a border is impossible, but there is a trick to create a scrollbar:

.custom-scrollbar-wrapper {
  width: 100%;
  height: 5px;
  background-color: #999;
}

.custom-scrollbar {
  height: 100%;
  width: 30%;
  background-color: blue;
}
<div class="custom-scrollbar-wrapper">
  <div class="custom-scrollbar"></div>
</div>

Then, you can easily adjust the width percentage of .custom-scrollbar using JavaScript

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Three.js to load blender JSON files

Hey there! I'm currently facing some challenges when it comes to importing models from Blender into three.js. Currently, I am using the latest version of three.js (R71). I have successfully installed the three.js exporter in Blender and it works fine ...

Select specific values from a JSON object based on the keys defined in a TypeScript type

I am working with the following content structure: interface User { email: string; name: string; } ...and have created a react component as shown below: const MyComponent = <Values extends object>({ values }: { values: Values }) => { consol ...

Having difficulty toggling a <div> element with jQuery

I am attempting to implement a button that toggles the visibility of a div containing replies to comments. My goal is to have the ability to hide and display the replies by clicking the button. The "show all replies" button should only appear if there are ...

What is the proper way to invoke an instance method through an inherited method using its name and ensuring the arguments are correctly typed?

We have created a foundational class that will be extended numerous times. Our goal is to implement an `exec` method on this base class, which will take the name and arguments of a method from a derived class and execute it. However, we are encountering a ...

Connecting static CSS files to Django

I am fairly new to working with Django and I am having trouble linking CSS to my project. I have included the necessary static settings in my app's configuration, which allows me to access images in the static folder without any issues. However, when ...

Increase the size of the logo in the navbar without causing any distortion to the other elements

I am currently facing an issue with my logo placement in the header section of my website. The header consists of a background image with a navbar and logo embedded within it. HTML <div class="header"> <div class="container"> < ...

When registering the onHardwareBackButton event in Ionic, the back button continues to successfully navigate to the previous page

I recently started working with Ionic and encountered an issue with the onHardwareBackButton event. The event is functioning properly and directing me to the register function, but even after going to the register function, it still navigates back to the p ...

Validating a string as a date input by utilizing the moment library

Utilizing the momentjs library for validating dates can be tricky. The typical format for validation is as follows: moment(date, formats, true).isValid() However, if you only want to check if a string is a valid date without specifying a format, things ...

Bootstrap4 slide-out menu displayed at the top of the main page

I've been experimenting with creating a pop-out menu using bootstrap 4 and jquery. Following this tutorial at My implementation currently looks like this... https://i.sstatic.net/47AST.png Having trouble figuring out the cause of this issue. Initi ...

Converting Interfaces from Typescript to Javascript

Can the interface in typescript be converted into Javascript? If so, what is the process for converting the typescript code shown below into Javascript. interface xyz{ something? : string, somethingStyle? : Textstyle } ...

What is the optimal approach for managing script initialization on both desktop and mobile devices?

I have implemented a feature on my website that can detect whether the viewer is using a mobile device. Additionally, I have created a JavaScript script that adjusts settings based on whether the user is on a mobile device or not. However, I am wondering ...

Can a Bootstrap 4 column be designed to have the same height as its width?

Can a Bootstrap 4 column have equal height and width, creating a quadratic design with three columns? Is it feasible to make the first two columns as quadratic dimensions, with the third column matching their height? <div class="row"> <div ...

Exploring the vulnerability in switching an ajax request to another PHP file for potential exploitation clarification

I am currently developing an application that processes an ajax call (using jquery) and provides validated users with an entry token for the website. For instance, if the ajax call is made to checkAuth.php and all other php files are in the same directory ...

Adding numerous objects to a Vuex store using mutations

I am currently working with the following store setup: import Vue from 'vue' import Vuex from 'vuex' import axios from 'axios' Vue.use(Vuex) export default new Vuex.Store({ plugins: [createPersistedState()], state: { ...

NgZone is no longer functioning properly

Seemingly out of the blue, my NgZone functionality has ceased to work. I'm currently in the process of developing an application using Ionic, Angular, and Firebase. An error is being thrown: Unhandled Promise rejection: Missing Command Error ; Zon ...

Changing an array into an object in JavaScript without rearranging the keys

I have a collection { 1: {id: 1, first: 1, last: 5} 2: {id: 2, first: 6, last: 10} 3: {id: 3, first: 11, last: 15} } My goal is to reverse the order of items without rearranging the keys so that it looks like this: { 1: {id: 3, first: 11, last: 15} 2: { ...

The issue encountered with Bootstrap Carousel and the <img> tag displaying incorrect object-fit and object-position properties

Currently, I am working on a carousel design that looks like the code snippet below: <div id="myCarousel" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> ... </ol> <div class="carousel ...

Issues Arise with Bootstrap Side Navigation Tab Content Navigation

As someone new to web development, I am currently working on a web app and struggling with the page design. Specifically, I am attempting to create a fixed side navbar with content displayed in the second column of a split row. Below is the code I have man ...

"Connection Failure: MongoDB Server Unreachable"`

I've been working on a basic web application using MongoDB, Express, and NodeJS. Unfortunately, I've encountered an issue where I cannot connect to MongoDB and keep receiving the following error message in the terminal: (node:28265) UnhandledPro ...

Navigating in a react login interface

Recently, I developed a backend code for a login system that verifies the validity of usernames and passwords. While everything is functioning as intended, I am facing an issue with automating the redirect to /dashboard. The client side operates on Port ...