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
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256

ash / webui / common / resources / keyboard_key.html [blame]

<style include="cr-shared-style">
    @media (min-width: 600px) {
      :host {
        --keyboard-key-icon-size: 10px;
      }
      #key {
        font-size: 10px;
        line-height: 10px;
      }
    }

    @media (min-width: 768px) {
      :host {
        --keyboard-key-icon-size: 12px;
      }
      #key {
        font-size: 11px;
        line-height: 16px;
      }
    }

    @media (min-width: 960px) {
      :host {
        --keyboard-key-icon-size: 14px;
      }
      #key {
        font-size: 12px;
        line-height: 18px;
      }
    }

    @media (min-width: 1280px) {
      :host {
        --keyboard-key-icon-size: 20px;
      }
      #key {
        font-size: 13px;
        line-height: 20px;
      }
    }

  :host {
    --background-color-disabled: var(--cros-bg-color-dropped-elevation-2);
    --background-color-pressed: var(--google-blue-800);
    --background-color-unpressed: var(--cros-highlight-color);
    --background-color-tested: rgba(var(--cros-icon-color-selection-rgb),
        .85);
    --border-color: var(--cros-text-color-selection);
    --border-radius:
        var(--keyboard-key-top-radii, 4px)
        var(--keyboard-key-top-radii, 4px)
        var(--keyboard-key-bottom-right-radius, 4px)
        4px;
    --host-bg-color: var(--diagram-bg-color);
    --icon-size: min(100%, var(--keyboard-key-icon-size, 100%));
    --travel: var(--keyboard-key-travel, 4px);
    --text-color-unpressed: var(--cros-text-color-selection);
    --text-color-pressed: var(--cros-button-icon-color-primary);
    --text-color-tested: var(--cros-button-icon-color-primary);
    position: relative;
  }

  /* TODO(276493287): Remove host-context and replace default colors with jelly
                      colors once experiment launches. */
  :host-context(body.jelly-enabled) {
    --background-color-disabled: var(--cros-sys-disabled_container);
    --background-color-pressed: var(--cros-button-background-color-primary);
    --background-color-unpressed: var(--cros-sys-highlight_shape);
    --background-color-tested: var(--cros-sys-highlight_text);
    --border-color: var(--cros-icon-color-prominent);
    --text-color-unpressed: var(--cros-icon-color-prominent);
    --text-color-pressed: var(--cros-button-icon-color-primary);
    --text-color-tested: var(--cros-icon-color-prominent);
  }

  @media (prefers-color-scheme: dark) {
    :host {
      --background-color-disabled: var(--cros-bg-color-elevation-4);
      --background-color-pressed: var(--cros-icon-color-selection);
      --background-color-unpressed: var(--cros-button-active-shadow-color-ambient-primary);
      --background-color-tested: rgba(var(--cros-icon-color-selection-rgb),
        .65);
    }

    /* TODO(276493287): Remove host-context and replace default colors with
                        jelly colors once experiment launches. */
    :host-context(body.jelly-enabled) {
      --background-color-disabled: var(--cros-sys-disabled_container);
      --background-color-tested: var(--cros-sys-highlight_text);
    }
  }

  #key {
    background-color: var(--background-color-unpressed);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    border-top-width: var(--keyboard-key-border-top-width, 1px);
    bottom: var(--travel);
    color: var(--text-color-unpressed);
    display: grid;
    font-family: 'Google Sans', sans-serif;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, 1fr);
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: all 150ms ease-in-out;
  }

  #key-background {
    background-color: var(--host-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    border-top-width: var(--keyboard-key-border-top-width, 1px);
    bottom: var(--travel);
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: all 150ms ease-in-out;
  }

  iron-icon {
    --iron-icon-fill-color: var(--text-color-unpressed);
    --iron-icon-height: var(--icon-size);
    --iron-icon-width: var(--icon-size);
    align-self: center;
    grid-row: span 2;
    justify-self: center;
  }

  :host(.left) iron-icon,
  :host(.right) iron-icon {
    --iron-icon-width: 24px;
    padding: 0 5px;
  }

  :host(.left) iron-icon {
    justify-self: left;
  }

  :host(.right) iron-icon {
    justify-self: right;
  }

  #mainGlyph {
    left: 0;
    overflow: clip visible;
    position: absolute;
    right: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #mainGlyph:not(:empty) {
    padding: 0 5px;
  }

  /* Key labels won't change sides in RTL locales, so disable lint warning. */
  :host(.left) #mainGlyph {
    text-align: left;  /* csschecker-disable-line left-right */
  }

  :host(.right) #mainGlyph {
    text-align: right;  /* csschecker-disable-line left-right */
  }

  span {
    align-self: center;
    text-align: center;
  }

  :host([state='pressed']) #key {
    background-color: var(--background-color-pressed);
    border-color: var(--background-color-pressed);
    bottom: 0;
    color: var(--text-color-pressed);
    top: var(--travel);
  }

  :host([state='pressed']) #key-background {
    bottom: 0;
    top: var(--travel);
  }

  :host([state='pressed']) iron-icon {
    --iron-icon-fill-color: var(--text-color-pressed);
  }

  :host([state='tested']) #key {
    background-color: var(--background-color-tested);
    color: var(--text-color-tested);
  }

  :host([state='tested']) iron-icon {
    --iron-icon-fill-color: var(--text-color-tested);
  }

  #shadow {
    background-color: var(--border-color);
    border-radius: var(--border-radius);
    bottom: 0;
    left: 0;
    position: absolute;
    right: 0;
    top: var(--travel);
  }

  :host(.disabled) {
    --travel: 0;
  }

  :host(.disabled) #key {
    background-color: var(--background-color-disabled);
    border-color: transparent;
    bottom: 0;
    color: var(--cros-icon-color-disabled);
    top: var(--travel);
  }

  :host(.disabled) #key-background {
    border-color: transparent;
    bottom: 0;
    top: var(--travel);
  }

  :host(.disabled) #shadow {
    background-color: var(--background-color-disabled);
  }
</style>
<div id="shadow"></div>
<div id="key-background"></div>
<div id="key" aria-label="[[ariaLabel_]]" role="img">
  <!--
    Child elements are aria-hidden to make ChromeVox treat the whole key as
    one unit with an aria-label, rather than individual labels that don't
    reflect the key's state.
  -->
  <template is="dom-if" if="[[icon]]">
    <iron-icon aria-hidden="true" icon="[[icon]]"></iron-icon>
  </template>
  <template is="dom-if" if="[[mainGlyph]]">
    <span aria-hidden="true" id="mainGlyph">[[mainGlyph]]</span>
  </template>
  <template is="dom-if" if="[[showCornerGlyphs_]]">
    <span aria-hidden="true">[[topLeftGlyph]]</span>
    <span aria-hidden="true">[[bottomLeftGlyph]]</span>
    <template is="dom-if" if="[[showSecondColumn_]]">
      <span aria-hidden="true">[[topRightGlyph]]</span>
      <span aria-hidden="true">[[bottomRightGlyph]]</span>
    </template>
  </template>
</div>