def hex_color_to_rgba(hex_color, opacity):
    """Convert a color code string like '#123' or '#123456' to an rgba with opacity like 'rgba(12,34},56},0.2})'"""
    hex = hex_color.replace('#', '')

    if len(hex) == 3:
        hex = f"${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}"

    r = int(hex[0:2], 16)
    g = int(hex[2:4], 16)
    b = int(hex[4:6], 16)
    return f"rgba({r},{g},{b},{opacity / 100})"