ui_components 0.1.0 → 0.1.2
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/README.md +18 -11
- data/app/assets/javascripts/ui_components/controllers/countdown_controller.js +55 -0
- data/app/components/documentation/body/example_preview_component.rb +1 -1
- data/app/components/documentation/body_component.html.erb +1 -1
- data/app/components/documentation/body_component.rb +4 -4
- data/app/components/ui_components/daisy_ui/action/button_component.rb +13 -13
- data/app/components/ui_components/daisy_ui/action/dropdown/anchor_component.rb +1 -11
- data/app/components/ui_components/daisy_ui/action/dropdown/card/item_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/card_component.rb +4 -14
- data/app/components/ui_components/daisy_ui/action/dropdown/menu/item_component.rb +32 -0
- data/app/components/ui_components/daisy_ui/action/dropdown/menu_component.rb +2 -12
- data/app/components/ui_components/daisy_ui/action/dropdown_component.rb +12 -12
- data/app/components/ui_components/daisy_ui/action/modal/anchor_component.rb +1 -11
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action/item_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/action_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/body_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/close_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box/title_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog/box_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/modal/dialog_component.rb +2 -12
- data/app/components/ui_components/daisy_ui/action/swap/off_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/swap/on_component.rb +0 -9
- data/app/components/ui_components/daisy_ui/action/swap_component.rb +6 -6
- data/app/components/ui_components/daisy_ui/base_component.rb +24 -3
- data/app/components/ui_components/daisy_ui/data_display/accordion/item/anchor_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion/item/body_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/accordion/item_component.rb +15 -15
- data/app/components/ui_components/daisy_ui/data_display/avatar/item/box_component.rb +63 -0
- data/app/components/ui_components/daisy_ui/data_display/avatar/item_component.rb +8 -8
- data/app/components/ui_components/daisy_ui/data_display/badge_component.rb +7 -7
- data/app/components/ui_components/daisy_ui/data_display/card/body/action_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/card/body/context_component.rb +17 -0
- data/app/components/ui_components/daisy_ui/data_display/card/body/title_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/card/body_component.rb +34 -0
- data/app/components/ui_components/daisy_ui/data_display/card/figure_component.rb +15 -0
- data/app/components/ui_components/daisy_ui/data_display/card_component.rb +83 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel/indicator_component.rb +18 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel/item/passer_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel/item_component.rb +26 -0
- data/app/components/ui_components/daisy_ui/data_display/carousel_component.rb +63 -0
- data/app/components/ui_components/daisy_ui/data_display/chat/bubble_component.rb +42 -0
- data/app/components/ui_components/daisy_ui/data_display/chat/footer_component.rb +18 -0
- data/app/components/ui_components/daisy_ui/data_display/chat/header_component.rb +18 -0
- data/app/components/ui_components/daisy_ui/data_display/chat_component.rb +58 -0
- data/app/components/ui_components/daisy_ui/data_display/countdown/item_component.rb +49 -0
- data/app/components/ui_components/daisy_ui/data_display/countdown_component.rb +37 -0
- data/app/components/ui_components/daisy_ui/data_display/{accordion/anchor_component.rb → diff/item1_component.rb} +5 -8
- data/app/components/ui_components/daisy_ui/data_display/{accordion/body_component.rb → diff/item2_component.rb} +6 -8
- data/app/components/ui_components/daisy_ui/data_display/diff/resizer_component.rb +25 -0
- data/app/components/ui_components/daisy_ui/data_display/diff_component.rb +35 -0
- data/app/components/ui_components/daisy_ui/data_display/kbd_component.rb +40 -0
- data/app/components/ui_components/daisy_ui/data_display/list/item_component.rb +40 -0
- data/app/components/ui_components/daisy_ui/data_display/list_component.rb +22 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/action_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/description_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/figure_component.rb +24 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/title_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item/value_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/stat/item_component.rb +39 -0
- data/app/components/ui_components/daisy_ui/data_display/stat_component.rb +50 -0
- data/app/components/ui_components/daisy_ui/data_display/status_component.rb +59 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/body_component.rb +23 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/foot_component.rb +23 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/head_component.rb +23 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/row/data_component.rb +19 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/row/header_component.rb +19 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item/row_component.rb +32 -0
- data/app/components/ui_components/daisy_ui/data_display/table/item_component.rb +29 -0
- data/app/components/ui_components/daisy_ui/data_display/table_component.rb +72 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_end_component.rb +44 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_middle_component.rb +20 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/item_start_component.rb +44 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item/line_component.rb +17 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline/item_component.rb +40 -0
- data/app/components/ui_components/daisy_ui/data_display/timeline_component.rb +50 -0
- data/app/controllers/ui_components/daisy_ui/data_display_components_controller.rb +22 -0
- data/app/helpers/data_display/carousel_helper.rb +13 -0
- data/app/views/ui_components/daisy_ui/action_components/button.html.erb +35 -33
- data/app/views/ui_components/daisy_ui/action_components/dropdown.html.erb +38 -25
- data/app/views/ui_components/daisy_ui/action_components/modal.html.erb +31 -18
- data/app/views/ui_components/daisy_ui/action_components/swap.html.erb +31 -17
- data/app/views/ui_components/daisy_ui/data_display_components/accordion.html.erb +59 -105
- data/app/views/ui_components/daisy_ui/data_display_components/avatar.html.erb +40 -27
- data/app/views/ui_components/daisy_ui/data_display_components/badge.html.erb +45 -42
- data/app/views/ui_components/daisy_ui/data_display_components/card.html.erb +302 -0
- data/app/views/ui_components/daisy_ui/data_display_components/carousel.html.erb +303 -0
- data/app/views/ui_components/daisy_ui/data_display_components/chat.html.erb +190 -0
- data/app/views/ui_components/daisy_ui/data_display_components/countdown.html.erb +211 -0
- data/app/views/ui_components/daisy_ui/data_display_components/diff.html.erb +69 -0
- data/app/views/ui_components/daisy_ui/data_display_components/kbd.html.erb +157 -0
- data/app/views/ui_components/daisy_ui/data_display_components/list.html.erb +247 -0
- data/app/views/ui_components/daisy_ui/data_display_components/stat.html.erb +208 -0
- data/app/views/ui_components/daisy_ui/data_display_components/status.html.erb +93 -0
- data/app/views/ui_components/daisy_ui/data_display_components/table.html.erb +358 -0
- data/app/views/ui_components/daisy_ui/data_display_components/timeline.html.erb +431 -0
- data/app/views/ui_components/daisy_ui/home/index.html.erb +11 -0
- data/config/routes.rb +13 -2
- data/lib/tasks/ui_components_tasks.rake +0 -3
- data/lib/ui_components/config/daisy_ui_class_names.rb +3 -2
- data/lib/ui_components/config/tailwind_class_names.rb +27 -4
- data/lib/ui_components/version.rb +1 -1
- metadata +65 -7
- data/app/components/ui_components/daisy_ui/action/dropdown/card_item_component.rb +0 -29
- data/app/components/ui_components/daisy_ui/action/dropdown/list_item_component.rb +0 -30
- data/app/components/ui_components/daisy_ui/data_display/avatar/box_component.rb +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 120dc503191b4b508b4ef7ce75702960054a54e35da8d23e885ee76c5374f28f
|
4
|
+
data.tar.gz: af4df82c998db4bf226f4225292514daa11863522d8bc7dbbd14fe1acd5aac41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 368bde69e7761b242bcd58f27976e5d43ccba197739c7f44c559bb66f2df0cfade5a542ae8768a5e8431f054ab6b53675978957d5f7ed094ecd4d80215658e32
|
7
|
+
data.tar.gz: 64e902a2adab8a39438705b81c94db0c9e63031f4894eb6ff9a4b1c765353296bbe40f76585b45abf13c6ed483084f0989d230935a4119fe5eaaa9f60d661b6b
|
data/README.md
CHANGED
@@ -1,28 +1,35 @@
|
|
1
1
|
# UiComponents
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ui_components`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
This gem makes it easy to set up and view UI components using Daisy UI.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
Install the gem and add to the application's Gemfile by executing:
|
7
|
+
Add the gem to your Gemfile:
|
12
8
|
|
13
9
|
```bash
|
14
|
-
bundle add
|
10
|
+
bundle add ui_components
|
15
11
|
```
|
16
12
|
|
17
|
-
|
13
|
+
Or install it directly:
|
18
14
|
|
19
15
|
```bash
|
20
|
-
gem install
|
16
|
+
gem install ui_components
|
21
17
|
```
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
21
|
+
To set up the gem and prepare the components, run:
|
22
|
+
```bash
|
23
|
+
bin/rails ui_components:setup
|
24
|
+
```
|
25
|
+
|
26
|
+
After setup, start your app:
|
27
|
+
```bash
|
28
|
+
bin/dev
|
29
|
+
```
|
30
|
+
|
31
|
+
>Then, open your browser and navigate to: [UI Components](http://localhost:3000/ui_components/daisy_ui)
|
32
|
+
|
26
33
|
|
27
34
|
## Development
|
28
35
|
|
@@ -40,4 +47,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
47
|
|
41
48
|
## Code of Conduct
|
42
49
|
|
43
|
-
Everyone interacting in the UiComponents project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ui_components/blob/main/CODE_OF_CONDUCT.md).
|
50
|
+
Everyone interacting in the UiComponents project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ui_components/blob/main/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ["value"]
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
this.timers = []
|
8
|
+
this.targetsData = []
|
9
|
+
|
10
|
+
this.valueTargets.forEach(target => {
|
11
|
+
const type = target.dataset.countdownType || "second"
|
12
|
+
const initialStr = target.style.getPropertyValue('--value').trim()
|
13
|
+
const initial = parseInt(initialStr) || 0
|
14
|
+
const dataObj = { target, type, original: initial, current: initial }
|
15
|
+
|
16
|
+
this.targetsData.push(dataObj)
|
17
|
+
|
18
|
+
let timer = this.startCountdown(dataObj)
|
19
|
+
|
20
|
+
this.timers.push(timer)
|
21
|
+
})
|
22
|
+
}
|
23
|
+
|
24
|
+
startCountdown(dataObj) {
|
25
|
+
let intervalDuration
|
26
|
+
|
27
|
+
switch (dataObj.type.toLowerCase()) {
|
28
|
+
case "minute":
|
29
|
+
intervalDuration = 60 * 1000
|
30
|
+
break
|
31
|
+
case "hour":
|
32
|
+
intervalDuration = 3600 * 1000
|
33
|
+
break
|
34
|
+
case "day":
|
35
|
+
intervalDuration = 86400 * 1000
|
36
|
+
break
|
37
|
+
default:
|
38
|
+
intervalDuration = 1000
|
39
|
+
}
|
40
|
+
|
41
|
+
return setInterval(() => {
|
42
|
+
if (dataObj.current > 0) {
|
43
|
+
dataObj.current--
|
44
|
+
} else {
|
45
|
+
dataObj.current = dataObj.original
|
46
|
+
}
|
47
|
+
dataObj.target.textContent = dataObj.current
|
48
|
+
dataObj.target.style.setProperty('--value', dataObj.current)
|
49
|
+
}, intervalDuration)
|
50
|
+
}
|
51
|
+
|
52
|
+
disconnect() {
|
53
|
+
this.timers.forEach(timer => clearInterval(timer))
|
54
|
+
}
|
55
|
+
}
|
@@ -22,19 +22,19 @@ module Documentation
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def set_preview_options
|
25
|
-
@preview_options.merge!(class:
|
25
|
+
@preview_options.merge!(class: preview_css_class_string)
|
26
26
|
@preview_options.compact_blank!
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def preview_css_class_string
|
30
30
|
TailwindMerge::Merger.new.merge([
|
31
31
|
*CSS_CLASSES_DEFAULT,
|
32
|
-
@preview_options
|
32
|
+
@preview_options.delete(:css_class)
|
33
33
|
])
|
34
34
|
end
|
35
35
|
|
36
36
|
def set_code_options
|
37
|
-
@code_options.merge!(class: @code_options
|
37
|
+
@code_options.merge!(class: @code_options.delete(:css_class))
|
38
38
|
@code_options.compact_blank!
|
39
39
|
end
|
40
40
|
end
|
@@ -4,8 +4,8 @@ module UiComponents
|
|
4
4
|
module DaisyUi
|
5
5
|
module Action
|
6
6
|
class ButtonComponent < BaseComponent
|
7
|
-
SHAPES = %w[square circle]
|
8
|
-
WIDE_SIZES = %w[wide block]
|
7
|
+
SHAPES = %w[square circle].freeze
|
8
|
+
WIDE_SIZES = %w[wide block].freeze
|
9
9
|
|
10
10
|
CSS_CLASSES_DEFAULT = %w[btn].freeze
|
11
11
|
CSS_CLASSES_VARIANTS = (
|
@@ -42,14 +42,14 @@ module UiComponents
|
|
42
42
|
|
43
43
|
private
|
44
44
|
|
45
|
-
def
|
45
|
+
def css_class_string
|
46
46
|
TailwindMerge::Merger.new.merge([
|
47
47
|
*css_classes_default,
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
size_css_class,
|
49
|
+
color_css_class,
|
50
|
+
kind_css_class,
|
51
|
+
shape_css_class,
|
52
|
+
wide_size_css_class,
|
53
53
|
@css_class
|
54
54
|
])
|
55
55
|
end
|
@@ -58,23 +58,23 @@ module UiComponents
|
|
58
58
|
CSS_CLASSES_DEFAULT unless @no_btn
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def size_css_class
|
62
62
|
"btn-#{@size}" if SIZES.include?(@size)
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def color_css_class
|
66
66
|
"btn-#{@color}" if COLORS.include?(@color)
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def kind_css_class
|
70
70
|
"btn-#{@kind}" if KINDS.include?(@kind)
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def shape_css_class
|
74
74
|
"btn-#{@shape}" if SHAPES.include?(@shape)
|
75
75
|
end
|
76
76
|
|
77
|
-
def
|
77
|
+
def wide_size_css_class
|
78
78
|
"btn-#{@wide_size}" if WIDE_SIZES.include?(@wide_size)
|
79
79
|
end
|
80
80
|
end
|
@@ -14,19 +14,9 @@ module UiComponents
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def
|
18
|
-
@options.merge!(class: class_string)
|
19
|
-
@options.merge!(style: @css_style)
|
17
|
+
def other_options
|
20
18
|
@options.merge!(role: "button")
|
21
19
|
@options.merge!(tabindex: "0")
|
22
|
-
@options.compact_blank!
|
23
|
-
end
|
24
|
-
|
25
|
-
def class_string
|
26
|
-
TailwindMerge::Merger.new.merge([
|
27
|
-
*CSS_CLASSES_DEFAULT,
|
28
|
-
@css_class
|
29
|
-
])
|
30
20
|
end
|
31
21
|
end
|
32
22
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module Action
|
6
|
+
module Dropdown
|
7
|
+
module Card
|
8
|
+
class ItemComponent < BaseComponent
|
9
|
+
CSS_CLASSES_DEFAULT = %w[card-body].freeze
|
10
|
+
CSS_CLASSES = CSS_CLASSES_DEFAULT
|
11
|
+
|
12
|
+
erb_template <<-ERB
|
13
|
+
<%= tag.div(**set_options) { content } %>
|
14
|
+
ERB
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -5,10 +5,10 @@ module UiComponents
|
|
5
5
|
module Action
|
6
6
|
module Dropdown
|
7
7
|
class CardComponent < BaseComponent
|
8
|
-
CSS_CLASSES_DEFAULT = %w[dropdown-content card card-sm bg-base-100 z-1 w-64 shadow-md]
|
8
|
+
CSS_CLASSES_DEFAULT = %w[dropdown-content card card-sm bg-base-100 z-1 w-64 shadow-md].freeze
|
9
9
|
CSS_CLASSES = (
|
10
10
|
CSS_CLASSES_DEFAULT +
|
11
|
-
|
11
|
+
Card::ItemComponent::CSS_CLASSES
|
12
12
|
).freeze
|
13
13
|
|
14
14
|
erb_template <<-ERB
|
@@ -17,22 +17,12 @@ module UiComponents
|
|
17
17
|
<% end %>
|
18
18
|
ERB
|
19
19
|
|
20
|
-
renders_one :item,
|
20
|
+
renders_one :item, Card::ItemComponent
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
def
|
25
|
-
@options.merge!(class: class_string)
|
26
|
-
@options.merge!(style: @css_style)
|
24
|
+
def other_options
|
27
25
|
@options.merge!(tabindex: "0")
|
28
|
-
@options.compact_blank!
|
29
|
-
end
|
30
|
-
|
31
|
-
def class_string
|
32
|
-
TailwindMerge::Merger.new.merge([
|
33
|
-
*CSS_CLASSES_DEFAULT,
|
34
|
-
@css_class
|
35
|
-
])
|
36
26
|
end
|
37
27
|
end
|
38
28
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiComponents
|
4
|
+
module DaisyUi
|
5
|
+
module Action
|
6
|
+
module Dropdown
|
7
|
+
module Menu
|
8
|
+
class ItemComponent < BaseComponent
|
9
|
+
erb_template <<-ERB
|
10
|
+
<%= tag.li(**set_options) do %>
|
11
|
+
<% if @with_tag_a %>
|
12
|
+
<a><%= content %></a>
|
13
|
+
<% else %>
|
14
|
+
<%= content %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
ERB
|
18
|
+
|
19
|
+
def initialize(
|
20
|
+
with_tag_a: true,
|
21
|
+
**args
|
22
|
+
)
|
23
|
+
@with_tag_a = with_tag_a
|
24
|
+
|
25
|
+
super(**args)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -16,22 +16,12 @@ module UiComponents
|
|
16
16
|
<% end %>
|
17
17
|
ERB
|
18
18
|
|
19
|
-
renders_many :items,
|
19
|
+
renders_many :items, Menu::ItemComponent
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
@options.merge!(class: class_string)
|
25
|
-
@options.merge!(style: @css_style)
|
23
|
+
def other_options
|
26
24
|
@options.merge!(tabindex: "0")
|
27
|
-
@options.compact_blank!
|
28
|
-
end
|
29
|
-
|
30
|
-
def class_string
|
31
|
-
TailwindMerge::Merger.new.merge([
|
32
|
-
*CSS_CLASSES_DEFAULT,
|
33
|
-
@css_class
|
34
|
-
])
|
35
25
|
end
|
36
26
|
end
|
37
27
|
end
|
@@ -4,11 +4,11 @@ module UiComponents
|
|
4
4
|
module DaisyUi
|
5
5
|
module Action
|
6
6
|
class DropdownComponent < BaseComponent
|
7
|
-
CSS_CLASSES_DEFAULT = %w[dropdown]
|
7
|
+
CSS_CLASSES_DEFAULT = %w[dropdown].freeze
|
8
8
|
CSS_CLASSES_VARIANTS = (
|
9
9
|
%w[dropdown-hover dropdown-open] +
|
10
|
-
ALIGNS.map { |
|
11
|
-
AXES.map { |
|
10
|
+
ALIGNS.map { |key| "dropdown-#{key}" } +
|
11
|
+
AXES.map { |key| "dropdown-#{key}" }
|
12
12
|
).freeze
|
13
13
|
|
14
14
|
CSS_CLASSES = (
|
@@ -47,30 +47,30 @@ module UiComponents
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
def
|
50
|
+
def css_class_string
|
51
51
|
TailwindMerge::Merger.new.merge([
|
52
52
|
*CSS_CLASSES_DEFAULT,
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
align_css_class,
|
54
|
+
axis_css_class,
|
55
|
+
hover_css_class,
|
56
|
+
opened_css_class,
|
57
57
|
@css_class
|
58
58
|
])
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def align_css_class
|
62
62
|
"dropdown-#{@align}" if ALIGNS.include?(@align)
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def axis_css_class
|
66
66
|
"dropdown-#{@axis}" if AXES.include?(@axis)
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def hover_css_class
|
70
70
|
"dropdown-hover" if @hover
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def opened_css_class
|
74
74
|
"dropdown-open" if @opened
|
75
75
|
end
|
76
76
|
end
|
@@ -23,18 +23,8 @@ module UiComponents
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def
|
27
|
-
@options.merge!(class: class_string)
|
28
|
-
@options.merge!(style: @css_style) if @css_style.present?
|
26
|
+
def other_options
|
29
27
|
@options.merge!(onclick: "#{@opener}.showModal()")
|
30
|
-
@options.compact_blank!
|
31
|
-
end
|
32
|
-
|
33
|
-
def class_string
|
34
|
-
TailwindMerge::Merger.new.merge([
|
35
|
-
*CSS_CLASSES_DEFAULT,
|
36
|
-
@css_class
|
37
|
-
])
|
38
28
|
end
|
39
29
|
end
|
40
30
|
end
|
@@ -36,20 +36,10 @@ module UiComponents
|
|
36
36
|
super(**args)
|
37
37
|
end
|
38
38
|
|
39
|
-
def set_options
|
40
|
-
@options.merge!(class: class_string)
|
41
|
-
@options.merge!(style: @css_style) if @css_style.present?
|
42
|
-
@options.merge!(id: @opener)
|
43
|
-
@options.compact_blank!
|
44
|
-
end
|
45
|
-
|
46
39
|
private
|
47
40
|
|
48
|
-
def
|
49
|
-
|
50
|
-
*CSS_CLASSES_DEFAULT,
|
51
|
-
@css_class
|
52
|
-
])
|
41
|
+
def other_options
|
42
|
+
@options.merge!(id: @opener)
|
53
43
|
end
|
54
44
|
end
|
55
45
|
end
|
@@ -4,7 +4,7 @@ module UiComponents
|
|
4
4
|
module DaisyUi
|
5
5
|
module Action
|
6
6
|
class SwapComponent < BaseComponent
|
7
|
-
EFFECTS = %w[rotate flip]
|
7
|
+
EFFECTS = %w[rotate flip].freeze
|
8
8
|
|
9
9
|
CSS_CLASSES_DEFAULT = %w[swap].freeze
|
10
10
|
CSS_CLASSES_VARIANTS = (
|
@@ -37,20 +37,20 @@ module UiComponents
|
|
37
37
|
|
38
38
|
private
|
39
39
|
|
40
|
-
def
|
40
|
+
def css_class_string
|
41
41
|
TailwindMerge::Merger.new.merge([
|
42
42
|
*CSS_CLASSES_DEFAULT,
|
43
|
-
|
44
|
-
|
43
|
+
effect_css_class,
|
44
|
+
active_css_class,
|
45
45
|
@css_class
|
46
46
|
])
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def effect_css_class
|
50
50
|
"swap-#{@effect}" if EFFECTS.include?(@effect)
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def active_css_class
|
54
54
|
"swap-active" if @active
|
55
55
|
end
|
56
56
|
end
|