flowbite-components 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -4
  3. data/README.md +23 -4
  4. data/app/components/flowbite/breadcrumb/home_icon.rb +28 -0
  5. data/app/components/flowbite/breadcrumb/item/current.rb +35 -0
  6. data/app/components/flowbite/breadcrumb/item/first.rb +37 -0
  7. data/app/components/flowbite/breadcrumb/item.rb +50 -0
  8. data/app/components/flowbite/breadcrumb/separator_icon.rb +34 -0
  9. data/app/components/flowbite/breadcrumb.rb +54 -0
  10. data/app/components/flowbite/button.rb +6 -5
  11. data/app/components/flowbite/card.rb +15 -1
  12. data/app/components/flowbite/input/checkbox.rb +2 -2
  13. data/app/components/flowbite/input/date.rb +2 -2
  14. data/app/components/flowbite/input/date_time.rb +11 -0
  15. data/app/components/flowbite/input/email.rb +2 -2
  16. data/app/components/flowbite/input/file.rb +2 -2
  17. data/app/components/flowbite/input/hint.rb +6 -1
  18. data/app/components/flowbite/input/label.rb +1 -1
  19. data/app/components/flowbite/input/number.rb +2 -2
  20. data/app/components/flowbite/input/password.rb +2 -2
  21. data/app/components/flowbite/input/phone.rb +2 -2
  22. data/app/components/flowbite/input/radio_button.rb +2 -2
  23. data/app/components/flowbite/input/select.rb +2 -2
  24. data/app/components/flowbite/input/textarea.rb +2 -2
  25. data/app/components/flowbite/input/url.rb +2 -2
  26. data/app/components/flowbite/input/validation_error.rb +1 -1
  27. data/app/components/flowbite/input.rb +155 -0
  28. data/app/components/flowbite/input_field/date_time.rb +13 -0
  29. data/app/components/flowbite/input_field/input_field.html.erb +2 -2
  30. data/app/components/flowbite/input_field/radio_button.rb +9 -15
  31. data/app/components/flowbite/input_field.rb +91 -47
  32. data/app/components/flowbite/link.rb +2 -0
  33. data/app/components/flowbite/toast/icon.html.erb +5 -0
  34. data/app/components/flowbite/toast/icon.rb +57 -0
  35. data/app/components/flowbite/toast/toast.html.erb +40 -0
  36. data/app/components/flowbite/toast.rb +37 -0
  37. data/lib/flowbite/components/version.rb +1 -1
  38. data/lib/yard/flowbite_viewcomponent.rb +24 -0
  39. metadata +33 -5
  40. data/app/components/flowbite/input/field.rb +0 -126
@@ -0,0 +1,155 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flowbite
4
+ # The individual input form element used in forms - without labels, error
5
+ # messages, hints, etc.
6
+ #
7
+ # Use this when you want to render an input field on its own without any
8
+ # surrounding elements, i.e. as a building block in more complex input
9
+ # components. To render a complete input field with labels and error messages,
10
+ # use {Flowbite::InputField} instead.
11
+ #
12
+ # By default this renders a text input field. To render other types of input
13
+ # fields, use one of the subclasses, such as {Flowbite::Input::Checkbox} or
14
+ # {Flowbite::Input::Textarea}.
15
+ #
16
+ # @example Usage
17
+ # <%= render(Flowbite::Input::Email.new(attribute: :email, form: form)) %>
18
+ #
19
+ # @lookbook_embed InputPreview
20
+ class Input < ViewComponent::Base
21
+ SIZES = {
22
+ sm: ["px-2.5", "py-2", "text-sm"],
23
+ default: ["px-3", "py-2.5", "text-sm"],
24
+ lg: ["px-3.5", "py-3", "text-base"]
25
+ }.freeze
26
+
27
+ STATES = [
28
+ DEFAULT = :default,
29
+ DISABLED = :disabled,
30
+ ERROR = :error
31
+ ].freeze
32
+
33
+ attr_reader :options, :size, :style
34
+
35
+ class << self
36
+ # @return [Array<String>] The CSS classes to apply to the input field
37
+ # given the specified +size+, +state+, and +style+.
38
+ def classes(size: :default, state: :default, style: :default)
39
+ style = styles.fetch(style)
40
+ state_classes = style.fetch(state)
41
+ state_classes + sizes.fetch(size)
42
+ end
43
+
44
+ # Returns the sizes this Input supports.
45
+ #
46
+ # This is effectively the {SIZES} constant, but provided as a method to
47
+ # return the constant from the current class, not the superclass.
48
+ #
49
+ # @return [Hash] A hash mapping size names to their corresponding CSS
50
+ # classes.
51
+ def sizes
52
+ const_get(:SIZES)
53
+ end
54
+
55
+ # @return [Flowbite::Styles] The available styles for this input field.
56
+ def styles
57
+ # rubocop:disable Layout/LineLength
58
+ Flowbite::Styles.from_hash(
59
+ {
60
+ default: {
61
+ default: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-heading", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "placeholder:text-body"],
62
+ disabled: ["bg-neutral-secondary-medium", "border", "border-default-medium", "text-fg-disabled", "rounded-base", "focus:ring-brand", "focus:border-brand", "block", "w-full", "shadow-xs", "cursor-not-allowed", "placeholder:text-fg-disabled"],
63
+ error: ["bg-danger-soft", "border", "border-danger-subtle", "text-fg-danger-strong", "rounded-base", "focus:ring-danger", "focus:border-danger", "block", "w-full", "shadow-xs", "placeholder:text-fg-danger-strong"]
64
+ }
65
+ }.freeze
66
+ )
67
+ # rubocop:enable Layout/LineLength
68
+ end
69
+ end
70
+
71
+ # @param attribute [Symbol] The attribute on the form's object this input
72
+ # field is for.
73
+ #
74
+ # @param form [ActionView::Helpers::FormBuilder] The form builder this
75
+ # input field is part of.
76
+ #
77
+ # @param class [String, Array<String>] Additional CSS classes to apply to
78
+ # the input field.
79
+ #
80
+ # @param disabled [Boolean] Whether the input field should be disabled.
81
+ #
82
+ # @param options [Hash] Additional HTML attributes to pass to the input
83
+ # field. For example, you can use this to set placeholder text by
84
+ # passing +options: {placeholder: "Enter your name"}+
85
+ #
86
+ # @param size [Symbol] The size of the input field. Can be one of +:sm+,
87
+ # +:default+, or +:lg+.
88
+ def initialize(attribute:, form:, class: nil, disabled: false, options: {}, size: :default)
89
+ @attribute = attribute
90
+ @class = Array.wrap(binding.local_variable_get(:class))
91
+ @disabled = disabled
92
+ @form = form
93
+ @options = options || {}
94
+ @object = form.object
95
+ @size = size
96
+ end
97
+
98
+ # Returns the HTML to use for the actual input field element.
99
+ def call
100
+ @form.send(
101
+ input_field_type,
102
+ @attribute,
103
+ **input_options
104
+ )
105
+ end
106
+
107
+ # Returns the CSS classes to apply to the input field
108
+ #
109
+ # @return [Array<String>] An array of CSS classes.
110
+ def classes
111
+ self.class.classes(size: size, state: state) + @class
112
+ end
113
+
114
+ # Returns the name of the method used to generate HTML for the input field
115
+ #
116
+ # @return [Symbol] The form helper method name to call on +form+.
117
+ def input_field_type
118
+ :text_field
119
+ end
120
+
121
+ protected
122
+
123
+ # @return [Boolean] Returns true if the field is disabled
124
+ def disabled?
125
+ !!@disabled
126
+ end
127
+
128
+ # Returns true if the object has errors. Returns false if there is no
129
+ # object.
130
+ #
131
+ # @return [Boolean] true if there are errors, false otherwise.
132
+ def errors?
133
+ return false unless @object
134
+
135
+ @object.errors.include?(@attribute.intern)
136
+ end
137
+
138
+ private
139
+
140
+ # Returns the options argument for the input field
141
+ def input_options
142
+ {
143
+ class: classes,
144
+ disabled: disabled?
145
+ }.merge(options)
146
+ end
147
+
148
+ def state
149
+ return DISABLED if disabled?
150
+ return ERROR if errors?
151
+
152
+ DEFAULT
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flowbite
4
+ class InputField
5
+ class DateTime < InputField
6
+ protected
7
+
8
+ def input_component
9
+ Flowbite::Input::DateTime
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,8 +1,8 @@
1
- <div class="<%= classes.join(" ") %>">
1
+ <%= content_tag(:div, container_options) do %>
2
2
  <%= label %>
3
3
  <%= input %>
4
4
  <%= hint %>
5
5
  <% errors.each do |error| %>
6
6
  <%= render(Flowbite::Input::ValidationError.new) { error.upcase_first } %>
7
7
  <% end %>
8
- </div>
8
+ <% end %>
@@ -26,6 +26,15 @@ module Flowbite
26
26
  input_component.new(**args)
27
27
  end
28
28
 
29
+ def default_hint_options
30
+ return {} unless @hint
31
+
32
+ {
33
+ class: hint_classes,
34
+ id: id_for_hint_element
35
+ }.merge(@hint[:options] || {})
36
+ end
37
+
29
38
  # Returns options for the default label element. This includes CSS classes
30
39
  # since they are specific to RadioButton labels (and Checkbox ones).
31
40
  def default_label_options
@@ -37,21 +46,6 @@ module Flowbite
37
46
  })
38
47
  end
39
48
 
40
- # Returns the HTML to use for the hint element if any
41
- def hint
42
- return unless hint?
43
-
44
- component = Flowbite::Input::Hint.new(
45
- attribute: @attribute,
46
- form: @form,
47
- options: {
48
- class: hint_classes,
49
- id: id_for_hint_element
50
- }
51
- ).with_content(@hint)
52
- render(component)
53
- end
54
-
55
49
  def input_component
56
50
  ::Flowbite::Input::RadioButton
57
51
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flowbite
4
- # A form element for a single field, containing label, input field, error
5
- # messages, helper text and whatever else is needed for a user friendly input
6
- # experience.
4
+ # A fully fledged form element for an attribute containing label, input field,
5
+ # error messages, helper text and whatever else is needed for a user-friendly
6
+ # input experience.
7
7
  #
8
8
  # @see https://flowbite.com/docs/forms/input-field/
9
9
  #
@@ -13,54 +13,55 @@ module Flowbite
13
13
  # more.
14
14
  #
15
15
  # Usually you'd use one of the subclasses of this class which implement the
16
- # different input types, like `Flowbite::InputField::Text`,
17
- # `Flowbite::InputField::Email`, etc.
16
+ # different input types, like {Flowbite::InputField::Text},
17
+ # {Flowbite::InputField::Email}, etc.
18
18
  #
19
- # Expects 2 arguments:
19
+ # To render an input without labels or error messages etc, see
20
+ # {Flowbite::Input} instead and one of its subclasses.
20
21
  #
21
- # @param attribute [Symbol] The name of the attribute to render in this input
22
- # field.
22
+ # @example Basic usage
23
+ # <% form_for @person do |form| %>
24
+ # <%= render(
25
+ # Flowbite::InputField::Number.new(
26
+ # attribute: :name,
27
+ # form: form
28
+ # )
29
+ # ) %>
30
+ # <% end %>
23
31
  #
24
- # @param form [ActionView::Helpers::FormBuilder] The form builder object that
25
- # will be used to generate the input field.
32
+ # @example Kitchen sink
33
+ # <% form_for @person do |form| %>
34
+ # <%= render(
35
+ # Flowbite::InputField::Number.new(
36
+ # attribute: :name,
37
+ # class: ["mb-4", "w-full"],
38
+ # disabled: true,
39
+ # form: form,
40
+ # hint: {
41
+ # content: "Please enter your full name.",
42
+ # options: {id: "name-helper-text"}
43
+ # },
44
+ # input: {
45
+ # options: {placeholder: "All of your names here"}
46
+ # },
47
+ # label: {
48
+ # content: "Full name",
49
+ # options: {class: ["mb-2", "font-medium"]}
50
+ # },
51
+ # options: {data: {controller: "form-field"}},
52
+ # size: :lg
53
+ # )
54
+ # ) %>
55
+ # <% end %>
26
56
  #
27
- # Supports additional arguments:
57
+ # @viewcomponent_slot [Flowbite::Input::Hint] hint Helper text displayed
58
+ # below the input field to provide additional context or instructions.
59
+ # @viewcomponent_slot [Flowbite::Input] input The input element itself.
60
+ # Usually auto-generated based on the input type subclass.
61
+ # @viewcomponent_slot [Flowbite::Input::Label] label The label for the input
62
+ # field, rendered above the input element.
28
63
  #
29
- # @param hint [String] A hint to display below the input field, providing
30
- # additional context or instructions for the user. This is optional. See
31
- # https://flowbite.com/docs/forms/input-field/#helper-text
32
- #
33
- # @param label [Hash] A hash with options for the label. These are passed to
34
- # Flowbite::Input::Label, see that for details. Can contain:
35
- # - `content`: The content of the label. If not provided, the label will
36
- # default to the attribute name.
37
- # - `options`: A hash of additional options to pass to the label component.
38
- # This can be used to set the class, for example.
39
- #
40
- # @param disabled [Boolean] Whether the input field should be disabled.
41
- # Defaults to `false`.
42
- #
43
- # @param input [Hash] A hash with options for the default input component.
44
- # These are passed to the input components constructor, so see whatever
45
- # component is being used for details. Can contain:
46
- # - `options`: Additional HTML attributes to pass to the input element.
47
- #
48
- # @param size [Symbol] The size of the input field. Can be one of `:sm`,
49
- # `:md`, or `:lg`. Defaults to `:md`.
50
- #
51
- # Sample usage
52
- #
53
- # <% form_for @person do |form| %>
54
- # <%= render(
55
- # Flowbite::InputField::Number.new(
56
- # :attribute => :name,
57
- # :form => form
58
- # )
59
- # ) %>
60
- # <% end %>
61
- #
62
- # To render an input without labels or error messages etc, use
63
- # `Flowbite::Input::Field` instead.
64
+ # @lookbook_embed InputFieldPreview
64
65
  class InputField < ViewComponent::Base
65
66
  renders_one :hint
66
67
  renders_one :input
@@ -75,6 +76,45 @@ module Flowbite
75
76
  @object.errors[@attribute] || []
76
77
  end
77
78
 
79
+ # @param attribute [Symbol] The name of the attribute to render in this
80
+ # input field.
81
+ #
82
+ # @param form [ActionView::Helpers::FormBuilder] The form builder object that
83
+ # will be used to generate the input field.
84
+ #
85
+ # @param class [String, Array<String>] Additional CSS classes to apply to
86
+ # the input field container, i.e. the outermost element. To add classes to
87
+ # individual components of the InputField, use the +input+, +label+ and
88
+ # +hint+ arguments.
89
+ #
90
+ # @param disabled [Boolean] Whether the input field should be disabled.
91
+ #
92
+ # @param hint [Hash] A hint to display below the input field, providing
93
+ # additional context or instructions for the user. If provided, this Hash
94
+ # is passed to the {Flowbite::Input::Hint} constructor.
95
+ # @option hint [String] content The content of the hint element.
96
+ # @option hint [Hash] options Additional options to pass to the hint
97
+ # component. This can be used to set the class, for example.
98
+ #
99
+ # @param input [Hash] A hash with options for the input component.
100
+ # These are passed to the input component's constructor, see the
101
+ # documentation for whatever input component is being used.
102
+ # See {Flowbite::Input}.
103
+ # @option input [Hash] options Additional HTML attributes to pass to
104
+ # the input element.
105
+ #
106
+ # @param label [Hash] A hash with options for the label element. If
107
+ # provided, this Hash is passed to the {Flowbite::Input::Label}
108
+ # constructor.
109
+ # @option label [String] content The content of the label element.
110
+ # @option label [Hash] options Additional options to pass to the label
111
+ # component. This can be used to set the class, for example.
112
+ #
113
+ # @param options [Hash] Additional HTML attributes to pass to the input
114
+ # field container element.
115
+ #
116
+ # @param size [Symbol] The size of the input field. Can be one of +:sm+,
117
+ # +:default+, or +:lg+.
78
118
  def initialize(attribute:, form:, class: nil, disabled: false, hint: nil, input: {}, label: {}, options: {}, size: :default)
79
119
  @attribute = attribute
80
120
  @class = Array.wrap(binding.local_variable_get(:class))
@@ -89,7 +129,7 @@ module Flowbite
89
129
  end
90
130
 
91
131
  def input_component
92
- ::Flowbite::Input::Field
132
+ ::Flowbite::Input
93
133
  end
94
134
 
95
135
  protected
@@ -102,6 +142,10 @@ module Flowbite
102
142
  end
103
143
  end
104
144
 
145
+ def container_options
146
+ @options.merge({class: classes.join(" ")})
147
+ end
148
+
105
149
  def default_container_classes
106
150
  []
107
151
  end
@@ -5,6 +5,8 @@ module Flowbite
5
5
  # to an external website when clicking on an inline text item, button, or card
6
6
  #
7
7
  # Use this component to add default styles to an inline link element.
8
+ #
9
+ # @lookbook_embed LinkPreview
8
10
  class Link < ViewComponent::Base
9
11
  attr_reader :href, :options
10
12
 
@@ -0,0 +1,5 @@
1
+ <div class="<%= container_classes.join(" ") %>">
2
+ <svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
3
+ <path d="<%= svg_path %>"/>
4
+ </svg>
5
+ </div>
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flowbite
4
+ class Toast
5
+ # Renders an icon for a toast notification.
6
+ #
7
+ # @param style [Symbol] The color style of the icon (:default, :success, :danger, :warning).
8
+ class Icon < ViewComponent::Base
9
+ class << self
10
+ def classes(style: :default)
11
+ styles.fetch(style).fetch(:classes)
12
+ end
13
+
14
+ def svg_path(style: :default)
15
+ styles.fetch(style).fetch(:svg_path)
16
+ end
17
+
18
+ # rubocop:disable Layout/LineLength
19
+ def styles
20
+ {
21
+ default: {
22
+ classes: ["inline-flex", "items-center", "justify-center", "shrink-0", "w-8", "h-8", "text-blue-500", "bg-blue-100", "rounded-lg", "dark:bg-blue-800", "dark:text-blue-200"],
23
+ svg_path: "M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"
24
+ },
25
+ success: {
26
+ classes: ["inline-flex", "items-center", "justify-center", "shrink-0", "w-8", "h-8", "text-green-500", "bg-green-100", "rounded-lg", "dark:bg-green-800", "dark:text-green-200"],
27
+ svg_path: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"
28
+ },
29
+ danger: {
30
+ classes: ["inline-flex", "items-center", "justify-center", "shrink-0", "w-8", "h-8", "text-red-500", "bg-red-100", "rounded-lg", "dark:bg-red-800", "dark:text-red-200"],
31
+ svg_path: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"
32
+ },
33
+ warning: {
34
+ classes: ["inline-flex", "items-center", "justify-center", "shrink-0", "w-8", "h-8", "text-orange-500", "bg-orange-100", "rounded-lg", "dark:bg-orange-700", "dark:text-orange-200"],
35
+ svg_path: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"
36
+ }
37
+ }.freeze
38
+ end
39
+ # rubocop:enable Layout/LineLength
40
+ end
41
+
42
+ attr_reader :style
43
+
44
+ def initialize(style: :default)
45
+ @style = style
46
+ end
47
+
48
+ def container_classes
49
+ self.class.classes(style: style)
50
+ end
51
+
52
+ def svg_path
53
+ self.class.svg_path(style: style)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,40 @@
1
+ <div
2
+ class="<%= container_classes.join(" ") %>"
3
+ role="alert"
4
+ <%= options.map { |k, v| "#{k}=\"#{v}\"" }.join(" ").html_safe %>
5
+ >
6
+ <%= render Flowbite::Toast::Icon.new(style: style) %>
7
+
8
+ <div class="ms-3 text-sm font-normal"><%= message %></div>
9
+
10
+ <% if dismissible %>
11
+ <%# Styles from https://flowbite.com/docs/components/toast/#default-toast %>
12
+ <button
13
+ type="button"
14
+ class="
15
+ ms-auto flex items-center justify-center text-body
16
+ hover:text-heading bg-transparent box-border border
17
+ border-transparent hover:bg-neutral-secondary-medium focus:ring-4
18
+ focus:ring-neutral-tertiary font-medium leading-5 rounded text-sm
19
+ h-8 w-8 focus:outline-none
20
+ "
21
+ aria-label="Close"
22
+ >
23
+ <svg
24
+ class="w-3 h-3"
25
+ aria-hidden="true"
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ fill="none"
28
+ viewBox="0 0 14 14"
29
+ >
30
+ <path
31
+ stroke="currentColor"
32
+ stroke-linecap="round"
33
+ stroke-linejoin="round"
34
+ stroke-width="2"
35
+ d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"
36
+ />
37
+ </svg>
38
+ </button>
39
+ <% end %>
40
+ </div>
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flowbite
4
+ # Renders a toast notification element.
5
+ #
6
+ # @example Usage
7
+ # <%= render(Flowbite::Toast.new(message: "Something has happened!")) %>
8
+ #
9
+ # @see https://flowbite.com/docs/components/toast/
10
+ # @lookbook_embed ToastPreview
11
+ class Toast < ViewComponent::Base
12
+ class << self
13
+ def classes
14
+ ["flex", "items-center", "w-full", "max-w-xs", "p-4", "text-body", "bg-neutral-primary-soft", "rounded-base", "shadow-xs", "border", "border-default"]
15
+ end
16
+ end
17
+
18
+ attr_reader :dismissible, :message, :options, :style
19
+
20
+ # @param class [Array<String>] Additional CSS classes for the toast container.
21
+ # @param dismissible [Boolean] Whether the toast can be dismissed (default: true).
22
+ # @param message [String] The message to display in the toast.
23
+ # @param options [Hash] Additional HTML options for the toast container.
24
+ # @param style [Symbol] The color style of the toast (:default, :success, :danger, :warning).
25
+ def initialize(message:, dismissible: true, style: :default, class: nil, **options)
26
+ @message = message
27
+ @style = style
28
+ @dismissible = dismissible
29
+ @class = Array.wrap(binding.local_variable_get(:class))
30
+ @options = options
31
+ end
32
+
33
+ def container_classes
34
+ self.class.classes + @class
35
+ end
36
+ end
37
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Flowbite
4
4
  module Components
5
- VERSION = "0.1.4"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # YARD plugin for documenting ViewComponent slots
4
+ #
5
+ # This plugin adds a @viewcomponent_slot tag that can be used to document
6
+ # slots defined with renders_one and renders_many in ViewComponent classes.
7
+ #
8
+ # Usage:
9
+ # # @viewcomponent_slot [Flowbite::Card::Title] title The title of the card
10
+ # renders_one :title
11
+ #
12
+ # # @viewcomponent_slot [Flowbite::Breadcrumb::Item] items The breadcrumb items
13
+ # renders_many :items
14
+ #
15
+ # The tag accepts:
16
+ # - Types (optional): The component class(es) that can be rendered in the slot
17
+ # - Name (required): The slot name (matching the symbol passed to renders_one/renders_many)
18
+ # - Description (optional): A description of what the slot is for
19
+
20
+ YARD::Tags::Library.define_tag(
21
+ "ViewComponent Slot",
22
+ :viewcomponent_slot,
23
+ :with_types_and_name
24
+ )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowbite-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Skjerning
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: 4.0.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: yard
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
26
40
  description: A library of View Components based on the Flowbite design system to be
27
41
  used in Rails applications.
28
42
  email:
@@ -35,16 +49,23 @@ files:
35
49
  - LICENSE
36
50
  - README.md
37
51
  - app/assets/tailwind/flowbite_components/engine.css
52
+ - app/components/flowbite/breadcrumb.rb
53
+ - app/components/flowbite/breadcrumb/home_icon.rb
54
+ - app/components/flowbite/breadcrumb/item.rb
55
+ - app/components/flowbite/breadcrumb/item/current.rb
56
+ - app/components/flowbite/breadcrumb/item/first.rb
57
+ - app/components/flowbite/breadcrumb/separator_icon.rb
38
58
  - app/components/flowbite/button.rb
39
59
  - app/components/flowbite/button/outline.rb
40
60
  - app/components/flowbite/button/pill.rb
41
61
  - app/components/flowbite/card.rb
42
62
  - app/components/flowbite/card/card.html.erb
43
63
  - app/components/flowbite/card/title.rb
64
+ - app/components/flowbite/input.rb
44
65
  - app/components/flowbite/input/checkbox.rb
45
66
  - app/components/flowbite/input/date.rb
67
+ - app/components/flowbite/input/date_time.rb
46
68
  - app/components/flowbite/input/email.rb
47
- - app/components/flowbite/input/field.rb
48
69
  - app/components/flowbite/input/file.rb
49
70
  - app/components/flowbite/input/hint.rb
50
71
  - app/components/flowbite/input/label.rb
@@ -60,6 +81,7 @@ files:
60
81
  - app/components/flowbite/input_field/checkbox.html.erb
61
82
  - app/components/flowbite/input_field/checkbox.rb
62
83
  - app/components/flowbite/input_field/date.rb
84
+ - app/components/flowbite/input_field/date_time.rb
63
85
  - app/components/flowbite/input_field/email.rb
64
86
  - app/components/flowbite/input_field/file.rb
65
87
  - app/components/flowbite/input_field/input_field.html.erb
@@ -75,14 +97,20 @@ files:
75
97
  - app/components/flowbite/link.rb
76
98
  - app/components/flowbite/style.rb
77
99
  - app/components/flowbite/styles.rb
100
+ - app/components/flowbite/toast.rb
101
+ - app/components/flowbite/toast/icon.html.erb
102
+ - app/components/flowbite/toast/icon.rb
103
+ - app/components/flowbite/toast/toast.html.erb
78
104
  - lib/flowbite/components.rb
79
105
  - lib/flowbite/components/engine.rb
80
106
  - lib/flowbite/components/version.rb
81
- homepage: https://github.com/substancelab/flowbite-components
107
+ - lib/yard/flowbite_viewcomponent.rb
108
+ homepage: https://flowbite-components.substancelab.com
82
109
  licenses: []
83
110
  metadata:
84
111
  allowed_push_host: https://rubygems.org/
85
- homepage_uri: https://github.com/substancelab/flowbite-components
112
+ documentation_uri: https://flowbite-components.substancelab.com/docs
113
+ homepage_uri: https://flowbite-components.substancelab.com
86
114
  source_code_uri: https://github.com/substancelab/flowbite-components
87
115
  changelog_uri: https://github.com/substancelab/flowbite-components/blob/main/CHANGELOG.md
88
116
  rdoc_options: []
@@ -100,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
128
  - !ruby/object:Gem::Version
101
129
  version: '0'
102
130
  requirements: []
103
- rubygems_version: 3.6.9
131
+ rubygems_version: 4.0.3
104
132
  specification_version: 4
105
133
  summary: ViewComponents using the Flowbite design system
106
134
  test_files: []