// Copyright (c) 2016-2018 VMware, Inc. All Rights Reserved.
// This software is released under MIT license.
// The full license information can be found in LICENSE in the root directory of this project.

@mixin populateButtonProperties($button-type: default, $button-global-map: $clr-global-button-properties-map) {
    $button-property-map: map-get($button-global-map, $button-type);
    border-color: map-get($button-property-map, border-color);
    background-color: map-get($button-property-map, background-color);
    color: map-get($button-property-map, color);

    //To override the visited state of anchor links styled as buttons
    &:visited {
        color: map-get($button-property-map, color);
    }

    &:hover {
        background-color: map-get($button-property-map, hover-background-color);
        color: map-get($button-property-map, hover-color);
    }

    &:active {
        box-shadow: 0 map-get($button-property-map, active-box-shadow-width-top) 0 0
            map-get($button-property-map, active-box-shadow-color) inset;
    }

    &.disabled,
    &:disabled {
        color: map-get($button-property-map, disabled-color);
        cursor: not-allowed;
        background-color: map-get($button-property-map, disabled-background-color);
        border-color: map-get($button-property-map, disabled-border-color);
        opacity: 0.4;
    }
}

@mixin btn-checked-styles(
    $button-type: default,
    $type: checkbox,
    $button-global-map: $clr-global-button-properties-map
) {
    $button-property-map: map-get($button-global-map, $button-type);

    $background-color: map-get(
        $button-property-map,
        checked-background-color
    ); // add semantic prop: group-checked-font-color
    $color: map-get($button-property-map, checked-color);

    input[type="#{$type}"]:checked + label {
        background-color: $background-color;
        color: $color;
    }
}

@mixin btn-nowrap() {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

@mixin btn-min-max-widths() {
    min-width: 3rem;
    max-width: 15rem;
}

@mixin btn-text-properties() {
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    vertical-align: middle;

    &:hover {
        text-decoration: none;
    }
}

@mixin btn-default-border-styles() {
    border-radius: $clr-global-borderradius;
    border: $clr-default-borderwidth solid;
}

@mixin btn-appearance() {
    cursor: pointer;
    display: inline-block;

    // Overrides a Fix for IOS in BS4 _normalize.scss (~ln 330)
    // `!important` is to override specificity in this instance
    // But we wanted to preserve the normalize fix in non-Clarity buttons for iOS
    -webkit-appearance: none !important;
}

@mixin generateButton() {
    @include btn-appearance();
    @include btn-default-border-styles();
    @include btn-min-max-widths();
    @include btn-nowrap();
    @include btn-text-properties();
}
