Commit fef13eca authored by Gavin Williams's avatar Gavin Williams Committed by Commit Bot

scanning: Create a new element for Done section

Splitting this out to a new element for better compartmentalization for
the Done section features.

http://screen/6DrzkKGwwfkXcgr

Bug: 1059779
Change-Id: Ia81015785081904d46320754977fff9fb5190a42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542670Reviewed-by: default avatarJesse Schettler <jschettler@chromium.org>
Commit-Queue: Gavin Williams <gavinwill@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828431}
parent 0e7097ec
...@@ -276,7 +276,7 @@ export function scanningAppTest() { ...@@ -276,7 +276,7 @@ export function scanningAppTest() {
* @return {!Promise} * @return {!Promise}
*/ */
function clickDoneButton() { function clickDoneButton() {
const button = scanningApp.$$('#doneButton'); const button = scanningApp.$$('scan-done-section').$$('#doneButton');
assertTrue(!!button); assertTrue(!!button);
button.click(); button.click();
return flushTasks(); return flushTasks();
...@@ -380,7 +380,8 @@ export function scanningAppTest() { ...@@ -380,7 +380,8 @@ export function scanningAppTest() {
assertTrue(isVisible(helperText)); assertTrue(isVisible(helperText));
assertFalse(isVisible(scanProgress)); assertFalse(isVisible(scanProgress));
assertFalse(isVisible( assertFalse(isVisible(
/** @type {!HTMLElement} */ (scanningApp.$$('#fileSaved')))); /** @type {!HTMLElement} */ (
scanningApp.$$('scan-done-section'))));
// Click the Scan button and wait till the scan is started. // Click the Scan button and wait till the scan is started.
scanButton.click(); scanButton.click();
...@@ -403,7 +404,8 @@ export function scanningAppTest() { ...@@ -403,7 +404,8 @@ export function scanningAppTest() {
assertFalse(isVisible(helperText)); assertFalse(isVisible(helperText));
assertTrue(isVisible(scanProgress)); assertTrue(isVisible(scanProgress));
assertFalse(isVisible( assertFalse(isVisible(
/** @type {!HTMLElement} */ (scanningApp.$$('#fileSaved')))); /** @type {!HTMLElement} */ (
scanningApp.$$('scan-done-section'))));
assertEquals('Scanning page 1', progressText.textContent.trim()); assertEquals('Scanning page 1', progressText.textContent.trim());
assertEquals(0, progressBar.value); assertEquals(0, progressBar.value);
...@@ -440,10 +442,13 @@ export function scanningAppTest() { ...@@ -440,10 +442,13 @@ export function scanningAppTest() {
}) })
.then(() => { .then(() => {
assertTrue(isVisible( assertTrue(isVisible(
/** @type {!HTMLElement} */ (scanningApp.$$('#fileSaved')))); /** @type {!HTMLElement} */ (
scanningApp.$$('scan-done-section'))));
assertEquals( assertEquals(
'Scanned files saved!', 'Scanned files saved!',
scanningApp.$$('#fileSaved').textContent.trim()); scanningApp.$$('scan-done-section')
.$$('#title')
.textContent.trim());
// Click the Done button to return to READY state. // Click the Done button to return to READY state.
return clickDoneButton(); return clickDoneButton();
...@@ -463,7 +468,8 @@ export function scanningAppTest() { ...@@ -463,7 +468,8 @@ export function scanningAppTest() {
assertTrue(isVisible(helperText)); assertTrue(isVisible(helperText));
assertFalse(isVisible(scanProgress)); assertFalse(isVisible(scanProgress));
assertFalse(isVisible( assertFalse(isVisible(
/** @type {!HTMLElement} */ (scanningApp.$$('#fileSaved')))); /** @type {!HTMLElement} */ (
scanningApp.$$('scan-done-section'))));
}); });
}); });
......
...@@ -15,6 +15,7 @@ js_type_check("closure_compile_module") { ...@@ -15,6 +15,7 @@ js_type_check("closure_compile_module") {
":mojo_interface_provider", ":mojo_interface_provider",
":page_size_select", ":page_size_select",
":resolution_select", ":resolution_select",
":scan_done_section",
":scan_preview", ":scan_preview",
":scan_to_select", ":scan_to_select",
":scanner_select", ":scanner_select",
...@@ -72,6 +73,15 @@ js_library("resolution_select") { ...@@ -72,6 +73,15 @@ js_library("resolution_select") {
] ]
} }
js_library("scan_done_section") {
deps = [
":icons",
":scanning_app_types",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
]
}
js_library("scan_preview") { js_library("scan_preview") {
deps = [ deps = [
":scanning_app_types", ":scanning_app_types",
...@@ -107,7 +117,6 @@ js_library("scanning_app") { ...@@ -107,7 +117,6 @@ js_library("scanning_app") {
deps = [ deps = [
":color_mode_select", ":color_mode_select",
":file_type_select", ":file_type_select",
":icons",
":mojo_interface_provider", ":mojo_interface_provider",
":page_size_select", ":page_size_select",
":resolution_select", ":resolution_select",
...@@ -161,6 +170,7 @@ html_to_js("web_components") { ...@@ -161,6 +170,7 @@ html_to_js("web_components") {
"page_size_select.js", "page_size_select.js",
"resolution_select.js", "resolution_select.js",
"scan_preview.js", "scan_preview.js",
"scan_done_section.js",
"scan_settings_section.js", "scan_settings_section.js",
"scanner_select.js", "scanner_select.js",
"scan_to_select.js", "scan_to_select.js",
......
<style include="scanning-fonts">
#checkMarkIcon {
margin-inline-end: 12px;
min-width: 24px;
padding-bottom: 2px;
}
.done-button-container {
display: flex;
justify-content: flex-end;
margin-top: 32px;
width: 264px;
}
#title {
@apply --scanning-done-section-title-font;
color: var(--scanning-done-section-title-text-color);
display: inline-block;
}
</style>
<iron-icon id="checkMarkIcon" icon="scanning:check-mark"></iron-icon>
<h1 id="title" >
[[getTitleText_(pageNumber)]]
</h1>
<div class="done-button-container">
<cr-button id="doneButton" class="action-button"
on-click="onDoneClick_">
[[i18n('doneButtonText')]]
</cr-button>
</div>
// Copyright 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 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
import './icons.js';
import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {AppState} from './scanning_app_types.js';
/**
* @fileoverview
* 'scan-done-section' shows the post-scan user options.
*/
Polymer({
is: 'scan-done-section',
_template: html`{__html_template__}`,
behaviors: [I18nBehavior],
properties: {
/** @type {number} */
pageNumber: Number,
},
/**
* @return {string}
* @private
*/
getTitleText_() {
return this.i18n(
this.pageNumber > 1 ? 'fileSavedTextPlural' : 'fileSavedText');
},
/** @private */
onDoneClick_() {
this.fire('change-app-state', AppState.READY);
},
});
...@@ -4,16 +4,6 @@ ...@@ -4,16 +4,6 @@
color: var(--scanning-section-title-text-color); color: var(--scanning-section-title-text-color);
} }
#checkMarkIcon {
margin-inline-end: 12px;
min-width: 24px;
padding-bottom: 2px;
}
#fileSaved {
display: inline-block;
}
#moreSettingsButton { #moreSettingsButton {
--ink-color: var(--menu-text-color); --ink-color: var(--menu-text-color);
--paper-ripple-opacity: 0; --paper-ripple-opacity: 0;
...@@ -85,12 +75,6 @@ ...@@ -85,12 +75,6 @@
justify-content: flex-end; justify-content: flex-end;
width: 289px; width: 289px;
} }
.done-button-container {
display: flex;
justify-content: flex-end;
width: 280px;
}
</style> </style>
<div id="scanningContainer"> <div id="scanningContainer">
<div class="panel-container"> <div class="panel-container">
...@@ -100,7 +84,7 @@ ...@@ -100,7 +84,7 @@
progress-percent="[[progressPercent_]]"></scan-preview> progress-percent="[[progressPercent_]]"></scan-preview>
</div> </div>
<div class="right-panel"> <div class="right-panel">
<template is="dom-if" if="[[!shouldShowDonePage_(appState_)]]"> <template is="dom-if" if="[[!shouldShowDoneSection_(appState_)]]">
<h1 id="appTitle">[[i18n('appTitle')]]</h1> <h1 id="appTitle">[[i18n('appTitle')]]</h1>
<scanner-select id="scannerSelect" scanners="[[scanners_]]" <scanner-select id="scannerSelect" scanners="[[scanners_]]"
loaded="[[areScannersLoaded_(appState_)]]" loaded="[[areScannersLoaded_(appState_)]]"
...@@ -154,17 +138,9 @@ ...@@ -154,17 +138,9 @@
</div> </div>
<p id="statusText">[[statusText_]]</p> <p id="statusText">[[statusText_]]</p>
</template> </template>
<template is="dom-if" if="[[shouldShowDonePage_(appState_)]]"> <template is="dom-if" if="[[shouldShowDoneSection_(appState_)]]">
<iron-icon id="checkMarkIcon" icon="scanning:check-mark"></iron-icon> <scan-done-section page-number="[[pageNumber_]]"
<h1 id="fileSaved" class="title"> on-change-app-state="onChangeAppState_"></scan-done-section>
[[getFileSavedText_(pageNumber_)]]
</h1>
<div class="done-button-container">
<cr-button id="doneButton" class="action-button"
on-click="onDoneClick_">
[[i18n('doneButtonText')]]
</cr-button>
</div>
</template> </template>
</div> </div>
</div> </div>
......
...@@ -12,9 +12,9 @@ import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js'; ...@@ -12,9 +12,9 @@ import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
import './file_path.mojom-lite.js'; import './file_path.mojom-lite.js';
import './color_mode_select.js'; import './color_mode_select.js';
import './file_type_select.js'; import './file_type_select.js';
import './icons.js';
import './page_size_select.js'; import './page_size_select.js';
import './resolution_select.js'; import './resolution_select.js';
import './scan_done_section.js';
import './scan_preview.js'; import './scan_preview.js';
import './scan_to_select.js'; import './scan_to_select.js';
import './scanner_select.js'; import './scanner_select.js';
...@@ -372,7 +372,7 @@ Polymer({ ...@@ -372,7 +372,7 @@ Polymer({
* @return {boolean} * @return {boolean}
* @private * @private
*/ */
shouldShowDonePage_() { shouldShowDoneSection_() {
return this.appState_ === AppState.DONE; return this.appState_ === AppState.DONE;
}, },
...@@ -442,4 +442,12 @@ Polymer({ ...@@ -442,4 +442,12 @@ Polymer({
this.appState_ = newState; this.appState_ = newState;
}, },
/**
* @param {!Event} event
* @private
*/
onChangeAppState_(event) {
this.setAppState_(event.detail);
}
}); });
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
<include name="IDR_SCANNING_APP_SCANNER_SELECT_JS" file="${root_gen_dir}/chromeos/components/scanning/resources/scanner_select.js" use_base_dir="false" type="BINDATA"/> <include name="IDR_SCANNING_APP_SCANNER_SELECT_JS" file="${root_gen_dir}/chromeos/components/scanning/resources/scanner_select.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_SCANNING_APP_SOURCE_SELECT_HTML" file="source_select.html" type="BINDATA"/> <include name="IDR_SCANNING_APP_SOURCE_SELECT_HTML" file="source_select.html" type="BINDATA"/>
<include name="IDR_SCANNING_APP_SOURCE_SELECT_JS" file="${root_gen_dir}/chromeos/components/scanning/resources/source_select.js" use_base_dir="false" type="BINDATA"/> <include name="IDR_SCANNING_APP_SOURCE_SELECT_JS" file="${root_gen_dir}/chromeos/components/scanning/resources/source_select.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_SCANNING_APP_SCAN_DONE_SECTION_HTML" file="scan_done_section.html" type="BINDATA"/>
<include name="IDR_SCANNING_APP_SCAN_DONE_SECTION_JS" file="${root_gen_dir}/chromeos/components/scanning/resources/scan_done_section.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_SCANNING_APP_FILE_TYPE_SELECT_HTML" file="file_type_select.html" type="BINDATA"/> <include name="IDR_SCANNING_APP_FILE_TYPE_SELECT_HTML" file="file_type_select.html" type="BINDATA"/>
<include name="IDR_SCANNING_APP_FILE_TYPE_SELECT_JS" file="${root_gen_dir}/chromeos/components/scanning/resources/file_type_select.js" use_base_dir="false" type="BINDATA"/> <include name="IDR_SCANNING_APP_FILE_TYPE_SELECT_JS" file="${root_gen_dir}/chromeos/components/scanning/resources/file_type_select.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_SCANNING_APP_COLOR_MODE_SELECT_HTML" file="color_mode_select.html" type="BINDATA"/> <include name="IDR_SCANNING_APP_COLOR_MODE_SELECT_HTML" file="color_mode_select.html" type="BINDATA"/>
......
<template> <template>
<style> <style>
:host { :host {
--scanning-done-section-title-font-family: "Google Sans", Roboto, sans-serif;
--scanning-done-section-option-font-family: Roboto;
--scanning-helper-text-font-family: "Google Sans", Roboto, sans-serif; --scanning-helper-text-font-family: "Google Sans", Roboto, sans-serif;
--scanning-more-settings-font-family: Roboto; --scanning-more-settings-font-family: Roboto;
--scanning-progress-text-font-family: "Google Sans", Roboto, sans-serif; --scanning-progress-text-font-family: "Google Sans", Roboto, sans-serif;
...@@ -8,6 +10,8 @@ ...@@ -8,6 +10,8 @@
--scanning-select-font-family: Roboto; --scanning-select-font-family: Roboto;
--scanning-chevron-icon-font-size: 20px; --scanning-chevron-icon-font-size: 20px;
--scanning-done-section-title-font-size: 20px;
--scanning-done-section-options-font-size: 13px;
--scanning-helper-text-font-size: 16px; --scanning-helper-text-font-size: 16px;
--scanning-more-settings-font-size: 12px; --scanning-more-settings-font-size: 12px;
--scanning-progress-text-font-size: 16px; --scanning-progress-text-font-size: 16px;
...@@ -15,6 +19,8 @@ ...@@ -15,6 +19,8 @@
--scanning-select-font-size: 13px; --scanning-select-font-size: 13px;
--scanning-chevron-icon-color: var(--google-grey-700); --scanning-chevron-icon-color: var(--google-grey-700);
--scanning-done-section-title-text-color: var(--google-grey-900);
--scanning-done-section-option-text-color: var(--google-grey-900);
--scanning-helper-text-color: var(--google-grey-700); --scanning-helper-text-color: var(--google-grey-700);
--scanning-more-settings-text-color: var(--google-grey-700); --scanning-more-settings-text-color: var(--google-grey-700);
--scanning-progress-text-color: var(--google-grey-700); --scanning-progress-text-color: var(--google-grey-700);
...@@ -40,6 +46,16 @@ ...@@ -40,6 +46,16 @@
font-family: var(--scanning-progress-text-font-family); font-family: var(--scanning-progress-text-font-family);
font-size: var(--scanning-progress-text-font-size); font-size: var(--scanning-progress-text-font-size);
} }
--scanning-done-section-title-font: {
font-family: var(--scanning-done-section-title-font-family);
font-size: var(--scanning-done-section-title-font-size);
}
--scanning-done-section-option-font: {
font-family: var(--scanning-done-section-option-font-family);
font-size: var(--scanning-done-section-option-font-size);
}
} }
</style> </style>
</template> </template>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment