trek 0.1.20 → 0.1.21

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: 8836f5f71ee9aeae0475df30e1e941038aeac1d3ba5a1f0a8bc548ddf87cedff
4
- data.tar.gz: 2b07e244708e2e9a6258d9d352f04fc03bba3777e11b2a6ae3a7ad7e0e100fd5
3
+ metadata.gz: 5cea2a831c71a33aa66c06d9c482aaa195a32eab3d15036892d42b7ad780d896
4
+ data.tar.gz: 8589d77eec5df070bea04c13fea05a46e7b516533e3a044f5bbf10a1551dda27
5
5
  SHA512:
6
- metadata.gz: 568c5f70e0482e4ef6c86e66d4ffe46bc5828848c28ec8646129468bbc4db60c362fb3ddd4bee9ba9e747fffc5d24385f3198876bc8a3dc9031658c3eb1dc380
7
- data.tar.gz: 322f0ab2ab3fc8d3bef7cabc8fadbd750b43b790163e9abf915c7bb8766c594bec7161980695e020e6d0e8b7a3e8e4a6c47309edefea2a2df72bd1918a8ffe77
6
+ metadata.gz: 0d9a672bbf54060d276ae97b2897b5fb5769d15ab3a64ad8cda2fedfe7875395d89a04bc0116100ee667b195197d1ba610a2e3ff5180492a7743ff8294877d44
7
+ data.tar.gz: df786a478a60fa19944403b15bf41d2c2c9eef5f25e1d5ed638ae2a8be7a8bcf8d33482cec0a1c68254a6424668ad0ac3afc472b49da85882cb2250cd70a7a90
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trek (0.1.20)
4
+ trek (0.1.21)
5
5
  action_policy (~> 0.6)
6
6
  actioncable
7
7
  acts_as_list (~> 1.1)
@@ -37,7 +37,7 @@ GEM
37
37
  specs:
38
38
  action_policy (0.7.5)
39
39
  ruby-next-core (>= 1.0)
40
- action_text-trix (2.1.16)
40
+ action_text-trix (2.1.17)
41
41
  railties
42
42
  actioncable (8.1.1)
43
43
  actionpack (= 8.1.1)
@@ -200,7 +200,7 @@ GEM
200
200
  dry-inflector (~> 1.0)
201
201
  dry-logic (~> 1.4)
202
202
  zeitwerk (~> 2.6)
203
- erb (6.0.1)
203
+ erb (6.0.2)
204
204
  erubi (1.13.1)
205
205
  fastimage (2.4.0)
206
206
  ffi (1.17.3-arm64-darwin)
@@ -230,12 +230,13 @@ GEM
230
230
  mini_magick (>= 4.9.5, < 6)
231
231
  ruby-vips (>= 2.0.17, < 3)
232
232
  io-console (0.8.2)
233
- irb (1.16.0)
233
+ irb (1.17.0)
234
234
  pp (>= 0.6.0)
235
+ prism (>= 1.3.0)
235
236
  rdoc (>= 4.0.0)
236
237
  reline (>= 0.4.2)
237
238
  jmespath (1.6.2)
238
- json (2.18.0)
239
+ json (2.19.2)
239
240
  kaminari (1.2.2)
240
241
  activesupport (>= 4.1.0)
241
242
  kaminari-actionview (= 1.2.2)
@@ -254,7 +255,7 @@ GEM
254
255
  rb-fsevent (~> 0.10, >= 0.10.3)
255
256
  rb-inotify (~> 0.9, >= 0.9.10)
256
257
  logger (1.7.0)
257
- loofah (2.25.0)
258
+ loofah (2.25.1)
258
259
  crass (~> 1.0.2)
259
260
  nokogiri (>= 1.12.0)
260
261
  lookbook (2.3.14)
@@ -280,7 +281,8 @@ GEM
280
281
  mini_magick (5.3.1)
281
282
  logger
282
283
  mini_mime (1.1.5)
283
- minitest (6.0.1)
284
+ minitest (6.0.2)
285
+ drb (~> 2.0)
284
286
  prism (~> 1.5)
285
287
  mobility (1.3.2)
286
288
  i18n (>= 0.6.10, < 2)
@@ -295,9 +297,9 @@ GEM
295
297
  net-smtp (0.5.1)
296
298
  net-protocol
297
299
  nio4r (2.7.5)
298
- nokogiri (1.19.1-arm64-darwin)
300
+ nokogiri (1.19.2-arm64-darwin)
299
301
  racc (~> 1.4)
300
- nokogiri (1.19.1-x86_64-darwin)
302
+ nokogiri (1.19.2-x86_64-darwin)
301
303
  racc (~> 1.4)
302
304
  parallel (1.27.0)
303
305
  parser (3.3.10.0)
@@ -312,7 +314,7 @@ GEM
312
314
  pp (0.6.3)
313
315
  prettyprint
314
316
  prettyprint (0.2.0)
315
- prism (1.7.0)
317
+ prism (1.9.0)
316
318
  prosemirror_to_html (0.3.0)
317
319
  nokogiri
318
320
  psych (5.3.1)
@@ -349,8 +351,8 @@ GEM
349
351
  rails-healthcheck (1.4.0)
350
352
  actionpack
351
353
  railties
352
- rails-html-sanitizer (1.6.2)
353
- loofah (~> 2.21)
354
+ rails-html-sanitizer (1.7.0)
355
+ loofah (~> 2.25)
354
356
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
355
357
  rails-i18n (8.1.0)
356
358
  i18n (>= 0.7, < 2)
@@ -369,7 +371,7 @@ GEM
369
371
  rb-fsevent (0.11.2)
370
372
  rb-inotify (0.11.1)
371
373
  ffi (~> 1.0)
372
- rdoc (7.0.3)
374
+ rdoc (7.2.0)
373
375
  erb
374
376
  psych (>= 4.0.0)
375
377
  tsort
@@ -483,7 +485,7 @@ GEM
483
485
  temple (0.10.4)
484
486
  terminal-table (4.0.0)
485
487
  unicode-display_width (>= 1.1.1, < 4)
486
- thor (1.4.0)
488
+ thor (1.5.0)
487
489
  tilt (2.6.1)
488
490
  timeout (0.6.0)
489
491
  tsort (0.2.0)
@@ -513,7 +515,7 @@ GEM
513
515
  xpath (3.2.0)
514
516
  nokogiri (~> 1.8)
515
517
  yard (0.9.38)
516
- zeitwerk (2.7.4)
518
+ zeitwerk (2.7.5)
517
519
 
518
520
  PLATFORMS
519
521
  arm64-darwin-24
@@ -1,4 +1,4 @@
1
- = link_to href, class: classes
1
+ = link_to href, class: classes, rel: rel, target: target
2
2
  - if icon
3
3
  = render Trek::IconComponent.new(icon, classnames: class_for("icon"))
4
4
  span(class=class_for("text")) = formatted_text
@@ -5,6 +5,8 @@ module Trek
5
5
  option :color, default: proc { :slate }
6
6
  option :href
7
7
  option :icon, optional: true
8
+ option :rel, optional: true
9
+ option :target, optional: true
8
10
  option :text
9
11
  option :allowed_to, default: -> { true }
10
12
 
@@ -9,6 +9,7 @@
9
9
 
10
10
  align-items: center;
11
11
  background-color: var(--slate-4);
12
+ flex-shrink: 0;
12
13
  border: 1px solid var(--slate-a6);
13
14
  border-radius: 0.2rem;
14
15
  color: var(--slate-8);
@@ -29,3 +30,10 @@
29
30
  .preview img {
30
31
  object-fit: contain;
31
32
  }
33
+
34
+ .actions {
35
+ align-items: flex-start;
36
+ display: flex;
37
+ flex-direction: column;
38
+ gap: 0.8rem;
39
+ }
@@ -10,12 +10,24 @@
10
10
  value: cached_data,
11
11
  id: nil,
12
12
  data: stimulus_target_hash("hiddenInput")
13
+ = form.hidden_field "remove_#{method_name}",
14
+ value: nil,
15
+ id: nil,
16
+ data: stimulus_target_hash("removeInput")
17
+
18
+ div(class=class_for("actions"))
19
+ = render Trek::ButtonComponent.new( \
20
+ tag: :label,
21
+ text: button_text,
22
+ size: :narrow,
23
+ )
24
+ = form.file_field method_name,
25
+ class: "sr-only",
26
+ data: file_field_data_attributes
13
27
 
14
- = render Trek::ButtonComponent.new( \
15
- tag: :label,
16
- text: button_text,
17
- size: :narrow,
18
- )
19
- = form.file_field method_name,
20
- class: "sr-only",
21
- data: file_field_data_attributes
28
+ - if image&.exists?
29
+ = render Trek::ButtonComponent.new( \
30
+ text: t("admin.actions.remove"),
31
+ size: :narrow,
32
+ data: remove_button_data_attributes,
33
+ )
@@ -8,7 +8,13 @@ import French from "@uppy/locales/lib/fr_FR";
8
8
  import "@uppy/core/dist/style.css";
9
9
 
10
10
  export class Controller extends BaseController {
11
- static targets = ["content", "fileInput", "hiddenInput", "preview"];
11
+ static targets = [
12
+ "content",
13
+ "fileInput",
14
+ "hiddenInput",
15
+ "preview",
16
+ "removeInput",
17
+ ];
12
18
 
13
19
  connect() {
14
20
  this.uppy = new Uppy({
@@ -48,6 +54,9 @@ export class Controller extends BaseController {
48
54
  const uploadedFileData = response.body["data"];
49
55
 
50
56
  this.hiddenInputTarget.value = JSON.stringify(uploadedFileData);
57
+
58
+ // Clear the remove flag when a new file is uploaded
59
+ this.removeInputTarget.value = "";
51
60
  });
52
61
 
53
62
  this.uppy.on("file-removed", () => {
@@ -64,6 +73,19 @@ export class Controller extends BaseController {
64
73
  this.uppy = null;
65
74
  }
66
75
 
76
+ removeImage() {
77
+ // Clear the cached upload data
78
+ this.hiddenInputTarget.value = "";
79
+
80
+ // Set the remove flag so Shrine deletes the attachment on save
81
+ this.removeInputTarget.value = "1";
82
+
83
+ // Reset preview to placeholder icon
84
+ this.previewTarget.innerHTML = `<svg class="c-trek--icon-root c-trek--icon-trek--pic" role="img" focusable="false">
85
+ <use xlink:href="#c-icon-trek--pic"></use>
86
+ </svg>`;
87
+ }
88
+
67
89
  addFiles(event) {
68
90
  const files = Array.from(event.target.files);
69
91
 
@@ -7,6 +7,13 @@ module Trek
7
7
  include StimulusHelpers
8
8
  include Turbo::FramesHelper
9
9
 
10
+ # Ensure the placeholder icon is in the sprite even when an image exists,
11
+ # because the JS removeImage action needs it.
12
+ def before_render
13
+ Current.icons ||= []
14
+ Current.icons << "trek--pic" unless Current.icons.include?("trek--pic")
15
+ end
16
+
10
17
  private
11
18
 
12
19
  def preview
@@ -48,6 +55,12 @@ module Trek
48
55
  }.merge(stimulus_target_hash("fileInput"))
49
56
  end
50
57
 
58
+ def remove_button_data_attributes
59
+ {
60
+ action: stimulus_action("removeImage")
61
+ }
62
+ end
63
+
51
64
  def button_text
52
65
  image&.exists? ? t("admin.actions.replace") : t("admin.actions.browse")
53
66
  end
@@ -43,6 +43,7 @@ en:
43
43
  n: New %{resource}
44
44
  reorder_resource:
45
45
  n: Reorder %{resources}
46
+ remove: Remove
46
47
  replace: Replace
47
48
  search_resource:
48
49
  n: Search for a %{resource}
@@ -49,6 +49,7 @@ fr:
49
49
  f: Réorganiser les %{resources}
50
50
  m: Réorganiser les %{resources}
51
51
  m_alt: Réorganiser les %{resources}
52
+ remove: Enlever
52
53
  replace: Remplacer
53
54
  search_resource:
54
55
  "n": Rechercher un·e %{resources}
@@ -35,6 +35,7 @@ end
35
35
 
36
36
  Shrine.plugin :activerecord
37
37
  Shrine.plugin :cached_attachment_data # for retaining the cached file across form redisplays
38
+ Shrine.plugin :remove_attachment
38
39
  Shrine.plugin :restore_cached_data # re-extract metadata when attaching a cached file
39
40
  Shrine.plugin :determine_mime_type, analyzer: :marcel
40
41
  Shrine.plugin :pretty_location
data/lib/trek/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trek
4
- VERSION = "0.1.20"
4
+ VERSION = "0.1.21"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etaminstudio/trek",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "A modern CMS for Ruby on Rails",
5
5
  "main": "app/javascript/trek.js",
6
6
  "repository": {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohamed Bengrich