INNER CODE UNIT · JavaScript

extends

dradis/dradis-ce · app/javascript/controllers/theme_controller.js:3

export default class extends Controller {
  static targets = ["autoIcon", "lightIcon", "darkIcon", "autoItem", "lightItem", "darkItem"]
  static values = { preferencesPath: String }

  connect() {
    this.preference = this.element.dataset.theme || "auto"
    this.updateUI(this.preference)
  }

  select({ params: { name } }) {
    this.preference = name
    this.element.dataset.theme = name
    this.updateUI(name)
    this.persist(name)
  }

  updateUI(preference) {
    if (!this.hasAutoIconTarget) return

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…