mirror of
https://github.com/we-promise/sure.git
synced 2026-04-08 14:54:49 +00:00
Add privacy mode with blur toggle for financial data
- Stimulus controller on global layout (persists across all pages) - CSS blur effect on .privacy-sensitive elements (8px active, 4px on hover) - localStorage persistence survives page navigations - Toggle button on dashboard with aria-pressed for accessibility - Applied to 28+ views: accounts, budgets, transactions, reports, etc. Fixes: UTF-8 encoding, global controller mount, aria-pressed attribute
This commit is contained in:
32
app/javascript/controllers/privacy_mode_controller.js
Normal file
32
app/javascript/controllers/privacy_mode_controller.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// Privacy Mode Controller
|
||||
// Toggles visibility of financial numbers across the page.
|
||||
// Elements with class "privacy-sensitive" will be blurred when active.
|
||||
// State persists in localStorage so it survives page navigations.
|
||||
export default class extends Controller {
|
||||
static targets = ["toggle"]
|
||||
|
||||
connect() {
|
||||
this.active = localStorage.getItem("privacyMode") === "true"
|
||||
this._apply()
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.active = !this.active
|
||||
localStorage.setItem("privacyMode", this.active.toString())
|
||||
this._apply()
|
||||
}
|
||||
|
||||
_apply() {
|
||||
if (this.active) {
|
||||
document.documentElement.classList.add("privacy-mode")
|
||||
} else {
|
||||
document.documentElement.classList.remove("privacy-mode")
|
||||
}
|
||||
|
||||
this.toggleTargets.forEach((el) => {
|
||||
el.setAttribute("aria-pressed", this.active.toString())
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user