Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <link rel="import" href="chrome://resources/html/polymer.html"> | 1 <link rel="import" href="chrome://resources/html/polymer.html"> |
| 2 <link rel="import" href="chrome://resources/polymer/v1_0/iron-input/iron-input.h tml"> | 2 <link rel="import" href="chrome://resources/polymer/v1_0/iron-input/iron-input.h tml"> |
| 3 <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper -icon-button.html"> | 3 <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper -icon-button.html"> |
| 4 <link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input -container.html"> | 4 <link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input -container.html"> |
| 5 <link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spi nner-lite.html"> | 5 <link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spi nner-lite.html"> |
| 6 <link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_searc h_field_behavior.html"> | 6 <link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_searc h_field_behavior.html"> |
| 7 <link rel="import" href="chrome://resources/cr_elements/icons.html"> | 7 <link rel="import" href="chrome://resources/cr_elements/icons.html"> |
| 8 | 8 |
| 9 <dom-module id="cr-toolbar-search-field"> | 9 <dom-module id="cr-toolbar-search-field"> |
| 10 <template> | 10 <template> |
| 11 <style> | 11 <style> |
| 12 :host { | 12 :host { |
| 13 align-items: center; | 13 align-items: center; |
| 14 display: flex; | 14 display: flex; |
| 15 height: 40px; | 15 height: 40px; |
| 16 transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1), | 16 transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1), |
| 17 width 150ms cubic-bezier(0.4, 0, 0.2, 1); | 17 width 150ms cubic-bezier(0.4, 0, 0.2, 1); |
| 18 width: 44px; | 18 width: 44px; |
| 19 } | 19 } |
| 20 | 20 |
| 21 [hidden] { | 21 [hidden] { |
| 22 display: none !important; | 22 display: none !important; |
| 23 } | 23 } |
| 24 | 24 |
| 25 paper-icon-button { | 25 paper-icon-button { |
| 26 height: 32px; | 26 height: 32px; |
| 27 margin: 6px; | 27 margin: 6px; |
| 28 min-width: 32px; | |
| 28 padding: 6px; | 29 padding: 6px; |
| 29 width: 32px; | 30 width: 32px; |
| 30 } | 31 } |
| 31 | 32 |
| 32 #icon { | 33 #icon { |
| 33 --paper-icon-button-ink-color: white; | 34 --paper-icon-button-ink-color: white; |
| 34 } | 35 transition: margin 150ms, opacity 200ms; |
| 35 | |
| 36 #icon, | |
| 37 paper-spinner-lite { | |
| 38 transition: opacity 200ms; | |
| 39 } | 36 } |
| 40 | 37 |
| 41 #prompt { | 38 #prompt { |
| 42 visibility: hidden; | 39 opacity: 0; |
| 43 } | 40 } |
| 44 | 41 |
| 45 paper-spinner-lite { | 42 paper-spinner-lite { |
| 46 --paper-spinner-color: white; | 43 --paper-spinner-color: white; |
| 47 height: 20px; | 44 height: 20px; |
| 48 margin: 0 6px; | 45 margin: 0 6px; |
| 49 opacity: 0; | 46 opacity: 0; |
| 50 padding: 6px; | 47 padding: 6px; |
| 51 position: absolute; | 48 position: absolute; |
| 52 width: 20px; | 49 width: 20px; |
| 53 } | 50 } |
| 54 | 51 |
| 55 paper-spinner-lite[active] { | 52 paper-spinner-lite[active] { |
| 56 opacity: 1; | 53 opacity: 1; |
| 57 } | 54 } |
| 58 | 55 |
| 56 #prompt, | |
| 57 paper-spinner-lite { | |
| 58 transition: opacity 200ms; | |
| 59 } | |
| 60 | |
| 59 paper-input-container { | 61 paper-input-container { |
| 60 --paper-input-container-input-color: white; | 62 --paper-input-container-input-color: white; |
| 61 --paper-input-container-underline: { | 63 --paper-input-container-underline: { |
| 62 display: none; | 64 display: none; |
| 63 }; | 65 }; |
| 64 --paper-input-container-underline-focus: { | 66 --paper-input-container-underline-focus: { |
| 65 display: none; | 67 display: none; |
| 66 }; | 68 }; |
| 67 --paper-input-container-label: { | 69 --paper-input-container-label: { |
| 68 color: inherit; | 70 color: inherit; |
| 69 font-size: inherit; | 71 font-size: inherit; |
| 70 }; | 72 }; |
| 71 -webkit-padding-start: 2px; | 73 -webkit-padding-start: 2px; |
| 72 flex: 1; | 74 flex: 1; |
| 73 } | 75 } |
| 74 | 76 |
| 75 input[type='search']::-webkit-search-decoration, | 77 input[type='search']::-webkit-search-decoration, |
| 76 input[type='search']::-webkit-search-cancel-button, | 78 input[type='search']::-webkit-search-cancel-button, |
| 77 input[type='search']::-webkit-search-results-button { | 79 input[type='search']::-webkit-search-results-button { |
| 78 -webkit-appearance: none; | 80 -webkit-appearance: none; |
| 79 } | 81 } |
| 80 | 82 |
| 81 /** Wide layout, no search open. */ | 83 /** Wide layout. */ |
| 82 :host(:not([narrow]):not([showing-search])) { | 84 :host(:not([narrow])) { |
| 83 -webkit-padding-end: 0; | 85 -webkit-padding-end: 0; |
| 84 background: rgba(0, 0, 0, 0.22); | 86 background: rgba(0, 0, 0, 0.22); |
| 85 border-radius: 2px; | 87 border-radius: 2px; |
| 86 cursor: text; | 88 cursor: text; |
| 87 width: 580px; | 89 width: 580px; |
| 88 } | 90 } |
| 89 | 91 |
| 90 :host(:not([narrow]):not([showing-search])) #icon, | 92 :host(:not([narrow]):not([showing-search])) #icon, |
| 91 :host(:not([narrow]):not([showing-search])) #prompt { | 93 :host(:not([narrow]):not([showing-search])) #prompt { |
| 92 opacity: 0.6; | 94 opacity: 0.6; |
| 93 } | 95 } |
| 94 | 96 |
| 95 :host(:not([narrow]):not([showing-search])) #prompt { | 97 :host([narrow]:not([showing-search])) paper-input-container { |
| 96 visibility: visible; | 98 display: none; |
| 97 } | 99 } |
| 98 | 100 |
| 99 /* Any layout, search open. */ | 101 /* Search open. */ |
| 100 :host([showing-search]) { | |
| 101 width: 100%; | |
| 102 } | |
| 103 | |
| 104 :host([showing-search][spinner-active]) #icon { | 102 :host([showing-search][spinner-active]) #icon { |
| 105 opacity: 0; | 103 opacity: 0; |
| 106 } | 104 } |
| 107 | 105 |
| 108 :host([narrow][showing-search]) #icon { | 106 :host([narrow][showing-search]) { |
| 109 -webkit-margin-start: 18px; | 107 width: 100%; |
| 108 } | |
| 109 | |
| 110 /* | |
| 111 * Margin needs to be animated to prevent jumping around during | |
| 112 * opening/closing. -webkit-margin-start is not animatable, so we have to | |
| 113 * use regular margin-left/right instead. | |
| 114 */ | |
| 115 :host-context([dir=ltr]):host([narrow][showing-search]) #icon { | |
| 116 margin-left: 18px; | |
|
dpapad
2016/07/13 20:50:11
Can we not merge this CSS rule and the next one by
tsergeant
2016/07/14 03:50:51
-webkit-margin-start doesn't animate, and having t
| |
| 117 } | |
| 118 | |
| 119 :host-context([dir=rtl]):host([narrow][showing-search]) #icon { | |
| 120 margin-right: 18px; | |
| 110 } | 121 } |
| 111 </style> | 122 </style> |
| 112 <paper-spinner-lite | 123 <paper-spinner-lite |
| 113 active="[[isSpinnerShown_(spinnerActive, showingSearch)]]"> | 124 active="[[isSpinnerShown_(spinnerActive, showingSearch)]]"> |
| 114 </paper-spinner-lite> | 125 </paper-spinner-lite> |
| 115 <paper-icon-button id="icon" icon="cr:search" title="[[label]]" | 126 <paper-icon-button id="icon" icon="cr:search" title="[[label]]" |
| 116 tabindex$="[[computeIconTabIndex_(narrow)]]"> | 127 tabindex$="[[computeIconTabIndex_(narrow)]]"> |
| 117 </paper-icon-button> | 128 </paper-icon-button> |
| 118 <paper-input-container on-search="onSearchTermSearch" | 129 <paper-input-container on-search="onSearchTermSearch" |
| 119 on-keydown="onSearchTermKeydown" no-label-float> | 130 on-keydown="onSearchTermKeydown" no-label-float> |
| 120 <label id="prompt" for="searchInput">[[label]]</label> | 131 <label id="prompt" for="searchInput">[[label]]</label> |
| 121 <input is="iron-input" id="searchInput" type="search" | 132 <input is="iron-input" id="searchInput" type="search" |
| 122 on-blur="onInputBlur_" incremental></input> | 133 on-blur="onInputBlur_" incremental></input> |
| 123 </paper-input-container> | 134 </paper-input-container> |
| 124 <paper-icon-button icon="cr:cancel" id="clearSearch" | 135 <paper-icon-button icon="cr:cancel" id="clearSearch" |
| 125 title="[[clearLabel]]" hidden$="[[!hasSearchText_]]" | 136 title="[[clearLabel]]" hidden$="[[!hasSearchText_]]" |
| 126 on-tap="hideSearch_"> | 137 on-tap="hideSearch_"> |
| 127 </paper-icon-button> | 138 </paper-icon-button> |
| 128 </template> | 139 </template> |
| 129 <script src="cr_toolbar_search_field.js"></script> | 140 <script src="cr_toolbar_search_field.js"></script> |
| 130 </dom-module> | 141 </dom-module> |
| OLD | NEW |