@plusscommunities/pluss-core-web 1.7.3-beta.0 → 1.7.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +3 -0
- package/dist/components.js +390 -33094
- package/dist/components.js.map +1 -1
- package/dist/index.cjs.js +10388 -0
- package/dist/index.esm.js +10349 -0
- package/dist/index.js +394 -33098
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +10361 -0
- package/package.json +31 -22
- package/rollup.config.js +57 -0
- package/src/actions/AuthActions.js +83 -0
- package/src/actions/LocalActions.js +8 -0
- package/src/actions/NavActions.js +8 -0
- package/src/actions/ScheduledActionsActions.js +8 -0
- package/src/actions/TemplateActions.js +15 -0
- package/src/actions/UsersActions.js +95 -0
- package/src/actions/index.js +6 -0
- package/src/actions/types.js +23 -0
- package/src/analytics.js +183 -0
- package/src/apis/analyticsActions.js +53 -0
- package/src/apis/authActions.js +58 -0
- package/src/apis/fileActions.js +152 -0
- package/src/apis/index.js +10 -0
- package/src/apis/profileActions.js +133 -0
- package/src/apis/scheduledActionsActions.js +12 -0
- package/src/apis/stringActions.js +25 -0
- package/src/apis/templateActions.js +41 -0
- package/src/apis/typeActions.js +186 -0
- package/src/apis/userActions.js +169 -0
- package/src/apis/utilityActions.js +35 -0
- package/src/colours.js +134 -0
- package/src/components/AddButton.js +27 -0
- package/src/components/AnalyticsFilter.js +115 -0
- package/src/components/Attachment.js +27 -0
- package/src/components/AudienceIncluder.js +175 -0
- package/src/components/AudienceSelector.js +700 -0
- package/src/components/Button.js +66 -0
- package/src/components/CheckBox.js +77 -0
- package/src/components/ColourOptions.js +197 -0
- package/src/components/ColourPicker.js +267 -0
- package/src/components/Comment.js +46 -0
- package/src/components/CommentSection.js +116 -0
- package/src/components/DatePicker.js +290 -0
- package/src/components/DropdownInput.js +223 -0
- package/src/components/DurationInput.js +51 -0
- package/src/components/ExportCsvPopup.js +222 -0
- package/src/components/FileInput.js +389 -0
- package/src/components/GenericInput.js +169 -0
- package/src/components/Header.js +82 -0
- package/src/components/HubSidebar.js +134 -0
- package/src/components/ImageInput.js +987 -0
- package/src/components/InputGroup.js +18 -0
- package/src/components/MakerPopup.js +310 -0
- package/src/components/MoreMenu.js +22 -0
- package/src/components/OptionsSection.js +84 -0
- package/src/components/OverlayPage.js +74 -0
- package/src/components/OverlayPageBottomButtons.js +48 -0
- package/src/components/OverlayPageContents.js +48 -0
- package/src/components/OverlayPageSection.js +38 -0
- package/src/components/P60Icon.js +40 -0
- package/src/components/PageTitle.js +13 -0
- package/src/components/Popup.js +104 -0
- package/src/components/ProfilePic.js +50 -0
- package/src/components/RadioButton.js +144 -0
- package/src/components/Reactions.js +77 -0
- package/src/components/SVGIcon.js +33 -0
- package/src/components/SideNavItem.js +98 -0
- package/src/components/StatBox.js +49 -0
- package/src/components/StatusButton.js +22 -0
- package/src/components/SuccessPopup.js +57 -0
- package/src/components/Tabs.js +56 -0
- package/src/components/Tag.js +62 -0
- package/src/components/Text.js +20 -0
- package/src/components/TextFormatPopup.js +54 -0
- package/src/components/TimePicker.js +225 -0
- package/src/components/UserListing.js +111 -0
- package/src/components/index.js +46 -0
- package/src/components/svg-icons.json +821 -0
- package/src/config.js +25 -0
- package/src/helper/HelpDeskWidget.js +16 -0
- package/src/helper/api/getUrl.js +15 -0
- package/src/helper/api/getUrlParams.js +9 -0
- package/src/helper/api/safeReadParams.js +6 -0
- package/src/helper/auth/getUserFromState.js +8 -0
- package/src/helper/colours/getAppColourFromState.js +10 -0
- package/src/helper/files/canvasImageUploader.js +159 -0
- package/src/helper/files/generateImageName.js +10 -0
- package/src/helper/files/get1400.js +32 -0
- package/src/helper/files/getExtension.js +9 -0
- package/src/helper/files/getFileName.js +13 -0
- package/src/helper/files/getThumb300.js +36 -0
- package/src/helper/files/isVideo.js +8 -0
- package/src/helper/helper.js +97 -0
- package/src/helper/index.js +44 -0
- package/src/helper/site/getMerchantsFromState.js +9 -0
- package/src/helper/site/getSiteLevelFromState.js +34 -0
- package/src/helper/site/getSiteName.js +16 -0
- package/src/helper/site/getSiteNameFromRoles.js +12 -0
- package/src/helper/site/getSiteSettingFromState.js +10 -0
- package/src/helper/storage/readJSONFromStorage.js +9 -0
- package/src/helper/storage/readStorageWithCookie.js +22 -0
- package/src/helper/storage/setLocalStorage.js +5 -0
- package/src/helper/strings/getFirstName.js +10 -0
- package/src/helper/strings/htmlDecode.js +4 -0
- package/src/helper/strings/htmlEncode.js +4 -0
- package/src/helper/strings/isEmail.js +11 -0
- package/src/helper/strings/isUrl.js +13 -0
- package/src/helper/strings/onlyAlphanumeric.js +8 -0
- package/src/helper/strings/randomString.js +10 -0
- package/src/helper/strings/toParagraphed.js +17 -0
- package/src/index.js +12 -0
- package/src/reducers/ScheduledActionsReducer.js +14 -0
- package/src/reducers/TemplatesReducer.js +29 -0
- package/src/reducers/index.js +7 -0
- package/src/session.js +289 -0
- package/src/urls.js +21 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import FontAwesome from 'react-fontawesome';
|
|
3
|
+
import { SVGIcon } from './SVGIcon';
|
|
4
|
+
|
|
5
|
+
class Button extends Component {
|
|
6
|
+
getClasses() {
|
|
7
|
+
let string = '';
|
|
8
|
+
if (this.props.inline) string = string + 'buttonWrapper--inline ';
|
|
9
|
+
if (this.props.isActive) string = string + 'button--active ';
|
|
10
|
+
if (this.props.buttonType) string = string + `button--${this.props.buttonType}`;
|
|
11
|
+
if (this.props.compact) string = string + ' buttonWrapper--compact';
|
|
12
|
+
if (this.props.narrow) string = string + ' buttonWrapper--narrow';
|
|
13
|
+
if (this.props.noHoverHighlight) string = string + ' button--noHoverHighlight';
|
|
14
|
+
if (this.props.className) string = string + ' ' + this.props.className;
|
|
15
|
+
return string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getButtonClasses() {
|
|
19
|
+
if (this.props.buttonClassName) {
|
|
20
|
+
return `button ${this.props.buttonClassName}`;
|
|
21
|
+
}
|
|
22
|
+
return 'button';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getButtonTextClasses() {
|
|
26
|
+
let result = 'buttonText';
|
|
27
|
+
if (this.props.leftIcon) {
|
|
28
|
+
result = result + ` buttonTextWithIcon`;
|
|
29
|
+
}
|
|
30
|
+
if (this.props.buttonTextClassName) {
|
|
31
|
+
result = result + ` ${this.props.buttonTextClassName}`;
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
buttonClick() {
|
|
37
|
+
if (this.props.onClick) {
|
|
38
|
+
this.props.onClick();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
renderLeftIcon() {
|
|
43
|
+
if (!this.props.leftIcon) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (this.props.leftIconType === 'svg') {
|
|
47
|
+
return <SVGIcon icon={this.props.leftIcon} className="buttonTextWithIcon_icon" colour={this.props.leftIconColour} />;
|
|
48
|
+
}
|
|
49
|
+
return <FontAwesome name={this.props.leftIcon} className="buttonTextWithIcon_icon" />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return (
|
|
54
|
+
<div className={`buttonWrapper ${this.getClasses()}`} style={{ ...this.props.buttonStyle }}>
|
|
55
|
+
<div onClick={() => this.buttonClick()} className={this.getButtonClasses()} style={{ ...this.props.style }}>
|
|
56
|
+
<div className={this.getButtonTextClasses()} style={{ ...this.props.textStyle }}>
|
|
57
|
+
{this.renderLeftIcon()}
|
|
58
|
+
{this.props.children}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { Button };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import FontAwesome from 'react-fontawesome';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
|
|
5
|
+
class CheckBox extends PureComponent {
|
|
6
|
+
generateClassNames() {
|
|
7
|
+
let result = 'checkBox';
|
|
8
|
+
if (this.props.isActive) {
|
|
9
|
+
result = result + ' checkBox--active';
|
|
10
|
+
}
|
|
11
|
+
if (this.props.disabled) {
|
|
12
|
+
result = result + ' checkBox--disabled';
|
|
13
|
+
}
|
|
14
|
+
if (this.props.noHoverHighlight) {
|
|
15
|
+
result = result + ' checkBox--noHoverHighlight';
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getLabelClasses() {
|
|
21
|
+
let result = 'actionText pointer';
|
|
22
|
+
if (this.props.disabled) {
|
|
23
|
+
result = result + ' actionText--disabled';
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getBoxStyle() {
|
|
29
|
+
const result = {};
|
|
30
|
+
if (this.props.highlightColour && this.props.isActive) {
|
|
31
|
+
result.borderColor = this.props.highlightColour;
|
|
32
|
+
result.backgroundColor = this.props.highlightColour;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onChange = (e) => {
|
|
38
|
+
if (this.props.disabled) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
return this.props.onChange(e);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
return (
|
|
46
|
+
<div className={this.props.className}>
|
|
47
|
+
<div className={this.props.showWarning ? 'checkBox--error' : null} style={{ ...styles.row, ...this.props.style }}>
|
|
48
|
+
<div className={this.generateClassNames()} onClick={this.onChange} style={this.getBoxStyle()}>
|
|
49
|
+
<div className="checkBoxTick">
|
|
50
|
+
<FontAwesome className="checkBoxTick-font" name={'check'} />
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
{!_.isEmpty(this.props.label) && (
|
|
54
|
+
<div
|
|
55
|
+
className={this.getLabelClasses()}
|
|
56
|
+
style={{ marginLeft: 8, fontSize: 14, lineHeight: '20px', ...this.props.labelStyle }}
|
|
57
|
+
onClick={this.onChange}
|
|
58
|
+
>
|
|
59
|
+
{this.props.label}
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
</div>
|
|
63
|
+
{this.props.children}
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const styles = {
|
|
70
|
+
row: {
|
|
71
|
+
display: 'flex',
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
marginBottom: 8,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { CheckBox };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import FontAwesome from 'react-fontawesome';
|
|
4
|
+
import { ChromePicker } from 'react-color';
|
|
5
|
+
import tinycolor from 'tinycolor2';
|
|
6
|
+
import { Tabs } from './Tabs';
|
|
7
|
+
|
|
8
|
+
class ColourOptions extends Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.state = {
|
|
12
|
+
selectedColour: props.value || '',
|
|
13
|
+
colour: props.value,
|
|
14
|
+
selectedOption: props.defaultTab || 'vibrant',
|
|
15
|
+
colourCircleTop: 0,
|
|
16
|
+
colourCircleLeft: 0,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
this.setColourCircle();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentDidUpdate(prevProps) {
|
|
25
|
+
if (this.props.value !== prevProps.value) {
|
|
26
|
+
const { value } = this.props;
|
|
27
|
+
this.setState({ selectedColour: value, colour: value }, this.setColourCircle);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setColourCircle = () => {
|
|
32
|
+
const tc = tinycolor(this.state.colour);
|
|
33
|
+
this.setState({
|
|
34
|
+
colourCircleTop: 100 - (100 * tc.getBrightness()) / 255,
|
|
35
|
+
colourCircleLeft: (100 * tc.toHsv().h) / 360,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
getQuickChoiceTabs() {
|
|
40
|
+
const { options } = this.props;
|
|
41
|
+
const optionsArray = typeof options === 'string' ? options.split(',').map((o) => o.trim()) : options;
|
|
42
|
+
const available = [
|
|
43
|
+
{
|
|
44
|
+
value: 'vibrant',
|
|
45
|
+
text: 'Vibrant',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: 'soft',
|
|
49
|
+
text: 'Soft',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: 'picker',
|
|
53
|
+
text: 'Picker',
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
return !optionsArray || optionsArray.length === 0 ? available : available.filter((o) => optionsArray.includes(o.value));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onColourChange = (color) => {
|
|
60
|
+
// console.log('onColourChange', color);
|
|
61
|
+
const colour = (typeof color === 'object' ? color.hex : color).toUpperCase();
|
|
62
|
+
this.setState({ selectedColour: colour, colour }, () => {
|
|
63
|
+
this.setColourCircle();
|
|
64
|
+
const { onColourSelected } = this.props;
|
|
65
|
+
if (onColourSelected) onColourSelected(this.state.colour);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
onSelectOption = (selectedOption) => {
|
|
70
|
+
this.setState({ selectedOption });
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
renderColourQuickChoicesCircle(colour, selectedColour) {
|
|
74
|
+
const isSelected = selectedColour.toLowerCase() === colour.toLowerCase();
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
className={`colourQuickChoices_circle${isSelected ? ' colourQuickChoices_circle-selected' : ''}`}
|
|
78
|
+
style={{ backgroundColor: colour }}
|
|
79
|
+
onClick={() => this.onColourChange(colour)}
|
|
80
|
+
>
|
|
81
|
+
<FontAwesome name="check" className="colourQuickChoices_circle_tick" />
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
renderColourOptions() {
|
|
87
|
+
const { selectedColour, selectedOption } = this.state;
|
|
88
|
+
|
|
89
|
+
let content;
|
|
90
|
+
switch (selectedOption) {
|
|
91
|
+
case 'picker':
|
|
92
|
+
content = (
|
|
93
|
+
<div className="flex flex-center-row colourQuickChoices" style={{ marginBottom: 'unset' }}>
|
|
94
|
+
<ChromePicker color={selectedColour} onChangeComplete={this.onColourChange} disableAlpha className="chrome-picker-noShadow" />
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
break;
|
|
98
|
+
case 'vibrant':
|
|
99
|
+
content = (
|
|
100
|
+
<div className="flex flex-between colourQuickChoices" style={{ marginBottom: 'unset' }}>
|
|
101
|
+
<div className="colourQuickChoices_column">
|
|
102
|
+
{this.renderColourQuickChoicesCircle('#c44569', selectedColour)}
|
|
103
|
+
{this.renderColourQuickChoicesCircle('#f1a459', selectedColour)}
|
|
104
|
+
{this.renderColourQuickChoicesCircle('#38ada9', selectedColour)}
|
|
105
|
+
{this.renderColourQuickChoicesCircle('#7064a7', selectedColour)}
|
|
106
|
+
</div>
|
|
107
|
+
<div className="colourQuickChoices_column">
|
|
108
|
+
{this.renderColourQuickChoicesCircle('#ea4c88', selectedColour)}
|
|
109
|
+
{this.renderColourQuickChoicesCircle('#e8bb67', selectedColour)}
|
|
110
|
+
{this.renderColourQuickChoicesCircle('#60a3bc', selectedColour)}
|
|
111
|
+
{this.renderColourQuickChoicesCircle('#546de5', selectedColour)}
|
|
112
|
+
</div>
|
|
113
|
+
<div className="colourQuickChoices_column">
|
|
114
|
+
{this.renderColourQuickChoicesCircle('#e66767', selectedColour)}
|
|
115
|
+
{this.renderColourQuickChoicesCircle('#94d0c5', selectedColour)}
|
|
116
|
+
{this.renderColourQuickChoicesCircle('#5badda', selectedColour)}
|
|
117
|
+
{this.renderColourQuickChoicesCircle('#dfad8c', selectedColour)}
|
|
118
|
+
</div>
|
|
119
|
+
<div className="colourQuickChoices_column">
|
|
120
|
+
{this.renderColourQuickChoicesCircle('#ff6c5c', selectedColour)}
|
|
121
|
+
{this.renderColourQuickChoicesCircle('#7abf9e', selectedColour)}
|
|
122
|
+
{this.renderColourQuickChoicesCircle('#9fcfd9', selectedColour)}
|
|
123
|
+
{this.renderColourQuickChoicesCircle('#dd91a7', selectedColour)}
|
|
124
|
+
</div>
|
|
125
|
+
<div className="colourQuickChoices_column">
|
|
126
|
+
{this.renderColourQuickChoicesCircle('#f19066', selectedColour)}
|
|
127
|
+
{this.renderColourQuickChoicesCircle('#a1ab94', selectedColour)}
|
|
128
|
+
{this.renderColourQuickChoicesCircle('#a67db7', selectedColour)}
|
|
129
|
+
{this.renderColourQuickChoicesCircle('#596275', selectedColour)}
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
break;
|
|
134
|
+
case 'soft':
|
|
135
|
+
content = (
|
|
136
|
+
<div className="flex flex-between colourQuickChoices" style={{ marginBottom: 'unset' }}>
|
|
137
|
+
<div className="colourQuickChoices_column">
|
|
138
|
+
{this.renderColourQuickChoicesCircle('#eacdd0', selectedColour)}
|
|
139
|
+
{this.renderColourQuickChoicesCircle('#a4c9d7', selectedColour)}
|
|
140
|
+
{this.renderColourQuickChoicesCircle('#c6b9c0', selectedColour)}
|
|
141
|
+
{this.renderColourQuickChoicesCircle('#cdc4af', selectedColour)}
|
|
142
|
+
</div>
|
|
143
|
+
<div className="colourQuickChoices_column">
|
|
144
|
+
{this.renderColourQuickChoicesCircle('#d6b7b1', selectedColour)}
|
|
145
|
+
{this.renderColourQuickChoicesCircle('#eaf2f4', selectedColour)}
|
|
146
|
+
{this.renderColourQuickChoicesCircle('#cce0db', selectedColour)}
|
|
147
|
+
{this.renderColourQuickChoicesCircle('#b9bee4', selectedColour)}
|
|
148
|
+
</div>
|
|
149
|
+
<div className="colourQuickChoices_column">
|
|
150
|
+
{this.renderColourQuickChoicesCircle('#9bd3cb', selectedColour)}
|
|
151
|
+
{this.renderColourQuickChoicesCircle('#f1d7bb', selectedColour)}
|
|
152
|
+
{this.renderColourQuickChoicesCircle('#fcbc7b', selectedColour)}
|
|
153
|
+
{this.renderColourQuickChoicesCircle('#caeff5', selectedColour)}
|
|
154
|
+
</div>
|
|
155
|
+
<div className="colourQuickChoices_column">
|
|
156
|
+
{this.renderColourQuickChoicesCircle('#e0dceb', selectedColour)}
|
|
157
|
+
{this.renderColourQuickChoicesCircle('#b1becd', selectedColour)}
|
|
158
|
+
{this.renderColourQuickChoicesCircle('#e6cfc5', selectedColour)}
|
|
159
|
+
{this.renderColourQuickChoicesCircle('#cfd6df', selectedColour)}
|
|
160
|
+
</div>
|
|
161
|
+
<div className="colourQuickChoices_column">
|
|
162
|
+
{this.renderColourQuickChoicesCircle('#f39ca4', selectedColour)}
|
|
163
|
+
{this.renderColourQuickChoicesCircle('#c0adc5', selectedColour)}
|
|
164
|
+
{this.renderColourQuickChoicesCircle('#fcbca4', selectedColour)}
|
|
165
|
+
{this.renderColourQuickChoicesCircle('#c5ceb9', selectedColour)}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
break;
|
|
170
|
+
default:
|
|
171
|
+
content = null;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
const tabs = this.getQuickChoiceTabs();
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div>
|
|
178
|
+
{tabs && tabs.length > 1 ? (
|
|
179
|
+
<Tabs
|
|
180
|
+
onSelectTab={this.onSelectOption}
|
|
181
|
+
selectedTab={selectedOption}
|
|
182
|
+
tabs={tabs}
|
|
183
|
+
containerStyle={{ display: 'flex' }}
|
|
184
|
+
tabStyle={{ flex: 1 }}
|
|
185
|
+
/>
|
|
186
|
+
) : null}
|
|
187
|
+
<div className="flex flex-center flex-center-row">{content}</div>
|
|
188
|
+
</div>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
render() {
|
|
193
|
+
return this.renderColourOptions();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export { ColourOptions };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import FontAwesome from 'react-fontawesome';
|
|
4
|
+
import { ChromePicker } from 'react-color';
|
|
5
|
+
import tinycolor from 'tinycolor2';
|
|
6
|
+
import { Popup } from './Popup';
|
|
7
|
+
import { Tabs } from './Tabs';
|
|
8
|
+
|
|
9
|
+
class ColourPicker extends Component {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.state = {
|
|
13
|
+
selectedColour: props.value,
|
|
14
|
+
colour: props.value,
|
|
15
|
+
selectedOption: props.defaultTab || 'vibrant',
|
|
16
|
+
colourPickerOpen: false,
|
|
17
|
+
colourCircleTop: 0,
|
|
18
|
+
colourCircleLeft: 0,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
componentDidMount() {
|
|
23
|
+
this.setColourCircle();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
componentDidUpdate(prevProps) {
|
|
27
|
+
if (this.props.value !== prevProps.value) {
|
|
28
|
+
const { value } = this.props;
|
|
29
|
+
this.setState({ selectedColour: value, colour: value }, this.setColourCircle);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setColourCircle = () => {
|
|
34
|
+
const tc = tinycolor(this.state.colour);
|
|
35
|
+
this.setState({
|
|
36
|
+
colourCircleTop: 100 - (100 * tc.getBrightness()) / 255,
|
|
37
|
+
colourCircleLeft: (100 * tc.toHsv().h) / 360,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
getQuickChoiceTabs() {
|
|
42
|
+
const { options } = this.props;
|
|
43
|
+
const optionsArray = typeof options === 'string' ? options.split(',').map((o) => o.trim()) : options;
|
|
44
|
+
const available = [
|
|
45
|
+
{
|
|
46
|
+
value: 'vibrant',
|
|
47
|
+
text: 'Vibrant',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
value: 'soft',
|
|
51
|
+
text: 'Soft',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
value: 'picker',
|
|
55
|
+
text: 'Picker',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
return !optionsArray || optionsArray.length === 0 ? available : available.filter((o) => optionsArray.includes(o.value));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
onTogglePopup = () => {
|
|
62
|
+
if (this.props.disabled) return;
|
|
63
|
+
this.setState({ colourPickerOpen: !this.state.colourPickerOpen });
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
onColourChange = (color) => {
|
|
67
|
+
// console.log('onColourChange', color);
|
|
68
|
+
let colour = color;
|
|
69
|
+
if (typeof color === 'object') {
|
|
70
|
+
colour = color.hex;
|
|
71
|
+
}
|
|
72
|
+
this.setState({ selectedColour: colour.toUpperCase() });
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
onSelectOption = (selectedOption) => {
|
|
76
|
+
this.setState({ selectedOption });
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
onDone = () => {
|
|
80
|
+
const { colourPickerOpen, selectedColour } = this.state;
|
|
81
|
+
this.setState({ colourPickerOpen: !colourPickerOpen, colour: selectedColour }, () => {
|
|
82
|
+
this.setColourCircle();
|
|
83
|
+
|
|
84
|
+
const { onColourSelected } = this.props;
|
|
85
|
+
if (onColourSelected) onColourSelected(this.state.colour);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
onCancel = () => {
|
|
90
|
+
const { colourPickerOpen, colour } = this.state;
|
|
91
|
+
this.setState({ colourPickerOpen: !colourPickerOpen, selectedColour: colour });
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
renderColourQuickChoicesCircle(colour, selectedColour) {
|
|
95
|
+
const isSelected = selectedColour.toLowerCase() === colour.toLowerCase();
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
className={`colourQuickChoices_circle${isSelected ? ' colourQuickChoices_circle-selected' : ''}`}
|
|
99
|
+
style={{ backgroundColor: colour }}
|
|
100
|
+
onClick={() => this.onColourChange(colour)}
|
|
101
|
+
>
|
|
102
|
+
<FontAwesome name="check" className="colourQuickChoices_circle_tick" />
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
renderColourOptions() {
|
|
108
|
+
const { selectedColour, selectedOption } = this.state;
|
|
109
|
+
|
|
110
|
+
let content;
|
|
111
|
+
switch (selectedOption) {
|
|
112
|
+
case 'picker':
|
|
113
|
+
content = (
|
|
114
|
+
<div className="flex flex-center-row colourQuickChoices" style={{ marginBottom: 'unset' }}>
|
|
115
|
+
<ChromePicker color={selectedColour} onChangeComplete={this.onColourChange} disableAlpha className="chrome-picker-noShadow" />
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
break;
|
|
119
|
+
case 'vibrant':
|
|
120
|
+
content = (
|
|
121
|
+
<div className="flex flex-between colourQuickChoices" style={{ marginBottom: 'unset' }}>
|
|
122
|
+
<div className="colourQuickChoices_column">
|
|
123
|
+
{this.renderColourQuickChoicesCircle('#c44569', selectedColour)}
|
|
124
|
+
{this.renderColourQuickChoicesCircle('#f1a459', selectedColour)}
|
|
125
|
+
{this.renderColourQuickChoicesCircle('#38ada9', selectedColour)}
|
|
126
|
+
{this.renderColourQuickChoicesCircle('#7064a7', selectedColour)}
|
|
127
|
+
</div>
|
|
128
|
+
<div className="colourQuickChoices_column">
|
|
129
|
+
{this.renderColourQuickChoicesCircle('#ea4c88', selectedColour)}
|
|
130
|
+
{this.renderColourQuickChoicesCircle('#e8bb67', selectedColour)}
|
|
131
|
+
{this.renderColourQuickChoicesCircle('#60a3bc', selectedColour)}
|
|
132
|
+
{this.renderColourQuickChoicesCircle('#546de5', selectedColour)}
|
|
133
|
+
</div>
|
|
134
|
+
<div className="colourQuickChoices_column">
|
|
135
|
+
{this.renderColourQuickChoicesCircle('#e66767', selectedColour)}
|
|
136
|
+
{this.renderColourQuickChoicesCircle('#94d0c5', selectedColour)}
|
|
137
|
+
{this.renderColourQuickChoicesCircle('#5badda', selectedColour)}
|
|
138
|
+
{this.renderColourQuickChoicesCircle('#dfad8c', selectedColour)}
|
|
139
|
+
</div>
|
|
140
|
+
<div className="colourQuickChoices_column">
|
|
141
|
+
{this.renderColourQuickChoicesCircle('#ff6c5c', selectedColour)}
|
|
142
|
+
{this.renderColourQuickChoicesCircle('#7abf9e', selectedColour)}
|
|
143
|
+
{this.renderColourQuickChoicesCircle('#9fcfd9', selectedColour)}
|
|
144
|
+
{this.renderColourQuickChoicesCircle('#dd91a7', selectedColour)}
|
|
145
|
+
</div>
|
|
146
|
+
<div className="colourQuickChoices_column">
|
|
147
|
+
{this.renderColourQuickChoicesCircle('#f19066', selectedColour)}
|
|
148
|
+
{this.renderColourQuickChoicesCircle('#a1ab94', selectedColour)}
|
|
149
|
+
{this.renderColourQuickChoicesCircle('#a67db7', selectedColour)}
|
|
150
|
+
{this.renderColourQuickChoicesCircle('#596275', selectedColour)}
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
break;
|
|
155
|
+
case 'soft':
|
|
156
|
+
content = (
|
|
157
|
+
<div className="flex flex-between colourQuickChoices" style={{ marginBottom: 'unset' }}>
|
|
158
|
+
<div className="colourQuickChoices_column">
|
|
159
|
+
{this.renderColourQuickChoicesCircle('#eacdd0', selectedColour)}
|
|
160
|
+
{this.renderColourQuickChoicesCircle('#a4c9d7', selectedColour)}
|
|
161
|
+
{this.renderColourQuickChoicesCircle('#c6b9c0', selectedColour)}
|
|
162
|
+
{this.renderColourQuickChoicesCircle('#cdc4af', selectedColour)}
|
|
163
|
+
</div>
|
|
164
|
+
<div className="colourQuickChoices_column">
|
|
165
|
+
{this.renderColourQuickChoicesCircle('#d6b7b1', selectedColour)}
|
|
166
|
+
{this.renderColourQuickChoicesCircle('#eaf2f4', selectedColour)}
|
|
167
|
+
{this.renderColourQuickChoicesCircle('#cce0db', selectedColour)}
|
|
168
|
+
{this.renderColourQuickChoicesCircle('#b9bee4', selectedColour)}
|
|
169
|
+
</div>
|
|
170
|
+
<div className="colourQuickChoices_column">
|
|
171
|
+
{this.renderColourQuickChoicesCircle('#9bd3cb', selectedColour)}
|
|
172
|
+
{this.renderColourQuickChoicesCircle('#f1d7bb', selectedColour)}
|
|
173
|
+
{this.renderColourQuickChoicesCircle('#fcbc7b', selectedColour)}
|
|
174
|
+
{this.renderColourQuickChoicesCircle('#caeff5', selectedColour)}
|
|
175
|
+
</div>
|
|
176
|
+
<div className="colourQuickChoices_column">
|
|
177
|
+
{this.renderColourQuickChoicesCircle('#e0dceb', selectedColour)}
|
|
178
|
+
{this.renderColourQuickChoicesCircle('#b1becd', selectedColour)}
|
|
179
|
+
{this.renderColourQuickChoicesCircle('#e6cfc5', selectedColour)}
|
|
180
|
+
{this.renderColourQuickChoicesCircle('#cfd6df', selectedColour)}
|
|
181
|
+
</div>
|
|
182
|
+
<div className="colourQuickChoices_column">
|
|
183
|
+
{this.renderColourQuickChoicesCircle('#f39ca4', selectedColour)}
|
|
184
|
+
{this.renderColourQuickChoicesCircle('#c0adc5', selectedColour)}
|
|
185
|
+
{this.renderColourQuickChoicesCircle('#fcbca4', selectedColour)}
|
|
186
|
+
{this.renderColourQuickChoicesCircle('#c5ceb9', selectedColour)}
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
);
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
content = null;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
const tabs = this.getQuickChoiceTabs();
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<div>
|
|
199
|
+
{tabs && tabs.length > 1 ? <Tabs onSelectTab={this.onSelectOption} selectedTab={selectedOption} tabs={tabs} /> : null}
|
|
200
|
+
<div className="flex flex-center flex-center-row">{content}</div>
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
renderColourPopup() {
|
|
206
|
+
const { colourPickerOpen } = this.state;
|
|
207
|
+
if (!colourPickerOpen) return null;
|
|
208
|
+
const { title } = this.props;
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<Popup
|
|
212
|
+
title={title || `Colour Picker`}
|
|
213
|
+
maxWidth={500}
|
|
214
|
+
hasPadding
|
|
215
|
+
buttons={[
|
|
216
|
+
{
|
|
217
|
+
type: 'primary',
|
|
218
|
+
onClick: this.onDone,
|
|
219
|
+
style: { width: 100 },
|
|
220
|
+
isActive: true,
|
|
221
|
+
text: 'Done',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
type: 'outlinedAction',
|
|
225
|
+
onClick: this.onCancel,
|
|
226
|
+
style: { width: 100 },
|
|
227
|
+
isActive: true,
|
|
228
|
+
text: 'Cancel',
|
|
229
|
+
},
|
|
230
|
+
]}
|
|
231
|
+
>
|
|
232
|
+
{this.renderColourOptions()}
|
|
233
|
+
</Popup>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
render() {
|
|
238
|
+
const { colourCircleTop, colourCircleLeft, colour } = this.state;
|
|
239
|
+
const { children, showHex } = this.props;
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div>
|
|
243
|
+
<div className="flex flex-center">
|
|
244
|
+
{children ? (
|
|
245
|
+
<div onClick={this.onTogglePopup}>{children}</div>
|
|
246
|
+
) : (
|
|
247
|
+
<div className="colourPicker_button" style={{ width: 80, marginBottom: 'unset' }} onClick={this.onTogglePopup}>
|
|
248
|
+
<div className="colourPicker_rainbow">
|
|
249
|
+
<div
|
|
250
|
+
className="colourPicker_rainbow_circle"
|
|
251
|
+
style={{
|
|
252
|
+
top: `${colourCircleTop}%`,
|
|
253
|
+
left: `${colourCircleLeft}%`,
|
|
254
|
+
}}
|
|
255
|
+
></div>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
)}
|
|
259
|
+
{showHex ? <div className="marginLeft-10">{colour && colour.toUpperCase()}</div> : null}
|
|
260
|
+
</div>
|
|
261
|
+
{this.renderColourPopup()}
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export { ColourPicker };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import { get1400, toParagraphed } from '../helper';
|
|
4
|
+
import { ProfilePic } from './ProfilePic';
|
|
5
|
+
import _ from 'lodash';
|
|
6
|
+
|
|
7
|
+
class Comment extends Component {
|
|
8
|
+
renderImage(image) {
|
|
9
|
+
if (_.isEmpty(image)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (
|
|
13
|
+
<div className="imageGrid">
|
|
14
|
+
<a href={image} target="_blank" rel="noopener noreferrer">
|
|
15
|
+
<div className="imageGrid_image" style={{ backgroundImage: `url('${get1400(image)}')` }}></div>
|
|
16
|
+
</a>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
renderComment() {
|
|
22
|
+
const { comment } = this.props;
|
|
23
|
+
return (
|
|
24
|
+
<div key={comment.Id} className="comment">
|
|
25
|
+
<p className="comment_text">{toParagraphed(comment.Comment)}</p>
|
|
26
|
+
{this.renderImage(comment.Image)}
|
|
27
|
+
<div className="comment_bottom">
|
|
28
|
+
<ProfilePic className="comment_profilePic" size={25} image={comment.User.profilePic} />
|
|
29
|
+
<p className="comment_name">{comment.User.displayName}</p>
|
|
30
|
+
<p className="comment_time">{moment.utc(comment.Timestamp).local().format('D MMM YYYY • h:mma')}</p>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
render() {
|
|
37
|
+
return (
|
|
38
|
+
<div>
|
|
39
|
+
{this.renderComment()}
|
|
40
|
+
{this.props.bottomContent}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Comment };
|