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

Feature: Add form inputs components to lookbook #288

Merged
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fcb5f18
add input field to lookbook
Bilelkihal Jul 6, 2023
8aa6195
add select component to lookbook
Bilelkihal Jul 6, 2023
b888400
add text area component to lookbook
Bilelkihal Jul 6, 2023
a1a6ce6
remove old undesired text area input from lookbook
Bilelkihal Jul 6, 2023
217b804
add margin to lookbook preview
Bilelkihal Jul 6, 2023
eb6504a
add Upload file input component to lookbook
Bilelkihal Jul 10, 2023
13d5e8d
combine all input components in one globale component
Bilelkihal Jul 11, 2023
192f73e
remove style params from input field component
Bilelkihal Jul 11, 2023
8f56500
recover text area field component (after deleting it by mistake in a …
Bilelkihal Jul 11, 2023
225d3dc
use inline svg in file input loader component
Bilelkihal Jul 11, 2023
1595b69
add hint to text input component
Bilelkihal Jul 11, 2023
51eb8ba
add error state to input field component
Bilelkihal Jul 11, 2023
b44eaae
add helper text to input field component
Bilelkihal Jul 11, 2023
602caee
add notes to input field component to explain how to use it
Bilelkihal Jul 11, 2023
4034e71
combine text area input component with input field component
Bilelkihal Jul 11, 2023
a59d056
groupe inputs in one folder in the lookbook
Bilelkihal Jul 11, 2023
76c4f61
fix style issues in input field component
Bilelkihal Jul 11, 2023
a46e007
refactor input field component code to remove repetition
Bilelkihal Jul 12, 2023
cfd373a
remove the duplicated alert component preview
syphax-bouazzouni Jul 12, 2023
7e01a59
make the input field component generic using a the content slot
syphax-bouazzouni Jul 12, 2023
351b1a4
implement form date component
syphax-bouazzouni Jul 12, 2023
8d7f47f
implement form text area component
syphax-bouazzouni Jul 12, 2023
c1f1db8
implement form text input component
syphax-bouazzouni Jul 12, 2023
d173a9b
duplicate the select component to be in the "form" namespace
syphax-bouazzouni Jul 12, 2023
6694a18
fix select input component inversed open_to_add_values argument usage
syphax-bouazzouni Jul 12, 2023
93f66f9
move and rename file input loader component to be in the form module
syphax-bouazzouni Jul 12, 2023
106b79c
update select component to use InputFieldComponent to have a label
syphax-bouazzouni Jul 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/assets/images/upload-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion app/assets/stylesheets/application.css.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
@import "ontolobridge";
@import "fair_assement";
@import "instances_table";
@import "file_uploader";
@import "register";
@import "lostpassword";
@import "flatpickr/dist/themes/light";
Expand Down
54 changes: 54 additions & 0 deletions app/assets/stylesheets/components/file_input_loader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.file_uploader {
color: #D7D7EF;
font-family: 'Lato', sans-serif;
border: 1px dashed #CFCFCF;
border-radius: 5px;
}

.file-message {
display: flex;
margin-top: 10px;
font-size: 12px;
color: #888888;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.file_uploader>h2 {
margin: 50px 0;
}

.file-drop-area {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
padding: 25px;
transition: 0.2s;
position: relative;
}

.choose-file-button {
flex-shrink: 0;
background-color: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 3px;
padding: 8px 15px;
margin-right: 10px;
font-size: 12px;
text-transform: uppercase;
}

.file-input {
height: 100%;
width: 100%;
cursor: pointer;
opacity: 0;
position: absolute;
}

.file-drop-area svg path {
fill: #CECECE;
}
6 changes: 4 additions & 2 deletions app/assets/stylesheets/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
@import 'chip_button';
@import 'rounded_button';
@import 'summary_section';
@import 'text_area_field';
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
@import 'dropdown';
@import 'field_container';
@import 'field_container';
@import 'input_field';
@import 'file_input_loader';
@import 'text_area_field';
30 changes: 30 additions & 0 deletions app/assets/stylesheets/components/input_field.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.input-field-component{
width: 100%;
font-size: 13px;
padding: 10px;
border: 1px solid #BDBDBD;
border-radius: 5px;
outline: none;
resize: none;
}

.input-field-component:focus{
border: 1px solid var(--primary-color);
}

.text-input-label{
font-size: 12px;
color: #666666;
margin-bottom: 5px;
}

.text-input-error-text{
font-size: 12px;
color: var(--error-color)
}

.text-input-helper-text{
font-size: 12px;
color: #666666;
margin-top: 5px;
}
18 changes: 9 additions & 9 deletions app/assets/stylesheets/components/text_area_field.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.text-content{
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--read-more-line-clamp, 5);
.text-content {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: var(--read-more-line-clamp, 5);
}


.see_more_text {
color: var(--primary-color);
font-size: 15px;
margin-top: 10px;
text-align: end;
color: var(--primary-color);
font-size: 15px;
margin-top: 10px;
text-align: end;
}
53 changes: 0 additions & 53 deletions app/assets/stylesheets/file_uploader.scss

This file was deleted.

10 changes: 10 additions & 0 deletions app/assets/stylesheets/theme-variables.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,38 @@
--hover-color: #40C811;
--secondary-color: #ffc107;
--light-color: #F1FAED;
--error-color: #EB4335;
}
<% when "stageportal" %>
:root{
--primary-color: #76A7CC;
--hover-color: #6B96B7;
--secondary-color: #ffc107;
--light-color: #F1F6FA;
--error-color: #EB4335;
}
<% when "bioportal" %>
:root{
--primary-color: #76A7CC;
--hover-color: #6B96B7;
--secondary-color: #ffc107;
--light-color: #F1F6FA;
--error-color: #EB4335;
}
<% when "ontoportal" %>
:root{
--primary-color: #6E98A2;
--hover-color: #7BABB6;
--secondary-color: #ffc107;
--light-color: #F0F5F6;
--error-color: #EB4335;
}
<%# Here to add a new theme ... %>
<% end %>
<% end %>






Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.file_uploader.d-flex.justify-content-center.p-2.bg-secondary{data: {controller: "file-input"}}
.file_uploader{data: {controller: "file-input"}}
.file-drop-area.w-100
%span.choose-file-button Choose file
%span.file-message{data:{'file-input': {target: 'message'}}} or drag and drop file here
= file_field_tag @name, class: 'file-input', data:{'file-input-target': 'input', action: 'file-input#updateMessage'}
= inline_svg_tag "upload-file.svg"
%span.file-message{data:{'file-input': {target: 'message'}}} Drop your file here or, browse files on your device.
= file_field_tag @name, class: 'file-input', data:{'file-input-target': 'input', action: 'file-input#updateMessage'}
11 changes: 11 additions & 0 deletions app/components/input_field_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class InputFieldComponent < ViewComponent::Base
def initialize(label: "" , name:, type: "text", choices:[], hint: "", error_message: "", helper_text: "")
@label = label
@name = name
@type = type
@choices = choices
@hint = hint
@error_message = error_message
@helper_text = helper_text
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
%div
- unless @label == ""
.text-input-label
= @label

- has_error = @error_message != ""

- case @type
- when "select"
syphax-bouazzouni marked this conversation as resolved.
Show resolved Hide resolved
%select.input-field-component{name: @name, style: "#{"border-color: var(--error-color);" if has_error}"}
- @choices.each do |choice|
%option{:value => choice}= choice
- if has_error
.text-input-error-text
= @error_message
- unless @helper_text == ""
.text-input-helper-text
= @helper_text

- when "textarea"
%textarea.input-field-component{name: @name, rows: "5", placeholder: @hint, style: "#{"border-color: var(--error-color);" if has_error}"}
- if has_error
.text-input-error-text
= @error_message
- unless @helper_text == ""
.text-input-helper-text
= @helper_text

- else
%input.input-field-component.text-input{name: @name, type: @type, placeholder: @hint, style: "#{"border-color: var(--error-color);" if has_error}"}
- if has_error
.text-input-error-text
= @error_message
- unless @helper_text == ""
.text-input-helper-text
= @helper_text









2 changes: 1 addition & 1 deletion app/components/text_area_field_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def initialize(value: , see_more_text:'See more...' , see_less_text: 'See less..
@see_less_text = see_less_text
end

end
end
7 changes: 5 additions & 2 deletions app/views/layouts/component_preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
</head>
<body class="d-flex align-items-center justify-content-center w-100 h-100">

<%= yield %> <!-- rendered preview will be injected here -->
<%= javascript_include_tag "application" %>
<div style="margin: 40px">
<%= yield %> <!-- rendered preview will be injected here -->
<%= javascript_include_tag "application" %>
</div>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Inputs::FileInputLoaderComponentPreview < ViewComponent::Preview


def default
render FileInputLoaderComponent.new(name: "file")
end


end
Loading