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

Show icon to add/remove project favorite on index #15423

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
Show icon to add/remove favorite on index
  • Loading branch information
oliverguenther committed Apr 30, 2024
commit e5413aa88fc9419807541e0a0d7fe71033d9e002
1 change: 1 addition & 0 deletions app/components/_index.sass
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
@import "open_project/common/attribute_component"
@import "filters_component"
@import "projects/settings/project_custom_field_sections/index_component"
@import "projects/row_component"
22 changes: 18 additions & 4 deletions app/components/projects/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,23 @@ def hierarchy
end

def favored
if favored_project_ids.include?(project.id)
render(Primer::Beta::Octicon.new(icon: "star-fill", classes: "op-primer--star-icon", "aria-label": I18n.t(:label_favoured)))
end
render(Primer::Beta::IconButton.new(
icon: currently_favored? ? "star-fill" : "star",
scheme: :invisible,
mobile_icon: currently_favored? ? "star-fill" : "star",
size: :medium,
tag: :a,
href: helpers.build_favorite_path(project, format: :html),
data: { method: currently_favored? ? :delete : :post },
classes: currently_favored? ? "op-primer--star-icon " : "op-project-row-component--favorite",
label: currently_favored? ? I18n.t(:button_unfavorite) : I18n.t(:button_favorite),
aria: { label: currently_favored? ? I18n.t(:button_unfavorite) : I18n.t(:button_favorite) },
test_selector: 'project-list-favorite-button'
))
end

def currently_favored?
@currently_favored ||= favored_project_ids.include?(project.id)
end

def column_value(column)
Expand Down Expand Up @@ -146,7 +160,7 @@ def public
end

def row_css_class
classes = %w[basics context-menu--reveal]
classes = %w[basics context-menu--reveal op-project-row-component]
classes << project_css_classes
classes << row_css_level_classes

Expand Down
6 changes: 6 additions & 0 deletions app/components/projects/row_component.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.op-project-row-component
&--favorite
opacity: 0

&:hover &--favorite
opacity: 1
2 changes: 1 addition & 1 deletion app/components/projects/table_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="generic-table--sort-header">
<span>
<% if column.attribute == :favored %>
<%= render(Primer::Beta::Octicon.new(icon: "star-fill", color: :subtle, "aria-label": I18n.t(:label_favoured))) %>
<%= render(Primer::Beta::Octicon.new(icon: "star-fill", color: :subtle, ml: 2, "aria-label": I18n.t(:label_favoured))) %>
<% else %>
<%= column.caption %>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/global_styles/primer/_icons.sass
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@

// Adjustments for icons

.op-primer--star-icon
.op-primer--star-icon,
.Button--invisible.Button--iconOnly.op-primer--star-icon svg
color: var(--color-scale-yellow-2) !important