# All files / progress progress.tsx

100% Statements 16/16
100% Branches 4/4
100% Functions 5/5
100% Lines 16/16

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    761x

    1x
    1x

    1x

    1x
    1x
    1x

    1x

    1x

    11x

    11x

    11x

    11x

    1x
    1x
    1x
     import * as React from "react";
    import * as ReactDOM from "react-dom";
    import { get } from "lodash-es";
    import Foundation, { HandledProps } from "@microsoft/fast-components-foundation-react";
    import {
        ProgressHandledProps,
        ProgressManagedClasses,
        ProgressProps,
        ProgressUnhandledProps
    } from "./progress.props";
    import { ManagedClasses, ProgressClassNameContract } from "@microsoft/fast-components-class-name-contracts-base";

    export enum ProgressType {
        determinate = "determinate",
        indeterminate = "indeterminate"
    }

    class Progress extends Foundation<
        ProgressHandledProps,
        ProgressUnhandledProps,
        {}
    > {
        public static defaultProps: Partial<ProgressProps> = {
            minValue: 0,
            maxValue: 100
        };

        public static displayName: string = "Progress";

        protected handledProps: HandledProps<ProgressHandledProps> = {
            children: void 0,
            managedClasses: void 0,
            maxValue: void 0,
            minValue: void 0,
            value: void 0
        };

        /**
         * Renders the component
         */
        public render(): React.ReactElement<HTMLDivElement> {
            return (
                <div
                    {...this.unhandledProps()}
                    className={this.generateClassNames()}
                    role="progressbar"
                    aria-valuenow={this.props.value}
                    aria-valuemin={this.props.minValue}
                    aria-valuemax={this.props.maxValue}
                >
                    {this.renderChildren()}
                </div>
            );
        }

        /**
         * Generates class names
         */
        protected generateClassNames(): string {
            return super.generateClassNames(get(this.props, "managedClasses.progress"));
        }

        /**
         * Renders children based on value prop
         */
        private renderChildren(): React.ReactNode {
            return this.props.value !== undefined
                ? this.withSlot(ProgressType.determinate)
                : this.withSlot(ProgressType.indeterminate);
        }
    }

    export default Progress;
    export * from "./progress.props";
    export { ProgressClassNameContract };