# All files / card card.tsx

100% Statements 13/13
100% Branches 2/2
100% Functions 4/4
100% Lines 13/13

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

    1x
    1x
    1x

    1x

    1x

    4x

    4x

    4x

    4x

    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 {
        CardHandledProps,
        CardManagedClasses,
        CardTag,
        CardUnhandledProps
    } from "./card.props";
    import { CardClassNameContract, ManagedClasses } from "@microsoft/fast-components-class-name-contracts-base";

    class Card extends Foundation<
        CardHandledProps,
        CardUnhandledProps,
        {}
    > {
        public static displayName: string = "Card";

        protected handledProps: HandledProps<CardHandledProps> = {
            children: void 0,
            managedClasses: void 0,
            tag: void 0
        };

        /**
         * Renders the component
         */
        public render(): React.ReactElement<HTMLDivElement | HTMLElement> {
            return (
                <this.tag
                    {...this.unhandledProps()}
                    className={this.generateClassNames()}
                >
                    {this.props.children}
                </this.tag>
            );
        }

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

        /**
         * Stores HTML tag for use in render
         */
        private get tag(): string {
            return CardTag[this.props.tag] || CardTag.div;
        }
    }

    export default Card;
    export * from "./card.props";
    export { CardClassNameContract };