python-gallery/onlylegs/filters.py

23 lines
558 B
Python
Raw Normal View History

"""
OnlyLegs filters
Custom Jinja2 filters
"""
from flask import Blueprint
2023-05-29 10:41:53 +00:00
from onlylegs.utils.colour import contrast
2023-04-22 14:11:47 +00:00
blueprint = Blueprint("filters", __name__)
@blueprint.app_template_filter()
def colour_contrast(colour):
"""
Pass in the colour of the background and will return
a css variable based on the contrast of text required to be readable
"color: var(--fg-white);" or "color: var(--fg-black);"
"""
bright = "var(--fg-white)"
dark = "var(--fg-black)"
2023-04-22 14:11:47 +00:00
2023-05-29 10:41:53 +00:00
return "color: RGB(" + contrast(colour, dark, bright) + ");"