Skip to content

Commit 15a8d65

Browse files
committed
Update Input::Checkbox to the new Flowbite 4.0 styles
1 parent 5c11436 commit 15a8d65

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

app/components/flowbite/input/checkbox.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def sizes
2424
def styles
2525
{
2626
default: Flowbite::Style.new(
27-
default: ["text-blue-600", "bg-gray-100", "border-gray-300", "rounded-sm", "focus:ring-blue-500", "dark:focus:ring-blue-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-gray-600"],
28-
disabled: ["text-blue-600", "bg-gray-100", "border-gray-300", "rounded-sm", "focus:ring-blue-500", "dark:focus:ring-blue-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-gray-600"],
29-
error: ["text-red-600", "bg-red-50", "border-red-500", "rounded-sm", "focus:ring-red-500", "dark:focus:ring-red-600", "dark:ring-offset-gray-800", "focus:ring-2", "dark:bg-gray-700", "dark:border-red-500"]
27+
default: ["text-brand", "bg-neutral-secondary-medium", "border-default-medium", "rounded-sm", "focus:ring-brand", "focus:ring-2"],
28+
disabled: ["text-brand", "bg-neutral-secondary-medium", "border-default-medium", "rounded-sm", "focus:ring-brand", "focus:ring-2", "cursor-not-allowed"],
29+
error: ["text-danger", "bg-danger-soft", "border-danger-subtle", "rounded-sm", "focus:ring-danger", "focus:ring-2"]
3030
)
3131
}.freeze
3232
end

app/components/flowbite/input_field/checkbox.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def input_component
3333

3434
def hint_classes
3535
if disabled?
36-
"text-xs font-normal text-gray-400 dark:text-gray-500"
36+
"text-xs font-normal text-fg-disabled"
3737
else
38-
"text-xs font-normal text-gray-500 dark:text-gray-300"
38+
"text-xs font-normal text-body"
3939
end
4040
end
4141

@@ -48,9 +48,9 @@ def input_arguments
4848

4949
def label_classes
5050
if disabled?
51-
"font-medium text-gray-400 dark:text-gray-500"
51+
"font-medium text-fg-disabled"
5252
else
53-
"font-medium text-gray-900 dark:text-gray-300"
53+
"font-medium text-heading"
5454
end
5555
end
5656
end

test/components/input/checkbox_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ def test_renders_unchecked_when_false
3434
def test_renders_with_default_state
3535
render_inline(Flowbite::Input::Checkbox.new(form: @form, attribute: :subscribed))
3636

37-
assert_selector("input[name='user[subscribed]'].border-gray-300")
37+
assert_selector("input[name='user[subscribed]'].border-default-medium")
3838
end
3939

4040
def test_renders_in_disabled_state
4141
render_inline(Flowbite::Input::Checkbox.new(form: @form, attribute: :subscribed, disabled: true))
4242

43-
assert_selector("input[name='user[subscribed]'][disabled].bg-gray-100.border-gray-300.text-blue-600")
43+
assert_selector("input[name='user[subscribed]'][disabled].bg-neutral-secondary-medium.border-default-medium.text-brand")
4444
end
4545

4646
def test_sets_value
@@ -58,7 +58,7 @@ def test_adds_attributes_to_input
5858
def test_adds_class_attribute_to_existing_classes
5959
render_inline(Flowbite::Input::Checkbox.new(class: "custom-class", form: @form, attribute: :subscribed))
6060

61-
assert_selector("input[name='user[subscribed]'].bg-gray-100.custom-class")
61+
assert_selector("input[name='user[subscribed]'].bg-neutral-secondary-medium.custom-class")
6262
end
6363

6464
def test_renders_a_hidden_input_for_the_unchecked_case
@@ -76,7 +76,7 @@ def test_renders_a_hidden_input_for_the_unchecked_case_with_unchecked_value
7676
def test_replaces_class_attribute_with_options_class
7777
render_inline(Flowbite::Input::Checkbox.new(form: @form, attribute: :subscribed, options: {class: "custom-class"}))
7878

79-
assert_no_selector("input[name='user[subscribed]'].bg-gray-100.custom-class")
79+
assert_no_selector("input[name='user[subscribed]'].bg-neutral-secondary-medium.custom-class")
8080
assert_selector("input[name='user[subscribed]'].custom-class")
8181
end
8282

test/components/input_field/checkbox_test.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_renders_a_checkbox_input_element_with_custom_value
2626
def test_renders_a_label
2727
render_inline(Flowbite::InputField::Checkbox.new(form: @form, attribute: :subscribed))
2828

29-
assert_selector("label[for='user_subscribed'].font-medium.text-gray-900")
29+
assert_selector("label[for='user_subscribed'].font-medium.text-heading")
3030
end
3131

3232
def test_renders_a_label_with_specific_content
@@ -38,7 +38,7 @@ def test_renders_a_label_with_specific_content
3838
def test_passes_options_to_the_label
3939
render_inline(Flowbite::InputField::Checkbox.new(form: @form, attribute: :subscribed, label: {content: "Check to receive updates", options: {title: "label"}}))
4040

41-
assert_selector("label[title='label'].font-medium.text-gray-900", text: "Check to receive updates")
41+
assert_selector("label[title='label'].font-medium.text-heading", text: "Check to receive updates")
4242
end
4343

4444
def test_uses_specified_label_classes
@@ -52,7 +52,7 @@ def test_replaces_the_label_entirely
5252
component.with_label { "This is the full label" }
5353
end
5454

55-
refute_selector("p.text-xs.font-normal.text-gray-500")
55+
refute_selector("p.text-xs.font-normal.text-body")
5656
assert_text("This is the full label")
5757
end
5858

@@ -73,13 +73,13 @@ def test_renders_unchecked_when_false
7373
def test_renders_a_hint
7474
render_inline(Flowbite::InputField::Checkbox.new(form: @form, attribute: :subscribed, hint: {content: "Check to receive updates"}))
7575

76-
assert_selector("p.text-xs.font-normal.text-gray-500", text: "Check to receive updates")
76+
assert_selector("p.text-xs.font-normal.text-body", text: "Check to receive updates")
7777
end
7878

7979
def test_passes_options_to_the_hint
8080
render_inline(Flowbite::InputField::Checkbox.new(form: @form, attribute: :subscribed, hint: {content: "Check to receive updates", options: {title: "Hint"}}))
8181

82-
assert_selector("p[title='Hint'].text-xs.font-normal.text-gray-500", text: "Check to receive updates")
82+
assert_selector("p[title='Hint'].text-xs.font-normal.text-body", text: "Check to receive updates")
8383
end
8484

8585
def test_adds_aria_attributes_for_hint
@@ -94,7 +94,7 @@ def test_replaces_the_hint_entirely
9494
component.with_hint { "This is the full hint" }
9595
end
9696

97-
refute_selector("p.text-xs.font-normal.text-gray-500")
97+
refute_selector("p.text-xs.font-normal.text-body")
9898
assert_text("This is the full hint")
9999
end
100100

@@ -113,7 +113,7 @@ def test_renders_disabled_checkbox
113113
def test_renders_disabled_label
114114
render_inline(Flowbite::InputField::Checkbox.new(form: @form, attribute: :subscribed, disabled: true))
115115

116-
assert_selector("label[for='user_subscribed'].text-gray-400")
116+
assert_selector("label[for='user_subscribed'].text-fg-disabled")
117117
end
118118

119119
def test_renders_enabled_checkbox_by_default

0 commit comments

Comments
 (0)