# All files / my/preview preview.js

100% Statements 16/16
100% Branches 2/2
100% Functions 14/14
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59

    2x

    60x

    1x

    1x

    1x

    1x

    1x

    1x

    4x

    25x

    4x

    25x

    4x

    4x

    66x

     /*
     * Copyright (c) 2021, salesforce.com, inc.
     * All rights reserved.
     * Licensed under the BSD 3-Clause license.
     * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
     */
    import { LightningElement, api } from 'lwc';

    export default class Preview extends LightningElement {
      @api
      contents;

      selected = 'meta';

      showHtml() {
        this.selected = 'html';
      }
      showJs() {
        this.selected = 'js';
      }
      showCss() {
        this.selected = 'css';
      }
      showMeta() {
        this.selected = 'meta';
      }
      showSvg() {
        this.selected = 'svg';
      }
      showTest() {
        this.selected = 'test';
      }

      get htmlContentClass() {
        return this.contentClass('html');
      }
      get jsContentClass() {
        return this.contentClass('js');
      }
      get cssContentClass() {
        return this.contentClass('css');
      }
      get metaContentClass() {
        return this.contentClass('meta');
      }
      get svgContentClass() {
        return this.contentClass('svg');
      }
      get testContentClass() {
        return this.contentClass('test');
      }

      contentClass(contentType) {
        return this.selected === contentType
          ? `preview-content selected ${contentType}`
          : contentType;
      }
    }