summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/content-src/asrouter/templates/OnboardingMessage/OnboardingMessage.jsx
blob: ce1a840247711690a68602897b09ff7f75efcbee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

import React from "react";
import { Localized } from "../../../aboutwelcome/components/MSLocalized";

export class OnboardingCard extends React.PureComponent {
  constructor(props) {
    super(props);
    this.onClick = this.onClick.bind(this);
  }

  onClick() {
    const { props } = this;
    const ping = {
      event: "CLICK_BUTTON",
      message_id: props.id,
      id: props.UISurface,
    };
    props.sendUserActionTelemetry(ping);
    props.onAction(props.content.primary_button.action, props.message);
  }

  render() {
    const { content } = this.props;
    const className = this.props.className || "onboardingMessage";
    return (
      <div className={className}>
        <div className={`onboardingMessageImage ${content.icon}`} />
        <div className="onboardingContent">
          <span>
            <Localized text={content.title}>
              <h2 className="onboardingTitle" />
            </Localized>
            <Localized text={content.text}>
              <p className="onboardingText" />
            </Localized>
          </span>
          <span className="onboardingButtonContainer">
            <Localized text={content.primary_button.label}>
              <button
                className="button onboardingButton"
                onClick={this.onClick}
              />
            </Localized>
          </span>
        </div>
      </div>
    );
  }
}