Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding LinearProgress's bar2Determinate styles not applied #12318

Closed
2 tasks done
agentmilindu opened this issue Jul 28, 2018 · 0 comments · Fixed by #12319
Closed
2 tasks done

Overriding LinearProgress's bar2Determinate styles not applied #12318

agentmilindu opened this issue Jul 28, 2018 · 0 comments · Fixed by #12319
Labels
component: LinearProgress The React component. package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.

Comments

@agentmilindu
Copy link
Contributor

agentmilindu commented Jul 28, 2018

I'm trying to overide the LinearProgress's bar2Determinate color as follows,

import React from 'react';
import PropTypes from 'prop-types';
import LinearProgress from '@material-ui/core/LinearProgress';
import { withStyles } from '@material-ui/core/styles';

const styles = theme => ({
  bar1Determinate:{
    background: 'linear-gradient(to left, #e21e4a, #a92fff)',
  },
  bar2Determinate:{
    background: '#333333',
  }
});

const Component = ({classes}) => (
  <div >
    <LinearProgress value={80} variant="determinate" classes={{
      bar1Determinate: classes.bar1Determinate,
      bar2Determinate: classes.bar2Determinate,
    }} />
  </div>
);

Component.propTypes = {
  classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(Component);

But I'm getting following warning and the color is nor overridden.

warning.js:36 Warning: Material-UI: the key bar2Determinate provided to the classes property is not implemented in LinearProgress.
You can only override one of the following: root,colorPrimary,colorSecondary,buffer,query,dashed,dashedColorPrimary,dashedColorSecondary,bar,barColorPrimary,barColorSecondary,bar1Indeterminate,bar2Indeterminate,bar1Determinate,bar1Buffer,bar2Buffer

When I checked the source code, I found this line,

https://github.com/mui-org/material-ui/blob/0efc81dad607437fa448d6b19a2c985266790848/packages/material-ui/src/LinearProgress/LinearProgress.js#L195

    [classes.bar2Indeterminate]: variant === 'indeterminate' || variant === 'query',
    [classes.bar1Determinate]: variant === 'determinate',
    [classes.bar2Buffer]: variant === 'buffer',

My guess is, it should be,

[classes.bar2Determinate]: variant === 'determinate',
  • This is a v1.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Should be able to override the bar2Determinate styles.

screenshot from 2018-07-29 00-52-17

Current Behavior

The bar2Determinate styles are not overridden.

screenshot from 2018-07-29 00-51-26

Steps to Reproduce

Link: https://codesandbox.io/s/rrn52ooqxn

  1. Identify if the ba2 color is #333333

Context

I'm trying to implement a custom styled LinearProgress

Your Environment

Tech Version
Material-UI v1.4.0
React 16.4.1
browser Chrome
agentmilindu added a commit to agentmilindu/material-ui that referenced this issue Jul 28, 2018
Overriding `LinearProgress`'s `bar2Determinate` styles not applied
oliviertassinari pushed a commit that referenced this issue Jul 28, 2018
Overriding `LinearProgress`'s `bar2Determinate` styles not applied
@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 20, 2022
@zannager zannager added component: LinearProgress The React component. package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: LinearProgress The React component. package: styles Specific to @mui/styles. Legacy package, @material-ui/styled-engine is taking over in v5.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants