From 04341148a9543dbde4a2f1517f1fe40c9bd0a812 Mon Sep 17 00:00:00 2001 From: Dani Hodovic Date: Tue, 25 Jun 2024 19:15:13 -0300 Subject: [PATCH] fix: use DaisyUI colors for social login buttons Using the brand colors from social login providers doesn't work well with the different DaisyUI themes. --- allauth_ui/static/allauth_ui/input.css | 24 ------------------- .../socialaccount/snippets/provider_list.html | 4 ++-- allauth_ui/templatetags/allauth_ui.py | 20 ---------------- .../theme/static_src/src/styles.css | 24 ------------------- tailwind.config.js | 3 --- 5 files changed, 2 insertions(+), 73 deletions(-) diff --git a/allauth_ui/static/allauth_ui/input.css b/allauth_ui/static/allauth_ui/input.css index 783dd50..b5c61c9 100644 --- a/allauth_ui/static/allauth_ui/input.css +++ b/allauth_ui/static/allauth_ui/input.css @@ -1,27 +1,3 @@ @tailwind base; @tailwind components; @tailwind utilities; - -@layer components { - .social-github { - @apply bg-stone-900 hover:bg-black - } - .social-facebook { - @apply bg-blue-700 hover:bg-blue-800 - } - .social-google { - @apply bg-red-700 hover:bg-red-800 - } - .social-linkedin { - @apply bg-cyan-600 hover:bg-cyan-700 - } - .social-strava { - @apply bg-orange-400 hover:bg-orange-500 - } - .social-exist { - @apply bg-gray-500 hover:bg-gray-600 - } - .social-wahoo { - @apply bg-cyan-500 hover:bg-cyan-700 - } -} diff --git a/allauth_ui/templates/socialaccount/snippets/provider_list.html b/allauth_ui/templates/socialaccount/snippets/provider_list.html index 56b9b93..f7293af 100644 --- a/allauth_ui/templates/socialaccount/snippets/provider_list.html +++ b/allauth_ui/templates/socialaccount/snippets/provider_list.html @@ -9,11 +9,11 @@ {% provider_login_url provider openid=brand.openid_url process=process as href %} {% element provider name=brand.name provider_id=provider.id href=href %} {% endelement %} - {{ brand.name }} + {{ brand.name }} {% endfor %} {% endif %} {% provider_login_url provider process=process scope=scope auth_params=auth_params as href %} - {{ provider.name }} {% endfor %} diff --git a/allauth_ui/templatetags/allauth_ui.py b/allauth_ui/templatetags/allauth_ui.py index 693ba4e..86904b6 100644 --- a/allauth_ui/templatetags/allauth_ui.py +++ b/allauth_ui/templatetags/allauth_ui.py @@ -1,28 +1,8 @@ -import re -from pathlib import Path - from django import template from django.conf import settings register = template.Library() -input_css_path = Path(__file__).parent / ".." / "static" / "allauth_ui" / "input.css" -social_colors = [] - -with open(input_css_path, encoding="utf8") as f: - for line in f.readlines(): - m = re.search(r"\.social-(?P\w+)\s?", line) - if m: - social_colors.append(m.groupdict()["provider"]) - - -@register.filter() -def socialprovider_color(socialprovider): - name = socialprovider.name.lower() - if name in social_colors: - return f"social-{name}" - return "bg-stone-900 hover:bg-stone-700" - @register.simple_tag def allauth_ui_theme(): diff --git a/sample_deployment/sample_deployment/theme/static_src/src/styles.css b/sample_deployment/sample_deployment/theme/static_src/src/styles.css index 783dd50..b5c61c9 100644 --- a/sample_deployment/sample_deployment/theme/static_src/src/styles.css +++ b/sample_deployment/sample_deployment/theme/static_src/src/styles.css @@ -1,27 +1,3 @@ @tailwind base; @tailwind components; @tailwind utilities; - -@layer components { - .social-github { - @apply bg-stone-900 hover:bg-black - } - .social-facebook { - @apply bg-blue-700 hover:bg-blue-800 - } - .social-google { - @apply bg-red-700 hover:bg-red-800 - } - .social-linkedin { - @apply bg-cyan-600 hover:bg-cyan-700 - } - .social-strava { - @apply bg-orange-400 hover:bg-orange-500 - } - .social-exist { - @apply bg-gray-500 hover:bg-gray-600 - } - .social-wahoo { - @apply bg-cyan-500 hover:bg-cyan-700 - } -} diff --git a/tailwind.config.js b/tailwind.config.js index 670ae1e..51074b3 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -2,9 +2,6 @@ module.exports = { content: [ './allauth_ui/templates/**/*.html', ], - safelist: [{ - pattern: /social-|bg-/ - }], theme: { extend: {}, },