flowbite-components 0.3.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -2
  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 +4 -1
  13. data/app/components/flowbite/card.rb +4 -8
  14. data/app/components/flowbite/input_field/input_field.html.erb +1 -0
  15. data/app/components/flowbite/pagination/chevron_left_icon.rb +34 -0
  16. data/app/components/flowbite/pagination/chevron_right_icon.rb +34 -0
  17. data/app/components/flowbite/pagination/gap.rb +24 -0
  18. data/app/components/flowbite/pagination/link.rb +52 -0
  19. data/app/components/flowbite/pagination/next_link.rb +67 -0
  20. data/app/components/flowbite/pagination/pagination.html.erb +11 -0
  21. data/app/components/flowbite/pagination/previous_link.rb +67 -0
  22. data/app/components/flowbite/pagination.rb +63 -0
  23. data/app/components/flowbite/progress/progress.html.erb +14 -0
  24. data/app/components/flowbite/progress.rb +163 -0
  25. data/app/components/flowbite/rating/rating.html.erb +13 -0
  26. data/app/components/flowbite/rating/star.html.erb +13 -0
  27. data/app/components/flowbite/rating/star.rb +59 -0
  28. data/app/components/flowbite/rating.rb +64 -0
  29. data/app/components/flowbite/spinner/spinner.html.erb +20 -0
  30. data/app/components/flowbite/spinner.rb +66 -0
  31. data/app/components/flowbite/toast/close_button.html.erb +17 -0
  32. data/app/components/flowbite/toast/close_button.rb +32 -0
  33. data/app/components/flowbite/toast/icon.html.erb +8 -2
  34. data/app/components/flowbite/toast/toast.html.erb +1 -28
  35. data/app/components/flowbite/toast.rb +39 -1
  36. data/lib/flowbite/components/version.rb +1 -1
  37. metadata +32 -3
@@ -0,0 +1,20 @@
1
+ <%= tag.div(role: "status", **options) do %>
2
+ <svg
3
+ aria-hidden="true"
4
+ class="<%= classes.join(" ") %>"
5
+ fill="none"
6
+ viewBox="0 0 100 101"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ >
9
+ <path
10
+ d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
11
+ fill="currentColor"
12
+ />
13
+
14
+ <path
15
+ d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
16
+ />
17
+ </svg>
18
+
19
+ <span class="sr-only"><%= message %></span>
20
+ <% end %>
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flowbite
4
+ # Renders a loading spinner.
5
+ #
6
+ # @example Basic usage
7
+ # <%= render(Flowbite::Spinner.new) %>
8
+ #
9
+ # @example With a custom style and size
10
+ # <%= render(Flowbite::Spinner.new(style: :success, size: :lg)) %>
11
+ #
12
+ # @see https://flowbite.com/docs/components/spinner/
13
+ # @lookbook_embed SpinnerPreview
14
+ class Spinner < ViewComponent::Base
15
+ SIZES = {
16
+ xs: ["w-4", "h-4"],
17
+ sm: ["w-6", "h-6"],
18
+ default: ["w-8", "h-8"],
19
+ lg: ["w-10", "h-10"],
20
+ xl: ["w-12", "h-12"]
21
+ }.freeze
22
+
23
+ class << self
24
+ def classes(size: :default, style: :brand)
25
+ style = styles.fetch(style)
26
+ ["text-neutral-tertiary", "animate-spin"] + style.fetch(:default) + sizes.fetch(size)
27
+ end
28
+
29
+ def sizes
30
+ SIZES
31
+ end
32
+
33
+ def styles
34
+ Flowbite::Styles.from_hash(
35
+ {
36
+ brand: {default: ["fill-brand"]},
37
+ danger: {default: ["fill-danger"]},
38
+ success: {default: ["fill-success"]},
39
+ warning: {default: ["fill-warning"]}
40
+ }.freeze
41
+ )
42
+ end
43
+ end
44
+
45
+ attr_reader :message, :options
46
+
47
+ # @param class [String, Array<String>] Additional CSS classes for the spinner icon.
48
+ # @param message [String] Text for screen readers announcing the loading state.
49
+ # @param options [Hash] Additional HTML options for the container element.
50
+ # @param size [Symbol] The size of the spinner (:xs, :sm, :default, :lg, :xl).
51
+ # @param style [Symbol] The color style of the spinner (:brand, :danger, :success, :warning).
52
+ def initialize(class: nil, message: "Loading...", size: :default, style: :brand, **options)
53
+ @class = Array.wrap(binding.local_variable_get(:class))
54
+ @message = message
55
+ @size = size
56
+ @style = style
57
+ @options = options
58
+ end
59
+
60
+ private
61
+
62
+ def classes
63
+ self.class.classes(size: @size, style: @style) + @class
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,17 @@
1
+ <%= tag.button(**button_options) do %>
2
+ <svg
3
+ aria-hidden="true"
4
+ class="w-3 h-3"
5
+ fill="none"
6
+ viewBox="0 0 14 14"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ >
9
+ <path
10
+ d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"
11
+ stroke="currentColor"
12
+ stroke-linecap="round"
13
+ stroke-linejoin="round"
14
+ stroke-width="2"
15
+ />
16
+ </svg>
17
+ <% end %>
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Flowbite
4
+ class Toast
5
+ # Renders the close button of a toast notification.
6
+ #
7
+ # @param options [Hash] Additional HTML options for the button element.
8
+ # These are merged over the default options.
9
+ class CloseButton < ViewComponent::Base
10
+ class << self
11
+ # Styles from https://flowbite.com/docs/components/toast/#default-toast
12
+ # rubocop:disable Layout/LineLength
13
+ def classes
14
+ ["ms-auto", "flex", "items-center", "justify-center", "text-body", "hover:text-heading", "bg-transparent", "box-border", "border", "border-transparent", "hover:bg-neutral-secondary-medium", "focus:ring-4", "focus:ring-neutral-tertiary", "font-medium", "leading-5", "rounded", "text-sm", "h-8", "w-8", "focus:outline-none"]
15
+ end
16
+ # rubocop:enable Layout/LineLength
17
+ end
18
+
19
+ def initialize(**options)
20
+ @options = options || {}
21
+ end
22
+
23
+ def button_options
24
+ {
25
+ aria: {label: "Close"},
26
+ class: self.class.classes,
27
+ type: "button"
28
+ }.merge(@options)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,11 @@
1
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 %>"/>
2
+ <svg
3
+ aria-hidden="true"
4
+ class="w-4 h-4"
5
+ fill="currentColor"
6
+ viewBox="0 0 20 20"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ >
9
+ <path d="<%= svg_path %>" />
4
10
  </svg>
5
11
  </div>
@@ -8,33 +8,6 @@
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
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.3.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.3.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,14 @@ 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
52
61
  - app/components/flowbite/badge.rb
53
62
  - app/components/flowbite/badge/badge.html.erb
54
63
  - app/components/flowbite/badge/dot.rb
@@ -99,12 +108,30 @@ files:
99
108
  - app/components/flowbite/input_field/textarea.rb
100
109
  - app/components/flowbite/input_field/url.rb
101
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
102
125
  - app/components/flowbite/sidebar.rb
103
126
  - app/components/flowbite/sidebar/item.rb
104
127
  - app/components/flowbite/sidebar/navigation.rb
128
+ - app/components/flowbite/spinner.rb
129
+ - app/components/flowbite/spinner/spinner.html.erb
105
130
  - app/components/flowbite/style.rb
106
131
  - app/components/flowbite/styles.rb
107
132
  - app/components/flowbite/toast.rb
133
+ - app/components/flowbite/toast/close_button.html.erb
134
+ - app/components/flowbite/toast/close_button.rb
108
135
  - app/components/flowbite/toast/icon.html.erb
109
136
  - app/components/flowbite/toast/icon.rb
110
137
  - app/components/flowbite/toast/toast.html.erb
@@ -120,6 +147,7 @@ metadata:
120
147
  homepage_uri: https://flowbite-components.substancelab.com
121
148
  source_code_uri: https://github.com/substancelab/flowbite-components
122
149
  changelog_uri: https://github.com/substancelab/flowbite-components/blob/main/CHANGELOG.md
150
+ post_install_message:
123
151
  rdoc_options: []
124
152
  require_paths:
125
153
  - app
@@ -135,7 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
163
  - !ruby/object:Gem::Version
136
164
  version: '0'
137
165
  requirements: []
138
- rubygems_version: 4.0.6
166
+ rubygems_version: 3.5.22
167
+ signing_key:
139
168
  specification_version: 4
140
169
  summary: ViewComponents using the Flowbite design system
141
170
  test_files: []