flowbite-components 0.2.0 → 0.4.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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +3 -5
  4. data/app/components/flowbite/alert/alert.html.erb +36 -0
  5. data/app/components/flowbite/alert/icon.rb +53 -0
  6. data/app/components/flowbite/alert.rb +156 -0
  7. data/app/components/flowbite/avatar/avatar.html.erb +23 -0
  8. data/app/components/flowbite/avatar/dot.rb +85 -0
  9. data/app/components/flowbite/avatar/placeholder_icon.html.erb +13 -0
  10. data/app/components/flowbite/avatar/placeholder_icon.rb +44 -0
  11. data/app/components/flowbite/avatar.rb +132 -0
  12. data/app/components/flowbite/badge/badge.html.erb +7 -0
  13. data/app/components/flowbite/badge/dot.rb +45 -0
  14. data/app/components/flowbite/badge/pill.rb +40 -0
  15. data/app/components/flowbite/badge.rb +116 -0
  16. data/app/components/flowbite/card.rb +4 -8
  17. data/app/components/flowbite/input_field/checkbox.rb +7 -7
  18. data/app/components/flowbite/input_field/input_field.html.erb +1 -0
  19. data/app/components/flowbite/input_field/select.rb +1 -1
  20. data/app/components/flowbite/input_field.rb +29 -22
  21. data/app/components/flowbite/pagination/chevron_left_icon.rb +34 -0
  22. data/app/components/flowbite/pagination/chevron_right_icon.rb +34 -0
  23. data/app/components/flowbite/pagination/gap.rb +24 -0
  24. data/app/components/flowbite/pagination/link.rb +52 -0
  25. data/app/components/flowbite/pagination/next_link.rb +67 -0
  26. data/app/components/flowbite/pagination/pagination.html.erb +11 -0
  27. data/app/components/flowbite/pagination/previous_link.rb +67 -0
  28. data/app/components/flowbite/pagination.rb +63 -0
  29. data/app/components/flowbite/progress/progress.html.erb +14 -0
  30. data/app/components/flowbite/progress.rb +163 -0
  31. data/app/components/flowbite/rating/rating.html.erb +13 -0
  32. data/app/components/flowbite/rating/star.html.erb +13 -0
  33. data/app/components/flowbite/rating/star.rb +59 -0
  34. data/app/components/flowbite/rating.rb +64 -0
  35. data/app/components/flowbite/sidebar/item.rb +68 -0
  36. data/app/components/flowbite/sidebar/navigation.rb +62 -0
  37. data/app/components/flowbite/sidebar.rb +62 -0
  38. data/app/components/flowbite/spinner/spinner.html.erb +20 -0
  39. data/app/components/flowbite/spinner.rb +66 -0
  40. data/app/components/flowbite/toast/close_button.html.erb +17 -0
  41. data/app/components/flowbite/toast/close_button.rb +32 -0
  42. data/app/components/flowbite/toast/icon.html.erb +8 -2
  43. data/app/components/flowbite/toast/toast.html.erb +7 -34
  44. data/app/components/flowbite/toast.rb +39 -1
  45. data/lib/flowbite/components/version.rb +1 -1
  46. metadata +39 -3
@@ -1,40 +1,13 @@
1
- <div
2
- class="<%= container_classes.join(" ") %>"
3
- role="alert"
4
- <%= options.map { |k, v| "#{k}=\"#{v}\"" }.join(" ").html_safe %>
5
- >
1
+ <%= tag.div(
2
+ class: container_classes.join(" "),
3
+ role: "alert",
4
+ **options,
5
+ ) do %>
6
6
  <%= render Flowbite::Toast::Icon.new(style: style) %>
7
7
 
8
8
  <div class="ms-3 text-sm font-normal"><%= message %></div>
9
9
 
10
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>
11
+ <%= button %>
39
12
  <% end %>
40
- </div>
13
+ <% end %>
@@ -6,9 +6,28 @@ module Flowbite
6
6
  # @example Usage
7
7
  # <%= render(Flowbite::Toast.new(message: "Something has happened!")) %>
8
8
  #
9
+ # @example Passing options to the default button
10
+ # <%= render(Flowbite::Toast.new(
11
+ # button: {options: {data: {action: "toast#dismiss"}}},
12
+ # message: "Something has happened!"
13
+ # )) %>
14
+ #
15
+ # @example Using the button slot
16
+ # <%= render(Flowbite::Toast.new(message: "Something has happened!")) do |toast| %>
17
+ # <% toast.with_button do %>
18
+ # <%= render(Flowbite::Toast::CloseButton.new(data: {action: "toast#dismiss"})) %>
19
+ # <% end %>
20
+ # <% end %>
21
+ #
22
+ # @viewcomponent_slot [Flowbite::Toast::CloseButton] button The button
23
+ # rendered at the end of the toast. Defaults to a close button. Use
24
+ # +with_button+ to set custom content.
25
+ #
9
26
  # @see https://flowbite.com/docs/components/toast/
10
27
  # @lookbook_embed ToastPreview
11
28
  class Toast < ViewComponent::Base
29
+ renders_one :button
30
+
12
31
  class << self
13
32
  def classes
14
33
  ["flex", "items-center", "w-full", "max-w-xs", "p-4", "text-body", "bg-neutral-primary-soft", "rounded-base", "shadow-xs", "border", "border-default"]
@@ -17,12 +36,19 @@ module Flowbite
17
36
 
18
37
  attr_reader :dismissible, :message, :options, :style
19
38
 
39
+ # @param button [Hash] Configuration for the default button, rendered
40
+ # using the Toast::CloseButton component. The hash can contain:
41
+ # - `options`: Additional HTML options to pass to the button element,
42
+ # e.g. `{data: {action: "toast#dismiss"}}`
43
+ # Alternatively, you can use the `button` slot to provide the entire
44
+ # button element yourself.
20
45
  # @param class [Array<String>] Additional CSS classes for the toast container.
21
46
  # @param dismissible [Boolean] Whether the toast can be dismissed (default: true).
22
47
  # @param message [String] The message to display in the toast.
23
48
  # @param options [Hash] Additional HTML options for the toast container.
24
49
  # @param style [Symbol] The color style of the toast (:default, :success, :danger, :warning).
25
- def initialize(message:, dismissible: true, style: :default, class: nil, **options)
50
+ def initialize(message:, button: {}, dismissible: true, style: :default, class: nil, **options)
51
+ @button = button
26
52
  @message = message
27
53
  @style = style
28
54
  @dismissible = dismissible
@@ -33,5 +59,17 @@ module Flowbite
33
59
  def container_classes
34
60
  self.class.classes + @class
35
61
  end
62
+
63
+ protected
64
+
65
+ # Returns the HTML to use for the button, unless the button slot is used
66
+ def default_button
67
+ render(Flowbite::Toast::CloseButton.new(**default_button_options))
68
+ end
69
+
70
+ # @return [Hash] The options to pass to the default button component
71
+ def default_button_options
72
+ @button[:options] || {}
73
+ end
36
74
  end
37
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Flowbite
4
4
  module Components
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowbite-components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Skjerning
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-11-04 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: view_component
@@ -49,6 +50,18 @@ files:
49
50
  - LICENSE
50
51
  - README.md
51
52
  - app/assets/tailwind/flowbite_components/engine.css
53
+ - app/components/flowbite/alert.rb
54
+ - app/components/flowbite/alert/alert.html.erb
55
+ - app/components/flowbite/alert/icon.rb
56
+ - app/components/flowbite/avatar.rb
57
+ - app/components/flowbite/avatar/avatar.html.erb
58
+ - app/components/flowbite/avatar/dot.rb
59
+ - app/components/flowbite/avatar/placeholder_icon.html.erb
60
+ - app/components/flowbite/avatar/placeholder_icon.rb
61
+ - app/components/flowbite/badge.rb
62
+ - app/components/flowbite/badge/badge.html.erb
63
+ - app/components/flowbite/badge/dot.rb
64
+ - app/components/flowbite/badge/pill.rb
52
65
  - app/components/flowbite/breadcrumb.rb
53
66
  - app/components/flowbite/breadcrumb/home_icon.rb
54
67
  - app/components/flowbite/breadcrumb/item.rb
@@ -95,9 +108,30 @@ files:
95
108
  - app/components/flowbite/input_field/textarea.rb
96
109
  - app/components/flowbite/input_field/url.rb
97
110
  - app/components/flowbite/link.rb
111
+ - app/components/flowbite/pagination.rb
112
+ - app/components/flowbite/pagination/chevron_left_icon.rb
113
+ - app/components/flowbite/pagination/chevron_right_icon.rb
114
+ - app/components/flowbite/pagination/gap.rb
115
+ - app/components/flowbite/pagination/link.rb
116
+ - app/components/flowbite/pagination/next_link.rb
117
+ - app/components/flowbite/pagination/pagination.html.erb
118
+ - app/components/flowbite/pagination/previous_link.rb
119
+ - app/components/flowbite/progress.rb
120
+ - app/components/flowbite/progress/progress.html.erb
121
+ - app/components/flowbite/rating.rb
122
+ - app/components/flowbite/rating/rating.html.erb
123
+ - app/components/flowbite/rating/star.html.erb
124
+ - app/components/flowbite/rating/star.rb
125
+ - app/components/flowbite/sidebar.rb
126
+ - app/components/flowbite/sidebar/item.rb
127
+ - app/components/flowbite/sidebar/navigation.rb
128
+ - app/components/flowbite/spinner.rb
129
+ - app/components/flowbite/spinner/spinner.html.erb
98
130
  - app/components/flowbite/style.rb
99
131
  - app/components/flowbite/styles.rb
100
132
  - app/components/flowbite/toast.rb
133
+ - app/components/flowbite/toast/close_button.html.erb
134
+ - app/components/flowbite/toast/close_button.rb
101
135
  - app/components/flowbite/toast/icon.html.erb
102
136
  - app/components/flowbite/toast/icon.rb
103
137
  - app/components/flowbite/toast/toast.html.erb
@@ -113,6 +147,7 @@ metadata:
113
147
  homepage_uri: https://flowbite-components.substancelab.com
114
148
  source_code_uri: https://github.com/substancelab/flowbite-components
115
149
  changelog_uri: https://github.com/substancelab/flowbite-components/blob/main/CHANGELOG.md
150
+ post_install_message:
116
151
  rdoc_options: []
117
152
  require_paths:
118
153
  - app
@@ -128,7 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
163
  - !ruby/object:Gem::Version
129
164
  version: '0'
130
165
  requirements: []
131
- rubygems_version: 4.0.3
166
+ rubygems_version: 3.5.22
167
+ signing_key:
132
168
  specification_version: 4
133
169
  summary: ViewComponents using the Flowbite design system
134
170
  test_files: []