keystone_ui 0.53.0 → 0.54.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7f6b6d63755b597d7b876ddba35bd4f6bbdb6039b0b16be57197cf4af01ea48
4
- data.tar.gz: c2093a32f35bf5beb3a469cfffe14033e491f8e6435bb32003b203652574f990
3
+ metadata.gz: 43359bd6e64474a6d13c8d40ce91b0d92883f73f941db147f88ba5a51a7f83e2
4
+ data.tar.gz: e204d14c0526bc5ffae69c2fdaa58e094b879a39e035553c09b9ca125a52d270
5
5
  SHA512:
6
- metadata.gz: ac7541139dd31e4269cbca2dc13e3201d6c44ffd9b4a8088f90a2361f15cee3e627d808277b31e7a5981c0c19d56fa453cb186350870cf48d5416d7ef0ab6a2b
7
- data.tar.gz: bf3cb63e70d990d5b01bee266a2446d15cd8f7b710b63c767e129134312d9f6e999d6e56ef6d709614ff4a63699b303e231cbebed874001ce4c03f7c46756401
6
+ metadata.gz: 16845938b705f24c366616906e2d5ae19530143e59e1e411f167bc8c39bf41380975653fc4f10e4e2bee1ea521db1988dff5a71b8f36c954ccac43328f7e31c7
7
+ data.tar.gz: 1fa972e398b10bc3c74eaa5b241b46cdf5581139a23f2d2f7044317568aefa72c5d92e7b61e6cb1f0f263e8c32b8e5b977e776b0769ae73645f808281254665d
@@ -16,9 +16,13 @@ module Keystone
16
16
  lg: "ks-button-lg"
17
17
  }.freeze
18
18
 
19
- def initialize(label:, href: nil, variant: :primary, size: :md, type: :submit, data: nil)
19
+ FULL_WIDTH_CLASSES = "w-full"
20
+
21
+ def initialize(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil)
20
22
  @label = label
21
23
  @href = href
24
+ @method = method.to_sym
25
+ @full_width = full_width
22
26
  @variant = variant
23
27
  @size = size
24
28
  @type = type.to_s
@@ -31,7 +35,7 @@ module Keystone
31
35
  else
32
36
  VARIANT_CLASSES.fetch(@variant)
33
37
  end
34
- [ BASE_CLASSES, variant_css, SIZE_CLASSES.fetch(@size) ].join(" ")
38
+ [ BASE_CLASSES, variant_css, SIZE_CLASSES.fetch(@size), (FULL_WIDTH_CLASSES if @full_width) ].compact.join(" ")
35
39
  end
36
40
 
37
41
  def tag_name
@@ -52,6 +56,20 @@ module Keystone
52
56
  def button?
53
57
  @href.nil?
54
58
  end
59
+
60
+ def call
61
+ return button_to(@href, method: @method, class: classes, form_class: form_classes) { @label } if request?
62
+
63
+ content_tag(tag_name, @label, **tag_options)
64
+ end
65
+
66
+ def form_classes
67
+ FULL_WIDTH_CLASSES if @full_width
68
+ end
69
+
70
+ def request?
71
+ @href && @method != :get
72
+ end
55
73
  end
56
74
  end
57
75
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Keystone
4
+ module Ui
5
+ class PictureComponent < ViewComponent::Base
6
+ IMAGE_CLASSES = "mx-auto max-h-[50svh]"
7
+
8
+ def initialize(src:, alt:, full_size_url: nil)
9
+ @src = src
10
+ @alt = alt
11
+ @full_size_url = full_size_url
12
+ end
13
+
14
+ def call
15
+ image = tag.img(src: @src, alt: @alt, class: IMAGE_CLASSES)
16
+ return image unless @full_size_url
17
+
18
+ link_to(image, @full_size_url, target: "_blank", rel: "noopener")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -245,6 +245,10 @@ module KeystoneUiHelper
245
245
  render Keystone::Ui::FigureComponent.new(**args)
246
246
  end
247
247
 
248
+ def ui_picture(**args)
249
+ render Keystone::Ui::PictureComponent.new(**args)
250
+ end
251
+
248
252
  def ui_heading(**args)
249
253
  render Keystone::Ui::HeadingComponent.new(**args)
250
254
  end
@@ -71,7 +71,8 @@ module Keystone
71
71
  Keystone::Ui::DesktopBackLinkComponent,
72
72
  Keystone::Ui::BreadcrumbsComponent,
73
73
  Keystone::Ui::InfoComponent,
74
- Keystone::Ui::BreakdownComponent
74
+ Keystone::Ui::BreakdownComponent,
75
+ Keystone::Ui::PictureComponent
75
76
  ].freeze
76
77
 
77
78
  # Constants that hold non-CSS values (e.g. HTML input type maps)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.53.0"
4
+ VERSION = "0.54.0"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: keystone_ui-develop
3
- description: Use PROACTIVELY for building or editing screens in a Rails app that has keystone_ui — page shells with Back links and breadcrumbs, forms and fields, a search field that picks a record or enters a new one, data tables with saved columns, desktop navigation, sidebars and bottom tabs, action menus for a record's Edit and Delete, dashboards with stat cards, charts, funnels and goal buckets, amounts shown in green or red as a gain or loss, info buttons and breakdowns, marketing sections, a light/dark theme switch — MUST BE USED instead of hand-writing ERB and Tailwind for UI.
3
+ description: Use PROACTIVELY for building or editing screens in a Rails app that has keystone_ui — page shells with Back links and breadcrumbs, forms and fields, a search field that picks a record or enters a new one, data tables with saved columns, desktop navigation, sidebars and bottom tabs, action menus for a record's Edit and Delete, dashboards with stat cards, charts, funnels and goal buckets, amounts shown in green or red as a gain or loss, pictures held to half the screen, info buttons and breakdowns, marketing sections, a light/dark theme switch — MUST BE USED instead of hand-writing ERB and Tailwind for UI.
4
4
  tools: Bash, Read, Write, Edit, Grep
5
5
  scope: UI — pages, forms, tables, navigation, dashboards
6
6
  ---
@@ -61,9 +61,10 @@ not available in the app yet, that is `keystone_ui-install`'s job.
61
61
  - `ui_data_table` — a table of records with links, row actions, sorting and hideable columns.
62
62
  - `Keystone::Ui::Column` — a table column with options a `{ key: "Label" }` hash cannot carry.
63
63
  - `ui_column_picker` — a Columns menu that saves which columns are hidden and their order to an app endpoint.
64
- - `ui_button` — a link or a button styled as a button.
64
+ - `ui_button` — a link or a button styled as a button, or a button sending a POST, PATCH or DELETE request.
65
65
  - `ui_badge` — a coloured pill holding a short label.
66
66
  - `ui_figure` — one amount as inline text, coloured as a gain or a loss.
67
+ - `ui_picture` — an image never taller than half the screen, optionally opening its full-size file.
67
68
  - `ui_heading` — a heading at one of three sizes, with an optional short note on its right.
68
69
  - `ui_caption` — small uppercase muted text placed above a title or a figure.
69
70
  - `ui_paragraph` — a paragraph of running text.
@@ -421,10 +422,24 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
421
422
 
422
423
  9. Show content and status.
423
424
 
424
- - `ui_button(label:, href: nil, variant: :primary, size: :md, type: :submit, data: nil)`
425
+ - `ui_button(label:, href: nil, method: :get, variant: :primary, size: :md, full_width: false, type: :submit, data: nil)`
425
426
  renders a link with `href:` and a button without it. `variant:` is
426
427
  `:primary` `:secondary` `:danger`, `size:` is `:sm` `:md` `:lg`, and
427
428
  `type:` applies only to the button.
429
+ - With `href:` and `method:` `:post` `:patch` `:put` or `:delete`, it
430
+ renders a button inside its own small form that sends that request to
431
+ `href:` when tapped. Do not write a form around it. It cannot sit inside
432
+ another form, since a form cannot hold a form. `type:` and `data:` are not
433
+ used on it.
434
+ - `full_width: true` makes the button as wide as its row at every screen
435
+ width, and for a button sending a request its form too. Use it for large
436
+ choices stacked down a phone screen.
437
+ - `ui_picture(src:, alt:, full_size_url: nil)` shows an image centred and
438
+ never taller than half the visible screen, so what follows it stays in
439
+ view. `alt:` is the text read out in place of the image. With
440
+ `full_size_url:`, tapping the picture opens that address in a new tab, so
441
+ pass `src:` a smaller version and `full_size_url:` the original file. Ask
442
+ the developer which version of an uploaded image each address points at.
428
443
  - `ui_badge(label:, variant: :neutral, class: nil)` — `variant:` is
429
444
  `:neutral` `:success` `:danger` `:warning` `:info`.
430
445
  - `ui_alert(message:, type: :info, title: nil, dismissible: false, class: nil)`
@@ -66,6 +66,7 @@ develop:
66
66
  - ui_calculation
67
67
  - ui_info
68
68
  - ui_figure
69
+ - ui_picture
69
70
  - ui_heading
70
71
  - ui_caption
71
72
  - ui_paragraph
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.53.0
4
+ version: 0.54.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider
@@ -97,7 +97,6 @@ files:
97
97
  - app/components/keystone/ui/bucket_component.rb
98
98
  - app/components/keystone/ui/bucket_series_component.html.erb
99
99
  - app/components/keystone/ui/bucket_series_component.rb
100
- - app/components/keystone/ui/button_component.html.erb
101
100
  - app/components/keystone/ui/button_component.rb
102
101
  - app/components/keystone/ui/calculation_component.html.erb
103
102
  - app/components/keystone/ui/calculation_component.rb
@@ -180,6 +179,7 @@ files:
180
179
  - app/components/keystone/ui/panel_component.rb
181
180
  - app/components/keystone/ui/paragraph_component.html.erb
182
181
  - app/components/keystone/ui/paragraph_component.rb
182
+ - app/components/keystone/ui/picture_component.rb
183
183
  - app/components/keystone/ui/pipeline_component.html.erb
184
184
  - app/components/keystone/ui/pipeline_component.rb
185
185
  - app/components/keystone/ui/progress_component.html.erb
@@ -1 +0,0 @@
1
- <%= content_tag(tag_name, @label, **tag_options) %>