phlexy_ui 0.1.1 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ # @private
5
+ class SubMenu < Base
6
+ include Phlex::DeferredRender
7
+
8
+ def initialize(*, **)
9
+ super
10
+ @items ||= []
11
+ end
12
+
13
+ def view_template(&)
14
+ if @title
15
+ div do
16
+ render @title
17
+ end
18
+ end
19
+
20
+ if @items.any?
21
+ ul do
22
+ @items.each do |item|
23
+ render item
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def title(&block)
30
+ @title = block
31
+ end
32
+
33
+ def item(*, **, &)
34
+ @items << MenuItem.new(*, **, &)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ # @private
5
+ class Tab < Base
6
+ include Phlex::DeferredRender
7
+
8
+ def initialize(*, id: nil, **)
9
+ super(*, **)
10
+ @id = id
11
+ end
12
+
13
+ def view_template(&)
14
+ if @content
15
+ render TabWithContent.new(
16
+ *base_modifiers,
17
+ id:,
18
+ content: @content,
19
+ **options,
20
+ &
21
+ )
22
+ else
23
+ render TabWithoutContent.new(*base_modifiers, id:, **options, &)
24
+ end
25
+ end
26
+
27
+ def content(*, **options, &)
28
+ unless id
29
+ raise ArgumentError,
30
+ "You must pass an id to Tabs#new if you want to add content"
31
+ end
32
+
33
+ @content = -> do
34
+ generate_classes!(
35
+ component_html_class: :"tab-content",
36
+ options:
37
+ ).then do |classes|
38
+ div role: :tabpanel, class: classes, **options, &
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ # @private
5
+ class TabWithContent < Base
6
+ def initialize(*base_modifiers, content:, id: nil, **)
7
+ super(*base_modifiers, **)
8
+ @title = title
9
+ @id = id
10
+ @content = content
11
+ end
12
+
13
+ def view_template(&)
14
+ title, *base_modifiers = @base_modifiers
15
+
16
+ attributes = generate_attributes(
17
+ base_modifiers,
18
+ ATTRIBUTES_MAP
19
+ )
20
+
21
+ generate_classes!(
22
+ component_html_class: :tab,
23
+ modifiers_map: modifiers,
24
+ base_modifiers:,
25
+ options:
26
+ ).then do |classes|
27
+ input(
28
+ type: :radio,
29
+ name: id,
30
+ class: classes,
31
+ role: :tab,
32
+ aria_label: title,
33
+ **attributes,
34
+ **options
35
+ )
36
+ end
37
+
38
+ @content&.call
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :title
44
+
45
+ ATTRIBUTES_MAP = {
46
+ open: {checked: true},
47
+ closed: true
48
+ }.freeze
49
+
50
+ register_modifiers(
51
+ # "sm:tab-active"
52
+ # "md:tab-active"
53
+ # "lg:tab-active"
54
+ active: "tab-active",
55
+ # "sm:tab-disabled"
56
+ # "md:tab-disabled"
57
+ # "lg:tab-disabled"
58
+ disabled: "tab-disabled"
59
+ )
60
+ end
61
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ # @private
5
+ class TabWithoutContent < Base
6
+ def view_template(&)
7
+ generate_classes!(
8
+ component_html_class: :tab,
9
+ modifiers_map: modifiers,
10
+ base_modifiers:,
11
+ options:
12
+ ).then do |classes|
13
+ div role: :tab, class: classes, &
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :title
20
+
21
+ register_modifiers(
22
+ # "sm:tab-active"
23
+ # "md:tab-active"
24
+ # "lg:tab-active"
25
+ active: "tab-active",
26
+ # "sm:tab-disabled"
27
+ # "md:tab-disabled"
28
+ # "lg:tab-disabled"
29
+ disabled: "tab-disabled"
30
+ )
31
+ end
32
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ class Table < Base
5
+ def view_template(&)
6
+ generate_classes!(
7
+ component_html_class: :table,
8
+ modifiers_map: modifiers,
9
+ base_modifiers:,
10
+ options:
11
+ ).then do |classes|
12
+ table(class: classes, **options, &)
13
+ end
14
+ end
15
+
16
+ def header(*, **, &)
17
+ thead(*, **, &)
18
+ end
19
+
20
+ def row(*, **, &)
21
+ render TableRow.new(*, **, &)
22
+ end
23
+
24
+ def body(*, **, &)
25
+ tbody(*, **, &)
26
+ end
27
+
28
+ def footer(*, **, &)
29
+ tfoot(*, **, &)
30
+ end
31
+
32
+ private
33
+
34
+ register_modifiers(
35
+ # "sm:table-zebra"
36
+ # "md:table-zebra"
37
+ # "lg:table-zebra"
38
+ zebra: "table-zebra",
39
+ # "sm:table-pin-rows"
40
+ # "md:table-pin-rows"
41
+ # "lg:table-pin-rows"
42
+ pin_rows: "table-pin-rows",
43
+ # "sm:table-pin-cols"
44
+ # "md:table-pin-cols"
45
+ # "lg:table-pin-cols"
46
+ pin_cols: "table-pin-cols",
47
+ # "sm:table-xs"
48
+ # "md:table-xs"
49
+ # "lg:table-xs"
50
+ xs: "table-xs",
51
+ # "sm:table-sm"
52
+ # "md:table-sm"
53
+ # "lg:table-sm"
54
+ sm: "table-sm",
55
+ # "sm:table-md"
56
+ # "md:table-md"
57
+ # "lg:table-md"
58
+ md: "table-md",
59
+ # "sm:table-lg"
60
+ # "md:table-lg"
61
+ # "lg:table-lg"
62
+ lg: "table-lg"
63
+ )
64
+ end
65
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ class TableRow < Base
5
+ def view_template(&)
6
+ generate_classes!(
7
+ modifiers_map: modifiers,
8
+ base_modifiers:,
9
+ options:
10
+ ).then do |classes|
11
+ tr(class: classes, **options, &)
12
+ end
13
+ end
14
+
15
+ def head(*, **, &)
16
+ th(*, **, &)
17
+ end
18
+
19
+ def column(*, **, &)
20
+ td(*, **, &)
21
+ end
22
+ alias_method :cell, :column
23
+
24
+ private
25
+
26
+ register_modifiers(
27
+ # "sm:table-row-hover"
28
+ # "md:table-row-hover"
29
+ # "lg:table-row-hover"
30
+ hover: "hover",
31
+ # "sm:bg-primary sm:text-primary-content"
32
+ # "md:bg-primary md:text-primary-content"
33
+ # "lg:bg-primary lg:text-primary-content"
34
+ primary: "bg-primary text-primary-content",
35
+ # "sm:bg-secondary sm:text-secondary-content"
36
+ # "md:bg-secondary md:text-secondary-content"
37
+ # "lg:bg-secondary lg:text-secondary-content"
38
+ secondary: "bg-secondary text-secondary-content",
39
+ # "sm:bg-accent sm:text-accent-content"
40
+ # "md:bg-accent md:text-accent-content"
41
+ # "lg:bg-accent lg:text-accent-content"
42
+ accent: "bg-accent text-accent-content",
43
+ # "sm:bg-neutral sm:text-neutral-content"
44
+ # "md:bg-neutral md:text-neutral-content"
45
+ # "lg:bg-neutral lg:text-neutral-content"
46
+ neutral: "bg-neutral text-neutral-content",
47
+ # "sm:bg-base-100 sm:text-base-content"
48
+ # "md:bg-base-100 md:text-base-content"
49
+ # "lg:bg-base-100 lg:text-base-content"
50
+ base_100: "bg-base-100 text-base-content",
51
+ # "sm:bg-base-200 sm:text-base-content"
52
+ # "md:bg-base-200 md:text-base-content"
53
+ # "lg:bg-base-200 lg:text-base-content"
54
+ base_200: "bg-base-200 text-base-content",
55
+ # "sm:bg-base-300 sm:text-base-content"
56
+ # "md:bg-base-300 md:text-base-content"
57
+ # "lg:bg-base-300 lg:text-base-content"
58
+ base_300: "bg-base-300 text-base-content",
59
+ # "sm:bg-info sm:text-info-content"
60
+ # "md:bg-info sm:text-info-content"
61
+ # "lg:bg-info sm:text-info-content"
62
+ info: "bg-info text-info-content",
63
+ # "sm:bg-success sm:text-success-content"
64
+ # "md:bg-success md:text-success-content"
65
+ # "lg:bg-success lg:text-success-content"
66
+ success: "bg-success text-success-content",
67
+ # "sm:bg-warning sm:text-warning-content"
68
+ # "md:bg-warning md:text-warning-content"
69
+ # "lg:bg-warning lg:text-warning-content"
70
+ warning: "bg-warning text-warning-content",
71
+ # "sm:bg-error sm:text-error-content"
72
+ # "md:bg-error md:text-error-content"
73
+ # "lg:bg-error lg:text-error-content"
74
+ error: "bg-error text-error-content"
75
+ )
76
+ end
77
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ class Tabs < Base
5
+ def initialize(*, id: nil, as: :div, **)
6
+ super(*, **)
7
+ @as = as
8
+ @id = id
9
+ end
10
+
11
+ def view_template(&)
12
+ generate_classes!(
13
+ component_html_class: :tabs,
14
+ modifiers_map: modifiers,
15
+ base_modifiers:,
16
+ options:
17
+ ).then do |classes|
18
+ public_send(as, role: :tablist, class: classes, **options, &)
19
+ end
20
+ end
21
+
22
+ def tab(*, **, &)
23
+ render Tab.new(*, id:, **, &)
24
+ end
25
+
26
+ private
27
+
28
+ register_modifiers(
29
+ # "sm:tabs-boxed"
30
+ # "md:tabs-boxed"
31
+ # "lg:tabs-boxed"
32
+ boxed: "tabs-boxed",
33
+ # "sm:tabs-bordered"
34
+ # "md:tabs-bordered"
35
+ # "lg:tabs-bordered"
36
+ bordered: "tabs-bordered",
37
+ # "sm:tabs-lifted"
38
+ # "md:tabs-lifted"
39
+ # "lg:tabs-lifted"
40
+ lifted: "tabs-lifted",
41
+ # "sm:tabs-xs"
42
+ # "md:tabs-xs"
43
+ # "lg:tabs-xs"
44
+ xs: "tabs-xs",
45
+ # "sm:tabs-sm"
46
+ # "md:tabs-sm"
47
+ # "lg:tabs-sm"
48
+ sm: "tabs-sm",
49
+ # "sm:tabs-md"
50
+ # "md:tabs-md"
51
+ # "lg:tabs-md"
52
+ md: "tabs-md",
53
+ # "sm:tabs-lg"
54
+ # "md:tabs-lg"
55
+ # "lg:tabs-lg"
56
+ lg: "tabs-lg"
57
+ )
58
+ end
59
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PhlexyUI
4
+ class Tooltip < Base
5
+ def initialize(*, tip:, as: :div, **)
6
+ super(*, **)
7
+ @tip = tip
8
+ @as = as
9
+ end
10
+
11
+ def view_template(&)
12
+ generate_classes!(
13
+ component_html_class: :tooltip,
14
+ modifiers_map: modifiers,
15
+ base_modifiers:,
16
+ options:
17
+ ).then do |classes|
18
+ public_send(as, class: classes, data_tip: tip, **options, &)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :tip
25
+
26
+ register_modifiers(
27
+ # "sm:tooltip-open"
28
+ # "md:tooltip-open"
29
+ # "lg:tooltip-open"
30
+ open: "tooltip-open",
31
+ # "sm:tooltip-top"
32
+ # "md:tooltip-top"
33
+ # "lg:tooltip-top"
34
+ top: "tooltip-top",
35
+ # "sm:tooltip-bottom"
36
+ # "md:tooltip-bottom"
37
+ # "lg:tooltip-bottom"
38
+ bottom: "tooltip-bottom",
39
+ # "sm:tooltip-left"
40
+ # "md:tooltip-left"
41
+ # "lg:tooltip-left"
42
+ left: "tooltip-left",
43
+ # "sm:tooltip-right"
44
+ # "md:tooltip-right"
45
+ # "lg:tooltip-right"
46
+ right: "tooltip-right",
47
+ # "sm:tooltip-primary"
48
+ # "md:tooltip-primary"
49
+ # "lg:tooltip-primary"
50
+ primary: "tooltip-primary",
51
+ # "sm:tooltip-secondary"
52
+ # "md:tooltip-secondary"
53
+ # "lg:tooltip-secondary"
54
+ secondary: "tooltip-secondary",
55
+ # "sm:tooltip-accent"
56
+ # "md:tooltip-accent"
57
+ # "lg:tooltip-accent"
58
+ accent: "tooltip-accent",
59
+ # "sm:tooltip-info"
60
+ # "md:tooltip-info"
61
+ # "lg:tooltip-info"
62
+ info: "tooltip-info",
63
+ # "sm:tooltip-success"
64
+ # "md:tooltip-success"
65
+ # "lg:tooltip-success"
66
+ success: "tooltip-success",
67
+ # "sm:tooltip-warning"
68
+ # "md:tooltip-warning"
69
+ # "lg:tooltip-warning"
70
+ warning: "tooltip-warning",
71
+ # "sm:tooltip-error"
72
+ # "md:tooltip-error"
73
+ # "lg:tooltip-error"
74
+ error: "tooltip-error"
75
+ )
76
+ end
77
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhlexyUI
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/phlexy_ui.rb CHANGED
@@ -7,12 +7,9 @@ loader.inflector.inflect(
7
7
  "phlexy_ui" => "PhlexyUI"
8
8
  )
9
9
  loader.setup # ready!
10
+ loader.load_file("#{__dir__}/phlexy_ui/base.rb")
10
11
 
11
12
  module PhlexyUI
12
13
  extend Configurable
13
14
  extend Phlex::Kit
14
-
15
- autoload :Button, "phlexy_ui/button"
16
15
  end
17
-
18
- loader.eager_load
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlexy_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Alejandro Aguilar Ramos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-02 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex
@@ -42,30 +42,50 @@ dependencies:
42
42
  name: standard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.39.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.39.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.13.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.13.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: debug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.9'
59
76
  - - ">="
60
77
  - !ruby/object:Gem::Version
61
- version: '0'
78
+ version: 1.9.2
62
79
  type: :development
63
80
  prerelease: false
64
81
  version_requirements: !ruby/object:Gem::Requirement
65
82
  requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '1.9'
66
86
  - - ">="
67
87
  - !ruby/object:Gem::Version
68
- version: '0'
88
+ version: 1.9.2
69
89
  description: PhlexyUI is a Ruby UI component library for DaisyUI using Phlex
70
90
  email: boil-dosage.0p@icloud.com
71
91
  executables: []
@@ -73,10 +93,31 @@ extensions: []
73
93
  extra_rdoc_files: []
74
94
  files:
75
95
  - lib/phlexy_ui.rb
96
+ - lib/phlexy_ui/attribute_set.rb
97
+ - lib/phlexy_ui/avatar.rb
98
+ - lib/phlexy_ui/badge.rb
76
99
  - lib/phlexy_ui/base.rb
77
100
  - lib/phlexy_ui/button.rb
78
101
  - lib/phlexy_ui/card.rb
102
+ - lib/phlexy_ui/class_list.rb
103
+ - lib/phlexy_ui/collapsible_sub_menu.rb
79
104
  - lib/phlexy_ui/configurable.rb
105
+ - lib/phlexy_ui/drawer.rb
106
+ - lib/phlexy_ui/dropdown.rb
107
+ - lib/phlexy_ui/link.rb
108
+ - lib/phlexy_ui/loading.rb
109
+ - lib/phlexy_ui/mask.rb
110
+ - lib/phlexy_ui/menu.rb
111
+ - lib/phlexy_ui/menu_item.rb
112
+ - lib/phlexy_ui/navbar.rb
113
+ - lib/phlexy_ui/sub_menu.rb
114
+ - lib/phlexy_ui/tab.rb
115
+ - lib/phlexy_ui/tab_with_content.rb
116
+ - lib/phlexy_ui/tab_without_content.rb
117
+ - lib/phlexy_ui/table.rb
118
+ - lib/phlexy_ui/table_row.rb
119
+ - lib/phlexy_ui/tabs.rb
120
+ - lib/phlexy_ui/tooltip.rb
80
121
  - lib/phlexy_ui/version.rb
81
122
  homepage: https://rubygems.org/gems/phlexy_ui
82
123
  licenses: