forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #303 from ontoportal-lirmm/feature/add-pill-button
Feature: Add pill button
- Loading branch information
Showing
13 changed files
with
114 additions
and
16 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.pill-button { | ||
color: var(--primary-color); | ||
font-size: 15px; | ||
display: flex; | ||
align-items: center; | ||
border: 1px solid var(--primary-color); | ||
border-radius: 32px; | ||
padding: 10px 20px; | ||
cursor: pointer; | ||
margin-left: 10px; | ||
transition: background-color ease 0.3s; | ||
white-space: nowrap; | ||
background-color: transparent; | ||
&:focus{ | ||
outline: none; | ||
} | ||
} | ||
|
||
.pill-button:hover { | ||
background-color: var(--primary-color); | ||
color: white !important; | ||
a { | ||
color: white !important; | ||
} | ||
} | ||
|
||
.pill-button:hover svg path { | ||
fill: white; | ||
} | ||
|
||
.pill-button svg { | ||
margin-right: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class OntologySubscribeButtonComponent < ViewComponent::Base | ||
def initialize(ontology_id: , subscribed: , user_id:) | ||
def initialize(ontology_id:, subscribed:, user_id:, count: 0, link: 'javascript:void(0);') | ||
super | ||
@sub_text = subscribed ? "Unsubscribe" : "Subscribe" | ||
@controller_params = { | ||
@sub_text = subscribed ? 'UnWatch' : 'Watch' | ||
@controller_params = { | ||
data: { | ||
controller: 'subscribe-notes', | ||
'subscribe-notes-ontology-id-value': ontology_id, | ||
'subscribe-notes-ontology-id-value': ontology_id, | ||
'subscribe-notes-is-subbed-value': subscribed.to_s, | ||
'subscribe-notes-user-id-value': user_id, | ||
'subscribe-notes-user-id-value': user_id, | ||
action: 'click->subscribe-notes#subscribeToNotes' | ||
} | ||
} | ||
@link = link | ||
@count = count | ||
end | ||
end |
18 changes: 13 additions & 5 deletions
18
...ponents/ontology_subscribe_button_component/ontology_subscribe_button_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
%span{@controller_params} | ||
%a.subscribe_to_notes.btn.btn-primary{href:'javascript:void(0);'} | ||
#{@sub_text} to notes emails | ||
%span{style:"display: none;", 'data-subscribe-notes-target': 'loader'} | ||
= image_tag("spinners/spinner_000000_16px.gif", style: "vertical-align: text-bottom; background: transparent") | ||
%div{@controller_params} | ||
= render PillButtonComponent.new do | ||
%a.d-flex.align-items-center{href: @link} | ||
= inline_svg_tag "eye.svg" | ||
%div | ||
%span{'data-subscribe-notes-target': 'text'} | ||
#{@sub_text} | ||
( | ||
%span{'data-subscribe-notes-target': 'count'} | ||
#{@count} | ||
) | ||
%span{style:"display: none;", class: 'px-1', 'data-subscribe-notes-target': 'loader'} | ||
= render LoaderComponent.new(small: true) | ||
%span.notes_sub_error{style:'color: red; display: none', 'data-subscribe-notes-target': 'error'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class PillButtonComponent < ViewComponent::Base | ||
|
||
def initialize(text: nil) | ||
super | ||
@text = text | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
app/components/pill_button_component/pill_button_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
%button.pill-button | ||
= @text || content |
8 changes: 8 additions & 0 deletions
8
test/components/previews/button/pill_button_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class Button::PillButtonComponentPreview < ViewComponent::Preview | ||
# @param text text | ||
def default(text: 'hello') | ||
render PillButtonComponent.new(text: text) | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...views/rounded_button_component_preview.rb → ...utton/rounded_button_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class LoaderComponentPreview < ViewComponent::Preview | ||
def default | ||
render LoaderComponent.new | ||
end | ||
|
||
def small | ||
render LoaderComponent.new(small: true) | ||
end | ||
|
||
end |
7 changes: 7 additions & 0 deletions
7
test/components/previews/ontology_subscribe_button_component_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class OntologySubscribeButtonComponentPreview < ViewComponent::Preview | ||
def default | ||
render OntologySubscribeButtonComponent.new(ontology_id: '', subscribed: true, user_id: '') | ||
end | ||
end |