From fcb5f18d512a8f6c06446427d99596c2017942e9 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:11:57 +0000 Subject: [PATCH 01/27] add input field to lookbook --- app/assets/stylesheets/components/index.scss | 3 ++- .../stylesheets/components/input_field.scss | 19 +++++++++++++++++++ app/components/input_field_component.rb | 9 +++++++++ .../input_field_component.html.haml | 4 ++++ .../previews/input_field_component_preview.rb | 16 ++++++++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/components/input_field.scss create mode 100644 app/components/input_field_component.rb create mode 100644 app/components/input_field_component/input_field_component.html.haml create mode 100644 test/components/previews/input_field_component_preview.rb diff --git a/app/assets/stylesheets/components/index.scss b/app/assets/stylesheets/components/index.scss index 163a1203a..d9dae8297 100644 --- a/app/assets/stylesheets/components/index.scss +++ b/app/assets/stylesheets/components/index.scss @@ -6,4 +6,5 @@ @import 'summary_section'; @import 'text_area_field'; @import 'dropdown'; -@import 'field_container'; \ No newline at end of file +@import 'field_container'; +@import 'input_field'; \ No newline at end of file diff --git a/app/assets/stylesheets/components/input_field.scss b/app/assets/stylesheets/components/input_field.scss new file mode 100644 index 000000000..ad904a6d8 --- /dev/null +++ b/app/assets/stylesheets/components/input_field.scss @@ -0,0 +1,19 @@ +.input-field-component{ + margin-top: 5px; + 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; +} \ No newline at end of file diff --git a/app/components/input_field_component.rb b/app/components/input_field_component.rb new file mode 100644 index 000000000..85130f375 --- /dev/null +++ b/app/components/input_field_component.rb @@ -0,0 +1,9 @@ +class InputFieldComponent < ViewComponent::Base + def initialize(label: , name:, type: "text", width: "100%", margin_bottom: "0px") + @label = label + @name = name + @type = type + @width = width + @margin_bottom = margin_bottom + end +end \ No newline at end of file diff --git a/app/components/input_field_component/input_field_component.html.haml b/app/components/input_field_component/input_field_component.html.haml new file mode 100644 index 000000000..148a20fe9 --- /dev/null +++ b/app/components/input_field_component/input_field_component.html.haml @@ -0,0 +1,4 @@ +%div + .text-input-label + = @label + %input.input-field-component.text-input{name: @name, type: @type, style: "margin-bottom: #{@margin_bottom}; width: #{@width};"} \ No newline at end of file diff --git a/test/components/previews/input_field_component_preview.rb b/test/components/previews/input_field_component_preview.rb new file mode 100644 index 000000000..3605b9054 --- /dev/null +++ b/test/components/previews/input_field_component_preview.rb @@ -0,0 +1,16 @@ +class InputFieldComponentPreview < ViewComponent::Preview + + # @param label text + + def default(label: "Label") + render InputFieldComponent.new(label: label, name: "name", type: "text", width: "100%", margin_bottom: "0") + end + + # @param label text + + def date(label: "Label") + render InputFieldComponent.new(label: label, name: "name", type: "text", width: "100%", margin_bottom: "0", type: "date") + end + + +end \ No newline at end of file From 8aa6195871203c3e09636d88858c49e535422a6d Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:15:15 +0000 Subject: [PATCH 02/27] add select component to lookbook --- app/assets/stylesheets/components/index.scss | 3 ++- app/assets/stylesheets/components/select.scss | 18 ++++++++++++++++++ app/components/select_component.rb | 9 +++++++++ .../select_component.html.haml | 5 +++++ .../previews/select_component_preview.rb | 9 +++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/components/select.scss create mode 100644 app/components/select_component.rb create mode 100644 app/components/select_component/select_component.html.haml create mode 100644 test/components/previews/select_component_preview.rb diff --git a/app/assets/stylesheets/components/index.scss b/app/assets/stylesheets/components/index.scss index d9dae8297..477ef2d2b 100644 --- a/app/assets/stylesheets/components/index.scss +++ b/app/assets/stylesheets/components/index.scss @@ -7,4 +7,5 @@ @import 'text_area_field'; @import 'dropdown'; @import 'field_container'; -@import 'input_field'; \ No newline at end of file +@import 'input_field'; +@import 'select'; \ No newline at end of file diff --git a/app/assets/stylesheets/components/select.scss b/app/assets/stylesheets/components/select.scss new file mode 100644 index 000000000..10fe26e66 --- /dev/null +++ b/app/assets/stylesheets/components/select.scss @@ -0,0 +1,18 @@ +.select-component{ + margin-top: 5px; + width: 100%; + font-size: 13px; + padding: 10px; + border: 1px solid #BDBDBD; + border-radius: 5px; + outline: none; + cursor: pointer; +} +.select-component:focus { + border: 1px solid var(--primary-color); +} + +.select-label { + font-size: 12px; + color: #666666; +} \ No newline at end of file diff --git a/app/components/select_component.rb b/app/components/select_component.rb new file mode 100644 index 000000000..4f99f2523 --- /dev/null +++ b/app/components/select_component.rb @@ -0,0 +1,9 @@ +class SelectComponent < ViewComponent::Base + def initialize(label: , name:, choices:, width: "100%", margin_bottom: "0px" ) + @label = label + @name = name + @choices = choices + @width = width + @margin_bottom = margin_bottom + end +end \ No newline at end of file diff --git a/app/components/select_component/select_component.html.haml b/app/components/select_component/select_component.html.haml new file mode 100644 index 000000000..bdeb268fa --- /dev/null +++ b/app/components/select_component/select_component.html.haml @@ -0,0 +1,5 @@ +.select-label + = @label +%select.select-component{style: "margin-bottom: #{@margin_bottom}; width: #{@width};", name: @name} + - @choices.each do |choice| + %option{:value => choice}= choice \ No newline at end of file diff --git a/test/components/previews/select_component_preview.rb b/test/components/previews/select_component_preview.rb new file mode 100644 index 000000000..a5e2bbbdd --- /dev/null +++ b/test/components/previews/select_component_preview.rb @@ -0,0 +1,9 @@ +class SelectComponentPreview < ViewComponent::Preview + + # @param label text + + def default(label: "Label") + render SelectComponent.new(label: label, name: "name", choices: ["choice 1", "choice 2", "choice 3"], width: "100%", margin_bottom: "0") + end + +end \ No newline at end of file From b888400532f5f5c51cc64b0cf503700d4fdc03d1 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:17:56 +0000 Subject: [PATCH 03/27] add text area component to lookbook --- .../stylesheets/components/text_area.scss | 21 +++++++++++++++++++ app/components/text_area_component.rb | 8 +++++++ .../text_area_component.html.haml | 4 ++++ .../previews/text_area_component_preview.rb | 9 ++++++++ 4 files changed, 42 insertions(+) create mode 100644 app/assets/stylesheets/components/text_area.scss create mode 100644 app/components/text_area_component.rb create mode 100644 app/components/text_area_component/text_area_component.html.haml create mode 100644 test/components/previews/text_area_component_preview.rb diff --git a/app/assets/stylesheets/components/text_area.scss b/app/assets/stylesheets/components/text_area.scss new file mode 100644 index 000000000..5ee4146c4 --- /dev/null +++ b/app/assets/stylesheets/components/text_area.scss @@ -0,0 +1,21 @@ +.text-area-component { + margin-top: 5px; + margin-bottom: 23px; + width: 100%; + font-size: 13px; + padding: 10px; + border: 1px solid #BDBDBD; + border-radius: 5px; + outline: none; + resize: none; + background-color: white; +} + +.text-area-component:focus { + border: 1px solid var(--primary-color); +} + +.text-area-label { + font-size: 12px; + color: #666666; +} \ No newline at end of file diff --git a/app/components/text_area_component.rb b/app/components/text_area_component.rb new file mode 100644 index 000000000..4582e6304 --- /dev/null +++ b/app/components/text_area_component.rb @@ -0,0 +1,8 @@ +class TextAreaComponent < ViewComponent::Base + def initialize(label: , name:, width: "100%", margin_bottom: "0px" ) + @label = label + @name = name + @width = width + @margin_bottom = margin_bottom + end +end \ No newline at end of file diff --git a/app/components/text_area_component/text_area_component.html.haml b/app/components/text_area_component/text_area_component.html.haml new file mode 100644 index 000000000..57e07a694 --- /dev/null +++ b/app/components/text_area_component/text_area_component.html.haml @@ -0,0 +1,4 @@ +%div + .text-area-label + = @label + %textarea.text-area-component{name: @name, rows: "5", style: "margin-bottom: #{@margin_bottom}; width: #{@width};"} \ No newline at end of file diff --git a/test/components/previews/text_area_component_preview.rb b/test/components/previews/text_area_component_preview.rb new file mode 100644 index 000000000..6d701b980 --- /dev/null +++ b/test/components/previews/text_area_component_preview.rb @@ -0,0 +1,9 @@ +class TextAreaComponentPreview < ViewComponent::Preview + + # @param label text + + def default(label: "Label") + render TextAreaComponent.new(label: label, name: "name", width: "100%", margin_bottom: "0") + end + +end \ No newline at end of file From a1a6ce604010fea2120739cd20595cd471b55d59 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:22:21 +0000 Subject: [PATCH 04/27] remove old undesired text area input from lookbook --- app/assets/stylesheets/components/index.scss | 4 ++-- .../stylesheets/components/text_area_field.scss | 14 -------------- app/components/text_area_field_component.rb | 12 ------------ .../text_area_field_component.html.haml | 5 ----- .../previews/text_area_field_component_preview.rb | 13 ------------- 5 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 app/assets/stylesheets/components/text_area_field.scss delete mode 100644 app/components/text_area_field_component.rb delete mode 100644 app/components/text_area_field_component/text_area_field_component.html.haml delete mode 100644 test/components/previews/text_area_field_component_preview.rb diff --git a/app/assets/stylesheets/components/index.scss b/app/assets/stylesheets/components/index.scss index 477ef2d2b..54d9c03eb 100644 --- a/app/assets/stylesheets/components/index.scss +++ b/app/assets/stylesheets/components/index.scss @@ -4,8 +4,8 @@ @import 'chip_button'; @import 'rounded_button'; @import 'summary_section'; -@import 'text_area_field'; @import 'dropdown'; @import 'field_container'; @import 'input_field'; -@import 'select'; \ No newline at end of file +@import 'select'; +@import 'text_area'; \ No newline at end of file diff --git a/app/assets/stylesheets/components/text_area_field.scss b/app/assets/stylesheets/components/text_area_field.scss deleted file mode 100644 index da0018b8a..000000000 --- a/app/assets/stylesheets/components/text_area_field.scss +++ /dev/null @@ -1,14 +0,0 @@ -.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; -} \ No newline at end of file diff --git a/app/components/text_area_field_component.rb b/app/components/text_area_field_component.rb deleted file mode 100644 index f7963afce..000000000 --- a/app/components/text_area_field_component.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -class TextAreaFieldComponent < ViewComponent::Base - - def initialize(value: , see_more_text:'See more...' , see_less_text: 'See less...') - super - @value = value - @see_more_text = see_more_text - @see_less_text = see_less_text - end - -end diff --git a/app/components/text_area_field_component/text_area_field_component.html.haml b/app/components/text_area_field_component/text_area_field_component.html.haml deleted file mode 100644 index 40226b7e5..000000000 --- a/app/components/text_area_field_component/text_area_field_component.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -%div{data:{controller:"text-truncate", 'text-truncate-more-text-value': @see_more_text , 'text-truncate-less-text-value': @see_less_text}} - %p.text-content{'data-text-truncate-target': 'content'} - = @value - %p.see_more_text{data:{'text-truncate-target': 'button', 'action':"click->text-truncate#toggle"}} - = @see_more_text \ No newline at end of file diff --git a/test/components/previews/text_area_field_component_preview.rb b/test/components/previews/text_area_field_component_preview.rb deleted file mode 100644 index 2d6cfa7b7..000000000 --- a/test/components/previews/text_area_field_component_preview.rb +++ /dev/null @@ -1,13 +0,0 @@ -class TextAreaFieldComponentPreview < ViewComponent::Preview - - - # @param value textarea - def default(value: '') - render TextAreaFieldComponent.new(value: value.empty? ? (long_text + long_text) : value ) - end - - private - def long_text - "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." - end -end \ No newline at end of file From 217b804858e2afb3f3e8cd9365019cbe2280c244 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:25:18 +0000 Subject: [PATCH 05/27] add margin to lookbook preview --- app/views/layouts/component_preview.html.erb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/component_preview.html.erb b/app/views/layouts/component_preview.html.erb index 745f4c563..f6fe9f26b 100644 --- a/app/views/layouts/component_preview.html.erb +++ b/app/views/layouts/component_preview.html.erb @@ -50,7 +50,10 @@
-<%= yield %> -<%= javascript_include_tag "application" %> +