From bfa772c48644081db244fa640f7390064cc0be22 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Wed, 8 Aug 2018 23:16:57 +0200 Subject: [PATCH] app/views/user/settings.volt: cleaning up social links with array and loop. --- app/views/user/settings.volt | 37 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/app/views/user/settings.volt b/app/views/user/settings.volt index 6ff4dc6..3f3af81 100644 --- a/app/views/user/settings.volt +++ b/app/views/user/settings.volt @@ -1,3 +1,10 @@ +{% + set social_links = [ + 'github' : [ 'connected': user.getGithubId() > 0 ], + 'gitlab' : [ 'connected': user.getGitlabId() > 0, 'class': 'text-gitlab' ], + 'google' : [ 'connected': user.getGoogleId() > 0, 'class': 'text-google' ] + ] +%}
@@ -44,33 +51,17 @@
+ {% for name,info in social_links %}
-
{{ icon('brand/github', [ '3x' ]) }}
- {% if user.getGithubId() > 0 %} - Disconnect + {% set class = info['class'] | default(false) %} + {{ icon('brand/' ~ name, [ '3x' ]) }}
+ {% if info['connected'] %} + Disconnect {% else %} - Connect + Connect {% endif %}
- -
-
{{ icon('brand/gitlab', [ '3x' ]) }}
- {% if user.getGitlabId() > 0 %} - Disconnect - {% else %} - Connect - {% endif %} -
- -
-
{{ icon('brand/google', [ '3x' ]) }}
- {% if user.getGoogleId() > 0 %} - Disconnect - {% else %} - Connect - {% endif %} - -
+ {% endfor %}