Skip to content

Commit

Permalink
Merge pull request #268 from sharetribe/Add_TikTok_option_to_footers
Browse files Browse the repository at this point in the history
Add TikTok option to footers
  • Loading branch information
thomasmalbaux committed Mar 21, 2023
2 parents 3122301 + f4494e3 commit 839226a
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 10 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/admin2/custom.scss
Expand Up @@ -282,3 +282,7 @@ div[data-mercury='full'] {
.CodeMirror-wrap {
border: 1px solid #ddd;
}

.social-link-label {
min-width: 50px;
}
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -810,6 +810,10 @@ def regex_definition_to_js(string)
soundcloud: {
name: "SoundCloud",
placeholder: "https://soundcloud.com/CHANGEME"
},
tiktok: {
name: 'TikTok',
placeholder: 'https://www.tiktok.com/CHANGEME'
}
}.freeze

Expand Down
3 changes: 2 additions & 1 deletion app/models/landing_page_version/section/footer.rb
Expand Up @@ -89,7 +89,8 @@ def serializable_hash(options = nil)
{service: "googleplus", url: ""},
{service: "linkedin", url: ""},
{service: "pinterest", url: ""},
{service: "soundcloud", url: ""}
{service: "soundcloud", url: ""},
{service: "tiktok", url: ""}
],
copyright: "",
logo: { type: "marketplace_data", id: "logo" }
Expand Down
3 changes: 2 additions & 1 deletion app/models/social_link.rb
Expand Up @@ -27,7 +27,8 @@ class SocialLink < ApplicationRecord
googleplus: 4,
linkedin: 5,
pinterest: 6,
soundcloud: 7
soundcloud: 7,
tiktok: 8
}.freeze

enum provider: SOCIAL_NETWORKS
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin2/design/footer/_social_link_fields.haml
Expand Up @@ -3,7 +3,7 @@
= f.hidden_field :id
= f.hidden_field :sort_priority, class: %i[social-link-sort-prior]
= f.hidden_field :provider
= f.label :url, social_link_name(social_link.provider)
= f.text_field :url, maxlength: 255, disabled: defined?(disabled) && disabled, url: true, placeholder: 'https://', class: %i[form-control social-link-row]
= f.label :url, social_link_name(social_link.provider), class: %i[social-link-label]
= f.text_field :url, maxlength: 255, disabled: defined?(disabled) && disabled, url: true, placeholder: social_link_placeholder(social_link.provider), class: %i[form-control social-link-row]
- unless disabled
%span.handle-move
Expand Up @@ -3,7 +3,7 @@
= f.hidden_field :sort_priority, class: 'sort-priority-social'
= f.hidden_field :provider
- social_link = f.object
%label
%label.social-link-label
= social_link_name(social_link.provider)
= f.text_field :url, maxlength: 255, url: true, placeholder: social_link_placeholder(social_link.provider), provider: social_link.provider, class: 'form-control'
.actions
Expand Down
3 changes: 3 additions & 0 deletions app/views/landing_page/_social_icon.erb
Expand Up @@ -36,5 +36,8 @@
<% when "soundcloud" %>
<svg class="footer__social-media-icon footer__soundcloud-icon" width="24" height="24"><g fill-rule="evenodd" stroke="none" stroke-linejoin="round" stroke-miterlimit="10"><path d="M12.807 16.496c.193.004 7.791.004 7.84.004 1.562 0 2.829-1.266 2.829-2.829 0-1.562-1.267-2.83-2.829-2.83-.388 0-.758.079-1.094.219-.226-2.549-2.363-4.549-4.972-4.549-.638 0-1.26.126-1.809.339-.215.082-.271.167-.273.333v8.979c.003.172.137.33.308.334z"/><path class="icon-with-stroke" stroke-linecap="round" d="M10.5 7.489v9.007M8.5 8.489v8.007M6.5 8.989v7.507M4.5 10.989v5.507M2.5 10.989v5.507M.5 11.992v3.991"/></g></svg>

<% when "tiktok" %>
<svg class="footer__social-media-icon footer__tiktok-icon" width="21" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M20.124 9.93a9.436 9.436 0 0 1-5.515-1.764v8.028c-.002 5.621-6.088 9.132-10.955 6.32-4.867-2.812-4.865-9.839.004-12.647a7.302 7.302 0 0 1 4.652-.908v4.038c-2.462-.774-4.838 1.406-4.278 3.925.56 2.519 3.637 3.487 5.538 1.742a3.352 3.352 0 0 0 1.086-2.47V.5h3.953c-.003.334.025.667.083.996a5.488 5.488 0 0 0 2.422 3.603c.893.59 1.94.905 3.01.905V9.93Z" fill-rule="evenodd" stroke="none"/></svg>

<% end # case %>
</a>
4 changes: 3 additions & 1 deletion app/views/layouts/footer/_social_icons.haml
Expand Up @@ -25,4 +25,6 @@
%g{"fill-rule" => "evenodd", :stroke => "none", "stroke-linejoin" => "round", "stroke-miterlimit" => "10"}
%path{:d => "M12.807 16.496c.193.004 7.791.004 7.84.004 1.562 0 2.829-1.266 2.829-2.829 0-1.562-1.267-2.83-2.829-2.83-.388 0-.758.079-1.094.219-.226-2.549-2.363-4.549-4.972-4.549-.638 0-1.26.126-1.809.339-.215.082-.271.167-.273.333v8.979c.003.172.137.33.308.334z"}
%path.icon-with-stroke{:d => "M10.5 7.489v9.007M8.5 8.489v8.007M6.5 8.989v7.507M4.5 10.989v5.507M2.5 10.989v5.507M.5 11.992v3.991", "stroke-linecap" => "round"}
- end # case
- when 'tiktok'
%svg.footer__social-media-icon.footer__tiktok-icon{width: "21", height: "24"}
%path{d: "M20.124 9.93a9.436 9.436 0 0 1-5.515-1.764v8.028c-.002 5.621-6.088 9.132-10.955 6.32-4.867-2.812-4.865-9.839.004-12.647a7.302 7.302 0 0 1 4.652-.908v4.038c-2.462-.774-4.838 1.406-4.278 3.925.56 2.519 3.637 3.487 5.538 1.742a3.352 3.352 0 0 0 1.086-2.47V.5h3.953c-.003.334.025.667.083.996a5.488 5.488 0 0 0 2.422 3.603c.893.59 1.94.905 3.01.905V9.93Z", 'fill-rule': "evenodd", 'stroke': "none"}
Expand Up @@ -325,7 +325,7 @@ def stubbed_upload(filename, content_type)
expect(second_link['label']).to eq 'Contact us'
expect(second_link['href']['value']).to eq 'https://example.com/contact_us'
social = section['social']
expect(social.size).to eq 8
expect(social.size).to eq 9
enabled_social = social.select{|s| s['enabled']}
expect(enabled_social.size).to eq 2
first_social = enabled_social.first
Expand Down
10 changes: 8 additions & 2 deletions spec/controllers/admin2/design/footer_controller_spec.rb
Expand Up @@ -76,7 +76,12 @@
{"id" => "",
"sort_priority" => "7",
"provider" => "soundcloud",
"url" => ""}
"url" => ""},
"8" =>
{"id" => "",
"sort_priority" => "8",
"provider" => "tiktok",
"url" => ""}
}
}

Expand All @@ -88,9 +93,10 @@
patch :update_footer, params: params, xhr: true
expect(community.footer_enabled).to eq true
expect(community.reload.footer_menu_links.count).to eq 1
expect(community.social_links.count).to eq 8
expect(community.social_links.count).to eq 9
expect(community.social_links.enabled.count).to eq 1
expect(community.social_links.first.provider).to eq 'youtube'
expect(community.social_links.last.provider).to eq 'tiktok'
end
end
end
Expand Down
Expand Up @@ -325,7 +325,7 @@ def stubbed_upload(filename, content_type)
expect(second_link['label']).to eq 'Contact us'
expect(second_link['href']['value']).to eq 'https://example.com/contact_us'
social = section['social']
expect(social.size).to eq 8
expect(social.size).to eq 9
enabled_social = social.select{|s| s['enabled']}
expect(enabled_social.size).to eq 2
first_social = enabled_social.first
Expand Down

0 comments on commit 839226a

Please sign in to comment.