<commit_before>// Copyright (c) 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import * as Coordinator from '../../../render_coordinator/render_coordinator.js';
import * as LitHtml from '../../../third_party/lit-html/lit-html.js';

export interface IconWithPath {
  iconPath: string;
  color: string;
  width?: string;
  height?: string;
}

export interface IconWithName {
  iconName: string;
  color: string;
  width?: string;
  height?: string;
}

export type IconData = IconWithPath|IconWithName;

const isString = (value: string|undefined): value is string => value !== undefined;
const coordinator = Coordinator.RenderCoordinator.RenderCoordinator.instance();

export class Icon extends HTMLElement {
  private readonly shadow = this.attachShadow({mode: 'open'});

  private iconPath: Readonly<string> = '';
  private color: Readonly<string> = 'rgb(110 110 110)';
  private width: Readonly<string> = '100%';
  private height: Readonly<string> = '100%';
  private iconName?: Readonly<string>;

  set data(data: IconData) {
    const {width, height} = data;
    this.color = data.color;
    this.width = isString(width) ? width : (isString(height) ? height : this.width);
    this.height = isString(height) ? height : (isString(width) ? width : this.height);
    if ('iconPath' in data) {
      this.iconPath = data.iconPath;
    } else {
      this.iconPath = new URL(`../../Images/${data.iconName}.svg`, import.meta.url).toString();
      this.iconName = data.iconName;
    }
    this.render();
  }

  get data(): IconData {
    const commonData = {
      color: this.color,
      width: this.width,
      height: this.height,
    };
    if (this.iconName) {
      return {
        ...commonData,
        iconName: this.iconName,
      };
    }
    return {
      ...commonData,
      iconPath: this.iconPath,
    };
  }
<commit_msg>Fix image URL in icon_button<commit_after>// Copyright (c) 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import * as Coordinator from '../../../render_coordinator/render_coordinator.js';
import * as LitHtml from '../../../third_party/lit-html/lit-html.js';

export interface IconWithPath {
  iconPath: string;
  color: string;
  width?: string;
  height?: string;
}

export interface IconWithName {
  iconName: string;
  color: string;
  width?: string;
  height?: string;
}

export type IconData = IconWithPath|IconWithName;

const isString = (value: string|undefined): value is string => value !== undefined;
const coordinator = Coordinator.RenderCoordinator.RenderCoordinator.instance();

export class Icon extends HTMLElement {
  private readonly shadow = this.attachShadow({mode: 'open'});

  private iconPath: Readonly<string> = '';
  private color: Readonly<string> = 'rgb(110 110 110)';
  private width: Readonly<string> = '100%';
  private height: Readonly<string> = '100%';
  private iconName?: Readonly<string>;

  set data(data: IconData) {
    const {width, height} = data;
    this.color = data.color;
    this.width = isString(width) ? width : (isString(height) ? height : this.width);
    this.height = isString(height) ? height : (isString(width) ? width : this.height);
    if ('iconPath' in data) {
      this.iconPath = data.iconPath;
    } else {
      this.iconPath = new URL(`../../../Images/${data.iconName}.svg`, import.meta.url).toString();
      this.iconName = data.iconName;
    }
    this.render();
  }

  get data(): IconData {
    const commonData = {
      color: this.color,
      width: this.width,
      height: this.height,
    };
    if (this.iconName) {
      return {
        ...commonData,
        iconName: this.iconName,
      };
    }
    return {
      ...commonData,
      iconPath: this.iconPath,
    };
  }

{'fraction_non_alphanumeric': 0.14004096262160778, 'fraction_numerical': 0.00972862263184844, 'mean_word_length': 3.1475583864118897, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2356300', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1191, 'n_words': 330}