From 7f3b0b1cc0c482f927a1985d2a0eadd11ab7a9d8 Mon Sep 17 00:00:00 2001 From: Carlos Lima Date: Wed, 20 Nov 2024 15:23:34 -0300 Subject: [PATCH] [PBNTR-504] Adding Rails Indeterminate Checkbox variant doc (#3918) **What does this PR do?** Adding Rails Indeterminate Checkbox variant doc **Screenshots:** ![image](https://github.com/user-attachments/assets/b2da73ec-1dd1-4b1c-a8e2-f0627d008142) **How to test?** Steps to confirm the desired behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See addition/change #### Checklist: - [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [x] **DEPLOY** I have added the `milano` label to show I'm ready for a review. - [ ] **TESTS** I have added test coverage to my code. --- .../playbook/pb_checkbox/checkbox.html.erb | 4 +- .../pb_kits/playbook/pb_checkbox/checkbox.rb | 4 - .../docs/_checkbox_indeterminate.html.erb | 91 +++++++++++++++++-- 3 files changed, 86 insertions(+), 13 deletions(-) diff --git a/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb b/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb index bd3c0e6f47..331e50e609 100644 --- a/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +++ b/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb @@ -6,12 +6,12 @@ ) do %> <%= content.presence || object.input %> <% if object.indeterminate %> - + <%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon", fixed_width: true}) %> <%= pb_rails("icon", props: { icon: "check", classname: "check_icon hidden", fixed_width: true}) %> <% else %> - + <%= pb_rails("icon", props: { icon: "check", classname: "check_icon", fixed_width: true}) %> <%= pb_rails("icon", props: { icon: "minus", classname: "indeterminate_icon hidden", fixed_width: true}) %> diff --git a/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.rb b/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.rb index 394dc8c7fc..9d1e2d27e4 100644 --- a/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.rb +++ b/playbook/app/pb_kits/playbook/pb_checkbox/checkbox.rb @@ -18,10 +18,6 @@ class Checkbox < Playbook::KitBase prop :form_spacing, type: Playbook::Props::Boolean, default: false - def checked_html - checked ? "checked='true'" : nil - end - def classname generate_classname("pb_checkbox_kit", checked_class) + indeterminate_class + error_class end diff --git a/playbook/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb b/playbook/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb index cc114fda2c..49db036fcd 100644 --- a/playbook/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +++ b/playbook/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb @@ -1,7 +1,84 @@ -<%= pb_rails("checkbox" , props: { - text: "Select ", - value: "checkbox-value", - name: "main", - indeterminate: true, - id: "test-indeterminate-js" -}) %> +<% checkboxes = [ + { name: 'Coffee', id: 'coffee', checked: false }, + { name: 'Ice Cream', id: 'ice-cream', checked: false }, + { name: 'Chocolate', id: 'chocolate', checked: true } +] %> + +<%= pb_rails("table", props: { container: false, size: "md" }) do %> + + + + <%= pb_rails("checkbox", props: { + checked: true, + text: "Uncheck All", + value: "checkbox-value", + name: "main-checkbox", + indeterminate: true, + id: "indeterminate-checkbox" + }) %> + + + + + + <% checkboxes.each do |checkbox| %> + + + <%= pb_rails("checkbox", props: { + checked: checkbox[:checked], + text: checkbox[:name], + value: checkbox[:id], + name: "#{checkbox[:id]}-indeterminate-checkbox", + id: "#{checkbox[:id]}-indeterminate-checkbox", + }) %> + + + <% end %> + +<% end %> + +