-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NTP Quests] Adding tile element and tests
Added styling for dynamic tile and tests to make sure the elements are rendered properly. Bug: 1410808 Change-Id: I605be71bfbadf33326c68b5716b1458a5487ede0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4264743 Reviewed-by: Riley Tatum <rtatum@google.com> Commit-Queue: Marlon Facey <mfacey@chromium.org> Reviewed-by: Roman Arora <romanarora@chromium.org> Cr-Commit-Position: refs/heads/main@{#1108710}
- Loading branch information
Marlon Facey
authored and
Chromium LUCI CQ
committed
Feb 23, 2023
1 parent
6011fe7
commit 11340a2
Showing
6 changed files
with
211 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
chrome/browser/resources/new_tab_page/modules/history_clusters/tile.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<style include="history-clusters-shared-style"> | ||
#content { | ||
background: var(--google-grey-100); | ||
border-radius: 25px; | ||
color: var(--google-grey-900); | ||
} | ||
|
||
/* TODO(crbug.com/1414484): Add comprehensive theming to the hover states */ | ||
/*:host(:hover) #content {*/ | ||
/* background-color: var(--cr-hover-background-color);*/ | ||
/*}*/ | ||
|
||
/*:host(:active) #content {*/ | ||
/* background-color: var(--cr-active-background-color);*/ | ||
/*}*/ | ||
|
||
:host([large-format]) #content { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
:host([medium-format]) #content { | ||
display: flex; | ||
flex-direction: row; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
#image { | ||
background: red; | ||
border-radius: 25px; | ||
} | ||
|
||
:host([large-format]) #image { | ||
height: 152px; | ||
margin: 16px auto; | ||
width: 320px; | ||
} | ||
|
||
:host([medium-format]) #image { | ||
height: 128px; | ||
margin: 8px; | ||
width: 128px; | ||
} | ||
|
||
/* TODO(crbug.com/1418528): Add favicon */ | ||
/*#icon {*/ | ||
/* background-color: white;*/ | ||
/* height: 16px;*/ | ||
/* margin-inline-end: 8px;*/ | ||
/* width: 16px;*/ | ||
/*}*/ | ||
|
||
:host([medium-format]) #icon { | ||
margin-inline-start: 8px; | ||
} | ||
|
||
#title { | ||
font-size: 16px; | ||
white-space: initial; | ||
} | ||
|
||
:host([large-format]) #title { | ||
height: 48px; | ||
max-width: 298px; | ||
padding: 16px 24px 24px; | ||
} | ||
|
||
:host([medium-format]) #title { | ||
height: 60px; | ||
max-width: 184px; | ||
padding: 18px 16px 32px 8px; | ||
} | ||
|
||
#info-container { | ||
color: var(--google-grey-700); | ||
display: flex; | ||
flex-direction: row; | ||
font-size: 11px; | ||
margin-inline-start: 24px; | ||
} | ||
|
||
:host([large-format]) #label { | ||
max-width: 200px; | ||
} | ||
|
||
:host([medium-format]) #label { | ||
max-width: 90px; | ||
} | ||
|
||
#label, | ||
#date { | ||
bottom: -2px; | ||
position: relative; | ||
} | ||
|
||
#dot { | ||
line-height: 16px; | ||
} | ||
</style> | ||
<div id="content"> | ||
<div id="image"></div> | ||
<div id="text-container"> | ||
<div id="title" class="truncate">[[visit.pageTitle]]</div> | ||
<div id="info-container"> | ||
<div id="label" class="truncate"> [[label_]]</div> | ||
<span id="dot"> • </span> | ||
<div id="date">[[visit.relativeDate]]</div> | ||
</div> | ||
</div> | ||
</div> |
68 changes: 68 additions & 0 deletions
68
chrome/browser/resources/new_tab_page/modules/history_clusters/tile.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'chrome://resources/cr_components/history_clusters/history_clusters_shared_style.css.js'; | ||
|
||
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; | ||
|
||
import {Cluster, URLVisit} from '../../history_cluster_types.mojom-webui.js'; | ||
import {I18nMixin} from '../../i18n_setup.js'; | ||
|
||
import {getTemplate} from './tile.html.js'; | ||
|
||
export class TileModuleElement extends I18nMixin | ||
(PolymerElement) { | ||
static get is() { | ||
return 'ntp-history-clusters-tile'; | ||
} | ||
|
||
static get template() { | ||
return getTemplate(); | ||
} | ||
|
||
static get properties() { | ||
return { | ||
/* The visit to display. */ | ||
visit: Object, | ||
|
||
/* The icon to display. */ | ||
iconStyle_: { | ||
type: String, | ||
computed: `computeIconStyle_(visit.imageUrl)`, | ||
}, | ||
|
||
/* The label to display. */ | ||
label_: { | ||
type: String, | ||
computed: `computeLabel_(visit.urlForDisplay)`, | ||
}, | ||
}; | ||
} | ||
|
||
visit: URLVisit; | ||
cluster: Cluster; | ||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
override connectedCallback() { | ||
super.connectedCallback(); | ||
} | ||
|
||
override disconnectedCallback() { | ||
super.disconnectedCallback(); | ||
} | ||
|
||
private computeIconStyle_(): string { | ||
return `-webkit-mask-image: url(${this.visit.imageUrl})`; | ||
} | ||
|
||
private computeLabel_(): string { | ||
// TODO: Figure out better way to strip host name | ||
return this.visit.urlForDisplay; | ||
} | ||
} | ||
|
||
customElements.define(TileModuleElement.is, TileModuleElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters