-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcomponent.js
68 lines (62 loc) · 2.01 KB
/
component.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(RaiselyComponents, _React) => {
/**
* This is the closure area of your custom component, allowing you to
* specify and declare code used by your main component. This allows for
* a greater amount of complexity in your components while ensuring your
* component performs correctly.
*/
/**
* Anything declared in this area is only available to your custom component.
* This is great for text and values that aren't subject to change frequently.
*/
const config = {
internalTitle: 'Hello world!',
};
// We can access specific Raisely components through the
// RaiselyComponents prop
const { Button } = RaiselyComponents.Atoms;
/**
* Once you've declared your required components, be sure to return the function
* representing your final Raisely Component so it can be shown on your page.
*/
return (props) => {
/**
* If you declare fields within your Custom Component settings, they can be accessed
* by calling props.getValues() if set within your page editor. If values aren't set
* while editing, they will not be present on the values object.
*/
const values = props.getValues();
/**
* Raisely gives you access to global values that are based on the current state of the page.
* The campaign object represents the campaign object returned by Raisely, while user represents
* the currently logged in user (if your campaign allows user's to login).
*/
const {
campaign,
user,
} = props.global;
/**
* Depending on the page being viewed, you can also access values such as the currently
* displayed profile and post.
*/
const {
profile,
post,
} = props.global.current;
return (
<div className="my-custom-component">
<h1>
{config.maskedTitle} {values.customTitle || 'You did not provide a title'}
</h1>
<Button
onClick={() => {
// this action is being handled when a user clicks this button
console.log('This is a button click!');
}}
>
This button will perform an action
</Button>
</div>
);
}
}