Polymer 1.x:样式禁用纸张输入

Polymer 1.x: Styling disabled paper-input

我想将 <paper-input disabled ... 元素格式化为显示 NOT disabled(即,不让文本变亮)。

在我的代码 (and in this jsBin) 下方,我展示了我到目前为止所做的尝试。

我怎样才能做到这一点? (请提供工作演示。Ideally, a clone of the subject jsBin。)

http://jsbin.com/giguwoyoha/1/edit?html,输出
<!doctype html>
<head>
  <meta charset="utf-8">
  <base href="https://polygit.org/components/">
  <script src="webcomponentsjs/webcomponents-lite.min.js"></script>
  <link href="polymer/polymer.html" rel="import">
  <link href="paper-input/paper-input.html" rel="import">
</head>
<body>

<dom-module id="x-element">

<template>
  <style>
    /* Here is what I have tried so far */
    paper-input[disabled] {
      --paper-input: {
        color: black;
      }
    }
    paper-input {
      --paper-input-disabled: {
        color: black;
      }
    }
    paper-input {
      --paper-input-container-disabled: {
        color: black;
      }
    }
    paper-input[disabled] {
      color: black;
    }
    *[disabled] {
      color: black;
    }
  </style>

  <paper-input value="This is enabled text. I want to format the below to look like this."></paper-input>
  <paper-input value="This is disabled text. I want to format this to look like the above."
    disabled></paper-input>

</template>

<script>
  (function(){
    Polymer({
      is: "x-element",
      properties: {},
    });
  })();
</script>

</dom-module>

<x-element></x-element>

</body>

这里有一个关于如何正确应用混合宏的示例。

<style>
    :host {
      --paper-input-container-disabled: {
        color: pink;
        background: red;
        border: 5px dashed orange;
      };
    }
    paper-input {
      @apply(--paper-input-container-disabled);
    }
</style>
<style>
:host paper-input[disabled] {
  --paper-input-container-input-color: red;
  --paper-input-container-disabled: {
    opacity: 1;
  }
}

为了方便以后的用户,here is a jsBin demo of the accepted answer

这里是完整代码:

http://jsbin.com/mexirubida/1/edit?html,输出
<!doctype html>
<head>
  <meta charset="utf-8">
  <base href="https://polygit.org/components/">
  <script src="webcomponentsjs/webcomponents-lite.min.js"></script>
  <link href="polymer/polymer.html" rel="import">
  <link href="paper-input/paper-input.html" rel="import">
</head>
<body>

<dom-module id="x-element">

<template>
<style>
  :host paper-input[disabled] {
    --paper-input-container-input-color: red;
    --paper-input-container-disabled: {
      opacity: 1;
    }
  }
</style>
  <paper-input value="This is enabled text. I want to format the below to look like this."></paper-input>
  <paper-input value="This is disabled text. I want to format this to look like the above."
    disabled></paper-input>

</template>

<script>
  (function(){
    Polymer({
      is: "x-element",
      properties: {},
    });
  })();
</script>

</dom-module>

<x-element></x-element>

</body>

编辑

以上在 jsBin 演示中有效。但是,当尝试将其添加到我的自定义元素时,我不得不按如下方式修改代码:

:host {
  paper-input[disabled] {
    --paper-input-container-input-color: red;
    --paper-input-container-disabled: {
      opacity: 1;
    }
  }
}