Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use DaisyUI colors for social login buttons #85

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions allauth_ui/static/allauth_ui/input.css
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<a class="btn w-full my-1" title="{{ brand.name }}" href="{{ href }}">{{ brand.name }}</a>
<a class="w-full my-1 btn" title="{{ brand.name }}" href="{{ href }}">{{ brand.name }}</a>
{% endfor %}
{% endif %}
{% provider_login_url provider process=process scope=scope auth_params=auth_params as href %}
<a class="btn w-full my-1 text-white {{ provider | socialprovider_color }}"
<a class="btn w-full my-1 text-primary-content bg-primary hover:bg-accent "
title="{{ provider.name }}"
href="{{ href }}">{{ provider.name }}</a>
{% endfor %}
Expand Down
20 changes: 0 additions & 20 deletions allauth_ui/templatetags/allauth_ui.py
Original file line number Diff line number Diff line change
@@ -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<provider>\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():
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
3 changes: 0 additions & 3 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ module.exports = {
content: [
'./allauth_ui/templates/**/*.html',
],
safelist: [{
pattern: /social-|bg-/
}],
theme: {
extend: {},
},
Expand Down
Loading