Skip to content

Commit 397cfdb

Browse files
committed
Update link_to's to link_to_button (that has general and _outline variants)
1 parent 31a0dd3 commit 397cfdb

File tree

9 files changed

+41
-25
lines changed

9 files changed

+41
-25
lines changed

app/helpers/application_helper.rb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
module ApplicationHelper
22

3-
def link_to_button(text, url, variant: :secondary, **options)
3+
def link_to_button(text, url, variant: :secondary_outline, **options)
44
manual_classes = options.delete(:class)
55
base_classes = "inline-flex items-center gap-2 px-4 py-2 rounded-lg
66
transition-colors duration-200 font-medium shadow-sm text-sm"
77
variant_classes = {
8-
primary: "border border-blue-600 text-grey-600 hover:bg-blue-600 hover:text-white",
9-
secondary: "border border-gray-400 text-gray-600 hover:bg-gray-600 hover:text-white",
10-
info: "border border-sky-500 text-gray-600 hover:bg-sky-600 hover:text-white",
11-
warning: "border border-yellow-400 text-gray-600 hover:bg-yellow-500 hover:text-white",
12-
danger: "border border-red-600 text-gray-600 hover:bg-red-600 hover:text-white",
13-
utility: "border border-gray-200 text-gray-600 hover:bg-gray-200 hover:text-gray-800"
8+
primary: "border border-blue-600 bg-blue-600 text-white hover:text-grey-600 hover:bg-white",
9+
secondary: "border border-gray-400 bg-gray-600 text-white hover:text-grey-600 hover:bg-white",
10+
info: "border border-sky-500 bg-sky-600 text-white hover:text-grey-600 hover:bg-white",
11+
warning: "border border-yellow-400 bg-yellow-600 text-white hover:text-grey-600 hover:bg-white",
12+
danger: "border border-red-600 bg-red-600 text-white hover:text-grey-600 hover:bg-white",
13+
utility: "border border-gray-200 bg-gray-200 text-gray-800 hover:text-gray-600 hover:bg-white",
14+
15+
primary_outline: "border border-blue-600 text-grey-600 hover:bg-blue-600 hover:text-white",
16+
secondary_outline: "border border-gray-400 text-gray-600 hover:bg-gray-600 hover:text-white",
17+
info_outline: "border border-sky-500 text-gray-600 hover:bg-sky-600 hover:text-white",
18+
warning_outline: "border border-yellow-400 text-gray-600 hover:bg-yellow-500 hover:text-white",
19+
danger_outline: "border border-red-600 text-gray-600 hover:bg-red-600 hover:text-white",
20+
utility_outline: "border border-gray-200 text-gray-600 hover:bg-gray-200 hover:text-gray-800"
21+
# border border-gray-300 text-gray-700 bg-white hover:bg-gray-50
1422
}
1523
classes = [base_classes, variant_classes[variant.to_sym], manual_classes].join(" ")
1624
link_to text, url, options.merge(class: classes)

app/views/resources/_form.html.erb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,11 @@
143143

144144
<!-- Form Actions -->
145145
<div class="flex gap-2 mt-4">
146-
<%= link_to_button "Delete", @resource, variant: :danger, method: :delete, data: { confirm: "Are you sure?" } %><%= link_to 'Cancel', resources_path, class: 'px-4 py-2 border border-gray-400 text-gray-600 rounded-lg hover:bg-gray-600 hover:text-white text-sm font-medium' %>
147-
<%= f.submit 'Submit', class: "px-4 py-2 border border-blue-600 text-gray-600 rounded-lg hover:bg-blue-600 hover:text-white text-sm font-medium" %>
146+
<%= link_to_button "Delete", @resource, variant: :danger_outline, method: :delete, data: { confirm: "Are you sure?" } %>
147+
<%= link_to_button 'Cancel', resources_path, variant: :secondary_outline %>
148+
<%= f.submit 'Submit',
149+
class: "px-4 py-2 border border-blue-600 hover:text-gray-600 hover:bg-white
150+
rounded-lg bg-blue-600 text-white text-sm font-medium" %>
148151
</div>
149152
<% end %>
150153

app/views/resources/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<h2 class="text-2xl font-semibold mb-2">Resources</h2>
77
</div>
88
<% if current_user.super_user? %>
9-
<%= link_to_button 'New Resource', new_resource_path, variant: :primary %>
9+
<%= link_to_button 'New Resource', new_resource_path, variant: :primary_outline %>
1010
<% end %>
1111
</div>
1212
</div>

app/views/resources/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<div class="flex justify-end mb-6">
55
<% if current_user.super_user? %>
6-
<%= link_to_button("Edit", edit_resource_path(@resource), variant: :primary) %>
6+
<%= link_to_button("Edit", edit_resource_path(@resource), variant: :primary_outline) %>
77
<% end %>
88
<%= link_to_button("Download <span class='fa fa-download'></span>".html_safe,
99
@resource.attachments.first.file.url,

app/views/users/_form.html.erb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
</div>
9494
</div>
9595

96-
<%= link_to 'Cancel', users_path, class: 'btn secondary cancel-btn' %>
97-
<%= f.submit 'Submit', class: "btn btn-success" %>
96+
<%= link_to_button "Delete", @user, variant: :danger_outline, method: :delete, data: { confirm: "Are you sure?" } %>
97+
<%= link_to_button 'Cancel', users_path, variant: :secondary_outline %>
98+
<%= f.submit 'Submit',
99+
class: "px-4 py-2 border border-blue-600 hover:text-gray-600 hover:bg-white
100+
rounded-lg bg-blue-600 text-white text-sm font-medium" %>
98101
<% end %>

app/views/workshop_variations/_form.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
</div>
2828
</div>
2929

30-
<%= link_to 'Cancel', workshop_variations_path,
31-
class: 'btn btn-default btn-secondary' %>
32-
<%= f.submit 'Submit', class: "btn btn-primary" %>
30+
<%= link_to_button "Delete", @workshop_variation, variant: :danger_outline, method: :delete, data: { confirm: "Are you sure?" } %>
31+
<%= link_to_button 'Cancel', workshop_variations_path, variant: :secondary_outline %>
32+
<%= f.submit 'Submit',
33+
class: "px-4 py-2 border border-blue-600 hover:text-gray-600 hover:bg-white
34+
rounded-lg bg-blue-600 text-white text-sm font-medium" %>
3335
<% end %>

app/views/workshop_variations/index.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
</div>
99
<div class="pull-right">
1010
<div>
11-
<%= link_to 'New workshop variation',
12-
new_workshop_variation_path(from: "index"), class: 'btn btn-primary' %>
11+
<%= link_to_button 'New workshop variation',
12+
new_workshop_variation_path(from: "index"),
13+
variant: :primary_outline %>
1314
</div>
1415
</div>
1516
</div>

app/views/workshops/_form.html.erb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,11 @@
261261

262262

263263
<div class="btn-container">
264-
<%= link_to "Cancel",
265-
(action_name == "share_idea" ? root_path : workshops_path),
266-
class: "btn btn-secondary" %>
267-
<%= f.submit 'Submit', class: 'btn btn-primary btn-outline-primary' %>
264+
<%= link_to_button "Delete", @workshop, variant: :danger_outline, method: :delete, data: { confirm: "Are you sure?" } %>
265+
<%= link_to_button 'Cancel', (action_name == "share_idea" ? root_path : workshops_path), variant: :secondary_outline %>
266+
<%= f.submit 'Submit',
267+
class: "px-4 py-2 border border-blue-600 hover:text-gray-600 hover:bg-white
268+
rounded-lg bg-blue-600 text-white text-sm font-medium" %>
268269
</div>
269270
<% end %>
270271
</div>

app/views/workshops/index.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
</p>
1717
</div>
1818
<% if current_user.super_user? %>
19-
<%= link_to 'New Workshop', new_workshop_path,
20-
class: "inline-block px-4 py-2 border border-blue-600 text-blue-600
21-
rounded-lg hover:bg-blue-600 hover:text-white transition-colors duration-200 font-medium shadow-sm" %>
19+
<%= link_to_button "New workshop", new_workshop_path, variant: :primary_outline %>
2220
<% end %>
2321
</div>
2422
</div>

0 commit comments

Comments
 (0)