daisyui-view-components 0.0.2 → 0.0.3
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 +7 -0
- data/daisyui-view-components/app/components/daisyui_view_components/accordion/component.rb +28 -0
- data/daisyui-view-components/app/components/daisyui_view_components/alert/component.html.erb +34 -0
- data/daisyui-view-components/app/components/daisyui_view_components/alert/component.rb +27 -0
- data/daisyui-view-components/app/components/daisyui_view_components/avatar/component.rb +21 -0
- data/daisyui-view-components/app/components/daisyui_view_components/avatar_group/component.rb +19 -0
- data/daisyui-view-components/app/components/daisyui_view_components/badge/component.rb +41 -0
- data/daisyui-view-components/app/components/daisyui_view_components/base_component.rb +118 -0
- data/daisyui-view-components/app/components/daisyui_view_components/bottom_nav/component.rb +50 -0
- data/daisyui-view-components/app/components/daisyui_view_components/breadcrumbs/component.html.erb +7 -0
- data/daisyui-view-components/app/components/daisyui_view_components/breadcrumbs/component.rb +21 -0
- data/daisyui-view-components/app/components/daisyui_view_components/button/component.rb +68 -0
- data/daisyui-view-components/app/components/daisyui_view_components/card/component.rb +64 -0
- data/daisyui-view-components/app/components/daisyui_view_components/carousel/component.rb +35 -0
- data/daisyui-view-components/app/components/daisyui_view_components/checkbox/component.html.erb +19 -0
- data/daisyui-view-components/app/components/daisyui_view_components/checkbox/component.rb +40 -0
- data/daisyui-view-components/app/components/daisyui_view_components/collapse/component.html.erb +9 -0
- data/daisyui-view-components/app/components/daisyui_view_components/collapse/component.rb +62 -0
- data/daisyui-view-components/app/components/daisyui_view_components/dropdown/component.html.erb +4 -0
- data/daisyui-view-components/app/components/daisyui_view_components/dropdown/component.rb +37 -0
- data/daisyui-view-components/app/components/daisyui_view_components/file_input/component.html.erb +5 -0
- data/daisyui-view-components/app/components/daisyui_view_components/file_input/component.rb +44 -0
- data/daisyui-view-components/app/components/daisyui_view_components/form_control/component.rb +21 -0
- data/daisyui-view-components/app/components/daisyui_view_components/label/component.rb +22 -0
- data/daisyui-view-components/app/components/daisyui_view_components/link/component.rb +34 -0
- data/daisyui-view-components/app/components/daisyui_view_components/menu/component.html.erb +7 -0
- data/daisyui-view-components/app/components/daisyui_view_components/menu/component.rb +28 -0
- data/daisyui-view-components/app/components/daisyui_view_components/modal/action/component.rb +30 -0
- data/daisyui-view-components/app/components/daisyui_view_components/modal/box/component.html.erb +9 -0
- data/daisyui-view-components/app/components/daisyui_view_components/modal/box/component.rb +15 -0
- data/daisyui-view-components/app/components/daisyui_view_components/modal/component.html.erb +8 -0
- data/daisyui-view-components/app/components/daisyui_view_components/modal/component.rb +18 -0
- data/daisyui-view-components/app/components/daisyui_view_components/navbar/component.html.erb +9 -0
- data/daisyui-view-components/app/components/daisyui_view_components/navbar/component.rb +42 -0
- data/daisyui-view-components/app/components/daisyui_view_components/radio/component.html.erb +19 -0
- data/daisyui-view-components/app/components/daisyui_view_components/radio/component.rb +57 -0
- data/daisyui-view-components/app/components/daisyui_view_components/range/component.rb +45 -0
- data/daisyui-view-components/app/components/daisyui_view_components/rating/component.rb +73 -0
- data/daisyui-view-components/app/components/daisyui_view_components/select/component.html.erb +5 -0
- data/daisyui-view-components/app/components/daisyui_view_components/select/component.rb +73 -0
- data/daisyui-view-components/app/components/daisyui_view_components/steps/component.rb +56 -0
- data/daisyui-view-components/app/components/daisyui_view_components/swap/component.rb +49 -0
- data/daisyui-view-components/app/components/daisyui_view_components/table/component.html.erb +5 -0
- data/daisyui-view-components/app/components/daisyui_view_components/table/component.rb +92 -0
- data/daisyui-view-components/app/components/daisyui_view_components/tabs/component.html.erb +5 -0
- data/daisyui-view-components/app/components/daisyui_view_components/tabs/component.rb +50 -0
- data/daisyui-view-components/app/components/daisyui_view_components/text_input/component.html.erb +9 -0
- data/daisyui-view-components/app/components/daisyui_view_components/text_input/component.rb +71 -0
- data/daisyui-view-components/app/components/daisyui_view_components/textarea/component.html.erb +5 -0
- data/daisyui-view-components/app/components/daisyui_view_components/textarea/component.rb +50 -0
- data/daisyui-view-components/app/components/daisyui_view_components/toggle/component.rb +43 -0
- data/daisyui-view-components/lib/daisyui_view_components/cache.rb +50 -0
- data/daisyui-view-components/lib/daisyui_view_components/engine.rb +30 -0
- data/daisyui-view-components/lib/daisyui_view_components/helpers/component.rb +36 -0
- data/daisyui-view-components/lib/daisyui_view_components/tailwind_merger.rb +23 -0
- data/daisyui-view-components/lib/daisyui_view_components/version.rb +7 -0
- data/daisyui-view-components/lib/daisyui_view_components.rb +12 -0
- data/daisyui-view-components/previews/accordion/default.html.erb +29 -0
- data/daisyui-view-components/previews/accordion/preview.rb +14 -0
- data/daisyui-view-components/previews/alert/default.html.erb +4 -0
- data/daisyui-view-components/previews/alert/info_color.html.erb +4 -0
- data/daisyui-view-components/previews/alert/preview.rb +23 -0
- data/daisyui-view-components/previews/alert/with_buttons.html.erb +10 -0
- data/daisyui-view-components/previews/alert/with_icon_title_and_description.html.erb +14 -0
- data/daisyui-view-components/previews/avatar/default.html.erb +5 -0
- data/daisyui-view-components/previews/avatar/preview.rb +19 -0
- data/daisyui-view-components/previews/avatar_group/default.html.erb +17 -0
- data/daisyui-view-components/previews/avatar_group/preview.rb +12 -0
- data/daisyui-view-components/previews/badge/default.html.erb +1 -0
- data/daisyui-view-components/previews/badge/preview.rb +14 -0
- data/daisyui-view-components/previews/bottom_nav/default.html.erb +44 -0
- data/daisyui-view-components/previews/bottom_nav/preview.rb +16 -0
- data/daisyui-view-components/previews/bottom_nav/with_labels.html.erb +47 -0
- data/daisyui-view-components/previews/breadcrumbs/default.html.erb +11 -0
- data/daisyui-view-components/previews/breadcrumbs/preview.rb +16 -0
- data/daisyui-view-components/previews/breadcrumbs/with_icons.html.erb +50 -0
- data/daisyui-view-components/previews/button/default.html.erb +3 -0
- data/daisyui-view-components/previews/button/preview.rb +28 -0
- data/daisyui-view-components/previews/card/default.html.erb +24 -0
- data/daisyui-view-components/previews/card/preview.rb +12 -0
- data/daisyui-view-components/previews/carousel/default.html.erb +37 -0
- data/daisyui-view-components/previews/carousel/preview.rb +19 -0
- data/daisyui-view-components/previews/checkbox/default.html.erb +1 -0
- data/daisyui-view-components/previews/checkbox/preview.rb +34 -0
- data/daisyui-view-components/previews/checkbox/with_form.html.erb +3 -0
- data/daisyui-view-components/previews/collapse/default.html.erb +9 -0
- data/daisyui-view-components/previews/collapse/preview.rb +14 -0
- data/daisyui-view-components/previews/dropdown/default.html.erb +11 -0
- data/daisyui-view-components/previews/dropdown/preview.rb +13 -0
- data/daisyui-view-components/previews/file_input/default.html.erb +1 -0
- data/daisyui-view-components/previews/file_input/preview.rb +26 -0
- data/daisyui-view-components/previews/file_input/with_form.html.erb +13 -0
- data/daisyui-view-components/previews/link/default.html.erb +1 -0
- data/daisyui-view-components/previews/link/preview.rb +17 -0
- data/daisyui-view-components/previews/modal/default.html.erb +14 -0
- data/daisyui-view-components/previews/modal/preview.rb +19 -0
- data/daisyui-view-components/previews/navbar/default.html.erb +75 -0
- data/daisyui-view-components/previews/navbar/preview.rb +12 -0
- data/daisyui-view-components/previews/radio/default.html.erb +1 -0
- data/daisyui-view-components/previews/radio/preview.rb +26 -0
- data/daisyui-view-components/previews/radio/with_form.html.erb +4 -0
- data/daisyui-view-components/previews/range_slider/default.html.erb +1 -0
- data/daisyui-view-components/previews/range_slider/preview.rb +14 -0
- data/daisyui-view-components/previews/rating/default.html.erb +6 -0
- data/daisyui-view-components/previews/rating/preview.rb +14 -0
- data/daisyui-view-components/previews/select/default.html.erb +1 -0
- data/daisyui-view-components/previews/select/preview.rb +26 -0
- data/daisyui-view-components/previews/select/with_form.html.erb +13 -0
- data/daisyui-view-components/previews/steps/default.html.erb +14 -0
- data/daisyui-view-components/previews/steps/preview.rb +13 -0
- data/daisyui-view-components/previews/swap/default.html.erb +9 -0
- data/daisyui-view-components/previews/swap/flip_effect.html.erb +9 -0
- data/daisyui-view-components/previews/swap/hamburger_button.html.erb +26 -0
- data/daisyui-view-components/previews/swap/preview.rb +28 -0
- data/daisyui-view-components/previews/swap/rotate_effect.html.erb +23 -0
- data/daisyui-view-components/previews/swap/volume_icons.html.erb +27 -0
- data/daisyui-view-components/previews/table/default.html.erb +60 -0
- data/daisyui-view-components/previews/table/preview.rb +17 -0
- data/daisyui-view-components/previews/tabs/default.html.erb +11 -0
- data/daisyui-view-components/previews/tabs/preview.rb +21 -0
- data/daisyui-view-components/previews/text_input/default.html.erb +1 -0
- data/daisyui-view-components/previews/text_input/preview.rb +42 -0
- data/daisyui-view-components/previews/text_input/with_form.html.erb +13 -0
- data/daisyui-view-components/previews/text_input/with_icon_inside.html.erb +59 -0
- data/daisyui-view-components/previews/text_input/with_text_label_inside.html.erb +26 -0
- data/daisyui-view-components/previews/textarea/default.html.erb +1 -0
- data/daisyui-view-components/previews/textarea/preview.rb +26 -0
- data/daisyui-view-components/previews/textarea/with_form.html.erb +13 -0
- data/daisyui-view-components/previews/toggle/default.html.erb +1 -0
- data/daisyui-view-components/previews/toggle/preview.rb +26 -0
- data/daisyui-view-components/previews/toggle/with_form.html.erb +3 -0
- metadata +137 -7
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Collapse
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
option :open, default: proc { false }
|
8
|
+
option :arrow, default: proc { false }
|
9
|
+
|
10
|
+
renders_one :collapse_title, 'CollapseTitle'
|
11
|
+
renders_one :collapse_content, 'CollapseContent'
|
12
|
+
renders_one :checkbox, 'CollapseCheckbox'
|
13
|
+
renders_one :radio, 'CollapseRadio'
|
14
|
+
|
15
|
+
css_classes 'collapse bg-base-200' do |classes|
|
16
|
+
classes << 'collapse-open' if @open
|
17
|
+
classes << 'collapse-arrow' if @arrow
|
18
|
+
end
|
19
|
+
|
20
|
+
class CollapseRadio < DaisyUIViewComponents::BaseComponent
|
21
|
+
|
22
|
+
def call
|
23
|
+
html :input, type: :radio, class: css('w-auto h-auto') do
|
24
|
+
content
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class CollapseCheckbox < DaisyUIViewComponents::BaseComponent
|
31
|
+
|
32
|
+
def call
|
33
|
+
html :input, type: :checkbox, class: css('w-auto h-auto') do
|
34
|
+
content
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
class CollapseTitle < DaisyUIViewComponents::BaseComponent
|
41
|
+
|
42
|
+
def call
|
43
|
+
html :h2, class: css('collapse-title text-xl font-medium') do
|
44
|
+
content
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
class CollapseContent < DaisyUIViewComponents::BaseComponent
|
51
|
+
|
52
|
+
def call
|
53
|
+
html :div, class: css('collapse-content') do
|
54
|
+
content
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Dropdown
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
POSITIONS = [:end, :top, :bottom, :right, :left].freeze
|
8
|
+
|
9
|
+
option :position, optional: true, desc: POSITIONS, type: proc(&:to_sym)
|
10
|
+
|
11
|
+
css_classes 'dropdown' do |classes|
|
12
|
+
classes << "dropdown-#{@position}" if @position
|
13
|
+
end
|
14
|
+
|
15
|
+
renders_one :trigger, 'Trigger'
|
16
|
+
renders_one :menu, lambda { |*args, **kwargs, &block|
|
17
|
+
DaisyUIViewComponents::Menu::Component.new(
|
18
|
+
*args,
|
19
|
+
class: 'dropdown-content z-[1] menu p-2 shadow bg-base-200 rounded-box w-56',
|
20
|
+
**kwargs,
|
21
|
+
&block
|
22
|
+
)
|
23
|
+
}
|
24
|
+
|
25
|
+
class Trigger < DaisyUIViewComponents::BaseComponent
|
26
|
+
|
27
|
+
def call
|
28
|
+
html :div, role: 'button', tabindex: 0, class: css('btn m-1') do
|
29
|
+
content
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module FileInput
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
SIZE_CLASSES = {
|
8
|
+
xs: 'file-input-xs',
|
9
|
+
sm: 'file-input-sm',
|
10
|
+
md: 'file-input-md',
|
11
|
+
lg: 'file-input-lg'
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
COLOR_CLASSES = {
|
15
|
+
primary: 'file-input-primary',
|
16
|
+
secondary: 'file-input-secondary',
|
17
|
+
accent: 'file-input-accent',
|
18
|
+
info: 'file-input-info',
|
19
|
+
success: 'file-input-success',
|
20
|
+
warning: 'file-input-warning',
|
21
|
+
error: 'file-input-error'
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
SIZE_OPTIONS = SIZE_CLASSES.keys.freeze
|
25
|
+
COLOR_OPTIONS = COLOR_CLASSES.keys.freeze
|
26
|
+
DEFAULT_COLOR = :primary
|
27
|
+
|
28
|
+
option :size, optional: true, desc: SIZE_OPTIONS, type: proc(&:to_sym)
|
29
|
+
option :bordered, optional: true, default: false
|
30
|
+
option :ghost, optional: true, default: false
|
31
|
+
option :color, optional: true, desc: COLOR_CLASSES, type: proc(&:to_sym)
|
32
|
+
option :form, optional: true
|
33
|
+
option :field, optional: true, type: proc(&:to_s), default: proc { content&.to_sym }
|
34
|
+
|
35
|
+
css_classes 'file-input' do |classes|
|
36
|
+
classes << SIZE_CLASSES[size] if size
|
37
|
+
classes << COLOR_CLASSES[color] if color
|
38
|
+
classes << 'file-input-ghost' if ghost
|
39
|
+
classes << 'file-input-bordered' if bordered
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module FormControl
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
renders_one :top_label, DaisyUIViewComponents::Label::Component
|
8
|
+
renders_one :bottom_label, DaisyUIViewComponents::Label::Component
|
9
|
+
renders_one :control
|
10
|
+
|
11
|
+
def call
|
12
|
+
html :div, class: css('form-control') do
|
13
|
+
concat top_label if top_label?
|
14
|
+
concat content
|
15
|
+
concat bottom_label if bottom_label?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Label
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
renders_one :label_text, lambda { |content = '', css: 'label-text', &block|
|
8
|
+
content_tag :span, content, class: css, &block
|
9
|
+
}
|
10
|
+
renders_one :label_text_alt, lambda { |content = '', css: 'label-text-alt', &block|
|
11
|
+
content_tag :span, content, class: css, &block
|
12
|
+
}
|
13
|
+
|
14
|
+
def call
|
15
|
+
html :div, class: css('label') do
|
16
|
+
content
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Link
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
COLOR_CLASSES = {
|
8
|
+
neutral: 'link-neutral',
|
9
|
+
primary: 'link-primary',
|
10
|
+
secondary: 'link-secondary',
|
11
|
+
accent: 'link-accent',
|
12
|
+
success: 'link-success',
|
13
|
+
info: 'link-info',
|
14
|
+
warning: 'link-warning',
|
15
|
+
error: 'link-error',
|
16
|
+
hover: 'link-hover'
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
DEFAULT_COLOR = :neutral
|
20
|
+
|
21
|
+
COLOR_OPTIONS = COLOR_CLASSES.keys.freeze
|
22
|
+
|
23
|
+
option :color, optional: true, desc: COLOR_CLASSES, type: proc(&:to_sym)
|
24
|
+
option :url, type: proc(&:to_s)
|
25
|
+
|
26
|
+
css_classes 'link', with: :color
|
27
|
+
|
28
|
+
def call
|
29
|
+
link_to content, @url, class: css_classes, **html_options
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Menu
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
renders_many :items, 'Item'
|
8
|
+
|
9
|
+
class Item < DaisyUIViewComponents::BaseComponent
|
10
|
+
|
11
|
+
option :collapsible, default: proc { false }, optional: true
|
12
|
+
option :open, default: proc { false }, optional: true
|
13
|
+
|
14
|
+
def call
|
15
|
+
if collapsible
|
16
|
+
html :details, open: open do
|
17
|
+
content
|
18
|
+
end
|
19
|
+
else
|
20
|
+
content
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Modal
|
5
|
+
module Action
|
6
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
7
|
+
|
8
|
+
renders_many :buttons, DaisyUIViewComponents::Button::Component
|
9
|
+
renders_one :close_button, 'CloseButton'
|
10
|
+
|
11
|
+
def call
|
12
|
+
html :div , class: css('modal-action') do
|
13
|
+
content
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class CloseButton < DaisyUIViewComponents::BaseComponent
|
18
|
+
|
19
|
+
def call
|
20
|
+
html :form, method: 'dialog' do
|
21
|
+
concat content_tag :button, content || 'Close', class: css('btn')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Modal
|
5
|
+
module Box
|
6
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
7
|
+
|
8
|
+
option :close_button, default: proc { true }
|
9
|
+
|
10
|
+
renders_one :modal_action, DaisyUIViewComponents::Modal::Action::Component
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Modal
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
option :open, default: proc { false }
|
8
|
+
option :backdrop, default: proc { true }
|
9
|
+
|
10
|
+
css_classes 'modal' do |classes|
|
11
|
+
classes << 'modal-open' if @open
|
12
|
+
end
|
13
|
+
|
14
|
+
renders_one :modal_box, DaisyUIViewComponents::Modal::Box::Component
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Navbar
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
renders_one :start_element, lambda { |position: :start, **kwargs|
|
8
|
+
Element.new(position: position, **kwargs)
|
9
|
+
}
|
10
|
+
|
11
|
+
renders_one :center_element, lambda { |position: :center, **kwargs|
|
12
|
+
Element.new(position: position, **kwargs)
|
13
|
+
}
|
14
|
+
|
15
|
+
renders_one :end_element, lambda { |position: :end, **kwargs|
|
16
|
+
Element.new(position: position, **kwargs)
|
17
|
+
}
|
18
|
+
|
19
|
+
class Element < DaisyUIViewComponents::BaseComponent
|
20
|
+
|
21
|
+
option :position, default: proc { :start }
|
22
|
+
|
23
|
+
def call
|
24
|
+
case position
|
25
|
+
when :start
|
26
|
+
element_class = 'navbar-start'
|
27
|
+
when :center
|
28
|
+
element_class = 'navbar-center'
|
29
|
+
when :end
|
30
|
+
element_class = 'navbar-end'
|
31
|
+
end
|
32
|
+
|
33
|
+
html :div, class: css(element_class) do
|
34
|
+
content
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% if label %>
|
2
|
+
<% if form.present? %>
|
3
|
+
<div class="form-control">
|
4
|
+
<%= label_tag id_attribute, class: "cursor-pointer label" do %>
|
5
|
+
<%= content_tag :span, label, class: "label-text" %>
|
6
|
+
<%= form.radio_button field, value, id: id_attribute, class: css_classes, **html_options.except(:class) %>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
<% else %>
|
10
|
+
<div class="form-control">
|
11
|
+
<%= label_tag id, class: "cursor-pointer label" do %>
|
12
|
+
<%= content_tag :span, label, class: "label-text" %>
|
13
|
+
<%= radio_button_tag field, value, id: id_attribute, class: css_classes, **html_options.except(:class) %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
<% else %>
|
18
|
+
<%= radio_button_tag field, value, class: css_classes, **html_options.except(:class) %>
|
19
|
+
<% end %>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Radio
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
SIZE_CLASSES = {
|
8
|
+
xs: 'radio-xs',
|
9
|
+
sm: 'radio-sm',
|
10
|
+
md: 'radio-md',
|
11
|
+
lg: 'radio-lg'
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
COLOR_CLASSES = {
|
15
|
+
primary: 'radio-primary',
|
16
|
+
secondary: 'radio-secondary',
|
17
|
+
accent: 'radio-accent',
|
18
|
+
info: 'radio-info',
|
19
|
+
success: 'radio-success',
|
20
|
+
warning: 'radio-warning',
|
21
|
+
error: 'radio-error'
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
SIZE_OPTIONS = SIZE_CLASSES.keys.freeze
|
25
|
+
COLOR_OPTIONS = COLOR_CLASSES.keys.freeze
|
26
|
+
DEFAULT_COLOR = :primary
|
27
|
+
|
28
|
+
option :size, optional: true, desc: SIZE_OPTIONS, type: proc(&:to_sym)
|
29
|
+
option :color, optional: true, desc: COLOR_CLASSES, type: proc(&:to_sym)
|
30
|
+
option :form, optional: true
|
31
|
+
option :id, optional: true
|
32
|
+
option :label, optional: true
|
33
|
+
option :value, optional: true
|
34
|
+
option :field, optional: true, type: proc(&:to_s), default: proc { content&.to_sym }
|
35
|
+
|
36
|
+
css_classes 'radio' do |classes|
|
37
|
+
classes << SIZE_CLASSES[size] if size
|
38
|
+
classes << COLOR_CLASSES[color] if color
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def id_attribute
|
44
|
+
@id ||= begin
|
45
|
+
if label && value
|
46
|
+
"#{label.parameterize}-#{value}"
|
47
|
+
elsif label
|
48
|
+
"#{label.parameterize}-#{SecureRandom.hex(3)}"
|
49
|
+
else
|
50
|
+
SecureRandom.hex(3)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Range
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
SIZE_CLASSES = {
|
8
|
+
xs: 'range-xs',
|
9
|
+
sm: 'range-sm',
|
10
|
+
md: 'range-md',
|
11
|
+
lg: 'range-lg'
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
COLOR_CLASSES = {
|
15
|
+
primary: 'range-primary',
|
16
|
+
secondary: 'range-secondary',
|
17
|
+
accent: 'range-accent',
|
18
|
+
info: 'range-info',
|
19
|
+
success: 'range-success',
|
20
|
+
warning: 'range-warning',
|
21
|
+
error: 'range-error'
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
SIZE_OPTIONS = SIZE_CLASSES.keys.freeze
|
25
|
+
COLOR_OPTIONS = COLOR_CLASSES.keys.freeze
|
26
|
+
DEFAULT_COLOR = :primary
|
27
|
+
|
28
|
+
option :size, optional: true, desc: SIZE_OPTIONS, type: proc(&:to_sym)
|
29
|
+
option :color, optional: true, desc: COLOR_CLASSES, type: proc(&:to_sym)
|
30
|
+
option :min, type: proc(&:to_i)
|
31
|
+
option :max, type: proc(&:to_i)
|
32
|
+
option :form, optional: true
|
33
|
+
option :label, optional: true
|
34
|
+
option :value, optional: true
|
35
|
+
option :field, optional: true, type: proc(&:to_s)
|
36
|
+
|
37
|
+
css_classes 'range', with: [:size, :color]
|
38
|
+
|
39
|
+
def call
|
40
|
+
html :input, type: 'range', min: min, max: max, value: value
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DaisyUIViewComponents
|
4
|
+
module Rating
|
5
|
+
class Component < DaisyUIViewComponents::BaseComponent
|
6
|
+
|
7
|
+
SIZE_CLASSES = {
|
8
|
+
xs: 'rating-xs',
|
9
|
+
sm: 'rating-sm',
|
10
|
+
md: 'rating-md',
|
11
|
+
lg: 'rating-lg'
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
SIZE_OPTIONS = SIZE_CLASSES.keys.freeze
|
15
|
+
|
16
|
+
option :size, optional: true, desc: SIZE_OPTIONS, type: proc(&:to_sym)
|
17
|
+
option :mask_shape, optional: true
|
18
|
+
option :allow_halves, optional: true
|
19
|
+
option :hidden_input, optional: true
|
20
|
+
|
21
|
+
css_classes 'rating', with: :size
|
22
|
+
|
23
|
+
renders_many :inputs, lambda { |*args, **kwargs, &block|
|
24
|
+
Input.new(*args, mask_shape: @mask_shape, **kwargs, &block)
|
25
|
+
}
|
26
|
+
|
27
|
+
def call
|
28
|
+
html :div do
|
29
|
+
content
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Input < DaisyUIViewComponents::BaseComponent
|
34
|
+
|
35
|
+
# rubocop:disable Naming/VariableNumber
|
36
|
+
MASK_SHAPE_CLASSES = {
|
37
|
+
squircle: 'mask-squircle',
|
38
|
+
heart: 'mask-heart',
|
39
|
+
hexagon: 'mask-hexagon',
|
40
|
+
hexagon_2: 'mask-hexagon-2',
|
41
|
+
decagon: 'mask-decagon',
|
42
|
+
pentagon: 'mask-pentagon',
|
43
|
+
diamond: 'mask-diamond',
|
44
|
+
square: 'mask-square',
|
45
|
+
circle: 'mask-circle',
|
46
|
+
parallelogram: 'mask-parallelogram',
|
47
|
+
parallelogram_2: 'mask-parallelogram-2',
|
48
|
+
parallelogram_3: 'mask-parallelogram-3',
|
49
|
+
parallelogram_4: 'mask-parallelogram-4',
|
50
|
+
star: 'mask-star',
|
51
|
+
star_2: 'mask-star-2',
|
52
|
+
triangle: 'mask-triangle',
|
53
|
+
triangle_2: 'mask-triangle-2',
|
54
|
+
triangle_3: 'mask-triangle-3',
|
55
|
+
triangle_4: 'mask-triangle-4'
|
56
|
+
}.freeze
|
57
|
+
# rubocop:enable Naming/VariableNumber
|
58
|
+
|
59
|
+
MASK_SHAPE_OPTIONS = MASK_SHAPE_CLASSES .keys
|
60
|
+
|
61
|
+
option :mask_shape, default: -> { :star }, desc: MASK_SHAPE_OPTIONS
|
62
|
+
|
63
|
+
css_classes 'mask', with: :mask_shape
|
64
|
+
|
65
|
+
def call
|
66
|
+
html :input, type: 'radio'
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<% if form.present? %>
|
2
|
+
<%= form.select field, choices, include_blank_options, class: css_classes, **html_options.except(:class) %>
|
3
|
+
<% else %>
|
4
|
+
<%= select_tag field, prepare_choices, class: css_classes, **include_blank_options, **html_options.except(:class) %>
|
5
|
+
<% end %>
|