flowbite-components 0.1.3 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -4
- data/README.md +56 -8
- data/app/components/flowbite/breadcrumb/home_icon.rb +28 -0
- data/app/components/flowbite/breadcrumb/item/current.rb +35 -0
- data/app/components/flowbite/breadcrumb/item/first.rb +37 -0
- data/app/components/flowbite/breadcrumb/item.rb +50 -0
- data/app/components/flowbite/breadcrumb/separator_icon.rb +34 -0
- data/app/components/flowbite/breadcrumb.rb +54 -0
- data/app/components/flowbite/button/outline.rb +25 -10
- data/app/components/flowbite/button/pill.rb +26 -26
- data/app/components/flowbite/button.rb +39 -35
- data/app/components/flowbite/card/card.html.erb +7 -0
- data/app/components/flowbite/card/title.rb +39 -0
- data/app/components/flowbite/card.rb +71 -16
- data/app/components/flowbite/input/checkbox.rb +13 -11
- data/app/components/flowbite/input/date.rb +2 -2
- data/app/components/flowbite/input/date_time.rb +11 -0
- data/app/components/flowbite/input/email.rb +2 -2
- data/app/components/flowbite/input/file.rb +13 -11
- data/app/components/flowbite/input/hint.rb +16 -8
- data/app/components/flowbite/input/label.rb +15 -10
- data/app/components/flowbite/input/number.rb +2 -2
- data/app/components/flowbite/input/password.rb +2 -2
- data/app/components/flowbite/input/phone.rb +2 -2
- data/app/components/flowbite/input/radio_button.rb +13 -11
- data/app/components/flowbite/input/select.rb +7 -7
- data/app/components/flowbite/input/textarea.rb +13 -11
- data/app/components/flowbite/input/url.rb +2 -2
- data/app/components/flowbite/input/validation_error.rb +32 -2
- data/app/components/flowbite/input.rb +155 -0
- data/app/components/flowbite/input_field/checkbox.html.erb +2 -4
- data/app/components/flowbite/input_field/checkbox.rb +8 -4
- data/app/components/flowbite/input_field/date_time.rb +13 -0
- data/app/components/flowbite/input_field/input_field.html.erb +2 -2
- data/app/components/flowbite/input_field/radio_button.html.erb +2 -4
- data/app/components/flowbite/input_field/radio_button.rb +19 -21
- data/app/components/flowbite/input_field.rb +117 -49
- data/app/components/flowbite/link.rb +43 -0
- data/app/components/flowbite/styles.rb +34 -0
- data/app/components/flowbite/toast/icon.html.erb +5 -0
- data/app/components/flowbite/toast/icon.rb +57 -0
- data/app/components/flowbite/toast/toast.html.erb +40 -0
- data/app/components/flowbite/toast.rb +37 -0
- data/lib/flowbite/components/version.rb +1 -1
- data/lib/yard/flowbite_viewcomponent.rb +24 -0
- metadata +37 -5
- data/app/components/flowbite/input/field.rb +0 -117
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ca94dfc5af1c662f4a7cfb77f038f60402daf411673078c30b77672280c6055
|
|
4
|
+
data.tar.gz: 60ad1e86847bd59c9b8ba598d44562cbd8f24776b9e696bc55e60550da9cfc0b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2676a2b3da22cae60d35793a71d2e24637edb9cd61f5d3096c95352b1f6426d3e1116d124a474f05fa5198f4ce7935b1f0499f1ee82eb756101a9229a1ecf6bc
|
|
7
|
+
data.tar.gz: 18fc7aaad24ffad2d9ec01a5ae772bf0b7194a24d3d91800a535fa3b3fd22017f1fac025791ff59a4a6de249d931abf2d30d16e88e3e1f50e78fc04d747a9899
|
data/CHANGELOG.md
CHANGED
|
@@ -3,19 +3,42 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
|
6
|
-
## [
|
|
6
|
+
## [0.2.0]
|
|
7
7
|
|
|
8
8
|
### Added
|
|
9
9
|
|
|
10
|
-
*
|
|
10
|
+
* Breadcrumb component, including Flowbite::Breadcrumb::Item with Flowbite::Breadcrumb::Item::First and Flowbite::Breadcrumb::Item::Current variants.
|
|
11
|
+
* DateTime input field components.
|
|
12
|
+
* Toast component.
|
|
13
|
+
* Ruby 4.0 support (no changes).
|
|
11
14
|
|
|
12
15
|
### Changed
|
|
13
16
|
|
|
14
|
-
*
|
|
17
|
+
* [BREAKING] The API of Flowbite::InputField::RadioButton now follows the same structure as the other components for hints. Instead of passing a String (`hint: "This is the hint"`) you now have to pass a Hash that's passed along to the Hint component (i.e. `hint: {content: "This is the hint"}`), allowing you to customize other options (eg HTML attributes like class) as well.
|
|
18
|
+
* [BREAKING] Flowbite::Input::Field has been renamed to Flowbite::Input. All individual input components now use that as their superclass. This matches the class hierarchy of Flowbite::InputField::* classes better and allows Flowbite::Input to automagically appear in the documentation.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
* Flowbite::InputField classes now correctly add their options to the container element, so you can add id attributes or connect Stimulus controllers again.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [0.1.4]
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
* Flowbite::Link component to render links.
|
|
30
|
+
* Flowbite::Card now displays a title via the title argument/slot.
|
|
31
|
+
* Improved error message when an unknown style is requested.
|
|
32
|
+
* Input-elements now support forms without an object; i.e. forms built with `form_tag` - not `form_for` or `form_with`.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
* [BREAKING] All components now use Flowbite 4 style classes. This adds the option for easier styling, uses semantic variant names, and keeps us up to date with Flowbite proper.
|
|
37
|
+
* Extra CSS classes passed to components in the `class` argument are now added to the default classes from the component. This optimizes for minor tweaks and additions, which is likely to be the most common use case. If you need to replace all classes on the root element of the component, pass them in `options[:class]` instead.
|
|
15
38
|
|
|
16
39
|
### Removed
|
|
17
40
|
|
|
18
|
-
*
|
|
41
|
+
* [BREAKING] Color-specific styles from Flowbite::Button, i.e. `alternative`, `green`, `light`, `purple`, `red`, `yellow`.
|
|
19
42
|
|
|
20
43
|
|
|
21
44
|
## [0.1.3]
|
data/README.md
CHANGED
|
@@ -7,6 +7,8 @@ Unofficial, open source implementation of [Flowbite](https://flowbite.com/) comp
|
|
|
7
7
|
|
|
8
8
|
Flowbite Components provides a comprehensive library of UI components following the Flowbite design system, implemented as Rails ViewComponents with full Tailwind CSS integration and dark mode support.
|
|
9
9
|
|
|
10
|
+
Preview the components at https://flowbite-components.substancelab.com/lookbook/
|
|
11
|
+
|
|
10
12
|
## Features
|
|
11
13
|
|
|
12
14
|
- **Full Flowbite Design System**: Faithful implementation of Flowbite components
|
|
@@ -22,7 +24,7 @@ Flowbite Components provides a comprehensive library of UI components following
|
|
|
22
24
|
Add the gem to your application's Gemfile:
|
|
23
25
|
|
|
24
26
|
```ruby
|
|
25
|
-
gem
|
|
27
|
+
gem "flowbite-components"
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
Then execute:
|
|
@@ -31,9 +33,9 @@ Then execute:
|
|
|
31
33
|
bundle install
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
###
|
|
36
|
+
### tailwindcss-rails
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
Tailwind needs to be able to look through your code in order to generate the final CSS file with the class names you actually use. To allow Tailwind to find CSS class names inside flowbite-components you need to use [tailwindcss-rails](https://github.com/rails/tailwindcss-rails) gem:
|
|
37
39
|
|
|
38
40
|
```ruby
|
|
39
41
|
gem "tailwindcss-rails", ">= 4.3.0"
|
|
@@ -44,17 +46,19 @@ gem "tailwindcss-rails", ">= 4.3.0"
|
|
|
44
46
|
Install Flowbite as an npm dependency:
|
|
45
47
|
|
|
46
48
|
```bash
|
|
47
|
-
|
|
49
|
+
yarn add flowbite
|
|
48
50
|
```
|
|
49
51
|
|
|
50
52
|
Add Flowbite to your Tailwind CSS configuration. In your `app/assets/tailwind/application.css`:
|
|
51
53
|
|
|
52
54
|
```css
|
|
53
|
-
@import "flowbite/src/themes/default";
|
|
54
55
|
@plugin "flowbite/plugin";
|
|
56
|
+
@import "flowbite/src/themes/default";
|
|
55
57
|
@import "../builds/tailwind/flowbite_components";
|
|
56
58
|
```
|
|
57
59
|
|
|
60
|
+
If you want to use one of the other [Flowbite themes](https://flowbite.com/docs/customize/theming/), change `@import "flowbite/src/themes/default";` accordingly.
|
|
61
|
+
|
|
58
62
|
## Usage examples
|
|
59
63
|
|
|
60
64
|
### Basic Form Field
|
|
@@ -80,6 +84,8 @@ Add Flowbite to your Tailwind CSS configuration. In your `app/assets/tailwind/ap
|
|
|
80
84
|
<% end %>
|
|
81
85
|
```
|
|
82
86
|
|
|
87
|
+
See more examples at https://flowbite-components.substancelab.com/lookbook/inspect/input_field/inputfield.
|
|
88
|
+
|
|
83
89
|
### Button Examples
|
|
84
90
|
|
|
85
91
|
```erb
|
|
@@ -89,16 +95,18 @@ Add Flowbite to your Tailwind CSS configuration. In your `app/assets/tailwind/ap
|
|
|
89
95
|
<% end %>
|
|
90
96
|
|
|
91
97
|
<!-- Outline button with color -->
|
|
92
|
-
<%= render Flowbite::Button::Outline.new(style: :
|
|
98
|
+
<%= render Flowbite::Button::Outline.new(style: :success) do %>
|
|
93
99
|
Outline Button
|
|
94
100
|
<% end %>
|
|
95
101
|
|
|
96
102
|
<!-- Pill button -->
|
|
97
|
-
<%= render Flowbite::Button::Pill.new(style: :
|
|
103
|
+
<%= render Flowbite::Button::Pill.new(style: :danger) do %>
|
|
98
104
|
Pill Button
|
|
99
105
|
<% end %>
|
|
100
106
|
```
|
|
101
107
|
|
|
108
|
+
See more examples at https://flowbite-components.substancelab.com/lookbook/inspect/button/default.
|
|
109
|
+
|
|
102
110
|
### Custom Input Options
|
|
103
111
|
|
|
104
112
|
```erb
|
|
@@ -116,6 +124,8 @@ Add Flowbite to your Tailwind CSS configuration. In your `app/assets/tailwind/ap
|
|
|
116
124
|
) %>
|
|
117
125
|
```
|
|
118
126
|
|
|
127
|
+
See more examples at https://flowbite-components.substancelab.com/lookbook/inspect/input_field/inputfield.
|
|
128
|
+
|
|
119
129
|
### Custom Labels
|
|
120
130
|
|
|
121
131
|
```erb
|
|
@@ -129,6 +139,8 @@ Add Flowbite to your Tailwind CSS configuration. In your `app/assets/tailwind/ap
|
|
|
129
139
|
) %>
|
|
130
140
|
```
|
|
131
141
|
|
|
142
|
+
See more examples at https://flowbite-components.substancelab.com/lookbook/inspect/input_label/inputlabel.
|
|
143
|
+
|
|
132
144
|
### Disabled and Error States
|
|
133
145
|
|
|
134
146
|
```erb
|
|
@@ -147,6 +159,8 @@ Add Flowbite to your Tailwind CSS configuration. In your `app/assets/tailwind/ap
|
|
|
147
159
|
) %>
|
|
148
160
|
```
|
|
149
161
|
|
|
162
|
+
See more examples at https://flowbite-components.substancelab.com/lookbook/inspect/input_field/disabled_state.
|
|
163
|
+
|
|
150
164
|
## How to customize components
|
|
151
165
|
|
|
152
166
|
### Add specific CSS classes
|
|
@@ -217,6 +231,33 @@ renders
|
|
|
217
231
|
- **Outline Button**: `Flowbite::Button::Outline`
|
|
218
232
|
- **Pill Button**: `Flowbite::Button::Pill`
|
|
219
233
|
|
|
234
|
+
#### Cards
|
|
235
|
+
- **Card**: `Flowbite::Card` (default card with content and title)
|
|
236
|
+
|
|
237
|
+
#### Navigation
|
|
238
|
+
- **Link**: `Flowbite::Link` (default link styling)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
## Principles
|
|
242
|
+
|
|
243
|
+
### CSS classes are additive
|
|
244
|
+
|
|
245
|
+
Passing classes via the `class` argument to a component adds the classes to the
|
|
246
|
+
default ones instead of replacing them.
|
|
247
|
+
|
|
248
|
+
```ruby
|
|
249
|
+
render(Component.new(class: "these are added"))
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
This makes for easier customization of components, where you don't have to
|
|
253
|
+
recreate the entire classlist, i.e. in order to increase sizes or add margins or
|
|
254
|
+
whatever.
|
|
255
|
+
|
|
256
|
+
If you want to replace the entire class attribute for a component, pass it as part of the `options` hash, ie
|
|
257
|
+
|
|
258
|
+
```ruby
|
|
259
|
+
render(Component.new(options: {class: "these replace the classes"}))
|
|
260
|
+
```
|
|
220
261
|
|
|
221
262
|
## Development
|
|
222
263
|
|
|
@@ -247,7 +288,7 @@ This library includes a demo application with previews for all components. To vi
|
|
|
247
288
|
1. cd demo
|
|
248
289
|
2. Run `bundle && npm install`
|
|
249
290
|
3. Run `rails server`
|
|
250
|
-
4. Visit `http://localhost:3000/
|
|
291
|
+
4. Visit `http://localhost:3000/lookbook`
|
|
251
292
|
|
|
252
293
|
## Contributing
|
|
253
294
|
|
|
@@ -267,6 +308,13 @@ Bug reports and pull requests are welcome on GitHub at [https://github.com/subst
|
|
|
267
308
|
- [ViewComponent Documentation](https://viewcomponent.org/)
|
|
268
309
|
- [Tailwind CSS Documentation](https://tailwindcss.com/docs)
|
|
269
310
|
|
|
311
|
+
## Other ViewComponent-based libraries
|
|
312
|
+
|
|
313
|
+
If Flowbite isn't your preference, perhaps one of these other component libraries suits you better?
|
|
314
|
+
|
|
315
|
+
* [GOV.UK Components](https://govuk-components.netlify.app/introduction/get-started/)
|
|
316
|
+
* [Primer Product UI for Rails](https://primer.style/product/getting-started/rails/)
|
|
317
|
+
|
|
270
318
|
## Other Flowbite component libraries
|
|
271
319
|
|
|
272
320
|
* https://flowbite-react.com/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowbite
|
|
4
|
+
class Breadcrumb
|
|
5
|
+
# Renders a breadcrumb home icon.
|
|
6
|
+
#
|
|
7
|
+
# This is typically used as a prefix icon in the first breadcrumb item,
|
|
8
|
+
# but can be used standalone if needed.
|
|
9
|
+
#
|
|
10
|
+
# @example Standalone usage
|
|
11
|
+
# <%= render Flowbite::Breadcrumb::HomeIcon.new %>
|
|
12
|
+
class HomeIcon < ViewComponent::Base
|
|
13
|
+
def call
|
|
14
|
+
tag.svg(
|
|
15
|
+
class: "w-3 h-3 me-2.5",
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
18
|
+
fill: "currentColor",
|
|
19
|
+
viewBox: "0 0 20 20"
|
|
20
|
+
) do
|
|
21
|
+
tag.path(
|
|
22
|
+
d: "m19.707 9.293-2-2-7-7a1 1 0 0 0-1.414 0l-7 7-2 2a1 1 0 0 0 1.414 1.414L2 10.414V18a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v4a1 1 0 0 0 1 1h3a2 2 0 0 0 2-2v-7.586l.293.293a1 1 0 0 0 1.414-1.414Z"
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowbite
|
|
4
|
+
class Breadcrumb
|
|
5
|
+
class Item
|
|
6
|
+
# Renders the current page breadcrumb item.
|
|
7
|
+
# Current items are rendered as non-interactive spans with different styling.
|
|
8
|
+
#
|
|
9
|
+
# @param options [Hash] Additional HTML attributes to pass to the span element.
|
|
10
|
+
#
|
|
11
|
+
# @example Current page item
|
|
12
|
+
# <%= render Flowbite::Breadcrumb::Item::Current.new { "Current Page" } %>
|
|
13
|
+
class Current < Item
|
|
14
|
+
def initialize(**options)
|
|
15
|
+
super(href: nil, **options)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
|
|
20
|
+
def item_options
|
|
21
|
+
{"aria-current": "page"}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def render_link
|
|
25
|
+
link_options = {class: link_classes}.merge(options)
|
|
26
|
+
content_tag(:span, content, **link_options)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def link_classes
|
|
30
|
+
["ms-1", "text-sm", "font-medium", "text-body-subtle"]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowbite
|
|
4
|
+
class Breadcrumb
|
|
5
|
+
class Item
|
|
6
|
+
# Renders the first breadcrumb item (typically home).
|
|
7
|
+
# First items don't show a separator icon.
|
|
8
|
+
#
|
|
9
|
+
# @param href [String] The URL for the breadcrumb link.
|
|
10
|
+
# @param options [Hash] Additional HTML attributes to pass to the link element.
|
|
11
|
+
#
|
|
12
|
+
# @example First item
|
|
13
|
+
# <%= render Flowbite::Breadcrumb::Item::First.new(href: "/") { "Home" } %>
|
|
14
|
+
class First < Item
|
|
15
|
+
protected
|
|
16
|
+
|
|
17
|
+
def item_options
|
|
18
|
+
{class: "inline-flex items-center"}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def link_classes
|
|
22
|
+
["text-sm", "font-medium", "inline-flex", "items-center", "text-body", "hover:text-fg-brand"]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def prefix_icon
|
|
26
|
+
nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def render_link
|
|
30
|
+
icon = render(Flowbite::Breadcrumb::HomeIcon.new)
|
|
31
|
+
link_options = {class: link_classes}.merge(options)
|
|
32
|
+
content_tag(:a, safe_join([icon, content]), href: href, **link_options)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowbite
|
|
4
|
+
class Breadcrumb
|
|
5
|
+
# Base class for rendering a breadcrumb item (middle items in the breadcrumb trail).
|
|
6
|
+
#
|
|
7
|
+
# @param href [String] The URL for the breadcrumb link.
|
|
8
|
+
# @param options [Hash] Additional HTML attributes to pass to the link element.
|
|
9
|
+
#
|
|
10
|
+
# @example Middle item
|
|
11
|
+
# <%= render Flowbite::Breadcrumb::Item.new(href: "/projects") { "Projects" } %>
|
|
12
|
+
class Item < ViewComponent::Base
|
|
13
|
+
attr_reader :href, :options
|
|
14
|
+
|
|
15
|
+
def initialize(href:, **options)
|
|
16
|
+
super()
|
|
17
|
+
@href = href
|
|
18
|
+
@options = options
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def call
|
|
22
|
+
content_tag(:li, item_options) do
|
|
23
|
+
content_tag(:div, class: "flex items-center") do
|
|
24
|
+
concat(render(prefix_icon)) if prefix_icon
|
|
25
|
+
concat(render_link)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
|
|
32
|
+
def item_options
|
|
33
|
+
{}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def prefix_icon
|
|
37
|
+
Flowbite::Breadcrumb::SeparatorIcon.new
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def render_link
|
|
41
|
+
link_options = {class: link_classes}.merge(options)
|
|
42
|
+
content_tag(:a, content, href: href, **link_options)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def link_classes
|
|
46
|
+
["ms-1", "text-sm", "font-medium", "text-body", "hover:text-fg-brand"]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowbite
|
|
4
|
+
class Breadcrumb
|
|
5
|
+
# Renders a breadcrumb separator icon.
|
|
6
|
+
#
|
|
7
|
+
# This is automatically used by Breadcrumb::Item components, but can be
|
|
8
|
+
# used standalone if needed.
|
|
9
|
+
#
|
|
10
|
+
# @example Standalone usage
|
|
11
|
+
# <%= render Flowbite::Breadcrumb::SeparatorIcon.new %>
|
|
12
|
+
class SeparatorIcon < ViewComponent::Base
|
|
13
|
+
def call
|
|
14
|
+
tag.svg(
|
|
15
|
+
class: "w-3.5 h-3.5 rtl:rotate-180 text-body",
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
18
|
+
fill: "none",
|
|
19
|
+
height: 24,
|
|
20
|
+
viewBox: "0 0 24 24",
|
|
21
|
+
width: 24
|
|
22
|
+
) do
|
|
23
|
+
tag.path(
|
|
24
|
+
stroke: "currentColor",
|
|
25
|
+
"stroke-linecap": "round",
|
|
26
|
+
"stroke-linejoin": "round",
|
|
27
|
+
"stroke-width": "2",
|
|
28
|
+
d: "m9 5 7 7-7 7"
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Flowbite
|
|
4
|
+
# Renders a breadcrumb navigation component.
|
|
5
|
+
#
|
|
6
|
+
# Use {Flowbite::Breadcrumb} and the child {Flowbite::Breadcrumb::Item}
|
|
7
|
+
# components to create and indicate a series of page structure and URLs to
|
|
8
|
+
# help the user navigate through the website.
|
|
9
|
+
#
|
|
10
|
+
# Breadcrumbs consist of the following components:
|
|
11
|
+
#
|
|
12
|
+
# - {Flowbite::Breadcrumb}: Container for breadcrumb items.
|
|
13
|
+
# - {Flowbite::Breadcrumb::HomeIcon}: Home icon for the first breadcrumb item.
|
|
14
|
+
# - {Flowbite::Breadcrumb::SeparatorIcon}: Separator between breadcrumb items.
|
|
15
|
+
# - {Flowbite::Breadcrumb::Item}: An individual breadcrumb item.
|
|
16
|
+
# - {Flowbite::Breadcrumb::Item::Current}: An individual breadcrumb item
|
|
17
|
+
# without a link, usually used for the current page in the breadcrumb trail.
|
|
18
|
+
# - {Flowbite::Breadcrumb::Item::First}: An individual breadcrumb item with a
|
|
19
|
+
# home icon on it.
|
|
20
|
+
#
|
|
21
|
+
# @example Usage
|
|
22
|
+
# <%= render(Flowbite::Breadcrumb.new) do |breadcrumb| %>
|
|
23
|
+
# <% breadcrumb.with_item do %>
|
|
24
|
+
# <%= render(Flowbite::Breadcrumb::Item::First.new(href: "/")) { "Root page" } %>
|
|
25
|
+
# <% end %>
|
|
26
|
+
# <% breadcrumb.with_item do %>
|
|
27
|
+
# <%= render(Flowbite::Breadcrumb::Item.new(href: "/projects")) { "Parent page" } %>
|
|
28
|
+
# <% end %>
|
|
29
|
+
# <% breadcrumb.with_item do %>
|
|
30
|
+
# <%= render(Flowbite::Breadcrumb::Item::Current.new) { "Current Page" } %>
|
|
31
|
+
# <% end %>
|
|
32
|
+
# <% end %>
|
|
33
|
+
#
|
|
34
|
+
# @viewcomponent_slot [Flowbite::Breadcrumb::Item] items The items of the
|
|
35
|
+
# breadcrumb trail. Use {Flowbite::Breadcrumb::Item::First} for the first
|
|
36
|
+
# item to get a home icon, and {Flowbite::Breadcrumb::Item::Current} for the
|
|
37
|
+
# last item to render it without a link.
|
|
38
|
+
#
|
|
39
|
+
# @lookbook_embed BreadcrumbPreview
|
|
40
|
+
# @see https://flowbite.com/docs/components/breadcrumb/
|
|
41
|
+
class Breadcrumb < ViewComponent::Base
|
|
42
|
+
renders_many :items
|
|
43
|
+
|
|
44
|
+
def call
|
|
45
|
+
content_tag(:nav, class: "flex", "aria-label": "Breadcrumb") do
|
|
46
|
+
content_tag(:ol, class: "inline-flex items-center space-x-1 md:space-x-2 rtl:space-x-reverse") do
|
|
47
|
+
items.each do |item|
|
|
48
|
+
concat(item)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -4,18 +4,33 @@ module Flowbite
|
|
|
4
4
|
class Button
|
|
5
5
|
class Outline < Flowbite::Button
|
|
6
6
|
class << self
|
|
7
|
-
# rubocop:disable Layout/LineLength
|
|
7
|
+
# rubocop:disable Layout/LineLength, Metrics/MethodLength
|
|
8
8
|
def styles
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
default: ["text-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
default: ["
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
Flowbite::Styles.from_hash({
|
|
10
|
+
danger: {
|
|
11
|
+
default: ["focus:outline-none", "text-danger", "bg-transparent", "box-border", "border", "border-danger", "hover:text-white", "hover:bg-danger-strong", "focus:ring-4", "focus:ring-danger-medium", "shadow-xs", "font-medium", "leading-5", "rounded-base", "text-center", "me-2", "mb-2"]
|
|
12
|
+
},
|
|
13
|
+
dark: {
|
|
14
|
+
default: ["focus:outline-none", "text-dark", "bg-transparent", "box-border", "border", "border-dark", "hover:text-white", "hover:bg-dark-strong", "focus:ring-4", "focus:ring-neutral-tertiary", "shadow-xs", "font-medium", "leading-5", "rounded-base", "text-center", "me-2", "mb-2"]
|
|
15
|
+
},
|
|
16
|
+
default: {
|
|
17
|
+
default: ["focus:outline-none", "text-brand", "bg-transparent", "box-border", "border", "border-brand", "hover:text-white", "hover:bg-brand-strong", "focus:ring-4", "focus:ring-brand-medium", "shadow-xs", "font-medium", "leading-5", "rounded-base", "text-center", "me-2", "mb-2"]
|
|
18
|
+
},
|
|
19
|
+
secondary: {
|
|
20
|
+
default: ["focus:outline-none", "text-body", "bg-transparent", "box-border", "border", "border-default-medium", "hover:bg-neutral-tertiary-medium", "focus:ring-4", "focus:ring-neutral-tertiary", "shadow-xs", "font-medium", "leading-5", "rounded-base", "text-center", "me-2", "mb-2"]
|
|
21
|
+
},
|
|
22
|
+
success: {
|
|
23
|
+
default: ["focus:outline-none", "text-success", "bg-transparent", "box-border", "border", "border-success", "hover:text-white", "hover:bg-success-strong", "focus:ring-4", "focus:ring-success-medium", "shadow-xs", "font-medium", "leading-5", "rounded-base", "text-center", "me-2", "mb-2"]
|
|
24
|
+
},
|
|
25
|
+
tertiary: {
|
|
26
|
+
default: ["focus:outline-none", "text-body", "bg-transparent", "box-border", "border", "border-default", "hover:bg-neutral-secondary-medium", "focus:ring-4", "focus:ring-neutral-tertiary-soft", "shadow-xs", "font-medium", "leading-5", "rounded-base", "text-center", "me-2", "mb-2"]
|
|
27
|
+
},
|
|
28
|
+
warning: {
|
|
29
|
+
default: ["focus:outline-none", "text-warning", "bg-transparent", "box-border", "border", "border-warning", "hover:text-white", "hover:bg-warning-strong", "focus:ring-4", "focus:ring-warning-medium", "shadow-xs", "font-medium", "leading-5", "rounded-base", "text-center", "me-2", "mb-2"]
|
|
30
|
+
}
|
|
31
|
+
}.freeze)
|
|
17
32
|
end
|
|
18
|
-
# rubocop:enable Layout/LineLength
|
|
33
|
+
# rubocop:enable Layout/LineLength, Metrics/MethodLength
|
|
19
34
|
end
|
|
20
35
|
end
|
|
21
36
|
end
|
|
@@ -6,32 +6,32 @@ module Flowbite
|
|
|
6
6
|
class << self
|
|
7
7
|
# rubocop:disable Layout/LineLength, Metrics/MethodLength
|
|
8
8
|
def styles
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
default: ["
|
|
12
|
-
|
|
13
|
-
dark:
|
|
14
|
-
default: ["text-white", "bg-
|
|
15
|
-
|
|
16
|
-
default:
|
|
17
|
-
default: ["text-white", "bg-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
default: ["text-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
default: ["text-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
default: ["text-white", "bg-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
default: ["text-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
default: ["text-white", "bg-
|
|
33
|
-
|
|
34
|
-
}
|
|
9
|
+
Flowbite::Styles.from_hash({
|
|
10
|
+
danger: {
|
|
11
|
+
default: ["focus:outline-none", "text-white", "bg-danger", "box-border", "border", "border-transparent", "hover:bg-danger-strong", "focus:ring-4", "focus:ring-danger-medium", "shadow-xs", "font-medium", "leading-5", "rounded-full", "text-center"]
|
|
12
|
+
},
|
|
13
|
+
dark: {
|
|
14
|
+
default: ["focus:outline-none", "text-white", "bg-dark", "box-border", "border", "border-transparent", "hover:bg-dark-strong", "focus:ring-4", "focus:ring-neutral-tertiary", "shadow-xs", "font-medium", "leading-5", "rounded-full", "text-center"]
|
|
15
|
+
},
|
|
16
|
+
default: {
|
|
17
|
+
default: ["focus:outline-none", "text-white", "bg-brand", "box-border", "border", "border-transparent", "hover:bg-brand-strong", "focus:ring-4", "focus:ring-brand-medium", "shadow-xs", "font-medium", "leading-5", "rounded-full", "text-center"]
|
|
18
|
+
},
|
|
19
|
+
ghost: {
|
|
20
|
+
default: ["focus:outline-none", "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-full", "text-center"]
|
|
21
|
+
},
|
|
22
|
+
secondary: {
|
|
23
|
+
default: ["focus:outline-none", "text-body", "bg-neutral-secondary-medium", "box-border", "border", "border-default-medium", "hover:bg-neutral-tertiary-medium", "focus:ring-4", "focus:ring-neutral-tertiary", "shadow-xs", "font-medium", "leading-5", "rounded-full", "text-center"]
|
|
24
|
+
},
|
|
25
|
+
success: {
|
|
26
|
+
default: ["focus:outline-none", "text-white", "bg-success", "box-border", "border", "border-transparent", "hover:bg-success-strong", "focus:ring-4", "focus:ring-success-medium", "shadow-xs", "font-medium", "leading-5", "rounded-full", "text-center"]
|
|
27
|
+
},
|
|
28
|
+
tertiary: {
|
|
29
|
+
default: ["focus:outline-none", "text-body", "bg-neutral-primary-soft", "box-border", "border", "border-default", "hover:bg-neutral-secondary-medium", "focus:ring-4", "focus:ring-neutral-tertiary-soft", "shadow-xs", "font-medium", "leading-5", "rounded-full", "text-center"]
|
|
30
|
+
},
|
|
31
|
+
warning: {
|
|
32
|
+
default: ["focus:outline-none", "text-white", "bg-warning", "box-border", "border", "border-transparent", "hover:bg-warning-strong", "focus:ring-4", "focus:ring-warning-medium", "shadow-xs", "font-medium", "leading-5", "rounded-full", "text-center"]
|
|
33
|
+
}
|
|
34
|
+
}.freeze)
|
|
35
35
|
end
|
|
36
36
|
# rubocop:enable Layout/LineLength, Metrics/MethodLength
|
|
37
37
|
end
|