plutonium 0.47.0 → 0.49.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.
@@ -1,66 +1,73 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
2
 
3
3
  // Connects to data-controller="color-mode"
4
+ //
5
+ // Shared theme state across the app. localStorage key 'theme' holds one of:
6
+ // 'auto' — follow prefers-color-scheme (default when unset)
7
+ // 'light' — force light
8
+ // 'dark' — force dark
9
+ const ORDER = ['auto', 'light', 'dark'];
10
+
4
11
  export default class extends Controller {
5
12
  static values = { current: String };
6
13
 
7
14
  connect() {
8
- // Set initial mode from localStorage or default
9
- const mode = localStorage.getItem('theme') || "light";
10
- this.setMode(mode);
15
+ this.applyMode(this.readMode());
11
16
 
12
- // Listen for cross-tab theme changes
13
17
  this.handleStorageChange = (e) => {
14
- console.log('Storage event received in color-mode controller:', e.key, e.newValue, e.oldValue)
15
- if (e.key === 'theme' && e.newValue) {
16
- console.log('Updating color-mode theme to:', e.newValue)
17
- this.setMode(e.newValue);
18
- }
18
+ if (e.key === 'theme') this.applyMode(this.readMode());
19
19
  };
20
20
  window.addEventListener('storage', this.handleStorageChange);
21
+
22
+ this.mq = window.matchMedia('(prefers-color-scheme: dark)');
23
+ this.handleMqChange = () => {
24
+ if (this.readMode() === 'auto') this.applyMode('auto');
25
+ };
26
+ this.mq.addEventListener('change', this.handleMqChange);
21
27
  }
22
28
 
23
29
  disconnect() {
24
- // Clean up event listener
25
30
  window.removeEventListener('storage', this.handleStorageChange);
31
+ if (this.mq) this.mq.removeEventListener('change', this.handleMqChange);
26
32
  }
27
33
 
28
34
  toggleMode() {
29
- const current = this.currentValue || "light";
30
- const next = current === "light" ? "dark" : "light";
35
+ const current = this.readMode();
36
+ const next = ORDER[(ORDER.indexOf(current) + 1) % ORDER.length];
31
37
  this.setMode(next);
32
38
  }
33
39
 
34
40
  setMode(mode) {
35
- // Update html class
36
- if (mode === "dark") {
37
- document.documentElement.classList.add("dark");
38
- } else {
39
- document.documentElement.classList.remove("dark");
40
- }
41
+ localStorage.setItem('theme', mode);
42
+ this.applyMode(mode);
43
+ }
41
44
 
42
- // Update button state
45
+ applyMode(mode) {
46
+ const effective = this.effectiveMode(mode);
47
+ document.documentElement.classList.toggle('dark', effective === 'dark');
43
48
  this.currentValue = mode;
44
-
45
- // Show/hide icons
46
49
  this.toggleIcons(mode);
50
+ }
47
51
 
48
- // Store in localStorage to trigger storage events in other tabs
49
- localStorage.setItem('theme', mode);
52
+ readMode() {
53
+ const saved = localStorage.getItem('theme');
54
+ return ORDER.includes(saved) ? saved : 'auto';
50
55
  }
51
56
 
52
- toggleIcons(mode) {
53
- const sun = this.element.querySelector(".color-mode-icon-light");
54
- const moon = this.element.querySelector(".color-mode-icon-dark");
57
+ effectiveMode(mode) {
58
+ if (mode === 'light' || mode === 'dark') return mode;
59
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
60
+ }
55
61
 
56
- if (sun && moon) {
57
- if (mode === "light") {
58
- sun.classList.remove("hidden");
59
- moon.classList.add("hidden");
60
- } else {
61
- sun.classList.add("hidden");
62
- moon.classList.remove("hidden");
63
- }
62
+ toggleIcons(mode) {
63
+ const icons = {
64
+ auto: this.element.querySelector(".color-mode-icon-auto"),
65
+ light: this.element.querySelector(".color-mode-icon-light"),
66
+ dark: this.element.querySelector(".color-mode-icon-dark"),
67
+ };
68
+ for (const [key, el] of Object.entries(icons)) {
69
+ if (!el) continue;
70
+ el.classList.toggle("hidden", key !== mode);
64
71
  }
65
72
  }
66
73
  }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.0
4
+ version: 0.49.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-04-15 00:00:00.000000000 Z
10
+ date: 2026-05-04 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: zeitwerk
@@ -387,6 +387,34 @@ dependencies:
387
387
  - - ">="
388
388
  - !ruby/object:Gem::Version
389
389
  version: '0'
390
+ - !ruby/object:Gem::Dependency
391
+ name: capybara
392
+ requirement: !ruby/object:Gem::Requirement
393
+ requirements:
394
+ - - ">="
395
+ - !ruby/object:Gem::Version
396
+ version: '0'
397
+ type: :development
398
+ prerelease: false
399
+ version_requirements: !ruby/object:Gem::Requirement
400
+ requirements:
401
+ - - ">="
402
+ - !ruby/object:Gem::Version
403
+ version: '0'
404
+ - !ruby/object:Gem::Dependency
405
+ name: selenium-webdriver
406
+ requirement: !ruby/object:Gem::Requirement
407
+ requirements:
408
+ - - ">="
409
+ - !ruby/object:Gem::Version
410
+ version: '0'
411
+ type: :development
412
+ prerelease: false
413
+ version_requirements: !ruby/object:Gem::Requirement
414
+ requirements:
415
+ - - ">="
416
+ - !ruby/object:Gem::Version
417
+ version: '0'
390
418
  description: Plutonium is a Rapid Application Development toolkit for Rails. Convention-driven
391
419
  and fully customizable, it adds application-level concepts like resources, policies,
392
420
  definitions, and portals that make building complex apps faster. Built for the AI
@@ -637,6 +665,7 @@ files:
637
665
  - lib/generators/pu/field/renderer/templates/renderer.rb.tt
638
666
  - lib/generators/pu/gem/active_shrine/active_shrine_generator.rb
639
667
  - lib/generators/pu/gem/active_shrine/templates/config/initializers/shrine.rb.tt
668
+ - lib/generators/pu/gem/actual_db_schema/actual_db_schema_generator.rb
640
669
  - lib/generators/pu/gem/annotated/annotated_generator.rb
641
670
  - lib/generators/pu/gem/annotated/templates/.keep
642
671
  - lib/generators/pu/gem/annotated/templates/lib/tasks/auto_annotate_models.rake
@@ -1112,6 +1141,20 @@ metadata:
1112
1141
  allowed_push_host: https://rubygems.org
1113
1142
  homepage_uri: https://radioactive-labs.github.io/plutonium-core/
1114
1143
  source_code_uri: https://github.com/radioactive-labs/plutonium-core
1144
+ post_install_message: |
1145
+ ⚠️ Plutonium 0.49.0 — breaking change
1146
+
1147
+ Entity-scoped URL helpers and path params have been renamed from
1148
+ `<entity>_scope_*` to `<entity>_scoped_*`.
1149
+
1150
+ Examples:
1151
+ organization_scope_widgets_path → organization_scoped_widgets_path
1152
+ params[:organization_scope] → params[:organization_scoped]
1153
+
1154
+ If you reference these helpers or params directly (e.g. in tests, custom
1155
+ redirects, or hand-written links), update them to the new names.
1156
+
1157
+ Apps that only use `resource_url_for` are unaffected.
1115
1158
  rdoc_options: []
1116
1159
  require_paths:
1117
1160
  - lib