# All files / divider divider.tsx

100% Statements 14/14
100% Branches 4/4
100% Functions 4/4
100% Lines 14/14

    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
    561x

    1x
    1x
    1x
    1x

    1x

    5x

    5x

    5x
    1x

    5x

    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 { DividerHandledProps, DividerManagedClasses, DividerRoles, DividerUnhandledProps } from "./divider.props";
    import { DividerClassNameContract, ManagedClasses } from "@microsoft/fast-components-class-name-contracts-base";

    /* tslint:disable-next-line */
    class Divider extends Foundation<
        DividerHandledProps,
        DividerUnhandledProps,
        {}
    > {
        public static displayName: string = "Divider";

        protected handledProps: HandledProps<DividerHandledProps> = {
            managedClasses: void 0,
            role: void 0
        };

        /**
         * Renders the component
         */
        public render(): React.ReactElement<HTMLHRElement> {
            return (
                <hr
                    {...this.unhandledProps()}
                    {...this.generateAttributes()}
                    className={this.generateClassNames()}
                />
            );
        }

        /**
         * Generates the attributes
         */
        protected generateAttributes(): React.HTMLAttributes<HTMLHRElement> {

            // Do not render role="separator" on page because it's intrinsically set.
            if (this.props.role && this.props.role !== DividerRoles.separator) {
                return ({role: DividerRoles[this.props.role]});
            }
        }

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

    export default Divider;
    export * from "./divider.props";
    export { DividerClassNameContract };