diff --git a/docs/app/Examples/modules/Progress/Content/ProgressExampleProgressValuePercentageOfTotal.js b/docs/app/Examples/modules/Progress/Content/ProgressExampleProgressValuePercentageOfTotal.js new file mode 100644 index 0000000000..107183fcb0 --- /dev/null +++ b/docs/app/Examples/modules/Progress/Content/ProgressExampleProgressValuePercentageOfTotal.js @@ -0,0 +1,8 @@ +import React from 'react' +import { Progress } from 'semantic-ui-react' + +const ProgressExampleProgressValuePercentageOfTotal = () => ( + +) + +export default ProgressExampleProgressValuePercentageOfTotal diff --git a/docs/app/Examples/modules/Progress/Content/index.js b/docs/app/Examples/modules/Progress/Content/index.js index 2c261046cf..38d7f58be4 100644 --- a/docs/app/Examples/modules/Progress/Content/index.js +++ b/docs/app/Examples/modules/Progress/Content/index.js @@ -35,6 +35,10 @@ const ProgressContentExamples = () => ( description='A progress element display progress as a value.' examplePath='modules/Progress/Content/ProgressExampleProgressValue' /> + ) diff --git a/src/modules/Progress/Progress.js b/src/modules/Progress/Progress.js index 01abbdf74c..bb268daa66 100644 --- a/src/modules/Progress/Progress.js +++ b/src/modules/Progress/Progress.js @@ -127,9 +127,9 @@ class Progress extends Component { } getPercent = () => { - const { precision, progress, value } = this.props + const { precision, progress, total, value } = this.props const percent = _.clamp(this.calculatePercent(), 0, 100) - + if (!_.isUndefined(total) && !_.isUndefined(value) && progress === 'value') return (value / total) * 100 if (progress === 'value') return value if (_.isUndefined(precision)) return percent return _.round(percent, precision) diff --git a/test/specs/modules/Progress/Progress-test.js b/test/specs/modules/Progress/Progress-test.js index 56e628947a..e9f419ae68 100644 --- a/test/specs/modules/Progress/Progress-test.js +++ b/test/specs/modules/Progress/Progress-test.js @@ -86,6 +86,11 @@ describe('Progress', () => { .find('.bar') .should.have.style('width', '0%') }) + it('has a width equal to the percentage of the value of the total, when progress="value"', () => { + shallow() + .find('.bar') + .should.have.style('width', '50%') + }) }) describe('data-percent', () => {