mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2024-12-28 02:16:07 +00:00
Add colour contrast filter
Make colours on images yoinkable
This commit is contained in:
parent
76cc8456d2
commit
13a0b21710
|
@ -24,6 +24,7 @@ from onlylegs.views import (
|
|||
)
|
||||
from onlylegs.api import media as api_media, group as api_group, account as api_account
|
||||
from onlylegs import auth as view_auth
|
||||
from onlylegs import filters
|
||||
from onlylegs import gwagwa
|
||||
|
||||
|
||||
|
@ -125,6 +126,9 @@ def create_app(): # pylint: disable=R0914
|
|||
app.register_blueprint(api_media.blueprint)
|
||||
app.register_blueprint(api_group.blueprint)
|
||||
app.register_blueprint(api_account.blueprint)
|
||||
|
||||
# FILTERS
|
||||
app.register_blueprint(filters.blueprint)
|
||||
|
||||
# CACHE AND COMPRESS
|
||||
cache.init_app(app)
|
||||
|
|
22
onlylegs/filters.py
Normal file
22
onlylegs/filters.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
"""
|
||||
OnlyLegs filters
|
||||
Custom Jinja2 filters
|
||||
"""
|
||||
from flask import Blueprint
|
||||
from onlylegs.utils import contrast
|
||||
|
||||
|
||||
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)"
|
||||
|
||||
return "color: RGB(" + contrast.contrast(colour, dark, bright) + ");"
|
|
@ -188,19 +188,27 @@
|
|||
display: flex
|
||||
gap: 0.5rem
|
||||
|
||||
span
|
||||
button
|
||||
margin: 0
|
||||
padding: 0
|
||||
|
||||
width: 1.5rem
|
||||
height: 1.5rem
|
||||
width: 1.6rem
|
||||
height: 1.6rem
|
||||
|
||||
display: flex
|
||||
justify-content: center
|
||||
align-items: center
|
||||
|
||||
border-radius: $rad-inner
|
||||
// border: 1px solid RGB($white)
|
||||
border: none
|
||||
|
||||
i
|
||||
font-size: 1rem
|
||||
opacity: 0
|
||||
transition: opacity 0.15s ease-in-out
|
||||
|
||||
&:hover i
|
||||
opacity: 1
|
||||
|
||||
.img-groups
|
||||
width: 100%
|
||||
|
|
|
@ -158,7 +158,9 @@
|
|||
</table>
|
||||
<div class="img-colours">
|
||||
{% for col in image.colours %}
|
||||
<span style="background-color: rgb({{col.0}}, {{col.1}}, {{col.2}})"></span>
|
||||
<button style="background-color: rgb{{ col }}" onclick="copyToClipboard('rgb{{ col }}')">
|
||||
<i class="ph-fill ph-paint-bucket" style="{{ col|colour_contrast }}"></i>
|
||||
</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if image.groups %}
|
||||
|
|
Loading…
Reference in a new issue