Commit 6c526f44 authored by Shik Chen's avatar Shik Chen Committed by Chromium LUCI CQ

CCA: Add snackbar for copied link

Bug: b/172879638
Test: Manually in expert mode

Change-Id: I4507280850563ffdb684e3c41ad51bfd579c95ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583587
Commit-Queue: Shik Chen <shik@chromium.org>
Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835624}
parent 238ddcb1
......@@ -59,6 +59,7 @@ const struct {
{"expert_save_metadata", IDS_EXPERT_SAVE_METADATA},
{"expert_print_performance_logs", IDS_EXPERT_PRINT_PERFORMANCE_LOGS},
{"expert_scan_barcode", IDS_EXPERT_SCAN_BARCODE},
{"snackbar_link_copied", IDS_SNACKBAR_LINK_COPIED},
{"error_msg_expert_mode_not_supported",
IDS_ERROR_MSG_EXPERT_MODE_NOT_SUPPORTED},
{"feedback_button", IDS_FEEDBACK_BUTTON},
......
......@@ -87,6 +87,7 @@ copy("chrome_camera_app_js") {
"js/metrics.js",
"js/nav.js",
"js/perf.js",
"js/snackbar.js",
"js/sound.js",
"js/state.js",
"js/test_bridge.js",
......
......@@ -70,6 +70,7 @@
<structure name="IDR_CAMERA_RESULT_SAVER_JS" file="js/models/result_saver.js" type="chrome_html" />
<structure name="IDR_CAMERA_REVIEW_RESULT_JS" file="js/views/camera/review_result.js" type="chrome_html" />
<structure name="IDR_CAMERA_SETTINGS_JS" file="js/views/settings.js" type="chrome_html" />
<structure name="IDR_CAMERA_SNACKBAR_JS" file="js/snackbar.js" type="chrome_html" />
<structure name="IDR_CAMERA_SOUND_JS" file="js/sound.js" type="chrome_html" />
<structure name="IDR_CAMERA_STATE_JS" file="js/state.js" type="chrome_html" />
<structure name="IDR_CAMERA_TEST_BRIDGE_JS" file="js/test_bridge.js" type="chrome_html" />
......
......@@ -1578,3 +1578,47 @@ body:not(.mode-switching):not(.streaming):not(.review-result) #spinner {
width: var(--chip-height);
z-index: 50;
}
/* TODO(b/172879638): Tune the position and layout after we finalized the
* responsive window design. */
.snackbar {
align-items: center;
background: rgb(32, 33, 36);
border-radius: 4px;
bottom: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.15);
box-sizing: border-box;
color: rgb(232, 234, 237);
display: flex;
font-family: Roboto;
font-size: 13px;
height: 48px;
left: 4px;
opacity: 0;
padding: 14px 16px;
position: absolute;
visibility: hidden;
width: 256px;
}
.snackbar.animate {
animation: 3s show-snackbar linear;
visibility: visible;
}
@keyframes show-snackbar {
0% {
opacity: 0;
}
/* 100ms fade-in */
3.33% {
opacity: 1;
}
97.33% {
opacity: 1;
}
/* 80ms fade-out */
100% {
opacity: 0;
}
}
......@@ -93,6 +93,7 @@ js_library("compile_resources") {
"mojo/image_capture.js",
"nav.js",
"perf.js",
"snackbar.js",
"sound.js",
"state.js",
"test_bridge.js",
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
import * as dom from './dom.js';
import * as snackbar from './snackbar.js';
import * as toast from './toast.js';
import * as util from './util.js';
......@@ -43,8 +44,7 @@ function showUrl(url) {
dom.getFrom(container, '.barcode-copy-button', HTMLButtonElement);
copyButton.onclick = async () => {
await navigator.clipboard.writeText(url);
// TODO(b/172879638): Show "Link copied" in a snackbar.
toast.showDebugMessage('Link copied');
snackbar.show('snackbar_link_copied');
};
// TODO(b/172879638): Handle a11y.
......
// 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 {browserProxy} from './browser_proxy/browser_proxy.js';
import * as dom from './dom.js';
import * as util from './util.js';
/**
* Shows a snackbar message.
* @param {string} label The label of the message to show.
* @param {...string} substitutions The substitutions for the label.
*/
export function show(label, ...substitutions) {
const message = browserProxy.getI18nMessage(label, ...substitutions);
const el = dom.get('.snackbar', HTMLElement);
el.textContent = message;
util.animateOnce(el);
// TODO(b/172879638): Handle a11y.
}
......@@ -339,6 +339,9 @@
<message desc="Label for expert mode option: scan barcode." name="IDS_EXPERT_SCAN_BARCODE">
Scan barcode
</message>
<message desc="Label for snackbar message when a link is copied" name="IDS_SNACKBAR_LINK_COPIED">
Link copied
</message>
<message desc="Error message when the device does not support expert mode but tries to enable it." name="IDS_ERROR_MSG_EXPERT_MODE_NOT_SUPPORTED">
Expert mode is not supported on this device
</message>
......
......@@ -408,6 +408,7 @@
<button class="barcode-copy-button" tabindex="0"></button>
</div>
</div>
<div class="snackbar"></div>
<div id="tooltip" aria-hidden="true"></div>
<audio id="sound-tick-final" src="/sounds/tick_final.ogg"
data-timeout="1000">
......
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