tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

avatar.mjs (1395B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 import { MozLitElement } from "chrome://global/content/lit-utils.mjs";
      6 import { html } from "chrome://global/content/vendor/lit.all.mjs";
      7 
      8 /**
      9 * Element used for displaying an avatar on the about:editprofile and about:newprofile pages.
     10 */
     11 export class Avatar extends MozLitElement {
     12  static properties = {
     13    value: { type: String },
     14  };
     15 
     16  get imageL10nId() {
     17    switch (this.value) {
     18      case "book":
     19        return "book-avatar-alt";
     20      case "briefcase":
     21        return "briefcase-avatar-alt";
     22      case "flower":
     23        return "flower-avatar-alt";
     24      case "heart":
     25        return "heart-avatar-alt";
     26      case "shopping":
     27        return "shopping-avatar-alt";
     28      case "star":
     29        return "star-avatar-alt";
     30    }
     31 
     32    return "";
     33  }
     34 
     35  render() {
     36    return html`<link
     37        rel="stylesheet"
     38        href="chrome://browser/content/profiles/avatar.css"
     39      />
     40      <div class="avatar" aria-labelledby="avatar-img">
     41        <img
     42          id="avatar-img"
     43          data-l10n-id=${this.imageL10nId}
     44          src="chrome://browser/content/profiles/assets/48_${this.value}.svg"
     45        />
     46      </div>`;
     47  }
     48 }
     49 
     50 customElements.define("profiles-avatar", Avatar);