Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@material/linear-progress
Advanced tools
The Material Components for the web linear progress indicator component
@material/linear-progress is a Material Design component for displaying linear progress indicators. It provides a visual representation of the progress of a task, making it easy to integrate with React applications and ensuring a consistent look and feel with other Material Design components.
Indeterminate Progress
This feature allows you to display an indeterminate progress bar, which is useful when the duration of the task is unknown.
import React from 'react';
import { LinearProgress } from '@material-ui/core';
function IndeterminateProgress() {
return <LinearProgress />;
}
export default IndeterminateProgress;
Determinate Progress
This feature allows you to display a determinate progress bar, which is useful when you can track the progress of a task.
import React, { useState } from 'react';
import { LinearProgress } from '@material-ui/core';
function DeterminateProgress() {
const [progress, setProgress] = useState(0);
React.useEffect(() => {
const timer = setInterval(() => {
setProgress((oldProgress) => {
if (oldProgress === 100) {
return 0;
}
const diff = Math.random() * 10;
return Math.min(oldProgress + diff, 100);
});
}, 500);
return () => {
clearInterval(timer);
};
}, []);
return <LinearProgress variant="determinate" value={progress} />;
}
export default DeterminateProgress;
Buffer Progress
This feature allows you to display a buffer progress bar, which is useful when you want to show both the progress and the buffer of a task.
import React, { useState } from 'react';
import { LinearProgress } from '@material-ui/core';
function BufferProgress() {
const [progress, setProgress] = useState(0);
const [buffer, setBuffer] = useState(10);
React.useEffect(() => {
const timer = setInterval(() => {
setProgress((oldProgress) => {
if (oldProgress === 100) {
return 0;
}
const diff = Math.random() * 10;
return Math.min(oldProgress + diff, 100);
});
setBuffer((oldBuffer) => {
if (oldBuffer === 100) {
return 10;
}
const diff = Math.random() * 10;
return Math.min(oldBuffer + diff, 100);
});
}, 500);
return () => {
clearInterval(timer);
};
}, []);
return <LinearProgress variant="buffer" value={progress} valueBuffer={buffer} />;
}
export default BufferProgress;
Query Progress
This feature allows you to display a query progress bar, which is useful when you want to indicate that a task is being queried.
import React from 'react';
import { LinearProgress } from '@material-ui/core';
function QueryProgress() {
return <LinearProgress variant="query" />;
}
export default QueryProgress;
react-loader-spinner provides a collection of customizable loading spinners for React applications. It offers a variety of spinner types, including linear progress bars, and is highly customizable in terms of size, color, and animation speed. Compared to @material/linear-progress, it provides more variety in loading indicators but may not adhere strictly to Material Design guidelines.
react-progressbar.js is a React wrapper for ProgressBar.js, a library for creating animated progress bars. It supports linear and circular progress bars with customizable animations and styles. While it offers more animation options compared to @material/linear-progress, it may require more effort to integrate seamlessly with Material Design components.
nprogress is a simple and lightweight progress bar library for web applications. It is often used for indicating page load progress and can be easily integrated with React. However, it lacks the variety of progress bar types and customization options available in @material/linear-progress.
The MDC Linear Progress component is a spec-aligned linear progress indicator component adhering to the Material Design progress & activity requirements.
npm install --save @material/linear-progress
<div role="progressbar" class="mdc-linear-progress">
<div class="mdc-linear-progress__buffering-dots"></div>
<div class="mdc-linear-progress__buffer"></div>
<div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
<span class="mdc-linear-progress__bar-inner"></span>
</div>
<div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
<span class="mdc-linear-progress__bar-inner"></span>
</div>
</div>
The provided modifiers are:
Class | Description |
---|---|
mdc-linear-progress--indeterminate | Puts the linear progress indicator in an indeterminate state. |
mdc-linear-progress--reversed | Reverses the direction of the linear progress indicator. |
mdc-linear-progress--accent | Colors the linear progress indicator with the secondary color. |
MDC Linear Progress ships with an MDCLinearProgressFoundation
class that external frameworks and libraries can
use to integrate the component. As with all foundation classes, an adapter object must be provided.
The adapter for linear progress must provide the following functions, with correct signatures:
Method Signature | Description |
---|---|
addClass(className: string) => void | Adds a class to the root element. |
removeClass(className: string) => void | Removes a class from the root element. |
hasClass(className: string) => boolean | Returns boolean indicating whether the root element has a given class. |
getPrimaryBar() => Element | Returns the primary bar element. |
getBuffer() => Element | Returns the buffer element. |
setTransform(el: Element, value: string) => void | Sets the css transform property on the given element. |
MDC Linear Progress Foundation exposes the following methods:
Method Signature | Description |
---|---|
setDeterminate(value: boolean) => void | Toggles the component between the determinate and indeterminate state. |
setProgress(value: number) => void | Sets the progress bar to this value. Value should be between [0, 1]. |
setBuffer(value: number) => void | Sets the buffer bar to this value. Value should be between [0, 1]. |
setReverse(value: boolean) => void | Reverses the direction of the linear progress indicator. |
open() => void | Puts the component in the open state. |
close() => void | Puts the component in the closed state. |
MDC Linear Progress exposes the following methods:
Method Signature | Description |
---|---|
set determinate(value: boolean) => void | Toggles the component between the determinate and indeterminate state. |
set progress(value: number) => void | Sets the progress bar to this value. Value should be between [0, 1]. |
set buffer(value: number) => void | Sets the buffer bar to this value. Value should be between [0, 1]. |
set reverse(value: boolean) => void | Reverses the direction of the linear progress indicator. |
open() => void | Puts the component in the open state. |
close() => void | Puts the component in the closed state. |
FAQs
The Material Components for the web linear progress indicator component
The npm package @material/linear-progress receives a total of 451,483 weekly downloads. As such, @material/linear-progress popularity was classified as popular.
We found that @material/linear-progress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.