playbook_ui 16.5.0.pre.rc.3 → 16.5.0.pre.rc.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50ca8e58f947f8dbec4fc7f659410b09588f9b11d0404c18824a67866c5773e7
4
- data.tar.gz: d3e1e785a1f9b4f24910a199890f6c8342a5a479f7a3ec948d0f9bed0d88fed4
3
+ metadata.gz: e7dea3b3ac4ba79818f434283562129d10590e6ba4fed204f8c88044ef625cc8
4
+ data.tar.gz: 18d7def47926195b0e20252fded19e19151195881053f7260e583381523f6f3a
5
5
  SHA512:
6
- metadata.gz: cb09d5d1204fb4929189c91eab464aec3e55257119016aacf4c307a93a7b5626026a633e69905b17ea8c1f9f81e391e8311919fae5bab6f9a2ff6e53f83ff454
7
- data.tar.gz: 1a84b06d8c5943f8466234897a3218b27ff344ed65bdc0a96b67a0aa74d6337040ebff422ebcfae70d1cf4fb20b3e5a64ca5975e97d9f70a3878b6248bc0f246
6
+ metadata.gz: a749f50a68169e51b59ed941540f001800ab1e9627541a0a63aa14cc8dc8233ecddfb06a1aafaec2d675bd3911259acb8f336526100e03f3bcb246f6ef20ea81
7
+ data.tar.gz: 51b2b301c0b38f264cabda4c45c6f3296872075e0bbdbbae636c3bebaf33d9082bf67a7dce9f01e1c4035564239b7f93926ced594b2509e3e8600970f9a8b0a9
@@ -6,42 +6,31 @@ module Playbook
6
6
  base.prop :align_content
7
7
  end
8
8
 
9
- # rubocop:disable Style/IfInsideElse
10
- def align_content_props
11
- selected_props = align_content_options.keys.select { |sk| try(sk) }
12
- return nil unless selected_props.present?
13
-
14
- screen_size_values = %w[xs sm md lg xl]
15
-
16
- selected_props.map do |k|
17
- align_content = send(k)
18
- if align_content.is_a?(Hash)
19
- class_result = []
9
+ ALIGN_CONTENT_VALUES = %w[start end center spaceBetween spaceAround spaceEvenly].freeze
10
+ SCREEN_SIZES = %w[xs sm md lg xl].freeze
20
11
 
21
- # Handle default value separately (generates base class without size prefix)
22
- class_result << "align_content_#{align_content[:default].underscore}" if align_content.key?(:default) && align_content_values.include?(align_content[:default])
23
-
24
- # Handle responsive sizes (generates classes with size prefix)
25
- align_content.each do |media_size, align_value|
26
- class_result << "align_content_#{media_size}_#{align_value.underscore}" if screen_size_values.include?(media_size.to_s) && align_content_values.include?(align_value)
27
- end
28
-
29
- class_result
30
- else
31
- "align_content_#{align_content.underscore}" if align_content_values.include? align_content
12
+ def align_content_props
13
+ value = align_content
14
+ return nil unless value
15
+
16
+ if value.is_a?(::Hash)
17
+ css = +""
18
+ css << "align_content_#{value[:default].underscore} " if value.key?(:default) && ALIGN_CONTENT_VALUES.include?(value[:default])
19
+ value.each do |media_size, align_value|
20
+ css << "align_content_#{media_size}_#{align_value.underscore} " if SCREEN_SIZES.include?(media_size.to_s) && ALIGN_CONTENT_VALUES.include?(align_value)
32
21
  end
33
- end.flatten.compact.join(" ")
22
+ css.strip unless css.empty?
23
+ elsif ALIGN_CONTENT_VALUES.include?(value)
24
+ "align_content_#{value.underscore}"
25
+ end
34
26
  end
35
- # rubocop:enable Style/IfInsideElse
36
27
 
37
28
  def align_content_options
38
- {
39
- align_content: "align_content",
40
- }
29
+ { align_content: "align_content" }
41
30
  end
42
31
 
43
32
  def align_content_values
44
- %w[start end center spaceBetween spaceAround spaceEvenly]
33
+ ALIGN_CONTENT_VALUES
45
34
  end
46
35
  end
47
36
  end
@@ -6,42 +6,31 @@ module Playbook
6
6
  base.prop :align_items
7
7
  end
8
8
 
9
- # rubocop:disable Style/IfInsideElse
10
- def align_items_props
11
- selected_props = align_items_options.keys.select { |sk| try(sk) }
12
- return nil unless selected_props.present?
13
-
14
- screen_size_values = %w[xs sm md lg xl]
15
-
16
- selected_props.map do |k|
17
- align_items_value = send(k)
18
- if align_items_value.is_a?(Hash)
19
- class_result = []
9
+ ALIGN_ITEMS_VALUES = %w[flexStart flexEnd start end center baseline stretch].freeze
10
+ SCREEN_SIZES = %w[xs sm md lg xl].freeze
20
11
 
21
- # Handle default value separately (generates base class without size prefix)
22
- class_result << "align_items_#{align_items_value[:default].underscore}" if align_items_value.key?(:default) && align_items_values.include?(align_items_value[:default].to_s)
23
-
24
- # Handle responsive sizes (generates classes with size prefix)
25
- align_items_value.each do |media_size, align_value|
26
- class_result << "align_items_#{media_size}_#{align_value.underscore}" if screen_size_values.include?(media_size.to_s) && align_items_values.include?(align_value.to_s)
27
- end
28
-
29
- class_result
30
- else
31
- "align_items_#{align_items_value.underscore}" if align_items_values.include? align_items_value
12
+ def align_items_props
13
+ value = align_items
14
+ return nil unless value
15
+
16
+ if value.is_a?(::Hash)
17
+ css = +""
18
+ css << "align_items_#{value[:default].underscore} " if value.key?(:default) && ALIGN_ITEMS_VALUES.include?(value[:default].to_s)
19
+ value.each do |media_size, align_value|
20
+ css << "align_items_#{media_size}_#{align_value.underscore} " if SCREEN_SIZES.include?(media_size.to_s) && ALIGN_ITEMS_VALUES.include?(align_value.to_s)
32
21
  end
33
- end.flatten.compact.join(" ")
22
+ css.strip unless css.empty?
23
+ elsif ALIGN_ITEMS_VALUES.include?(value)
24
+ "align_items_#{value.underscore}"
25
+ end
34
26
  end
35
- # rubocop:enable Style/IfInsideElse
36
27
 
37
28
  def align_items_options
38
- {
39
- align_items: "align_items",
40
- }
29
+ { align_items: "align_items" }
41
30
  end
42
31
 
43
32
  def align_items_values
44
- %w[flexStart flexEnd start end center baseline stretch]
33
+ ALIGN_ITEMS_VALUES
45
34
  end
46
35
  end
47
36
  end
@@ -6,42 +6,31 @@ module Playbook
6
6
  base.prop :align_self
7
7
  end
8
8
 
9
- # rubocop:disable Style/IfInsideElse
10
- def align_self_props
11
- selected_props = align_self_options.keys.select { |sk| try(sk) }
12
- return nil unless selected_props.present?
13
-
14
- screen_size_values = %w[xs sm md lg xl]
15
-
16
- selected_props.map do |k|
17
- align_self_value = send(k)
18
- if align_self_value.is_a?(Hash)
19
- class_result = []
9
+ ALIGN_SELF_VALUES = %w[auto start end center stretch baseline].freeze
10
+ SCREEN_SIZES = %w[xs sm md lg xl].freeze
20
11
 
21
- # Handle default value separately (generates base class without size prefix)
22
- class_result << "align_self_#{align_self_value[:default]}" if align_self_value.key?(:default) && align_self_values.include?(align_self_value[:default])
23
-
24
- # Handle responsive sizes (generates classes with size prefix)
25
- align_self_value.each do |media_size, align_value|
26
- class_result << "align_self_#{media_size}_#{align_value}" if screen_size_values.include?(media_size.to_s) && align_self_values.include?(align_value)
27
- end
28
-
29
- class_result
30
- else
31
- "align_self_#{align_self_value}" if align_self_values.include? align_self_value
12
+ def align_self_props
13
+ value = align_self
14
+ return nil unless value
15
+
16
+ if value.is_a?(::Hash)
17
+ css = +""
18
+ css << "align_self_#{value[:default]} " if value.key?(:default) && ALIGN_SELF_VALUES.include?(value[:default])
19
+ value.each do |media_size, align_value|
20
+ css << "align_self_#{media_size}_#{align_value} " if SCREEN_SIZES.include?(media_size.to_s) && ALIGN_SELF_VALUES.include?(align_value)
32
21
  end
33
- end.flatten.compact.join(" ")
34
- # rubocop:enable Style/IfInsideElse
22
+ css.strip unless css.empty?
23
+ elsif ALIGN_SELF_VALUES.include?(value)
24
+ "align_self_#{value}"
25
+ end
35
26
  end
36
27
 
37
28
  def align_self_options
38
- {
39
- align_self: "align_self",
40
- }
29
+ { align_self: "align_self" }
41
30
  end
42
31
 
43
32
  def align_self_values
44
- %w[auto start end center stretch baseline]
33
+ ALIGN_SELF_VALUES
45
34
  end
46
35
  end
47
36
  end
@@ -6,24 +6,21 @@ module Playbook
6
6
  base.prop :border_radius
7
7
  end
8
8
 
9
+ BORDER_RADIUS_VALUES = %w[none xs sm md lg xl rounded].freeze
10
+
9
11
  def border_radius_props
10
- selected_props = border_radius_options.keys.select { |sk| try(sk) }
11
- return nil unless selected_props.present?
12
+ value = border_radius
13
+ return nil unless value
12
14
 
13
- selected_props.map do |k|
14
- border_radius_value = send(k)
15
- "border_radius_#{border_radius_value}" if border_radius_values.include? border_radius_value
16
- end.compact.join(" ")
15
+ "border_radius_#{value}" if BORDER_RADIUS_VALUES.include?(value)
17
16
  end
18
17
 
19
18
  def border_radius_options
20
- {
21
- border_radius: "border_radius",
22
- }
19
+ { border_radius: "border_radius" }
23
20
  end
24
21
 
25
22
  def border_radius_values
26
- %w[none xs sm md lg xl rounded]
23
+ BORDER_RADIUS_VALUES
27
24
  end
28
25
  end
29
26
  end
@@ -10,27 +10,23 @@ module Playbook
10
10
  base.prop :bottom
11
11
  end
12
12
 
13
+ BOTTOM_VALUES = %w[0 xxs xs sm md lg xl auto initial inherit].freeze
14
+
13
15
  def bottom_values
14
- %w[0 xxs xs sm md lg xl auto initial inherit]
16
+ BOTTOM_VALUES
15
17
  end
16
18
 
17
19
  def bottom_options
18
- {
19
- bottom: "bottom",
20
- }
20
+ { bottom: "bottom" }
21
21
  end
22
22
 
23
23
  private
24
24
 
25
25
  def bottom_props
26
- selected_props = bottom_options.keys.select { |sk| try(sk) }
27
- return nil unless selected_props.present?
28
-
29
- selected_props.map do |k|
30
- value = send(k)
31
- css = positioning_css("bottom", value) if bottom.present?
32
- css
33
- end.compact.join(" ")
26
+ value = bottom
27
+ return nil unless value
28
+
29
+ positioning_css("bottom", value)
34
30
  end
35
31
  end
36
32
  end
@@ -8,62 +8,78 @@ module Playbook
8
8
  end
9
9
 
10
10
  def generate_classname(*name_parts, separator: "_")
11
- [
12
- name_parts.compact.join(separator),
13
- prop(:classname),
14
- spacing_props,
15
- dark_props,
16
- width_props,
17
- min_width_props,
18
- max_width_props,
19
- gap_props,
20
- column_gap_props,
21
- row_gap_props,
22
- z_index_props,
23
- number_spacing_props,
24
- shadow_props,
25
- line_height_props,
26
- display_props,
27
- cursor_props,
28
- flex_direction_props,
29
- flex_wrap_props,
30
- justify_content_props,
31
- justify_self_props,
32
- align_items_props,
33
- align_content_props,
34
- align_self_props,
35
- flex_props,
36
- flex_grow_props,
37
- flex_shrink_props,
38
- order_props,
39
- position_props,
40
- hover_props,
41
- border_radius_props,
42
- text_align_props,
43
- overflow_props,
44
- truncate_props,
45
- left_props,
46
- top_props,
47
- right_props,
48
- bottom_props,
49
- vertical_align_props,
50
- height_props,
51
- min_height_props,
52
- max_height_props,
53
- ].compact.join(" ")
11
+ css = +name_parts.compact.join(separator)
12
+ append_classname(css, prop(:classname))
13
+
14
+ # Spacing props (handles margin, padding, and width sub-props)
15
+ append_classname(css, spacing_props)
16
+ css << " dark" if dark
17
+ append_classname(css, width_props)
18
+ append_classname(css, min_width_props)
19
+ append_classname(css, max_width_props)
20
+
21
+ # Gap utilities
22
+ append_classname(css, gap_props)
23
+ append_classname(css, column_gap_props)
24
+ append_classname(css, row_gap_props)
25
+
26
+ # Single-value utilities
27
+ append_classname(css, z_index_props)
28
+ append_classname(css, number_spacing_props)
29
+ append_classname(css, shadow_props)
30
+ append_classname(css, line_height_props)
31
+ append_classname(css, display_props)
32
+ append_classname(css, cursor_props)
33
+
34
+ # Flex utilities
35
+ append_classname(css, flex_direction_props)
36
+ append_classname(css, flex_wrap_props)
37
+ append_classname(css, justify_content_props)
38
+ append_classname(css, justify_self_props)
39
+ append_classname(css, align_items_props)
40
+ append_classname(css, align_content_props)
41
+ append_classname(css, align_self_props)
42
+ append_classname(css, flex_props)
43
+ append_classname(css, flex_grow_props)
44
+ append_classname(css, flex_shrink_props)
45
+ append_classname(css, order_props)
46
+
47
+ # Position and layout
48
+ append_classname(css, position_props)
49
+ append_classname(css, hover_props)
50
+ append_classname(css, border_radius_props)
51
+ append_classname(css, text_align_props)
52
+ append_classname(css, overflow_props)
53
+ append_classname(css, truncate_props)
54
+ append_classname(css, left_props)
55
+ append_classname(css, top_props)
56
+ append_classname(css, right_props)
57
+ append_classname(css, bottom_props)
58
+ append_classname(css, vertical_align_props)
59
+
60
+ # Height utilities
61
+ append_classname(css, height_props)
62
+ append_classname(css, min_height_props)
63
+ append_classname(css, max_height_props)
64
+ css
54
65
  end
55
66
 
56
67
  def generate_classname_without_spacing(*name_parts, separator: "_")
57
- [
58
- name_parts.compact.join(separator),
59
- prop(:classname),
60
- ].compact.join(" ")
68
+ css = +name_parts.compact.join(separator)
69
+ append_classname(css, prop(:classname))
70
+ css
61
71
  end
62
72
 
63
- private
64
-
65
73
  def dark_props
66
74
  dark ? "dark" : nil
67
75
  end
76
+
77
+ private
78
+
79
+ # Appends a CSS class string to the accumulator if the value is present.
80
+ # Used by generate_classname to conditionally add utility prop classes.
81
+ def append_classname(css, value)
82
+ css << " " << value if value
83
+ end
68
84
  end
69
85
  end
@@ -6,24 +6,21 @@ module Playbook
6
6
  base.prop :cursor
7
7
  end
8
8
 
9
+ CURSOR_VALUES = %w[auto default none contextMenu help pointer progress wait cell crosshair text verticalText alias copy move noDrop notAllowed grab grabbing eResize nResize neResize nwResize sResize seResize swResize wResize ewResize nsResize neswResize nwseResize colResize rowResize allScroll zoomIn zoomOut].freeze
10
+
9
11
  def cursor_props
10
- selected_props = cursor_options.keys.select { |sk| try(sk) }
11
- return nil unless selected_props.present?
12
+ value = cursor
13
+ return nil unless value
12
14
 
13
- selected_props.map do |k|
14
- cursor_value = send(k)
15
- "cursor_#{cursor_value.underscore}" if cursor_values.include? cursor_value
16
- end.compact.join(" ")
15
+ "cursor_#{value.underscore}" if CURSOR_VALUES.include?(value)
17
16
  end
18
17
 
19
18
  def cursor_options
20
- {
21
- cursor: "cursor",
22
- }
19
+ { cursor: "cursor" }
23
20
  end
24
21
 
25
22
  def cursor_values
26
- %w[auto default none contextMenu help pointer progress wait cell crosshair text verticalText alias copy move noDrop notAllowed grab grabbing eResize nResize neResize nwResize sResize seResize swResize wResize ewResize nsResize neswResize nwseResize colResize rowResize allScroll zoomIn zoomOut]
23
+ CURSOR_VALUES
27
24
  end
28
25
  end
29
26
  end
@@ -6,41 +6,35 @@ module Playbook
6
6
  base.prop :display
7
7
  end
8
8
 
9
- def display_props
10
- selected_props = display_options.keys.select { |sk| try(sk) }
11
- responsive = selected_props.present? && try(:display).is_a?(::Hash)
12
- css = ""
13
- if responsive
14
- display_value = send(:display)
9
+ DISPLAY_VALUES = %w[block inline_block inline flex inline_flex none grid].freeze
10
+ DISPLAY_SIZE_VALUES = %w[xs sm md lg xl].freeze
15
11
 
16
- # Handle default value separately (generates base class without size prefix)
17
- css += "display_#{display_value[:default]} " if display_value.key?(:default) && display_values.include?(display_value[:default].to_s)
12
+ def display_props
13
+ value = display
14
+ return nil unless value
18
15
 
19
- # Handle responsive sizes (generates classes with size prefix)
20
- display_value.each do |key, value|
21
- css += "display_#{key}_#{value} " if display_size_values.include?(key.to_s) && display_values.include?(value.to_s)
22
- end
23
- else
24
- selected_props.each do |k|
25
- display_value = send(k)
26
- css += "display_#{display_value}" if display_values.include?(display_value)
16
+ if value.is_a?(::Hash)
17
+ css = +""
18
+ css << "display_#{value[:default]} " if value.key?(:default) && DISPLAY_VALUES.include?(value[:default].to_s)
19
+ value.each do |key, val|
20
+ css << "display_#{key}_#{val} " if DISPLAY_SIZE_VALUES.include?(key.to_s) && DISPLAY_VALUES.include?(val.to_s)
27
21
  end
22
+ css.strip unless css.empty?
23
+ elsif DISPLAY_VALUES.include?(value)
24
+ "display_#{value}"
28
25
  end
29
- css unless css.blank?
30
26
  end
31
27
 
32
28
  def display_options
33
- {
34
- display: "display",
35
- }
29
+ { display: "display" }
36
30
  end
37
31
 
38
32
  def display_size_values
39
- %w[xs sm md lg xl]
33
+ DISPLAY_SIZE_VALUES
40
34
  end
41
35
 
42
36
  def display_values
43
- %w[block inline_block inline flex inline_flex none grid]
37
+ DISPLAY_VALUES
44
38
  end
45
39
  end
46
40
  end
data/lib/playbook/flex.rb CHANGED
@@ -6,42 +6,31 @@ module Playbook
6
6
  base.prop :flex
7
7
  end
8
8
 
9
- # rubocop:disable Style/IfInsideElse
10
- def flex_props
11
- selected_props = flex_options.keys.select { |sk| try(sk) }
12
- return nil unless selected_props.present?
13
-
14
- screen_size_values = %w[xs sm md lg xl]
15
-
16
- selected_props.map do |k|
17
- flex_value = send(k)
18
- if flex_value.is_a?(Hash)
19
- class_result = []
9
+ FLEX_VALUES = %w[auto initial 0 1 2 3 4 5 6 7 8 9 10 11 12 none].freeze
10
+ SCREEN_SIZES = %w[xs sm md lg xl].freeze
20
11
 
21
- # Handle default value separately (generates base class without size prefix)
22
- class_result << "flex_#{flex_value[:default]}" if flex_value.key?(:default) && flex_values.include?(flex_value[:default].to_s)
23
-
24
- # Handle responsive sizes (generates classes with size prefix)
25
- flex_value.each do |media_size, value|
26
- class_result << "flex_#{media_size}_#{value}" if screen_size_values.include?(media_size.to_s) && flex_values.include?(value.to_s)
27
- end
28
-
29
- class_result
30
- else
31
- "flex_#{flex_value}" if flex_values.include? flex_value.to_s
12
+ def flex_props
13
+ value = flex
14
+ return nil unless value
15
+
16
+ if value.is_a?(::Hash)
17
+ css = +""
18
+ css << "flex_#{value[:default]} " if value.key?(:default) && FLEX_VALUES.include?(value[:default].to_s)
19
+ value.each do |media_size, val|
20
+ css << "flex_#{media_size}_#{val} " if SCREEN_SIZES.include?(media_size.to_s) && FLEX_VALUES.include?(val.to_s)
32
21
  end
33
- end.flatten.compact.join(" ")
22
+ css.strip unless css.empty?
23
+ elsif FLEX_VALUES.include?(value.to_s)
24
+ "flex_#{value}"
25
+ end
34
26
  end
35
- # rubocop:enable Style/IfInsideElse
36
27
 
37
28
  def flex_options
38
- {
39
- flex: "flex",
40
- }
29
+ { flex: "flex" }
41
30
  end
42
31
 
43
32
  def flex_values
44
- %w[auto initial 0 1 2 3 4 5 6 7 8 9 10 11 12 none]
33
+ FLEX_VALUES
45
34
  end
46
35
  end
47
36
  end
@@ -6,42 +6,31 @@ module Playbook
6
6
  base.prop :flex_direction
7
7
  end
8
8
 
9
- # rubocop:disable Style/IfInsideElse
10
- def flex_direction_props
11
- selected_props = flex_direction_options.keys.select { |sk| try(sk) }
12
- return nil unless selected_props.present?
13
-
14
- screen_size_values = %w[xs sm md lg xl]
15
-
16
- selected_props.map do |k|
17
- flex_direction_value = send(k)
18
- if flex_direction_value.is_a?(Hash)
19
- class_result = []
9
+ FLEX_DIRECTION_VALUES = %w[row column rowReverse columnReverse].freeze
10
+ SCREEN_SIZES = %w[xs sm md lg xl].freeze
20
11
 
21
- # Handle default value separately (generates base class without size prefix)
22
- class_result << "flex_direction_#{flex_direction_value[:default].underscore}" if flex_direction_value.key?(:default) && flex_direction_values.include?(flex_direction_value[:default])
23
-
24
- # Handle responsive sizes (generates classes with size prefix)
25
- flex_direction_value.each do |media_size, flex_value|
26
- class_result << "flex_direction_#{media_size}_#{flex_value.underscore}" if screen_size_values.include?(media_size.to_s) && flex_direction_values.include?(flex_value)
27
- end
28
-
29
- class_result
30
- else
31
- "flex_direction_#{flex_direction_value.underscore}" if flex_direction_values.include? flex_direction_value
12
+ def flex_direction_props
13
+ value = flex_direction
14
+ return nil unless value
15
+
16
+ if value.is_a?(::Hash)
17
+ css = +""
18
+ css << "flex_direction_#{value[:default].underscore} " if value.key?(:default) && FLEX_DIRECTION_VALUES.include?(value[:default])
19
+ value.each do |media_size, flex_value|
20
+ css << "flex_direction_#{media_size}_#{flex_value.underscore} " if SCREEN_SIZES.include?(media_size.to_s) && FLEX_DIRECTION_VALUES.include?(flex_value)
32
21
  end
33
- end.flatten.compact.join(" ")
22
+ css.strip unless css.empty?
23
+ elsif FLEX_DIRECTION_VALUES.include?(value)
24
+ "flex_direction_#{value.underscore}"
25
+ end
34
26
  end
35
- # rubocop:enable Style/IfInsideElse
36
27
 
37
28
  def flex_direction_options
38
- {
39
- flex_direction: "flex_direction",
40
- }
29
+ { flex_direction: "flex_direction" }
41
30
  end
42
31
 
43
32
  def flex_direction_values
44
- %w[row column rowReverse columnReverse]
33
+ FLEX_DIRECTION_VALUES
45
34
  end
46
35
  end
47
36
  end