# -*- coding: utf-8 -*-
""" GENERIC CALLBACKS """

import dash 
from dash.dependencies import MATCH
from dash.dependencies import Input, Output


@dash.callback(
               Output({'type':'caret', 'index': MATCH}, 'style'), 
               [Input({'type':'collapse', 'index': MATCH}, 'is_open')],
               )
def rotate_section_caret(collapse_open):
    """ Rotate section 3 menu caret

    Parameters
    ----------
    collapse_open : bool
        Indicates wheter the caret is open or closed
    """

    rotation = 0 if collapse_open else 180
    rotate_caret = {
        'transform': 'rotate({}deg)'.format(rotation),
        '-ms-transform': 'rotate({}deg)'.format(rotation),
        '-webkit-transform': 'rotate({}deg)'.format(rotation)
    }

    return rotate_caret
