-
Notifications
You must be signed in to change notification settings - Fork 61
/
ButtonWidgetComponent.js
37 lines (32 loc) · 1.04 KB
/
ButtonWidgetComponent.js
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
import * as React from "react";
import * as Scrivito from "scrivito";
import InPlaceEditingPlaceholder from "../../Components/InPlaceEditingPlaceholder";
const ButtonWidgetComponent = Scrivito.connect(({ widget }) => {
const target = widget.get("target");
let text = target && target.title();
if (!text) {
text = (
<InPlaceEditingPlaceholder>
Provide the button text in the widget properties.
</InPlaceEditingPlaceholder>
);
}
const classNames = ["btn"];
classNames.push(widget.get("style") || "btn-primary");
return (
<Scrivito.LinkTag to={target} className={classNames.join(" ")}>
{text}
<i className="fa fa-angle-right fa-4" aria-hidden="true" />
</Scrivito.LinkTag>
);
});
Scrivito.provideComponent("ButtonWidget", ({ widget }) => {
if (["center", "right"].includes(widget.get("alignment"))) {
return (
<div className={`text-${widget.get("alignment")}`}>
<ButtonWidgetComponent widget={widget} />
</div>
);
}
return <ButtonWidgetComponent widget={widget} />;
});