glib-web 4.39.1 → 4.40.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.
@@ -0,0 +1,215 @@
1
+ json.title @component['class_name']
2
+
3
+ page = json_ui_page json
4
+
5
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
6
+ # Back button
7
+ scroll.button \
8
+ text: "← Back to #{@category.titleize}",
9
+ styleClasses: ['btn-outline-secondary', 'btn-sm'],
10
+ onClick: ->(action) do
11
+ action.windows_open url: json_ui_api_url(category: @category)
12
+ end
13
+
14
+ scroll.spacer height: 16
15
+
16
+ # Title
17
+ scroll.panels_horizontal align: 'middle', childViews: ->(title_row) do
18
+ title_row.h1 text: @component['class_name']
19
+
20
+ if @component['extends']
21
+ title_row.spacer width: 12
22
+ title_row.h5 text: "extends #{@component['extends']}", styleClass: 'text-muted'
23
+ end
24
+ end
25
+
26
+ # Deprecated warning
27
+ if @component['deprecated']
28
+ scroll.spacer height: 16
29
+ scroll.panels_vertical \
30
+ padding: { all: 16 },
31
+ backgroundColor: '#fff3cd',
32
+ styleClasses: ['rounded'],
33
+ childViews: ->(warning) do
34
+ warning.h5 text: '⚠️ Deprecated', color: '#856404'
35
+ deprecation_text = @component['deprecated'] == true ? 'This component is deprecated and should not be used in new code.' : @component['deprecated']
36
+ warning.p text: deprecation_text, color: '#856404'
37
+ end
38
+ end
39
+
40
+ scroll.spacer height: 24
41
+
42
+ # Description
43
+ if @component['description']
44
+ scroll.h3 text: 'Description'
45
+ @component['description'].split("\n\n").each do |paragraph|
46
+ scroll.p text: paragraph.strip, styleClass: 'lead'
47
+ end
48
+ scroll.spacer height: 32
49
+ end
50
+
51
+ # Properties
52
+ if @component['properties'] && @component['properties'].any?
53
+ scroll.h2 text: 'Properties'
54
+ scroll.spacer height: 16
55
+
56
+ @component['properties'].each do |prop_name, prop|
57
+ scroll.panels_vertical \
58
+ padding: { all: 16 },
59
+ styleClasses: ['card', 'rounded'],
60
+ childViews: ->(prop_card) do
61
+ # Property name and badges
62
+ prop_card.panels_horizontal align: 'middle', childViews: ->(header) do
63
+ header.h5 text: prop_name, styleClass: 'font-monospace'
64
+ header.spacer width: 8
65
+
66
+ # Type badge
67
+ type_color = case prop['type']
68
+ when 'string', 'text' then '#0d6efd'
69
+ when 'int', 'float' then '#198754'
70
+ when 'bool' then '#0dcaf0'
71
+ when 'action' then '#ffc107'
72
+ when 'views', 'panels_builder' then '#6c757d'
73
+ when 'hash', 'array' then '#212529'
74
+ else '#f8f9fa'
75
+ end
76
+
77
+ header.label text: prop['type'], backgroundColor: type_color, styleClasses: ['badge'], color: '#ffffff'
78
+
79
+ if prop['required']
80
+ header.spacer width: 4
81
+ header.label text: 'required', backgroundColor: '#dc3545', styleClasses: ['badge'], color: '#ffffff'
82
+ end
83
+
84
+ if prop['deprecated']
85
+ header.spacer width: 4
86
+ header.label text: 'deprecated', backgroundColor: '#ffc107', styleClasses: ['badge']
87
+ end
88
+ end
89
+
90
+ # Description
91
+ if prop['description']
92
+ prop_card.spacer height: 8
93
+ prop['description'].split("\n").each do |line|
94
+ prop_card.p text: line.strip
95
+ end
96
+ end
97
+
98
+ # Hash options
99
+ if prop['options'] && prop['options']['optional']
100
+ prop_card.spacer height: 8
101
+ prop_card.label text: 'Optional hash keys:', styleClass: 'text-muted'
102
+ prop_card.label text: prop['options']['optional'].join(', '), styleClass: 'font-monospace'
103
+ end
104
+
105
+ # Examples
106
+ if prop['examples'] && prop['examples'].any?
107
+ prop_card.spacer height: 8
108
+ prop_card.label text: 'Example:', styleClasses: ['text-muted', 'font-weight-bold']
109
+ prop['examples'].each do |example|
110
+ prop_card.panels_vertical \
111
+ padding: { all: 12 },
112
+ backgroundColor: '#f6f8fa',
113
+ styleClasses: ['rounded'],
114
+ childViews: ->(code_block) do
115
+ code_block.label text: example, styleClass: 'font-monospace'
116
+ end
117
+ end
118
+ end
119
+
120
+ # Notes
121
+ if prop['notes'] && prop['notes'].any?
122
+ prop_card.spacer height: 8
123
+ prop_card.panels_vertical \
124
+ padding: { all: 12 },
125
+ backgroundColor: '#cfe2ff',
126
+ styleClasses: ['rounded'],
127
+ childViews: ->(note_block) do
128
+ note_block.label text: 'Note:', styleClasses: ['font-weight-bold'], color: '#084298'
129
+ prop['notes'].each do |note|
130
+ note_block.label text: note, color: '#084298'
131
+ end
132
+ end
133
+ end
134
+
135
+ # Deprecation
136
+ if prop['deprecated']
137
+ prop_card.spacer height: 8
138
+ prop_card.panels_vertical \
139
+ padding: { all: 12 },
140
+ backgroundColor: '#fff3cd',
141
+ styleClasses: ['rounded'],
142
+ childViews: ->(dep_block) do
143
+ dep_block.label text: 'Deprecated:', styleClasses: ['font-weight-bold'], color: '#856404'
144
+ dep_block.label text: prop['deprecated'], color: '#856404'
145
+ end
146
+ end
147
+ end
148
+
149
+ scroll.spacer height: 12
150
+ end
151
+
152
+ scroll.spacer height: 32
153
+ end
154
+
155
+ # Examples
156
+ if @component['examples'] && @component['examples'].any?
157
+ scroll.h2 text: 'Examples'
158
+ scroll.spacer height: 16
159
+
160
+ @component['examples'].each_with_index do |example, index|
161
+ scroll.panels_vertical \
162
+ styleClasses: ['card'],
163
+ childViews: ->(example_card) do
164
+ # Header
165
+ example_card.panels_vertical \
166
+ padding: { all: 12 },
167
+ backgroundColor: '#f8f9fa',
168
+ childViews: ->(header) do
169
+ header.h5 text: example['label'] || "Example #{index + 1}"
170
+ end
171
+
172
+ # Code
173
+ example_card.panels_vertical \
174
+ padding: { all: 16 },
175
+ backgroundColor: '#f6f8fa',
176
+ childViews: ->(code_block) do
177
+ example['code'].split("\n").each do |line|
178
+ code_block.label text: line, styleClass: 'font-monospace'
179
+ end
180
+ end
181
+ end
182
+
183
+ scroll.spacer height: 12
184
+ end
185
+
186
+ scroll.spacer height: 32
187
+ end
188
+
189
+ # References
190
+ if @component['references'] && @component['references'].any?
191
+ scroll.h2 text: 'References'
192
+ scroll.spacer height: 16
193
+
194
+ scroll.panels_vertical styleClasses: ['card'], childViews: ->(refs) do
195
+ @component['references'].each do |ref|
196
+ refs.panels_vertical padding: { all: 12 }, childViews: ->(ref_item) do
197
+ if ref['url']
198
+ ref_item.button \
199
+ text: ref['url'],
200
+ styleClasses: ['btn-link', 'text-start'],
201
+ onClick: ->(action) do
202
+ action.windows_open url: ref['url']
203
+ end
204
+
205
+ if ref['description']
206
+ ref_item.label text: ref['description'], styleClasses: ['text-muted', 'text-small']
207
+ end
208
+ else
209
+ ref_item.label text: ref['text'], styleClass: 'font-monospace'
210
+ end
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,103 @@
1
+ json.title 'Glib Component API Documentation'
2
+
3
+ page = json_ui_page json
4
+
5
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
6
+ # Header
7
+ scroll.panels_vertical \
8
+ padding: { top: 32, bottom: 32 },
9
+ backgroundColor: '#667eea',
10
+ align: 'center',
11
+ childViews: ->(header) do
12
+ header.h1 text: 'Glib Component API', color: '#ffffff'
13
+ header.p text: 'Interactive documentation for all Glib UI components', color: '#ffffff'
14
+ header.label text: 'Auto-generated from YARD comments in source code', color: '#e0e0e0', styleClass: 'text-small'
15
+ end
16
+
17
+ scroll.spacer height: 32
18
+
19
+ # Title
20
+ scroll.h2 text: 'Component Categories'
21
+ scroll.p text: 'Browse components by category', styleClass: 'text-muted'
22
+
23
+ scroll.spacer height: 16
24
+
25
+ if @categories.empty?
26
+ # Warning message
27
+ scroll.panels_vertical \
28
+ padding: { all: 16 },
29
+ backgroundColor: '#fff3cd',
30
+ styleClasses: ['rounded'],
31
+ childViews: ->(warning) do
32
+ warning.h4 text: 'No Documentation Found', color: '#856404'
33
+ warning.p text: 'Component documentation has not been generated yet.'
34
+ warning.p text: 'Run bin/generate_component_docs to generate documentation.', styleClass: 'code'
35
+ end
36
+ else
37
+ # Categories grid
38
+ scroll.panels_responsive width: 'matchParent', childViews: ->(responsive) do
39
+ @categories.each do |category|
40
+ responsive.panels_column \
41
+ lg: { cols: 4 },
42
+ md: { cols: 6 },
43
+ xs: { cols: 12 },
44
+ childViews: ->(col) do
45
+ col.panels_vertical \
46
+ padding: { all: 16 },
47
+ styleClasses: ['card', 'rounded'],
48
+ onClick: ->(action) do
49
+ action.windows_open url: json_ui_api_url(category: category['key'])
50
+ end,
51
+ childViews: ->(card) do
52
+ # Title with badge
53
+ card.panels_horizontal \
54
+ align: 'middle',
55
+ childViews: ->(title_row) do
56
+ title_row.h5 text: category['name']
57
+ title_row.spacer width: 8
58
+ title_row.label \
59
+ text: "#{category['component_count']} components",
60
+ styleClasses: ['badge', 'bg-primary']
61
+ end
62
+
63
+ card.spacer height: 8
64
+
65
+ # Source file
66
+ if category['source_file']
67
+ card.label \
68
+ text: File.basename(category['source_file']),
69
+ styleClasses: ['text-muted', 'text-small', 'font-monospace']
70
+ end
71
+
72
+ card.spacer height: 12
73
+
74
+ # Button
75
+ card.button \
76
+ text: 'View Components →',
77
+ styleClasses: ['btn-outline-primary', 'btn-sm']
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ scroll.spacer height: 48
85
+
86
+ # About section
87
+ scroll.h3 text: 'About This Documentation'
88
+ scroll.panels_vertical styleClasses: ['card'], padding: { all: 16 }, childViews: ->(about) do
89
+ about.p text: 'This documentation is automatically generated from YARD comments in the Glib source code. Each component includes:'
90
+
91
+ about.panels_ul childViews: ->(ul) do
92
+ ul.label text: 'Description - What the component does and when to use it'
93
+ ul.label text: 'Properties - All available properties with types and descriptions'
94
+ ul.label text: 'Examples - Real code examples showing how to use the component'
95
+ ul.label text: 'References - Links to external documentation and garage examples'
96
+ end
97
+
98
+ about.spacer height: 8
99
+ about.label \
100
+ text: 'For more information, see doc/components/README.md and doc/common/component_documentation_guidelines.md',
101
+ styleClasses: ['text-muted', 'text-small']
102
+ end
103
+ end
@@ -0,0 +1,111 @@
1
+ json.title "#{@category.titleize} Components"
2
+
3
+ page = json_ui_page json
4
+
5
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
6
+ # Back button
7
+ scroll.button \
8
+ text: '← Back to Categories',
9
+ styleClasses: ['btn-outline-secondary', 'btn-sm'],
10
+ onClick: ->(action) do
11
+ action.windows_open url: json_ui_api_url
12
+ end
13
+
14
+ scroll.spacer height: 16
15
+
16
+ # Title
17
+ scroll.h2 text: "#{@category.titleize} Components"
18
+
19
+ # Metadata
20
+ if @doc['meta']
21
+ scroll.panels_vertical \
22
+ padding: { all: 12 },
23
+ backgroundColor: '#f8f9fa',
24
+ styleClasses: ['rounded'],
25
+ childViews: ->(meta) do
26
+ meta.label \
27
+ text: "Source: #{@doc['meta']['source_file']}",
28
+ styleClasses: ['text-muted', 'text-small', 'font-monospace']
29
+
30
+ if @doc['meta']['generated_at']
31
+ generated_time = Time.parse(@doc['meta']['generated_at']).strftime('%Y-%m-%d %H:%M') rescue @doc['meta']['generated_at']
32
+ meta.label \
33
+ text: "Generated: #{generated_time}",
34
+ styleClasses: ['text-muted', 'text-small']
35
+ end
36
+ end
37
+ end
38
+
39
+ scroll.spacer height: 24
40
+
41
+ # Component cards
42
+ @components.sort.each do |key, component|
43
+ scroll.panels_vertical \
44
+ id: key,
45
+ padding: { all: 16 },
46
+ styleClasses: ['card', 'rounded'],
47
+ childViews: ->(card) do
48
+ # Title
49
+ card.panels_horizontal align: 'middle', childViews: ->(title_row) do
50
+ title_row.h4 text: component['class_name']
51
+
52
+ if component['extends']
53
+ title_row.spacer width: 8
54
+ title_row.label \
55
+ text: "extends #{component['extends']}",
56
+ styleClasses: ['text-muted']
57
+ end
58
+ end
59
+
60
+ # Deprecated warning
61
+ if component['deprecated']
62
+ card.spacer height: 8
63
+ card.panels_vertical \
64
+ padding: { all: 12 },
65
+ backgroundColor: '#fff3cd',
66
+ styleClasses: ['rounded'],
67
+ childViews: ->(warning) do
68
+ warning.label text: '⚠️ Deprecated', color: '#856404', styleClass: 'font-weight-bold'
69
+ deprecation_text = component['deprecated'] == true ? 'This component is deprecated' : component['deprecated']
70
+ warning.label text: deprecation_text, color: '#856404'
71
+ end
72
+ end
73
+
74
+ # Description
75
+ if component['description']
76
+ card.spacer height: 12
77
+ component['description'].split("\n\n").each do |paragraph|
78
+ card.p text: paragraph.strip
79
+ end
80
+ end
81
+
82
+ card.spacer height: 12
83
+
84
+ # Metadata and View Details button
85
+ card.panels_horizontal align: 'middle', childViews: ->(actions) do
86
+ actions.button \
87
+ text: 'View Details →',
88
+ styleClasses: ['btn-outline-primary', 'btn-sm'],
89
+ onClick: ->(action) do
90
+ action.windows_open url: json_ui_api_url(category: @category, component: key)
91
+ end
92
+
93
+ if component['properties']
94
+ actions.spacer width: 12
95
+ actions.label \
96
+ text: "#{component['properties'].size} #{'property'.pluralize(component['properties'].size)}",
97
+ styleClasses: ['text-muted']
98
+ end
99
+
100
+ if component['examples']
101
+ actions.spacer width: 12
102
+ actions.label \
103
+ text: "#{component['examples'].size} #{'example'.pluralize(component['examples'].size)}",
104
+ styleClasses: ['text-muted']
105
+ end
106
+ end
107
+ end
108
+
109
+ scroll.spacer height: 16
110
+ end
111
+ end
@@ -7,73 +7,103 @@ end
7
7
  page = json_ui_page json
8
8
  render "#{@path_prefix}/nav_menu", json: json, page: page
9
9
 
10
- page.list firstSection: ->(section) do
11
- section.rows builder: ->(template) do
12
- template.thumbnail \
13
- title: 'Click menu (web) or swipe left (Android/iOS)',
14
- subtitle: "Page index: #{page_index}",
15
- leftButtons: ->(menu) do
16
- menu.button \
17
- styleClasses: ['icon', 'text', 'x-small'],
18
- icon: 'check_box',
19
- onClick: ->(subaction) do
20
- subaction.dialogs_alert message: 'Tick/untick'
10
+ page.list(
11
+ firstSection: ->(section) do
12
+ section.rows(
13
+ builder: ->(template) do
14
+ template.thumbnail(
15
+ title: 'Click menu (web) or swipe left (Android/iOS)',
16
+ subtitle: "Page index: #{page_index}",
17
+ leftButtons: ->(menu) do
18
+ menu.button(
19
+ styleClasses: ['icon', 'text', 'x-small'],
20
+ icon: 'check_box',
21
+ onClick: ->(subaction) do
22
+ subaction.dialogs_alert message: 'Tick/untick'
23
+ end
24
+ )
25
+ end,
26
+ rightButtons: ->(menu) do
27
+ menu.button(
28
+ styleClasses: ['icon', 'text', 'x-small'],
29
+ icon: 'share',
30
+ tooltip: { text: 'Share', placement: 'left' },
31
+ onClick: ->(subaction) do
32
+ subaction.dialogs_alert message: 'Share'
33
+ end
34
+ )
35
+ # TODO: Use popoever
36
+ # childButtons: ->(submenu) do
37
+ # submenu.button text: 'Dropdown item 1'
38
+ # submenu.button text: 'Dropdown item 2'
39
+ # submenu.button text: 'Dropdown item 3'
40
+ # end
41
+ menu.button(
42
+ styleClasses: ['icon', 'text', 'x-small'],
43
+ icon: 'open_in_new',
44
+ tooltip: { text: 'Open in new window' },
45
+ onClick: ->(subaction) do
46
+ subaction.dialogs_alert message: 'Open'
47
+ end
48
+ )
49
+ end,
50
+ # editButtons: ->(menu) do
51
+ # menu.button(
52
+ # text: "Edit (ID: #{page_index})",
53
+ # onClick: ->(action) do
54
+ # action.dialogs_alert message: 'Perform Edit action'
55
+ # end
56
+ # )
57
+ # menu.button(
58
+ # text: 'Delete',
59
+ # onClick: ->(action) do
60
+ # action.dialogs_alert message: 'Perform Delete action'
61
+ # end
62
+ # )
63
+ # end,
64
+ onClick: ->(action) do
65
+ action.windows_open url: json_ui_garage_url(path: 'lists/edit_actions', page: page_index + 1)
21
66
  end
22
- end, rightButtons: ->(menu) do
23
- menu.button \
24
- styleClasses: ['icon', 'text', 'x-small'],
25
- icon: 'share',
26
- tooltip: { text: 'Share', placement: 'left' }
27
-
28
- # TODO: Use popoever
29
- # childButtons: ->(submenu) do
30
- # submenu.button text: 'Dropdown item 1'
31
- # submenu.button text: 'Dropdown item 2'
32
- # submenu.button text: 'Dropdown item 3'
33
- # end
34
-
35
- menu.button \
36
- styleClasses: ['icon', 'text', 'x-small'],
37
- icon: 'open_in_new',
38
- tooltip: { text: 'Open in new window' },
39
- onClick: ->(subaction) do
40
- subaction.dialogs_alert message: 'Open'
67
+ )
68
+ template.thumbnail(
69
+ title: 'Long press to get an alert',
70
+ onLongPress: ->(action) do
71
+ action.dialogs_alert message: 'This is an alert'
41
72
  end
42
-
43
- end, editButtons: ->(menu) do
44
- menu.button text: "Edit (ID: #{page_index})", onClick: ->(action) do
45
- action.dialogs_alert message: 'Perform Edit action'
46
- end
47
- menu.button text: 'Delete', onClick: ->(action) do
48
- action.dialogs_alert message: 'Perform Delete action'
49
- end
50
- end, onClick: ->(action) do
51
- action.windows_open url: json_ui_garage_url(path: 'lists/edit_actions', page: page_index + 1)
52
- end
53
-
54
- template.thumbnail title: 'Long press to get an alert', onLongPress: ->(action) do
55
- action.dialogs_alert message: 'This is an alert'
56
- end
57
-
58
- template.thumbnail title: 'Long press to see menu', onLongPress: ->(action) do
59
- action.sheets_select message: 'Context Menu', buttons: ->(menu) do
60
- menu.button icon: 'edit', text: 'Edit', onClick: ->(subaction) do
61
- subaction.dialogs_alert message: 'Perform action'
62
- end
63
- menu.button icon: 'delete', text: 'Delete', onClick: ->(subaction) do
64
- subaction.dialogs_alert message: 'Perform action'
65
- end
73
+ )
74
+ template.thumbnail(
75
+ title: 'Long press to see menu',
76
+ onLongPress: ->(action) do
77
+ action.sheets_select(
78
+ message: 'Context Menu',
79
+ buttons: ->(menu) do
80
+ menu.button(
81
+ icon: 'edit',
82
+ text: 'Edit',
83
+ onClick: ->(subaction) do
84
+ subaction.dialogs_alert message: 'Perform action'
85
+ end
86
+ )
87
+ menu.button(
88
+ icon: 'delete',
89
+ text: 'Delete',
90
+ onClick: ->(subaction) do
91
+ subaction.dialogs_alert message: 'Perform action'
92
+ end
93
+ )
94
+ end
95
+ )
96
+ end
97
+ )
98
+ # template.thumbnail title: 'Long press to see menu', contextButtons: ->(menu) do
99
+ # menu.button text: 'Edit', onClick: ->(action) do
100
+ # action.dialogs_alert message: 'Perform action'
101
+ # end
102
+ # menu.button text: 'Delete', onClick: ->(action) do
103
+ # action.dialogs_alert message: 'Perform action'
104
+ # end
105
+ # end
66
106
  end
67
- end
68
-
69
- # template.thumbnail title: 'Long press to see menu', contextButtons: ->(menu) do
70
- # menu.button text: 'Edit', onClick: ->(action) do
71
- # action.dialogs_alert message: 'Perform action'
72
- # end
73
- # menu.button text: 'Delete', onClick: ->(action) do
74
- # action.dialogs_alert message: 'Perform action'
75
- # end
76
- # end
107
+ )
77
108
  end
78
-
79
- end
109
+ )