Skip to content

Commit 4c09c22

Browse files
PM-18215 Create UI for confirmation notification message (bitwarden#13364)
* PM-18215 wip * update storybook url * optional errors and storybook args * type safety * Update apps/browser/src/autofill/content/components/icons/warning.ts Co-authored-by: Jonathan Prusik <[email protected]> * updated svg to remove dark or light --------- Co-authored-by: Jonathan Prusik <[email protected]>
1 parent 993c056 commit 4c09c22

File tree

6 files changed

+400
-129
lines changed

6 files changed

+400
-129
lines changed

apps/browser/src/autofill/content/components/icons/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export { PartyHorn } from "./party-horn";
1010
export { PencilSquare } from "./pencil-square";
1111
export { Shield } from "./shield";
1212
export { User } from "./user";
13+
export { Warning } from "./warning";

apps/browser/src/autofill/content/components/icons/party-horn.ts

+223-129
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { html } from "lit";
2+
3+
// This icon has static multi-colors for each theme
4+
export function Warning() {
5+
return html`
6+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 40 36">
7+
<path
8+
fill="#FFBF00"
9+
d="M15.944 2.483c1.81-3.111 6.303-3.111 8.111 0l15.302 26.319c1.819 3.127-.438 7.049-4.055 7.049H4.698c-3.617 0-5.874-3.922-4.055-7.05L15.944 2.484Z"
10+
/>
11+
<path
12+
fill="#0E3781"
13+
fill-rule="evenodd"
14+
d="M37.735 29.745 22.433 3.425c-1.085-1.866-3.781-1.866-4.866 0L2.265 29.746c-1.091 1.876.263 4.23 2.433 4.23h30.604c2.17 0 3.524-2.354 2.433-4.23ZM24.055 2.483c-1.808-3.111-6.302-3.111-8.11 0L.643 28.802c-1.819 3.127.438 7.049 4.055 7.049h30.604c3.617 0 5.874-3.922 4.055-7.05L24.055 2.484Z"
15+
clip-rule="evenodd"
16+
/>
17+
<path
18+
fill="#0E3781"
19+
d="M21.876 28.345a1.876 1.876 0 1 1-3.752 0 1.876 1.876 0 0 1 3.752 0ZM17.24 11.976a.47.47 0 0 1 .467-.519h4.586c.279 0 .496.242.466.52l-1.307 12.196a.47.47 0 0 1-.466.42h-1.972a.47.47 0 0 1-.466-.42L17.24 11.976Z"
20+
/>
21+
</svg>
22+
`;
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Meta, StoryObj } from "@storybook/web-components";
2+
3+
import { Theme, ThemeTypes } from "@bitwarden/common/platform/enums";
4+
5+
import { NotificationConfirmationBody } from "../../notification/confirmation";
6+
7+
type Args = {
8+
buttonText: string;
9+
confirmationMessage: string;
10+
handleClick: () => void;
11+
theme: Theme;
12+
error: string;
13+
};
14+
15+
export default {
16+
title: "Components/Notifications/Notification Confirmation Body",
17+
argTypes: {
18+
error: { control: "text" },
19+
buttonText: { control: "text" },
20+
confirmationMessage: { control: "text" },
21+
theme: { control: "select", options: [...Object.values(ThemeTypes)] },
22+
},
23+
args: {
24+
error: "",
25+
buttonText: "View",
26+
confirmationMessage: "[item name] updated in Bitwarden.",
27+
theme: ThemeTypes.Light,
28+
},
29+
parameters: {
30+
design: {
31+
type: "figma",
32+
url: "https://www.figma.com/design/LEhqLAcBPY8uDKRfU99n9W/Autofill-notification-redesign?node-id=485-20160&m=dev",
33+
},
34+
},
35+
} as Meta<Args>;
36+
37+
const Template = (args: Args) => NotificationConfirmationBody({ ...args });
38+
39+
export const Default: StoryObj<Args> = {
40+
render: Template,
41+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { css } from "@emotion/css";
2+
import { html } from "lit";
3+
4+
import { Theme } from "@bitwarden/common/platform/enums";
5+
6+
import { themes } from "../constants/styles";
7+
8+
export function NotificationConfirmationMessage({
9+
buttonText,
10+
confirmationMessage,
11+
handleClick,
12+
theme,
13+
}: {
14+
buttonText: string;
15+
confirmationMessage: string;
16+
handleClick: (e: Event) => void;
17+
theme: Theme;
18+
}) {
19+
return html`
20+
<span title=${confirmationMessage} class=${notificationConfirmationMessageStyles(theme)}
21+
>${confirmationMessage}
22+
<a
23+
title=${buttonText}
24+
class=${notificationConfirmationButtonTextStyles(theme)}
25+
@click=${handleClick}
26+
>${buttonText}</a
27+
></span
28+
>
29+
`;
30+
}
31+
32+
const baseTextStyles = css`
33+
flex-grow: 1;
34+
overflow-x: hidden;
35+
text-align: left;
36+
text-overflow: ellipsis;
37+
line-height: 24px;
38+
white-space: nowrap;
39+
font-family: "DM Sans", sans-serif;
40+
font-size: 16px;
41+
`;
42+
43+
const notificationConfirmationMessageStyles = (theme: Theme) => css`
44+
${baseTextStyles}
45+
color: ${themes[theme].text.main};
46+
font-weight: 400;
47+
`;
48+
49+
const notificationConfirmationButtonTextStyles = (theme: Theme) => css`
50+
${baseTextStyles}
51+
color: ${themes[theme].primary[600]};
52+
font-weight: 700;
53+
cursor: pointer;
54+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import createEmotion from "@emotion/css/create-instance";
2+
import { html } from "lit";
3+
4+
import { Theme, ThemeTypes } from "@bitwarden/common/platform/enums";
5+
6+
import { themes } from "../constants/styles";
7+
import { PartyHorn, Warning } from "../icons";
8+
9+
import { NotificationConfirmationMessage } from "./confirmation-message";
10+
11+
export const componentClassPrefix = "notification-confirmation-body";
12+
13+
const { css } = createEmotion({
14+
key: componentClassPrefix,
15+
});
16+
17+
export function NotificationConfirmationBody({
18+
buttonText,
19+
error,
20+
confirmationMessage,
21+
theme = ThemeTypes.Light,
22+
}: {
23+
error?: string;
24+
buttonText: string;
25+
confirmationMessage: string;
26+
theme: Theme;
27+
}) {
28+
const IconComponent = !error ? PartyHorn : Warning;
29+
return html`
30+
<div class=${notificationConfirmationBodyStyles({ theme })}>
31+
<div class=${iconContainerStyles(error)}>${IconComponent({ theme })}</div>
32+
${confirmationMessage && buttonText
33+
? NotificationConfirmationMessage({
34+
handleClick: () => {},
35+
confirmationMessage,
36+
theme,
37+
buttonText,
38+
})
39+
: null}
40+
</div>
41+
`;
42+
}
43+
44+
const iconContainerStyles = (error?: string) => css`
45+
> svg {
46+
width: ${!error ? "50px" : "40px"};
47+
height: fit-content;
48+
}
49+
`;
50+
const notificationConfirmationBodyStyles = ({ theme }: { theme: Theme }) => css`
51+
gap: 16px;
52+
display: flex;
53+
align-items: center;
54+
justify-content: flex-start;
55+
background-color: ${themes[theme].background.alt};
56+
padding: 12px;
57+
white-space: nowrap;
58+
`;

0 commit comments

Comments
 (0)