Skip to content

Commit 13df30d

Browse files
committed
Bug 1971835 - Part 1: create an empty state component r=akulyk
Differential Revision: https://phabricator.services.mozilla.com/D268765
1 parent fb40638 commit 13df30d

File tree

5 files changed

+180
-0
lines changed

5 files changed

+180
-0
lines changed

browser/components/preferences/jar.mn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ browser.jar:
2424
content/browser/preferences/web-appearance-dark.svg
2525
content/browser/preferences/web-appearance-light.svg
2626
content/browser/preferences/widgets/dialog-button.mjs (widgets/dialog-button/dialog-button.mjs)
27+
content/browser/preferences/widgets/placeholder-message.mjs (widgets/placeholder-message/placeholder-message.mjs)
28+
content/browser/preferences/widgets/placeholder-message.css (widgets/placeholder-message/placeholder-message.css)
2729
content/browser/preferences/widgets/nav-notice.mjs (widgets/nav-notice/nav-notice.mjs)
2830
content/browser/preferences/widgets/nav-notice.css (widgets/nav-notice/nav-notice.css)
2931
content/browser/preferences/widgets/setting-control.css (widgets/setting-control/setting-control.css)

browser/components/preferences/preferences.xhtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<script src="chrome://browser/content/migration/migration-wizard.mjs" type="module"></script>
9292
<script type="module" src="chrome://browser/content/backup/backup-settings.mjs"></script>
9393
<script type="module" src="chrome://browser/content/preferences/widgets/dialog-button.mjs"></script>
94+
<script type="module" src="chrome://browser/content/preferences/widgets/placeholder-message.mjs"></script>
9495
<script type="module" src="chrome://browser/content/preferences/widgets/nav-notice.mjs"></script>
9596
<script type="module" src="chrome://browser/content/preferences/widgets/setting-pane.mjs"></script>
9697
<script type="module" src="chrome://browser/content/preferences/widgets/setting-group.mjs"></script>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
moz-box-item {
6+
--box-padding: var(--space-xxlarge);
7+
}
8+
9+
.placeholder-container {
10+
gap: var(--space-large);
11+
}
12+
13+
.placeholder-container,
14+
.text-container {
15+
display: flex;
16+
flex-direction: column;
17+
align-items: center;
18+
}
19+
20+
.text-container {
21+
gap: var(--space-xsmall);
22+
text-align: center;
23+
}
24+
25+
img {
26+
max-width: 160px;
27+
}
28+
29+
.label:has(+ .support-link),
30+
.description:has(+ .support-link) {
31+
margin-inline-end: var(--space-xsmall);
32+
}
33+
34+
.description {
35+
color: var(--text-color-deemphasized);
36+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import { MozLitElement } from "chrome://global/content/lit-utils.mjs";
6+
import { html } from "chrome://global/content/vendor/lit.all.mjs";
7+
8+
class PlaceholderMessage extends MozLitElement {
9+
static properties = {
10+
imageSrc: { type: String },
11+
label: { type: String, fluent: true },
12+
description: { type: String, fluent: true },
13+
supportPage: { type: String, attribute: "support-page" },
14+
};
15+
16+
constructor() {
17+
super();
18+
19+
/** @type {string} */
20+
this.imageSrc = "";
21+
22+
/** @type {string} */
23+
this.label = "";
24+
25+
/** @type {string} */
26+
this.description = "";
27+
28+
/** @type {string} */
29+
this.supportPage = "";
30+
}
31+
32+
labelTemplate() {
33+
if (!this.label) {
34+
return "";
35+
}
36+
return html`<div class="label-wrapper">
37+
<span class="label heading-medium" id="label">${this.label}</span>${!this
38+
.description
39+
? this.supportLinkTemplate()
40+
: ""}
41+
</div>`;
42+
}
43+
44+
descriptionTemplate() {
45+
if (!this.description) {
46+
return "";
47+
}
48+
return html`<div class="description-wrapper">
49+
<span class="description" id="description"> ${this.description}</span
50+
>${this.supportLinkTemplate()}
51+
</div>`;
52+
}
53+
54+
supportLinkTemplate() {
55+
if (!this.supportPage) {
56+
return "";
57+
}
58+
return html`<a
59+
is="moz-support-link"
60+
class="support-link"
61+
support-page=${this.supportPage}
62+
part="support-link"
63+
aria-describedby="label description"
64+
></a>`;
65+
}
66+
67+
render() {
68+
return html`
69+
<link
70+
rel="stylesheet"
71+
href="chrome://browser/content/preferences/widgets/placeholder-message.css"
72+
/>
73+
<link
74+
rel="stylesheet"
75+
href="chrome://global/skin/design-system/text-and-typography.css"
76+
/>
77+
<moz-box-item>
78+
<div class="placeholder-container">
79+
<img src=${this.imageSrc} role="presentation" />
80+
<div class="text-container">
81+
${this.labelTemplate()} ${this.descriptionTemplate()}
82+
</div>
83+
</div>
84+
</moz-box-item>
85+
`;
86+
}
87+
}
88+
customElements.define("placeholder-message", PlaceholderMessage);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import { html, ifDefined } from "chrome://global/content/vendor/lit.all.mjs";
6+
import "chrome://browser/content/preferences/widgets/placeholder-message.mjs";
7+
8+
export default {
9+
title: "Domain-specific UI Widgets/Settings/Placeholder Message",
10+
component: "placeholder-message",
11+
argTypes: {
12+
l10nId: {
13+
options: [
14+
"placeholder-message-label",
15+
"placeholder-message-label-description",
16+
],
17+
control: { type: "select" },
18+
},
19+
},
20+
parameters: {
21+
status: "in-development",
22+
fluent: `
23+
placeholder-message-label =
24+
.label = You are not signed in
25+
placeholder-message-label-description =
26+
.label = You are not signed in
27+
.description = With a Mozilla account, you can sync your bookmarks, history, tabs, passwords, add-ons, and settings across all your devices.
28+
`,
29+
},
30+
};
31+
32+
const Template = ({ imageSrc = "", l10nId = "", supportPage = "" }) => html`
33+
<div style="max-width: 500px">
34+
<placeholder-message
35+
imageSrc=${ifDefined(imageSrc)}
36+
data-l10n-id=${l10nId}
37+
support-page=${ifDefined(supportPage)}
38+
></placeholder-message>
39+
</div>
40+
`;
41+
42+
export const Default = Template.bind({});
43+
Default.args = {
44+
imageSrc: "chrome://global/skin/illustrations/security-error.svg",
45+
l10nId: "placeholder-message-label-description",
46+
supportPage: "",
47+
};
48+
49+
export const WithSupportPage = Template.bind({});
50+
WithSupportPage.args = {
51+
...Default.args,
52+
supportPage: "test",
53+
};

0 commit comments

Comments
 (0)