line-message-builder 0.9.0 → 0.10.0
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/.release-please-manifest.json +1 -1
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +20 -0
- data/CLAUDE.md +124 -0
- data/README.md +24 -16
- data/claudekit.json +11 -0
- data/docs/rubrics/rdoc.md +169 -0
- data/lib/line/message/builder/actions/message.rb +47 -26
- data/lib/line/message/builder/actions/postback.rb +56 -26
- data/lib/line/message/builder/actions/uri.rb +139 -0
- data/lib/line/message/builder/actions.rb +6 -3
- data/lib/line/message/builder/base.rb +92 -67
- data/lib/line/message/builder/container.rb +55 -60
- data/lib/line/message/builder/context.rb +51 -72
- data/lib/line/message/builder/flex/actionable.rb +53 -32
- data/lib/line/message/builder/flex/box.rb +342 -79
- data/lib/line/message/builder/flex/bubble.rb +73 -46
- data/lib/line/message/builder/flex/builder.rb +39 -28
- data/lib/line/message/builder/flex/button.rb +90 -42
- data/lib/line/message/builder/flex/carousel.rb +48 -20
- data/lib/line/message/builder/flex/icon.rb +152 -0
- data/lib/line/message/builder/flex/image.rb +95 -33
- data/lib/line/message/builder/flex/partial.rb +47 -49
- data/lib/line/message/builder/flex/position.rb +187 -100
- data/lib/line/message/builder/flex/separator.rb +49 -6
- data/lib/line/message/builder/flex/size.rb +67 -47
- data/lib/line/message/builder/flex/span.rb +106 -32
- data/lib/line/message/builder/flex/text.rb +166 -54
- data/lib/line/message/builder/flex.rb +26 -23
- data/lib/line/message/builder/quick_reply.rb +174 -4
- data/lib/line/message/builder/text.rb +70 -3
- data/lib/line/message/builder/version.rb +1 -1
- data/lib/line/message/builder.rb +14 -11
- data/lib/line/message/rspec/matchers/have_flex_bubble.rb +1 -1
- data/lib/line/message/rspec/matchers/have_flex_component.rb +16 -6
- data/lib/line/message/rspec/matchers/have_flex_message.rb +1 -1
- data/lib/line/message/rspec/matchers/have_flex_separator.rb +1 -1
- data/lib/line/message/rspec/matchers/have_quick_reply.rb +1 -1
- data/lib/line/message/rspec/matchers/have_text_message.rb +1 -1
- data/llm.txt +276 -35
- data/release-please-config.json +3 -1
- metadata +9 -3
|
@@ -4,34 +4,39 @@ module Line
|
|
|
4
4
|
module Message
|
|
5
5
|
module Builder
|
|
6
6
|
module Flex
|
|
7
|
-
# The
|
|
7
|
+
# The Position module serves as a namespace for several mixin modules
|
|
8
8
|
# that provide common positioning-related properties (options) to various
|
|
9
|
-
# Flex Message components (like
|
|
9
|
+
# Flex Message components (like Box, Text, Image, Button).
|
|
10
10
|
#
|
|
11
11
|
# These mixins are included in component classes to add DSL methods for
|
|
12
12
|
# setting properties like alignment, gravity, padding, margin, and offsets,
|
|
13
13
|
# which correspond to attributes in the LINE Flex Message JSON structure.
|
|
14
14
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
15
|
+
# See also:
|
|
16
|
+
# - Horizontal for +align+ property
|
|
17
|
+
# - Vertical for +gravity+ property
|
|
18
|
+
# - Padding for +padding_all+, +padding_top+, etc. properties
|
|
19
|
+
# - Margin for +margin+ property
|
|
20
|
+
# - Offset for +position+, +offset_top+, etc. properties
|
|
20
21
|
module Position
|
|
21
|
-
# Provides the
|
|
22
|
-
# within its parent
|
|
23
|
-
# For components like
|
|
22
|
+
# Provides the +align+ option for horizontal alignment of a component
|
|
23
|
+
# within its parent Box (if the parent box's +layout+ is vertical).
|
|
24
|
+
# For components like Image or Text, this controls their horizontal
|
|
24
25
|
# alignment within the space allocated to them.
|
|
25
|
-
#
|
|
26
|
-
# @!method align(value)
|
|
27
|
-
# Sets or gets the horizontal alignment.
|
|
28
|
-
# @param value [Symbol, String, nil] Alignment keyword:
|
|
29
|
-
# `:start` (aligns to the start of the horizontal space),
|
|
30
|
-
# `:center` (aligns to the center),
|
|
31
|
-
# `:end` (aligns to the end).
|
|
32
|
-
# @return [Symbol, String, nil] The current alignment value.
|
|
33
26
|
module Horizontal
|
|
34
|
-
|
|
27
|
+
##
|
|
28
|
+
# :method: align
|
|
29
|
+
# :call-seq:
|
|
30
|
+
# align() -> Symbol, String, or nil
|
|
31
|
+
# align(value) -> Symbol, String, or nil
|
|
32
|
+
#
|
|
33
|
+
# Sets or gets the horizontal alignment.
|
|
34
|
+
#
|
|
35
|
+
# [value]
|
|
36
|
+
# Alignment keyword: +:start+ (aligns to the start of the horizontal space),
|
|
37
|
+
# +:center+ (aligns to the center), +:end+ (aligns to the end)
|
|
38
|
+
|
|
39
|
+
# :nodoc:
|
|
35
40
|
def self.included(base)
|
|
36
41
|
base.option :align,
|
|
37
42
|
default: nil,
|
|
@@ -41,20 +46,24 @@ module Line
|
|
|
41
46
|
end
|
|
42
47
|
end
|
|
43
48
|
|
|
44
|
-
# Provides the
|
|
45
|
-
# within its parent
|
|
46
|
-
# or baseline). For components like
|
|
49
|
+
# Provides the +gravity+ option for vertical alignment of a component
|
|
50
|
+
# within its parent Box (if the parent box's +layout+ is horizontal
|
|
51
|
+
# or baseline). For components like Image or Text, this controls
|
|
47
52
|
# their vertical alignment within the space allocated to them.
|
|
48
|
-
#
|
|
49
|
-
# @!method gravity(value)
|
|
50
|
-
# Sets or gets the vertical alignment (gravity).
|
|
51
|
-
# @param value [Symbol, String, nil] Gravity keyword:
|
|
52
|
-
# `:top` (aligns to the top),
|
|
53
|
-
# `:center` (aligns to the center),
|
|
54
|
-
# `:bottom` (aligns to the bottom).
|
|
55
|
-
# @return [Symbol, String, nil] The current gravity value.
|
|
56
53
|
module Vertical
|
|
57
|
-
|
|
54
|
+
##
|
|
55
|
+
# :method: gravity
|
|
56
|
+
# :call-seq:
|
|
57
|
+
# gravity() -> Symbol, String, or nil
|
|
58
|
+
# gravity(value) -> Symbol, String, or nil
|
|
59
|
+
#
|
|
60
|
+
# Sets or gets the vertical alignment (gravity).
|
|
61
|
+
#
|
|
62
|
+
# [value]
|
|
63
|
+
# Gravity keyword: +:top+ (aligns to the top), +:center+ (aligns to the center),
|
|
64
|
+
# +:bottom+ (aligns to the bottom)
|
|
65
|
+
|
|
66
|
+
# :nodoc:
|
|
58
67
|
def self.included(base)
|
|
59
68
|
base.option :gravity, # NOTE: API key is `gravity` (lowercase `g`)
|
|
60
69
|
default: nil,
|
|
@@ -67,40 +76,83 @@ module Line
|
|
|
67
76
|
# Provides padding options for components, allowing space to be defined
|
|
68
77
|
# around the content of a component, inside its borders.
|
|
69
78
|
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
# @param value [String, Symbol, nil] Padding value (e.g., `"10px"`, `"md"`, `"5%"`).
|
|
74
|
-
# Keywords: `:none`, `:xs`, `:sm`, `:md`, `:lg`, `:xl`, `:xxl`.
|
|
75
|
-
# @return [String, Symbol, nil] The current padding value.
|
|
76
|
-
#
|
|
77
|
-
# @!method padding_top(value)
|
|
78
|
-
# Sets or gets the top padding. Corresponds to LINE API `paddingTop`.
|
|
79
|
-
# @param value [String, Symbol, nil] Padding value.
|
|
80
|
-
# @return [String, Symbol, nil] The current top padding.
|
|
81
|
-
#
|
|
82
|
-
# @!method padding_bottom(value)
|
|
83
|
-
# Sets or gets the bottom padding. Corresponds to LINE API `paddingBottom`.
|
|
84
|
-
# @param value [String, Symbol, nil] Padding value.
|
|
85
|
-
# @return [String, Symbol, nil] The current bottom padding.
|
|
86
|
-
#
|
|
87
|
-
# @!method padding_start(value)
|
|
88
|
-
# Sets or gets the start-edge padding (left in LTR, right in RTL).
|
|
89
|
-
# Corresponds to LINE API `paddingStart`.
|
|
90
|
-
# @param value [String, Symbol, nil] Padding value.
|
|
91
|
-
# @return [String, Symbol, nil] The current start padding.
|
|
92
|
-
#
|
|
93
|
-
# @!method padding_end(value)
|
|
94
|
-
# Sets or gets the end-edge padding (right in LTR, left in RTL).
|
|
95
|
-
# Corresponds to LINE API `paddingEnd`.
|
|
96
|
-
# @param value [String, Symbol, nil] Padding value.
|
|
97
|
-
# @return [String, Symbol, nil] The current end padding.
|
|
98
|
-
#
|
|
99
|
-
# @note In this DSL, `padding` is an alias for `padding_all`.
|
|
100
|
-
# The LINE API uses `paddingAll`. When using the DSL `padding(value)`,
|
|
101
|
-
# it sets the underlying value that will be output as `paddingAll`.
|
|
79
|
+
# Note: In this DSL, +padding+ is an alias for +padding_all+.
|
|
80
|
+
# The LINE API uses +paddingAll+. When using the DSL <code>padding(value)</code>,
|
|
81
|
+
# it sets the underlying value that will be output as +paddingAll+.
|
|
102
82
|
module Padding
|
|
103
|
-
|
|
83
|
+
##
|
|
84
|
+
# :method: padding
|
|
85
|
+
# :call-seq:
|
|
86
|
+
# padding() -> String, Symbol, or nil
|
|
87
|
+
# padding(value) -> String, Symbol, or nil
|
|
88
|
+
#
|
|
89
|
+
# Sets or gets the padding for all sides (alias for +padding_all+).
|
|
90
|
+
# Corresponds to LINE API +paddingAll+.
|
|
91
|
+
#
|
|
92
|
+
# [value]
|
|
93
|
+
# Padding value (e.g. <code>"10px"</code>, <code>"md"</code>, <code>"5%"</code>).
|
|
94
|
+
# Keywords: +:none+, +:xs+, +:sm+, +:md+, +:lg+, +:xl+, +:xxl+
|
|
95
|
+
|
|
96
|
+
##
|
|
97
|
+
# :method: padding_all
|
|
98
|
+
# :call-seq:
|
|
99
|
+
# padding_all() -> String, Symbol, or nil
|
|
100
|
+
# padding_all(value) -> String, Symbol, or nil
|
|
101
|
+
#
|
|
102
|
+
# Sets or gets the padding for all sides.
|
|
103
|
+
# Corresponds to LINE API +paddingAll+.
|
|
104
|
+
#
|
|
105
|
+
# [value]
|
|
106
|
+
# Padding value (e.g. <code>"10px"</code>, <code>"md"</code>, <code>"5%"</code>).
|
|
107
|
+
# Keywords: +:none+, +:xs+, +:sm+, +:md+, +:lg+, +:xl+, +:xxl+
|
|
108
|
+
|
|
109
|
+
##
|
|
110
|
+
# :method: padding_top
|
|
111
|
+
# :call-seq:
|
|
112
|
+
# padding_top() -> String, Symbol, or nil
|
|
113
|
+
# padding_top(value) -> String, Symbol, or nil
|
|
114
|
+
#
|
|
115
|
+
# Sets or gets the top padding. Corresponds to LINE API +paddingTop+.
|
|
116
|
+
#
|
|
117
|
+
# [value]
|
|
118
|
+
# Padding value
|
|
119
|
+
|
|
120
|
+
##
|
|
121
|
+
# :method: padding_bottom
|
|
122
|
+
# :call-seq:
|
|
123
|
+
# padding_bottom() -> String, Symbol, or nil
|
|
124
|
+
# padding_bottom(value) -> String, Symbol, or nil
|
|
125
|
+
#
|
|
126
|
+
# Sets or gets the bottom padding. Corresponds to LINE API +paddingBottom+.
|
|
127
|
+
#
|
|
128
|
+
# [value]
|
|
129
|
+
# Padding value
|
|
130
|
+
|
|
131
|
+
##
|
|
132
|
+
# :method: padding_start
|
|
133
|
+
# :call-seq:
|
|
134
|
+
# padding_start() -> String, Symbol, or nil
|
|
135
|
+
# padding_start(value) -> String, Symbol, or nil
|
|
136
|
+
#
|
|
137
|
+
# Sets or gets the start-edge padding (left in LTR, right in RTL).
|
|
138
|
+
# Corresponds to LINE API +paddingStart+.
|
|
139
|
+
#
|
|
140
|
+
# [value]
|
|
141
|
+
# Padding value
|
|
142
|
+
|
|
143
|
+
##
|
|
144
|
+
# :method: padding_end
|
|
145
|
+
# :call-seq:
|
|
146
|
+
# padding_end() -> String, Symbol, or nil
|
|
147
|
+
# padding_end(value) -> String, Symbol, or nil
|
|
148
|
+
#
|
|
149
|
+
# Sets or gets the end-edge padding (right in LTR, left in RTL).
|
|
150
|
+
# Corresponds to LINE API +paddingEnd+.
|
|
151
|
+
#
|
|
152
|
+
# [value]
|
|
153
|
+
# Padding value
|
|
154
|
+
|
|
155
|
+
# :nodoc:
|
|
104
156
|
def self.included(base)
|
|
105
157
|
# Individual side paddings
|
|
106
158
|
%i[padding padding_all padding_top padding_bottom padding_start padding_end].each do |option_name|
|
|
@@ -111,16 +163,22 @@ module Line
|
|
|
111
163
|
end
|
|
112
164
|
end
|
|
113
165
|
|
|
114
|
-
# Provides the
|
|
166
|
+
# Provides the +margin+ option, allowing space to be defined around a
|
|
115
167
|
# component, outside its borders.
|
|
116
|
-
#
|
|
117
|
-
# @!method margin(value)
|
|
118
|
-
# Sets or gets the margin space around the component.
|
|
119
|
-
# @param value [String, Symbol, nil] Margin value (e.g., `"10px"`, `"md"`).
|
|
120
|
-
# Keywords: `:none`, `:xs`, `:sm`, `:md`, `:lg`, `:xl`, `:xxl`.
|
|
121
|
-
# @return [String, Symbol, nil] The current margin value.
|
|
122
168
|
module Margin
|
|
123
|
-
|
|
169
|
+
##
|
|
170
|
+
# :method: margin
|
|
171
|
+
# :call-seq:
|
|
172
|
+
# margin() -> String, Symbol, or nil
|
|
173
|
+
# margin(value) -> String, Symbol, or nil
|
|
174
|
+
#
|
|
175
|
+
# Sets or gets the margin space around the component.
|
|
176
|
+
#
|
|
177
|
+
# [value]
|
|
178
|
+
# Margin value (e.g. <code>"10px"</code>, <code>"md"</code>).
|
|
179
|
+
# Keywords: +:none+, +:xs+, +:sm+, +:md+, +:lg+, +:xl+, +:xxl+
|
|
180
|
+
|
|
181
|
+
# :nodoc:
|
|
124
182
|
def self.included(base)
|
|
125
183
|
base.option :margin,
|
|
126
184
|
default: nil,
|
|
@@ -130,35 +188,64 @@ module Line
|
|
|
130
188
|
|
|
131
189
|
# Provides options for positioning components using offsets, either
|
|
132
190
|
# absolutely or relatively to their normal position.
|
|
133
|
-
#
|
|
134
|
-
# @!method position(value)
|
|
135
|
-
# Sets or gets the positioning scheme.
|
|
136
|
-
# @param value [Symbol, String, nil] Positioning type:
|
|
137
|
-
# `:relative` (default, offsets are relative to normal position),
|
|
138
|
-
# `:absolute` (offsets are relative to the parent component's edges).
|
|
139
|
-
# @return [Symbol, String, nil] The current position type.
|
|
140
|
-
#
|
|
141
|
-
# @!method offset_top(value)
|
|
142
|
-
# Sets or gets the top offset. Corresponds to LINE API `offsetTop`.
|
|
143
|
-
# @param value [String, Symbol, nil] Offset value (e.g., `"10px"`, `"md"`).
|
|
144
|
-
# @return [String, Symbol, nil] The current top offset.
|
|
145
|
-
#
|
|
146
|
-
# @!method offset_bottom(value)
|
|
147
|
-
# Sets or gets the bottom offset. Corresponds to LINE API `offsetBottom`.
|
|
148
|
-
# @param value [String, Symbol, nil] Offset value.
|
|
149
|
-
# @return [String, Symbol, nil] The current bottom offset.
|
|
150
|
-
#
|
|
151
|
-
# @!method offset_start(value)
|
|
152
|
-
# Sets or gets the start-edge offset. Corresponds to LINE API `offsetStart`.
|
|
153
|
-
# @param value [String, Symbol, nil] Offset value.
|
|
154
|
-
# @return [String, Symbol, nil] The current start offset.
|
|
155
|
-
#
|
|
156
|
-
# @!method offset_end(value)
|
|
157
|
-
# Sets or gets the end-edge offset. Corresponds to LINE API `offsetEnd`.
|
|
158
|
-
# @param value [String, Symbol, nil] Offset value.
|
|
159
|
-
# @return [String, Symbol, nil] The current end offset.
|
|
160
191
|
module Offset
|
|
161
|
-
|
|
192
|
+
##
|
|
193
|
+
# :method: position
|
|
194
|
+
# :call-seq:
|
|
195
|
+
# position() -> Symbol, String, or nil
|
|
196
|
+
# position(value) -> Symbol, String, or nil
|
|
197
|
+
#
|
|
198
|
+
# Sets or gets the positioning scheme.
|
|
199
|
+
#
|
|
200
|
+
# [value]
|
|
201
|
+
# Positioning type: +:relative+ (default, offsets are relative to normal position),
|
|
202
|
+
# +:absolute+ (offsets are relative to the parent component's edges)
|
|
203
|
+
|
|
204
|
+
##
|
|
205
|
+
# :method: offset_top
|
|
206
|
+
# :call-seq:
|
|
207
|
+
# offset_top() -> String, Symbol, or nil
|
|
208
|
+
# offset_top(value) -> String, Symbol, or nil
|
|
209
|
+
#
|
|
210
|
+
# Sets or gets the top offset. Corresponds to LINE API +offsetTop+.
|
|
211
|
+
#
|
|
212
|
+
# [value]
|
|
213
|
+
# Offset value (e.g. <code>"10px"</code>, <code>"md"</code>)
|
|
214
|
+
|
|
215
|
+
##
|
|
216
|
+
# :method: offset_bottom
|
|
217
|
+
# :call-seq:
|
|
218
|
+
# offset_bottom() -> String, Symbol, or nil
|
|
219
|
+
# offset_bottom(value) -> String, Symbol, or nil
|
|
220
|
+
#
|
|
221
|
+
# Sets or gets the bottom offset. Corresponds to LINE API +offsetBottom+.
|
|
222
|
+
#
|
|
223
|
+
# [value]
|
|
224
|
+
# Offset value
|
|
225
|
+
|
|
226
|
+
##
|
|
227
|
+
# :method: offset_start
|
|
228
|
+
# :call-seq:
|
|
229
|
+
# offset_start() -> String, Symbol, or nil
|
|
230
|
+
# offset_start(value) -> String, Symbol, or nil
|
|
231
|
+
#
|
|
232
|
+
# Sets or gets the start-edge offset. Corresponds to LINE API +offsetStart+.
|
|
233
|
+
#
|
|
234
|
+
# [value]
|
|
235
|
+
# Offset value
|
|
236
|
+
|
|
237
|
+
##
|
|
238
|
+
# :method: offset_end
|
|
239
|
+
# :call-seq:
|
|
240
|
+
# offset_end() -> String, Symbol, or nil
|
|
241
|
+
# offset_end(value) -> String, Symbol, or nil
|
|
242
|
+
#
|
|
243
|
+
# Sets or gets the end-edge offset. Corresponds to LINE API +offsetEnd+.
|
|
244
|
+
#
|
|
245
|
+
# [value]
|
|
246
|
+
# Offset value
|
|
247
|
+
|
|
248
|
+
# :nodoc:
|
|
162
249
|
def self.included(base)
|
|
163
250
|
base.option :position,
|
|
164
251
|
default: nil, # LINE API default is :relative if offsets are used
|
|
@@ -4,13 +4,14 @@ module Line
|
|
|
4
4
|
module Message
|
|
5
5
|
module Builder
|
|
6
6
|
module Flex
|
|
7
|
-
# Represents a
|
|
7
|
+
# Represents a separator component in a LINE Flex Message.
|
|
8
8
|
#
|
|
9
9
|
# Separator components are used to create a visual separation between components
|
|
10
10
|
# within a container. They draw a horizontal line that helps organize the layout
|
|
11
11
|
# and improve readability.
|
|
12
12
|
#
|
|
13
|
-
#
|
|
13
|
+
# == Example
|
|
14
|
+
#
|
|
14
15
|
# Line::Message::Builder.with do
|
|
15
16
|
# flex alt_text: "Separator Example" do
|
|
16
17
|
# bubble do
|
|
@@ -23,16 +24,58 @@ module Line
|
|
|
23
24
|
# end
|
|
24
25
|
# end
|
|
25
26
|
#
|
|
26
|
-
#
|
|
27
|
+
# === Example: Spacing and tinting the line
|
|
28
|
+
#
|
|
29
|
+
# Line::Message::Builder.with do
|
|
30
|
+
# flex alt_text: "Separator Example" do
|
|
31
|
+
# bubble do
|
|
32
|
+
# body do
|
|
33
|
+
# text "Section 1"
|
|
34
|
+
# separator margin: :xl, color: "#F0F0F0"
|
|
35
|
+
# text "Section 2"
|
|
36
|
+
# end
|
|
37
|
+
# end
|
|
38
|
+
# end
|
|
39
|
+
# end
|
|
40
|
+
#
|
|
41
|
+
# See also:
|
|
42
|
+
# - https://developers.line.biz/en/reference/messaging-api/#separator
|
|
43
|
+
# - Position::Margin for the +margin+ property
|
|
27
44
|
class Separator < Line::Message::Builder::Base
|
|
45
|
+
include Position::Margin # Adds `margin` option.
|
|
46
|
+
|
|
47
|
+
# :method: color
|
|
48
|
+
# :call-seq:
|
|
49
|
+
# color() -> String or nil
|
|
50
|
+
# color(value) -> String
|
|
51
|
+
#
|
|
52
|
+
# Sets or gets the color of the separator line.
|
|
53
|
+
#
|
|
54
|
+
# [value]
|
|
55
|
+
# Hexadecimal color code (e.g., <code>"#RRGGBB"</code>)
|
|
56
|
+
option :color, default: nil
|
|
57
|
+
|
|
28
58
|
# Converts the separator component to a hash representation compatible with
|
|
29
59
|
# the LINE Messaging API.
|
|
30
60
|
#
|
|
31
|
-
#
|
|
61
|
+
# The +margin+ and +color+ properties share the same name in both the API
|
|
62
|
+
# and SDK v2 formats, so a single representation serves both.
|
|
63
|
+
#
|
|
64
|
+
# Returns a hash containing the separator component's type and any set
|
|
65
|
+
# properties.
|
|
66
|
+
#
|
|
67
|
+
# == Example
|
|
68
|
+
#
|
|
69
|
+
# separator = Separator.new(margin: :md)
|
|
70
|
+
# separator.to_h
|
|
71
|
+
# # => { type: "separator", margin: :md }
|
|
32
72
|
def to_h
|
|
33
73
|
{
|
|
34
|
-
type: "separator"
|
|
35
|
-
|
|
74
|
+
type: "separator",
|
|
75
|
+
# Position::Margin
|
|
76
|
+
margin: margin,
|
|
77
|
+
color: color # From option
|
|
78
|
+
}.compact
|
|
36
79
|
end
|
|
37
80
|
end
|
|
38
81
|
end
|
|
@@ -4,50 +4,61 @@ module Line
|
|
|
4
4
|
module Message
|
|
5
5
|
module Builder
|
|
6
6
|
module Flex
|
|
7
|
-
# The
|
|
7
|
+
# The Size module acts as a namespace for several mixin modules that
|
|
8
8
|
# provide various size-related properties (options) to Flex Message
|
|
9
9
|
# components. These properties control aspects like the component's flex
|
|
10
10
|
# factor within a box, specific size keywords for images or text, and
|
|
11
11
|
# adjustment behaviors like shrink-to-fit.
|
|
12
12
|
#
|
|
13
|
-
# These mixins are included in component classes (e.g.,
|
|
13
|
+
# These mixins are included in component classes (e.g., Box, Image, Text)
|
|
14
14
|
# to add DSL methods for these sizing attributes.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
16
|
+
# See also:
|
|
17
|
+
# - Flex - For +flex+ property (flex grow/shrink factor)
|
|
18
|
+
# - Image - For image-specific +size+ keywords
|
|
19
|
+
# - Shared - For common +size+ keywords (text, icons, spans)
|
|
20
|
+
# - AdjustMode - For +adjust_mode+ property (e.g., shrink-to-fit)
|
|
20
21
|
module Size
|
|
21
|
-
# Provides the
|
|
22
|
-
# component occupies within its parent
|
|
22
|
+
# Provides the +flex+ option, which determines the ratio of space a
|
|
23
|
+
# component occupies within its parent Box relative to its siblings.
|
|
23
24
|
# A higher flex value means the component will take up more space.
|
|
24
25
|
# A value of 0 means the component does not flex (its size is fixed).
|
|
25
|
-
#
|
|
26
|
-
# @!method flex(value)
|
|
27
|
-
# Sets or gets the flex factor of the component.
|
|
28
|
-
# @param value [Integer, nil] The flex factor. `0` means no flex.
|
|
29
|
-
# Positive integers determine the ratio.
|
|
30
|
-
# @return [Integer, nil] The current flex factor.
|
|
31
26
|
module Flex
|
|
32
|
-
|
|
27
|
+
##
|
|
28
|
+
# :method: flex
|
|
29
|
+
# :call-seq:
|
|
30
|
+
# flex() -> Integer or nil
|
|
31
|
+
# flex(value) -> Integer
|
|
32
|
+
#
|
|
33
|
+
# Sets or gets the flex factor of the component.
|
|
34
|
+
#
|
|
35
|
+
# [value]
|
|
36
|
+
# The flex factor. +0+ means no flex. Positive integers determine the ratio.
|
|
37
|
+
|
|
38
|
+
# :nodoc:
|
|
33
39
|
def self.included(base)
|
|
34
40
|
base.option :flex,
|
|
35
41
|
default: nil # Default is 0 if not specified and parent is a Box
|
|
36
42
|
end
|
|
37
43
|
end
|
|
38
44
|
|
|
39
|
-
# Provides the
|
|
45
|
+
# Provides the +size+ option specifically for Image components.
|
|
40
46
|
# This allows setting the image size using keywords recognized by the
|
|
41
47
|
# LINE API for images, or explicit pixel/percentage values.
|
|
42
|
-
#
|
|
43
|
-
# @!method size(value)
|
|
44
|
-
# Sets or gets the size of the image.
|
|
45
|
-
# @param value [Symbol, String, nil] Image size. Can be keywords like
|
|
46
|
-
# `:xxs`, `:xs`, `:sm`, `:md`, `:lg`, `:xl`, `:xxl`, `:full`,
|
|
47
|
-
# or a string like `"50px"`, `"25%"`.
|
|
48
|
-
# @return [Symbol, String, nil] The current image size.
|
|
49
48
|
module Image
|
|
50
|
-
|
|
49
|
+
##
|
|
50
|
+
# :method: size
|
|
51
|
+
# :call-seq:
|
|
52
|
+
# size() -> Symbol, String, or nil
|
|
53
|
+
# size(value) -> Symbol or String
|
|
54
|
+
#
|
|
55
|
+
# Sets or gets the size of the image.
|
|
56
|
+
#
|
|
57
|
+
# [value]
|
|
58
|
+
# Image size. Can be keywords like +:xxs+, +:xs+, +:sm+, +:md+, +:lg+,
|
|
59
|
+
# +:xl+, +:xxl+, +:full+, or a string like <code>"50px"</code> or <code>"25%"</code>.
|
|
60
|
+
|
|
61
|
+
# :nodoc:
|
|
51
62
|
def self.included(base)
|
|
52
63
|
base.option :size,
|
|
53
64
|
default: nil,
|
|
@@ -55,18 +66,23 @@ module Line
|
|
|
55
66
|
end
|
|
56
67
|
end
|
|
57
68
|
|
|
58
|
-
# Provides a common
|
|
59
|
-
# and
|
|
69
|
+
# Provides a common +size+ option for components like Text, Icon,
|
|
70
|
+
# and Span. This allows setting size using standard keywords or explicit
|
|
60
71
|
# pixel values.
|
|
61
|
-
#
|
|
62
|
-
# @!method size(value)
|
|
63
|
-
# Sets or gets the size of the component (e.g., text font size).
|
|
64
|
-
# @param value [Symbol, String, nil] Component size. Can be keywords like
|
|
65
|
-
# `:xxs`, `:xs`, `:sm`, `:md`, `:lg`, `:xl`, `:xxl`, `3xl`, `4xl`, `5xl`,
|
|
66
|
-
# or a string like `"16px"`.
|
|
67
|
-
# @return [Symbol, String, nil] The current component size.
|
|
68
72
|
module Shared
|
|
69
|
-
|
|
73
|
+
##
|
|
74
|
+
# :method: size
|
|
75
|
+
# :call-seq:
|
|
76
|
+
# size() -> Symbol, String, or nil
|
|
77
|
+
# size(value) -> Symbol or String
|
|
78
|
+
#
|
|
79
|
+
# Sets or gets the size of the component (e.g., text font size).
|
|
80
|
+
#
|
|
81
|
+
# [value]
|
|
82
|
+
# Component size. Can be keywords like +:xxs+, +:xs+, +:sm+, +:md+, +:lg+,
|
|
83
|
+
# +:xl+, +:xxl+, +:3xl+, +:4xl+, +:5xl+, or a string like <code>"16px"</code>.
|
|
84
|
+
|
|
85
|
+
# :nodoc:
|
|
70
86
|
def self.included(base)
|
|
71
87
|
base.option :size,
|
|
72
88
|
default: nil,
|
|
@@ -74,17 +90,22 @@ module Line
|
|
|
74
90
|
end
|
|
75
91
|
end
|
|
76
92
|
|
|
77
|
-
# Provides the
|
|
93
|
+
# Provides the +adjust_mode+ option, primarily for Button components,
|
|
78
94
|
# to control how they fit within available space. Currently, only
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
# @!method adjust_mode(value)
|
|
82
|
-
# Sets or gets the adjust mode.
|
|
83
|
-
# @param value [Symbol, String, nil] The adjust mode. Currently, only
|
|
84
|
-
# `:"shrink-to-fit"` is a valid value.
|
|
85
|
-
# @return [Symbol, String, nil] The current adjust mode.
|
|
95
|
+
# <code>:"shrink-to-fit"</code> is supported by LINE API via this property.
|
|
86
96
|
module AdjustMode
|
|
87
|
-
|
|
97
|
+
##
|
|
98
|
+
# :method: adjust_mode
|
|
99
|
+
# :call-seq:
|
|
100
|
+
# adjust_mode() -> Symbol, String, or nil
|
|
101
|
+
# adjust_mode(value) -> Symbol or String
|
|
102
|
+
#
|
|
103
|
+
# Sets or gets the adjust mode.
|
|
104
|
+
#
|
|
105
|
+
# [value]
|
|
106
|
+
# The adjust mode. Currently, only <code>:"shrink-to-fit"</code> is a valid value.
|
|
107
|
+
|
|
108
|
+
# :nodoc:
|
|
88
109
|
def self.included(base)
|
|
89
110
|
base.option :adjust_mode,
|
|
90
111
|
default: nil,
|
|
@@ -93,12 +114,11 @@ module Line
|
|
|
93
114
|
)
|
|
94
115
|
end
|
|
95
116
|
|
|
96
|
-
# A convenience DSL method to set the
|
|
117
|
+
# A convenience DSL method to set the +adjust_mode+ to <code>:"shrink-to-fit"</code>.
|
|
97
118
|
#
|
|
98
|
-
#
|
|
99
|
-
# button_component.shrink_to_fit!
|
|
119
|
+
# == Example
|
|
100
120
|
#
|
|
101
|
-
#
|
|
121
|
+
# button_component.shrink_to_fit!
|
|
102
122
|
def shrink_to_fit!
|
|
103
123
|
adjust_mode(:"shrink-to-fit")
|
|
104
124
|
end
|