|

   Veteran Tools Platform - Developer Documentation

There are no notes for this item.

PropRequired?TypeDefaultDescription
current Yes number The current segment in progress
total Yes number The total number of segments in the progress bar
<div id="reactMount" data-tpl="segmentedprogressbar">
    <div class="progress-bar-segmented" role="progressbar" aria-valuenow="4" aria-valuemin="0" aria-valuemax="6" tabindex="0">
        <div class="progress-segment progress-segment-complete"></div>
        <div class="progress-segment progress-segment-complete"></div>
        <div class="progress-segment progress-segment-complete"></div>
        <div class="progress-segment progress-segment-complete"></div>
        <div class="progress-segment "></div>
        <div class="progress-segment "></div>
    </div>
</div>
<script>
    window.currentProps = {
        "package": {
            "name": "department-of-veteran-affairs/jean-pants",
            "version": "0.1.0"
        },
        "assetPath": "/design-system/",
        "isProduction": true,
        "componentSourcePath": "SegmentedProgressBar.jsx",
        "id": "default",
        "current": 4,
        "total": 6
    }
</script>
import React from 'react';
import SegmentedProgressBar from './SegmentedProgressBar';

export default function SegmentedProgressBarExample(props) {
  return (
    <SegmentedProgressBar
      current={props.current}
      total={props.total}/>
  );
}
package:
  name: department-of-veteran-affairs/jean-pants
  version: 0.1.0
assetPath: /design-system/
isProduction: true
componentSourcePath: SegmentedProgressBar.jsx
id: default
current: 4
total: 6
  • Content:
    import React from 'react';
    import PropTypes from 'prop-types';
    import _ from 'lodash';
    
    /**
     * Create a segmented progress bar for multi-page forms.
     *
     * @param {number} current - The index of the current chapter
     * @param {number} total   - The total number of chapters in the form
     */
    export default function SegmentedProgressBar({ current, total }) {
      return (
        <div className="progress-bar-segmented" role="progressbar" aria-valuenow={current} aria-valuemin="0" aria-valuemax={total} tabIndex="0">
          {_.range(total).map(step => (
            <div key={step} className={`progress-segment ${current > step ? 'progress-segment-complete' : ''}`}/>
          ))}
        </div>
      );
    }
    
    SegmentedProgressBar.propTypes = {
      /**
       * The current segment in progress
       */
      current: PropTypes.number.isRequired,
      /**
       * The total number of segments in the progress bar
       */
      total: PropTypes.number.isRequired
    };
    
  • URL: /components/raw/segmentedprogressbar/SegmentedProgressBar.jsx
  • Filesystem Path: src/components/form/SegmentedProgressBar/SegmentedProgressBar.jsx
  • Size: 912 Bytes
  • Content:
    import React from 'react';
    import { shallow } from 'enzyme';
    import { expect } from 'chai';
    import { axeCheck } from '../../../../lib/testing/helpers';
    
    import SegmentedProgressBar from './SegmentedProgressBar.jsx';
    
    describe('<SegmentedProgressBar/>', () => {
      it('should render', () => {
        const tree = shallow(<SegmentedProgressBar current={2} total={5}/>);
        expect(tree.find('.progress-segment')).to.have.length(5);
      });
    
      it('should pass aXe check', () => {
        return axeCheck(<SegmentedProgressBar current={2} total={5}/>);
      });
    });
    
  • URL: /components/raw/segmentedprogressbar/SegmentedProgressBar.unit.spec.jsx
  • Filesystem Path: src/components/form/SegmentedProgressBar/SegmentedProgressBar.unit.spec.jsx
  • Size: 549 Bytes
  • Handle: @segmentedprogressbar
  • Preview:
  • Filesystem Path: src/components/form/SegmentedProgressBar/SegmentedProgressBar.njk