daisyui_on_phlex 0.1.2 → 0.2.1

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +77 -7
  3. data/lib/daisyui_on_phlex/components/accordion.rb +59 -0
  4. data/lib/daisyui_on_phlex/components/avatar.rb +90 -0
  5. data/lib/daisyui_on_phlex/components/breadcrumbs.rb +27 -0
  6. data/lib/daisyui_on_phlex/components/calendar.rb +20 -0
  7. data/lib/daisyui_on_phlex/components/carousel.rb +37 -0
  8. data/lib/daisyui_on_phlex/components/chat.rb +54 -0
  9. data/lib/daisyui_on_phlex/components/checkbox.rb +64 -0
  10. data/lib/daisyui_on_phlex/components/collapse.rb +37 -0
  11. data/lib/daisyui_on_phlex/components/countdown.rb +20 -0
  12. data/lib/daisyui_on_phlex/components/diff.rb +27 -0
  13. data/lib/daisyui_on_phlex/components/divider.rb +20 -0
  14. data/lib/daisyui_on_phlex/components/dock.rb +33 -0
  15. data/lib/daisyui_on_phlex/components/drawer.rb +49 -0
  16. data/lib/daisyui_on_phlex/components/dropdown.rb +66 -0
  17. data/lib/daisyui_on_phlex/components/fieldset.rb +31 -0
  18. data/lib/daisyui_on_phlex/components/file_input.rb +69 -0
  19. data/lib/daisyui_on_phlex/components/filter.rb +34 -0
  20. data/lib/daisyui_on_phlex/components/footer.rb +32 -0
  21. data/lib/daisyui_on_phlex/components/hero.rb +28 -0
  22. data/lib/daisyui_on_phlex/components/indicator.rb +61 -0
  23. data/lib/daisyui_on_phlex/components/join.rb +24 -0
  24. data/lib/daisyui_on_phlex/components/kbd.rb +27 -0
  25. data/lib/daisyui_on_phlex/components/label.rb +23 -0
  26. data/lib/daisyui_on_phlex/components/link.rb +45 -0
  27. data/lib/daisyui_on_phlex/components/list.rb +19 -0
  28. data/lib/daisyui_on_phlex/components/loading.rb +36 -0
  29. data/lib/daisyui_on_phlex/components/mask.rb +42 -0
  30. data/lib/daisyui_on_phlex/components/menu.rb +60 -0
  31. data/lib/daisyui_on_phlex/components/mockup_browser.rb +25 -0
  32. data/lib/daisyui_on_phlex/components/mockup_code.rb +21 -0
  33. data/lib/daisyui_on_phlex/components/mockup_phone.rb +29 -0
  34. data/lib/daisyui_on_phlex/components/mockup_window.rb +29 -0
  35. data/lib/daisyui_on_phlex/components/navbar.rb +27 -0
  36. data/lib/daisyui_on_phlex/components/pagination.rb +56 -0
  37. data/lib/daisyui_on_phlex/components/progress.rb +50 -0
  38. data/lib/daisyui_on_phlex/components/radial_progress.rb +56 -0
  39. data/lib/daisyui_on_phlex/components/radio.rb +62 -0
  40. data/lib/daisyui_on_phlex/components/range.rb +62 -0
  41. data/lib/daisyui_on_phlex/components/rating.rb +61 -0
  42. data/lib/daisyui_on_phlex/components/select.rb +74 -0
  43. data/lib/daisyui_on_phlex/components/skeleton.rb +23 -0
  44. data/lib/daisyui_on_phlex/components/stack.rb +15 -0
  45. data/lib/daisyui_on_phlex/components/stat.rb +39 -0
  46. data/lib/daisyui_on_phlex/components/status.rb +34 -0
  47. data/lib/daisyui_on_phlex/components/steps.rb +42 -0
  48. data/lib/daisyui_on_phlex/components/swap.rb +45 -0
  49. data/lib/daisyui_on_phlex/components/tab.rb +72 -0
  50. data/lib/daisyui_on_phlex/components/table.rb +52 -0
  51. data/lib/daisyui_on_phlex/components/textarea.rb +66 -0
  52. data/lib/daisyui_on_phlex/components/theme_controller.rb +29 -0
  53. data/lib/daisyui_on_phlex/components/timeline.rb +52 -0
  54. data/lib/daisyui_on_phlex/components/toast.rb +56 -0
  55. data/lib/daisyui_on_phlex/components/toggle.rb +62 -0
  56. data/lib/daisyui_on_phlex/components/tooltip.rb +57 -0
  57. data/lib/daisyui_on_phlex/components/validator.rb +35 -0
  58. data/lib/daisyui_on_phlex/version.rb +1 -1
  59. metadata +62 -7
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ module Mockup
6
+ class Window < DaisyuiOnPhlex::Base
7
+ def initialize(**attributes)
8
+ @attributes = attributes
9
+ end
10
+
11
+ def view_template(&block)
12
+ div(class: "mockup-window border bg-base-300", **@attributes, &block)
13
+ end
14
+
15
+ def toolbar(**attributes)
16
+ div(class: "flex justify-start px-4 py-2", **attributes) do
17
+ div(class: "btn btn-xs btn-circle btn-ghost")
18
+ div(class: "btn btn-xs btn-circle btn-ghost")
19
+ div(class: "btn btn-xs btn-circle btn-ghost")
20
+ end
21
+ end
22
+
23
+ def content(**attributes, &block)
24
+ div(class: merge_classes("flex", "justify-center", "px-4", "py-16", "bg-base-200", attributes[:class]), **attributes.except(:class), &block)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Navbar < DaisyuiOnPhlex::Base
6
+ def initialize(**attributes)
7
+ @attributes = attributes
8
+ end
9
+
10
+ def view_template(&block)
11
+ div(class: "navbar bg-base-100", **@attributes, &block)
12
+ end
13
+
14
+ def start(**attributes, &block)
15
+ div(class: merge_classes("navbar-start", attributes[:class]), **attributes.except(:class), &block)
16
+ end
17
+
18
+ def center(**attributes, &block)
19
+ div(class: merge_classes("navbar-center", attributes[:class]), **attributes.except(:class), &block)
20
+ end
21
+
22
+ def end(**attributes, &block)
23
+ div(class: merge_classes("navbar-end", attributes[:class]), **attributes.except(:class), &block)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Pagination < DaisyuiOnPhlex::Base
6
+ def initialize(**attributes)
7
+ @attributes = attributes
8
+ end
9
+
10
+ def view_template(&block)
11
+ div(class: "join", **@attributes, &block)
12
+ end
13
+
14
+ def button(text, active: false, disabled: false, **attributes, &block)
15
+ button_tag(
16
+ class: pagination_button_classes(active: active, disabled: disabled),
17
+ disabled: disabled,
18
+ **attributes
19
+ ) do
20
+ if block_given?
21
+ yield
22
+ else
23
+ text
24
+ end
25
+ end
26
+ end
27
+
28
+ def link(href:, text, active: false, **attributes, &block)
29
+ a(
30
+ href: href,
31
+ class: pagination_button_classes(active: active),
32
+ **attributes
33
+ ) do
34
+ if block_given?
35
+ yield
36
+ else
37
+ text
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def pagination_button_classes(active: false, disabled: false)
45
+ classes = ["join-item", "btn"]
46
+ classes << "btn-active" if active
47
+ classes << "btn-disabled" if disabled
48
+ merge_classes(*classes)
49
+ end
50
+
51
+ def button_tag(...)
52
+ button(...)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Progress < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ value: 0,
8
+ max: 100,
9
+ variant: nil,
10
+ **attributes
11
+ )
12
+ @value = value
13
+ @max = max
14
+ @variant = variant
15
+ @attributes = attributes
16
+ end
17
+
18
+ def view_template
19
+ progress_tag(
20
+ class: progress_classes,
21
+ value: @value,
22
+ max: @max,
23
+ **@attributes
24
+ )
25
+ end
26
+
27
+ private
28
+
29
+ def progress_classes
30
+ classes = ["progress", "w-56"]
31
+
32
+ case @variant
33
+ when :primary then classes << "progress-primary"
34
+ when :secondary then classes << "progress-secondary"
35
+ when :accent then classes << "progress-accent"
36
+ when :info then classes << "progress-info"
37
+ when :success then classes << "progress-success"
38
+ when :warning then classes << "progress-warning"
39
+ when :error then classes << "progress-error"
40
+ end
41
+
42
+ merge_classes(*classes)
43
+ end
44
+
45
+ def progress_tag(...)
46
+ progress(...)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class RadialProgress < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ value: 0,
8
+ size: "4rem",
9
+ thickness: "2px",
10
+ variant: nil,
11
+ **attributes
12
+ )
13
+ @value = value
14
+ @size = size
15
+ @thickness = thickness
16
+ @variant = variant
17
+ @attributes = attributes
18
+ end
19
+
20
+ def view_template(&block)
21
+ div(
22
+ class: radial_progress_classes,
23
+ style: radial_progress_styles,
24
+ **@attributes,
25
+ &block
26
+ )
27
+ end
28
+
29
+ private
30
+
31
+ def radial_progress_classes
32
+ classes = ["radial-progress"]
33
+
34
+ case @variant
35
+ when :primary then classes << "text-primary"
36
+ when :secondary then classes << "text-secondary"
37
+ when :accent then classes << "text-accent"
38
+ when :info then classes << "text-info"
39
+ when :success then classes << "text-success"
40
+ when :warning then classes << "text-warning"
41
+ when :error then classes << "text-error"
42
+ end
43
+
44
+ merge_classes(*classes)
45
+ end
46
+
47
+ def radial_progress_styles
48
+ styles = []
49
+ styles << "--value: #{@value}"
50
+ styles << "--size: #{@size}"
51
+ styles << "--thickness: #{@thickness}"
52
+ styles.join("; ")
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Radio < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ variant: nil,
8
+ size: :md,
9
+ name: nil,
10
+ value: nil,
11
+ checked: false,
12
+ disabled: false,
13
+ **attributes
14
+ )
15
+ @variant = variant
16
+ @size = size
17
+ @name = name
18
+ @value = value
19
+ @checked = checked
20
+ @disabled = disabled
21
+ @attributes = attributes
22
+ end
23
+
24
+ def view_template
25
+ input(
26
+ type: "radio",
27
+ class: radio_classes,
28
+ name: @name,
29
+ value: @value,
30
+ checked: @checked,
31
+ disabled: @disabled,
32
+ **@attributes
33
+ )
34
+ end
35
+
36
+ private
37
+
38
+ def radio_classes
39
+ classes = ["radio"]
40
+
41
+ case @variant
42
+ when :primary then classes << "radio-primary"
43
+ when :secondary then classes << "radio-secondary"
44
+ when :accent then classes << "radio-accent"
45
+ when :success then classes << "radio-success"
46
+ when :warning then classes << "radio-warning"
47
+ when :info then classes << "radio-info"
48
+ when :error then classes << "radio-error"
49
+ end
50
+
51
+ case @size
52
+ when :xs then classes << "radio-xs"
53
+ when :sm then classes << "radio-sm"
54
+ when :md then classes << "radio-md"
55
+ when :lg then classes << "radio-lg"
56
+ end
57
+
58
+ merge_classes(*classes)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Range < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ min: 0,
8
+ max: 100,
9
+ value: 50,
10
+ step: 1,
11
+ variant: nil,
12
+ size: :md,
13
+ **attributes
14
+ )
15
+ @min = min
16
+ @max = max
17
+ @value = value
18
+ @step = step
19
+ @variant = variant
20
+ @size = size
21
+ @attributes = attributes
22
+ end
23
+
24
+ def view_template
25
+ input(
26
+ type: "range",
27
+ class: range_classes,
28
+ min: @min,
29
+ max: @max,
30
+ value: @value,
31
+ step: @step,
32
+ **@attributes
33
+ )
34
+ end
35
+
36
+ private
37
+
38
+ def range_classes
39
+ classes = ["range"]
40
+
41
+ case @variant
42
+ when :primary then classes << "range-primary"
43
+ when :secondary then classes << "range-secondary"
44
+ when :accent then classes << "range-accent"
45
+ when :success then classes << "range-success"
46
+ when :warning then classes << "range-warning"
47
+ when :info then classes << "range-info"
48
+ when :error then classes << "range-error"
49
+ end
50
+
51
+ case @size
52
+ when :xs then classes << "range-xs"
53
+ when :sm then classes << "range-sm"
54
+ when :md then classes << "range-md"
55
+ when :lg then classes << "range-lg"
56
+ end
57
+
58
+ merge_classes(*classes)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Rating < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ size: :md,
8
+ half: false,
9
+ **attributes
10
+ )
11
+ @size = size
12
+ @half = half
13
+ @attributes = attributes
14
+ end
15
+
16
+ def view_template(&block)
17
+ div(class: rating_classes, **@attributes, &block)
18
+ end
19
+
20
+ def star(
21
+ name:,
22
+ value:,
23
+ checked: false,
24
+ hidden: false,
25
+ **attributes
26
+ )
27
+ input(
28
+ type: "radio",
29
+ name: name,
30
+ value: value,
31
+ class: star_classes(hidden: hidden),
32
+ checked: checked,
33
+ **attributes
34
+ )
35
+ end
36
+
37
+ private
38
+
39
+ def rating_classes
40
+ classes = ["rating"]
41
+ classes << "rating-half" if @half
42
+
43
+ case @size
44
+ when :xs then classes << "rating-xs"
45
+ when :sm then classes << "rating-sm"
46
+ when :md then classes << "rating-md"
47
+ when :lg then classes << "rating-lg"
48
+ end
49
+
50
+ merge_classes(*classes)
51
+ end
52
+
53
+ def star_classes(hidden: false)
54
+ classes = []
55
+ classes << "rating-hidden" if hidden
56
+ classes << "mask mask-star-2 bg-orange-400"
57
+ merge_classes(*classes)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Select < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ variant: nil,
8
+ size: :md,
9
+ bordered: false,
10
+ ghost: false,
11
+ name: nil,
12
+ **attributes
13
+ )
14
+ @variant = variant
15
+ @size = size
16
+ @bordered = bordered
17
+ @ghost = ghost
18
+ @name = name
19
+ @attributes = attributes
20
+ end
21
+
22
+ def view_template(&block)
23
+ select(
24
+ class: select_classes,
25
+ name: @name,
26
+ **@attributes,
27
+ &block
28
+ )
29
+ end
30
+
31
+ def option(value:, selected: false, disabled: false, **attributes, &block)
32
+ option_tag(
33
+ value: value,
34
+ selected: selected,
35
+ disabled: disabled,
36
+ **attributes,
37
+ &block
38
+ )
39
+ end
40
+
41
+ private
42
+
43
+ def select_classes
44
+ classes = ["select", "w-full", "max-w-xs"]
45
+
46
+ case @variant
47
+ when :primary then classes << "select-primary"
48
+ when :secondary then classes << "select-secondary"
49
+ when :accent then classes << "select-accent"
50
+ when :info then classes << "select-info"
51
+ when :success then classes << "select-success"
52
+ when :warning then classes << "select-warning"
53
+ when :error then classes << "select-error"
54
+ end
55
+
56
+ case @size
57
+ when :xs then classes << "select-xs"
58
+ when :sm then classes << "select-sm"
59
+ when :md then classes << "select-md"
60
+ when :lg then classes << "select-lg"
61
+ end
62
+
63
+ classes << "select-bordered" if @bordered
64
+ classes << "select-ghost" if @ghost
65
+
66
+ merge_classes(*classes)
67
+ end
68
+
69
+ def option_tag(...)
70
+ option(...)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Skeleton < DaisyuiOnPhlex::Base
6
+ def initialize(**attributes)
7
+ @attributes = attributes
8
+ end
9
+
10
+ def view_template(&block)
11
+ div(class: "skeleton", **@attributes, &block)
12
+ end
13
+
14
+ def circle(size: "w-16", **attributes)
15
+ div(class: merge_classes("skeleton", size, "rounded-full"), **attributes)
16
+ end
17
+
18
+ def rectangle(width: "w-32", height: "h-4", **attributes)
19
+ div(class: merge_classes("skeleton", width, height), **attributes)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Stack < DaisyuiOnPhlex::Base
6
+ def initialize(**attributes)
7
+ @attributes = attributes
8
+ end
9
+
10
+ def view_template(&block)
11
+ div(class: "stack", **@attributes, &block)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Stat < DaisyuiOnPhlex::Base
6
+ def initialize(**attributes)
7
+ @attributes = attributes
8
+ end
9
+
10
+ def view_template(&block)
11
+ div(class: "stats shadow", **@attributes, &block)
12
+ end
13
+
14
+ def item(**attributes, &block)
15
+ div(class: "stat", **attributes, &block)
16
+ end
17
+
18
+ def figure(**attributes, &block)
19
+ div(class: "stat-figure text-secondary", **attributes, &block)
20
+ end
21
+
22
+ def title(**attributes, &block)
23
+ div(class: "stat-title", **attributes, &block)
24
+ end
25
+
26
+ def value(**attributes, &block)
27
+ div(class: "stat-value", **attributes, &block)
28
+ end
29
+
30
+ def desc(**attributes, &block)
31
+ div(class: "stat-desc", **attributes, &block)
32
+ end
33
+
34
+ def actions(**attributes, &block)
35
+ div(class: "stat-actions", **attributes, &block)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Status < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ variant: :online,
8
+ **attributes
9
+ )
10
+ @variant = variant
11
+ @attributes = attributes
12
+ end
13
+
14
+ def view_template
15
+ span(class: status_classes, **@attributes)
16
+ end
17
+
18
+ private
19
+
20
+ def status_classes
21
+ classes = ["badge", "badge-xs"]
22
+
23
+ case @variant
24
+ when :online then classes << "badge-success"
25
+ when :offline then classes << "badge-error"
26
+ when :busy then classes << "badge-warning"
27
+ when :away then classes << "badge-accent"
28
+ end
29
+
30
+ merge_classes(*classes)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Steps < DaisyuiOnPhlex::Base
6
+ def initialize(vertical: false, **attributes)
7
+ @vertical = vertical
8
+ @attributes = attributes
9
+ end
10
+
11
+ def view_template(&block)
12
+ ul(class: steps_classes, **@attributes, &block)
13
+ end
14
+
15
+ def step(
16
+ completed: false,
17
+ current: false,
18
+ error: false,
19
+ **attributes,
20
+ &block
21
+ )
22
+ li(class: step_classes(completed: completed, current: current, error: error), **attributes, &block)
23
+ end
24
+
25
+ private
26
+
27
+ def steps_classes
28
+ classes = ["steps"]
29
+ classes << "steps-vertical" if @vertical
30
+ merge_classes(*classes)
31
+ end
32
+
33
+ def step_classes(completed: false, current: false, error: false)
34
+ classes = ["step"]
35
+ classes << "step-primary" if completed
36
+ classes << "step-secondary" if current
37
+ classes << "step-error" if error
38
+ merge_classes(*classes)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DaisyuiOnPhlex
4
+ module Components
5
+ class Swap < DaisyuiOnPhlex::Base
6
+ def initialize(
7
+ active: false,
8
+ rotate: false,
9
+ flip: false,
10
+ **attributes
11
+ )
12
+ @active = active
13
+ @rotate = rotate
14
+ @flip = flip
15
+ @attributes = attributes
16
+ end
17
+
18
+ def view_template(&block)
19
+ label(class: swap_classes, **@attributes, &block)
20
+ end
21
+
22
+ def checkbox(**attributes)
23
+ input(type: "checkbox", class: "swap-checkbox", **attributes)
24
+ end
25
+
26
+ def on(**attributes, &block)
27
+ div(class: "swap-on", **attributes, &block)
28
+ end
29
+
30
+ def off(**attributes, &block)
31
+ div(class: "swap-off", **attributes, &block)
32
+ end
33
+
34
+ private
35
+
36
+ def swap_classes
37
+ classes = ["swap"]
38
+ classes << "swap-active" if @active
39
+ classes << "swap-rotate" if @rotate
40
+ classes << "swap-flip" if @flip
41
+ merge_classes(*classes)
42
+ end
43
+ end
44
+ end
45
+ end