umwd-components 0.1.97 → 0.1.99
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/dist/cjs/node_modules/@strapi/blocks-react-renderer/dist/Block.js +63 -0
- package/dist/cjs/node_modules/@strapi/blocks-react-renderer/dist/BlocksRenderer.js +109 -0
- package/dist/cjs/node_modules/@strapi/blocks-react-renderer/dist/Text.js +37 -0
- package/dist/cjs/src/components/BlockRendererClient.js +94 -0
- package/dist/cjs/src/components/BulletList.js +43 -0
- package/dist/cjs/src/components/Button.js +45 -0
- package/dist/cjs/src/components/ColumnsSection.js +69 -0
- package/dist/cjs/src/components/ContactForm.js +223 -0
- package/dist/cjs/src/components/FeaturesSection.js +100 -0
- package/dist/cjs/src/components/FleetSection.js +153 -0
- package/dist/cjs/src/components/Footer.js +211 -0
- package/dist/cjs/src/components/HeroSection.js +100 -0
- package/dist/cjs/src/components/IconSection.js +67 -0
- package/dist/cjs/src/components/MuiLink.js +23 -0
- package/dist/cjs/src/components/NavBar.js +307 -0
- package/dist/cjs/src/components/Page.js +88 -0
- package/dist/cjs/src/components/PersonaliaSection.js +96 -0
- package/dist/cjs/src/components/Stack.js +37 -0
- package/dist/cjs/src/components/StrapiImage.js +33 -0
- package/dist/cjs/src/components/TextImageSection.js +94 -0
- package/dist/cjs/src/components/WebsitePlaceholder.js +129 -0
- package/dist/cjs/src/components/WhatsAppClickToChatButton.js +78 -0
- package/dist/cjs/src/index.js +33 -0
- package/dist/cjs/src/lib/AmbulanceIcon.js +45 -0
- package/dist/cjs/src/lib/getIcon.js +97 -0
- package/dist/cjs/src/lib/utils.js +57 -0
- package/dist/esm/node_modules/@strapi/blocks-react-renderer/dist/Block.js +61 -0
- package/dist/esm/node_modules/@strapi/blocks-react-renderer/dist/BlocksRenderer.js +86 -0
- package/dist/esm/node_modules/@strapi/blocks-react-renderer/dist/Text.js +35 -0
- package/dist/esm/src/components/BlockRendererClient.js +90 -0
- package/dist/esm/src/components/BulletList.js +39 -0
- package/dist/esm/src/components/Button.js +41 -0
- package/dist/esm/src/components/ColumnsSection.js +67 -0
- package/dist/esm/src/components/ContactForm.js +219 -0
- package/dist/esm/src/components/FeaturesSection.js +98 -0
- package/dist/esm/src/components/FleetSection.js +151 -0
- package/dist/esm/src/components/Footer.js +207 -0
- package/dist/esm/src/components/HeroSection.js +98 -0
- package/dist/esm/src/components/IconSection.js +65 -0
- package/dist/esm/src/components/MuiLink.js +21 -0
- package/dist/esm/src/components/NavBar.js +303 -0
- package/dist/esm/src/components/Page.js +84 -0
- package/dist/esm/src/components/PersonaliaSection.js +94 -0
- package/dist/esm/src/components/Stack.js +33 -0
- package/dist/esm/src/components/StrapiImage.js +31 -0
- package/dist/esm/src/components/TextImageSection.js +90 -0
- package/dist/esm/src/components/WebsitePlaceholder.js +125 -0
- package/dist/esm/src/components/WhatsAppClickToChatButton.js +74 -0
- package/dist/esm/src/index.js +17 -0
- package/dist/esm/src/lib/AmbulanceIcon.js +22 -0
- package/dist/esm/src/lib/getIcon.js +93 -0
- package/dist/esm/src/lib/utils.js +53 -0
- package/package.json +2 -1
- package/src/components/BlockRendererClient.tsx +52 -0
- package/src/components/MuiLink.tsx +16 -0
- package/src/components/PersonaliaSection.tsx +52 -37
- package/src/index.js +1 -5
- package/src/stories/Page.stories.js +32 -33
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* UMWD-Components
|
|
3
|
+
* @copyright Jelle Paulus
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
var React = require('react');
|
|
11
|
+
var BlocksRenderer = require('./BlocksRenderer.js');
|
|
12
|
+
var Text = require('./Text.js');
|
|
13
|
+
|
|
14
|
+
const voidTypes = ["image"];
|
|
15
|
+
const augmentProps = (content) => {
|
|
16
|
+
const { children: childrenNodes, type, ...props } = content;
|
|
17
|
+
if (type === "code") {
|
|
18
|
+
const getPlainText = (children) => {
|
|
19
|
+
return children.reduce((currentPlainText, node) => {
|
|
20
|
+
if (node.type === "text") {
|
|
21
|
+
return currentPlainText.concat(node.text);
|
|
22
|
+
}
|
|
23
|
+
if (node.type === "link") {
|
|
24
|
+
return currentPlainText.concat(getPlainText(node.children));
|
|
25
|
+
}
|
|
26
|
+
return currentPlainText;
|
|
27
|
+
}, "");
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
...props,
|
|
31
|
+
plainText: getPlainText(content.children)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return props;
|
|
35
|
+
};
|
|
36
|
+
const Block = ({ content }) => {
|
|
37
|
+
const { children: childrenNodes, type, ...props } = content;
|
|
38
|
+
const { blocks, missingBlockTypes } = BlocksRenderer.useComponentsContext();
|
|
39
|
+
const BlockComponent = blocks[type];
|
|
40
|
+
if (!BlockComponent) {
|
|
41
|
+
if (!missingBlockTypes.includes(type)) {
|
|
42
|
+
console.warn(`[@strapi/block-react-renderer] No component found for block type "${type}"`);
|
|
43
|
+
missingBlockTypes.push(type);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
if (voidTypes.includes(type)) {
|
|
48
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlockComponent, { ...props });
|
|
49
|
+
}
|
|
50
|
+
if (type === "paragraph" && childrenNodes.length === 1 && childrenNodes[0].type === "text" && childrenNodes[0].text === "") {
|
|
51
|
+
return /* @__PURE__ */ jsxRuntime.jsx("br", {});
|
|
52
|
+
}
|
|
53
|
+
const augmentedProps = augmentProps(content);
|
|
54
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlockComponent, { ...augmentedProps, children: childrenNodes.map((childNode, index) => {
|
|
55
|
+
if (childNode.type === "text") {
|
|
56
|
+
const { type: _type, ...childNodeProps } = childNode;
|
|
57
|
+
return /* @__PURE__ */ React.createElement(Text.Text, { ...childNodeProps, key: index });
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Block, { content: childNode }, index);
|
|
60
|
+
}) });
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.Block = Block;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var Block = require('./Block.js');
|
|
13
|
+
|
|
14
|
+
function _interopNamespaceDefault(e) {
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
32
|
+
|
|
33
|
+
const defaultComponents = {
|
|
34
|
+
blocks: {
|
|
35
|
+
paragraph: (props) => /* @__PURE__ */ jsxRuntime.jsx("p", { children: props.children }),
|
|
36
|
+
quote: (props) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { children: props.children }),
|
|
37
|
+
code: (props) => /* @__PURE__ */ jsxRuntime.jsx("pre", { children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: props.plainText }) }),
|
|
38
|
+
heading: ({ level, children }) => {
|
|
39
|
+
switch (level) {
|
|
40
|
+
case 1:
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h1", { children });
|
|
42
|
+
case 2:
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h2", { children });
|
|
44
|
+
case 3:
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h3", { children });
|
|
46
|
+
case 4:
|
|
47
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h4", { children });
|
|
48
|
+
case 5:
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h5", { children });
|
|
50
|
+
case 6:
|
|
51
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h6", { children });
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
link: (props) => /* @__PURE__ */ jsxRuntime.jsx("a", { href: props.url, children: props.children }),
|
|
55
|
+
list: (props) => {
|
|
56
|
+
if (props.format === "ordered") {
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children: props.children });
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { children: props.children });
|
|
60
|
+
},
|
|
61
|
+
"list-item": (props) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: props.children }),
|
|
62
|
+
image: (props) => /* @__PURE__ */ jsxRuntime.jsx("img", { src: props.image.url, alt: props.image.alternativeText || void 0 })
|
|
63
|
+
},
|
|
64
|
+
modifiers: {
|
|
65
|
+
bold: (props) => /* @__PURE__ */ jsxRuntime.jsx("strong", { children: props.children }),
|
|
66
|
+
italic: (props) => /* @__PURE__ */ jsxRuntime.jsx("em", { children: props.children }),
|
|
67
|
+
underline: (props) => /* @__PURE__ */ jsxRuntime.jsx("u", { children: props.children }),
|
|
68
|
+
strikethrough: (props) => /* @__PURE__ */ jsxRuntime.jsx("del", { children: props.children }),
|
|
69
|
+
code: (props) => /* @__PURE__ */ jsxRuntime.jsx("code", { children: props.children })
|
|
70
|
+
},
|
|
71
|
+
missingBlockTypes: [],
|
|
72
|
+
missingModifierTypes: []
|
|
73
|
+
};
|
|
74
|
+
const ComponentsContext = React__namespace.createContext(defaultComponents);
|
|
75
|
+
const ComponentsProvider = ({ children, value = defaultComponents }) => {
|
|
76
|
+
const memoizedValue = React__namespace.useMemo(() => value, [value]);
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ComponentsContext.Provider, { value: memoizedValue, children });
|
|
78
|
+
};
|
|
79
|
+
function useComponentsContext() {
|
|
80
|
+
return React__namespace.useContext(ComponentsContext);
|
|
81
|
+
}
|
|
82
|
+
const BlocksRenderer = (props) => {
|
|
83
|
+
const blocks = {
|
|
84
|
+
...defaultComponents.blocks,
|
|
85
|
+
...props.blocks
|
|
86
|
+
};
|
|
87
|
+
const modifiers = {
|
|
88
|
+
...defaultComponents.modifiers,
|
|
89
|
+
...props.modifiers
|
|
90
|
+
};
|
|
91
|
+
const missingBlockTypes = React__namespace.useRef([]);
|
|
92
|
+
const missingModifierTypes = React__namespace.useRef([]);
|
|
93
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
+
ComponentsProvider,
|
|
95
|
+
{
|
|
96
|
+
value: {
|
|
97
|
+
blocks,
|
|
98
|
+
modifiers,
|
|
99
|
+
missingBlockTypes: missingBlockTypes.current,
|
|
100
|
+
missingModifierTypes: missingModifierTypes.current
|
|
101
|
+
},
|
|
102
|
+
children: props.content.map((content, index) => /* @__PURE__ */ jsxRuntime.jsx(Block.Block, { content }, index))
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
exports.BlocksRenderer = BlocksRenderer;
|
|
108
|
+
exports.ComponentsProvider = ComponentsProvider;
|
|
109
|
+
exports.useComponentsContext = useComponentsContext;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* UMWD-Components
|
|
3
|
+
* @copyright Jelle Paulus
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
var BlocksRenderer = require('./BlocksRenderer.js');
|
|
11
|
+
|
|
12
|
+
const Text = ({ text, ...modifiers }) => {
|
|
13
|
+
const { modifiers: modifierComponents, missingModifierTypes } = BlocksRenderer.useComponentsContext();
|
|
14
|
+
const modifierNames = Object.keys(modifiers);
|
|
15
|
+
return modifierNames.reduce(
|
|
16
|
+
(children, modifierName) => {
|
|
17
|
+
if (!modifiers[modifierName]) {
|
|
18
|
+
return children;
|
|
19
|
+
}
|
|
20
|
+
const ModifierComponent = modifierComponents[modifierName];
|
|
21
|
+
if (!ModifierComponent) {
|
|
22
|
+
if (!missingModifierTypes.includes(modifierName)) {
|
|
23
|
+
console.warn(
|
|
24
|
+
`[@strapi/block-react-renderer] No component found for modifier "${modifierName}"`
|
|
25
|
+
);
|
|
26
|
+
missingModifierTypes.push(modifierName);
|
|
27
|
+
}
|
|
28
|
+
return children;
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ModifierComponent, { children });
|
|
31
|
+
},
|
|
32
|
+
// By default, return the text without any wrapper to avoid useless nesting
|
|
33
|
+
/* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: text })
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.Text = Text;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var BlocksRenderer = require('../../node_modules/@strapi/blocks-react-renderer/dist/BlocksRenderer.js');
|
|
13
|
+
var material = require('@mui/material');
|
|
14
|
+
|
|
15
|
+
function BlockRendererClient(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
content
|
|
18
|
+
} = _ref;
|
|
19
|
+
if (!content) return null;
|
|
20
|
+
return /*#__PURE__*/React.createElement(BlocksRenderer.BlocksRenderer, {
|
|
21
|
+
content: content,
|
|
22
|
+
blocks: {
|
|
23
|
+
// You can use the default components to set class names...
|
|
24
|
+
paragraph: _ref2 => {
|
|
25
|
+
let {
|
|
26
|
+
children
|
|
27
|
+
} = _ref2;
|
|
28
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
29
|
+
variant: "body1",
|
|
30
|
+
sx: {
|
|
31
|
+
mb: 2
|
|
32
|
+
}
|
|
33
|
+
}, children);
|
|
34
|
+
},
|
|
35
|
+
// ...or point to a design system
|
|
36
|
+
heading: _ref3 => {
|
|
37
|
+
let {
|
|
38
|
+
children,
|
|
39
|
+
level
|
|
40
|
+
} = _ref3;
|
|
41
|
+
switch (level) {
|
|
42
|
+
case 1:
|
|
43
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
44
|
+
variant: "h1"
|
|
45
|
+
}, children);
|
|
46
|
+
case 2:
|
|
47
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
48
|
+
variant: "h2"
|
|
49
|
+
}, children);
|
|
50
|
+
case 3:
|
|
51
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
52
|
+
variant: "h3"
|
|
53
|
+
}, children);
|
|
54
|
+
case 4:
|
|
55
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
56
|
+
variant: "h4"
|
|
57
|
+
}, children);
|
|
58
|
+
case 5:
|
|
59
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
60
|
+
variant: "h5"
|
|
61
|
+
}, children);
|
|
62
|
+
case 6:
|
|
63
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
64
|
+
variant: "h6"
|
|
65
|
+
}, children);
|
|
66
|
+
default:
|
|
67
|
+
return /*#__PURE__*/React.createElement(material.Typography, {
|
|
68
|
+
variant: "h1"
|
|
69
|
+
}, children);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// For links, you may want to use the component from your router or framework
|
|
73
|
+
// link: ({ children, url }) => <Link to={url}>{children}</Link>,
|
|
74
|
+
},
|
|
75
|
+
modifiers: {
|
|
76
|
+
bold: _ref4 => {
|
|
77
|
+
let {
|
|
78
|
+
children
|
|
79
|
+
} = _ref4;
|
|
80
|
+
return /*#__PURE__*/React.createElement("strong", null, children);
|
|
81
|
+
},
|
|
82
|
+
italic: _ref5 => {
|
|
83
|
+
let {
|
|
84
|
+
children
|
|
85
|
+
} = _ref5;
|
|
86
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
87
|
+
className: "italic"
|
|
88
|
+
}, children);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.default = BlockRendererClient;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var material = require('@mui/material');
|
|
15
|
+
var FiberManualRecordIcon = require('@mui/icons-material/FiberManualRecord');
|
|
16
|
+
|
|
17
|
+
function BulletList(_ref) {
|
|
18
|
+
let {
|
|
19
|
+
bullets,
|
|
20
|
+
bulletSVG
|
|
21
|
+
} = _ref;
|
|
22
|
+
console.log("bulletSVG2", bulletSVG);
|
|
23
|
+
return /*#__PURE__*/React.createElement(material.Stack, {
|
|
24
|
+
spacing: 2
|
|
25
|
+
}, bullets.map((bullet, index) => /*#__PURE__*/React.createElement(material.Typography, {
|
|
26
|
+
key: index,
|
|
27
|
+
sx: {
|
|
28
|
+
verticalAlign: "center",
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
justifyContent: "flex-start",
|
|
31
|
+
display: "inline-flex"
|
|
32
|
+
}
|
|
33
|
+
}, bulletSVG ? /*#__PURE__*/React.createElement(material.SvgIcon, {
|
|
34
|
+
sx: {
|
|
35
|
+
mr: 1
|
|
36
|
+
}
|
|
37
|
+
}, bulletSVG) : /*#__PURE__*/React.createElement(FiberManualRecordIcon, null), bullet)));
|
|
38
|
+
}
|
|
39
|
+
BulletList.propTypes = {
|
|
40
|
+
bullets: PropTypes.arrayOf(PropTypes.string).isRequired
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.default = BulletList;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* UMWD-Components
|
|
3
|
+
* @copyright Jelle Paulus
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
+
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var PropTypes = require('prop-types');
|
|
13
|
+
|
|
14
|
+
function Button(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
label,
|
|
17
|
+
backgroundColor = "red",
|
|
18
|
+
size = "md",
|
|
19
|
+
onClick
|
|
20
|
+
} = _ref;
|
|
21
|
+
let scale = 1;
|
|
22
|
+
if (size === "sm") {
|
|
23
|
+
scale = 0.75;
|
|
24
|
+
}
|
|
25
|
+
if (size === "lg") {
|
|
26
|
+
scale = 1.25;
|
|
27
|
+
}
|
|
28
|
+
const style = {
|
|
29
|
+
backgroundColor,
|
|
30
|
+
padding: "".concat(0.5 * scale, "rem ").concat(1 * scale, "rem"),
|
|
31
|
+
border: "none"
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
34
|
+
style: style,
|
|
35
|
+
onClick: onClick
|
|
36
|
+
}, label);
|
|
37
|
+
}
|
|
38
|
+
Button.propTypes = {
|
|
39
|
+
label: PropTypes.string,
|
|
40
|
+
backgroundColor: PropTypes.string,
|
|
41
|
+
size: PropTypes.oneOf(["sm", "md", "lg"]),
|
|
42
|
+
onClick: PropTypes.func
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.default = Button;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* UMWD-Components
|
|
3
|
+
* @copyright Jelle Paulus
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var material = require('@mui/material');
|
|
11
|
+
var getIcon = require('../lib/getIcon.js');
|
|
12
|
+
|
|
13
|
+
function ColumnsSection(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
data
|
|
16
|
+
} = _ref;
|
|
17
|
+
const {
|
|
18
|
+
column,
|
|
19
|
+
maxWidth
|
|
20
|
+
} = data;
|
|
21
|
+
|
|
22
|
+
// TODO make suitable for multiple column layouts
|
|
23
|
+
|
|
24
|
+
return /*#__PURE__*/React.createElement(material.Container, {
|
|
25
|
+
maxWidth: maxWidth || "lg",
|
|
26
|
+
sx: {
|
|
27
|
+
my: 1
|
|
28
|
+
}
|
|
29
|
+
}, /*#__PURE__*/React.createElement(material.Grid, {
|
|
30
|
+
container: true,
|
|
31
|
+
spacing: 2
|
|
32
|
+
}, column.map(column => {
|
|
33
|
+
const Icon = getIcon.default(column.icon);
|
|
34
|
+
return /*#__PURE__*/React.createElement(material.Grid, {
|
|
35
|
+
item: true,
|
|
36
|
+
xs: 12,
|
|
37
|
+
md: 6,
|
|
38
|
+
key: column.id
|
|
39
|
+
}, /*#__PURE__*/React.createElement(material.Paper, {
|
|
40
|
+
sx: {
|
|
41
|
+
p: 2,
|
|
42
|
+
height: "100%"
|
|
43
|
+
}
|
|
44
|
+
}, /*#__PURE__*/React.createElement(material.Typography, {
|
|
45
|
+
variant: "h5",
|
|
46
|
+
sx: {
|
|
47
|
+
mb: 2,
|
|
48
|
+
display: "flex",
|
|
49
|
+
justifyContent: "flex-start",
|
|
50
|
+
alignItems: "center"
|
|
51
|
+
}
|
|
52
|
+
}, Icon !== null && /*#__PURE__*/React.createElement(Icon, {
|
|
53
|
+
sx: {
|
|
54
|
+
mr: 2,
|
|
55
|
+
mt: 0.2,
|
|
56
|
+
width: "50px",
|
|
57
|
+
height: "50px",
|
|
58
|
+
fill: "currentColor",
|
|
59
|
+
stroke: "none"
|
|
60
|
+
}
|
|
61
|
+
}), column.heading), /*#__PURE__*/React.createElement(material.Typography, {
|
|
62
|
+
variant: "body2",
|
|
63
|
+
color: "text.secondary",
|
|
64
|
+
component: "div"
|
|
65
|
+
}, column.text)));
|
|
66
|
+
})));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
exports.ColumnsSection = ColumnsSection;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/*
|
|
3
|
+
* UMWD-Components
|
|
4
|
+
* @copyright Jelle Paulus
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var material = require('@mui/material');
|
|
14
|
+
var isEmail = require('validator/lib/isEmail');
|
|
15
|
+
|
|
16
|
+
function ContactForm(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
data
|
|
19
|
+
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
maxWidth
|
|
22
|
+
} = data;
|
|
23
|
+
const [formValues, setFormValues] = React.useState({
|
|
24
|
+
name: "",
|
|
25
|
+
email: "",
|
|
26
|
+
subject: "",
|
|
27
|
+
message: ""
|
|
28
|
+
});
|
|
29
|
+
const [formErrors, setFormErrors] = React.useState({});
|
|
30
|
+
|
|
31
|
+
// Setting button text on form submission
|
|
32
|
+
React.useState("Send");
|
|
33
|
+
|
|
34
|
+
// Setting success or failure messages states
|
|
35
|
+
const [showSuccessMessage, setShowSuccessMessage] = React.useState(false);
|
|
36
|
+
const [showFailureMessage, setShowFailureMessage] = React.useState(false);
|
|
37
|
+
const handleChange = e => {
|
|
38
|
+
const {
|
|
39
|
+
name,
|
|
40
|
+
value
|
|
41
|
+
} = e.target;
|
|
42
|
+
setFormValues({
|
|
43
|
+
...formValues,
|
|
44
|
+
[name]: value
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const handleBlur = e => {
|
|
48
|
+
const {
|
|
49
|
+
name
|
|
50
|
+
} = e.target;
|
|
51
|
+
const errors = validate(formValues);
|
|
52
|
+
if (errors[name]) {
|
|
53
|
+
setFormErrors(prevErrors => ({
|
|
54
|
+
...prevErrors,
|
|
55
|
+
[name]: errors[name]
|
|
56
|
+
}));
|
|
57
|
+
} else {
|
|
58
|
+
setFormErrors(prevErrors => {
|
|
59
|
+
const updatedErrors = {
|
|
60
|
+
...prevErrors
|
|
61
|
+
};
|
|
62
|
+
delete updatedErrors[name];
|
|
63
|
+
return updatedErrors;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handleClear = () => {
|
|
68
|
+
setFormValues({
|
|
69
|
+
name: "",
|
|
70
|
+
email: "",
|
|
71
|
+
subject: "",
|
|
72
|
+
message: ""
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/* const handleSendCallback = () => {
|
|
77
|
+
console.log("Send callback");
|
|
78
|
+
}; */
|
|
79
|
+
|
|
80
|
+
const handleSubmit = async e => {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
let isValidForm = validate(formValues);
|
|
83
|
+
console.log("isValidForm", isValidForm);
|
|
84
|
+
if (Object.keys(isValidForm).length === 0) {
|
|
85
|
+
const res = await fetch("/api/sendgrid", {
|
|
86
|
+
body: JSON.stringify({
|
|
87
|
+
email: formValues.email,
|
|
88
|
+
fullname: formValues.name,
|
|
89
|
+
subject: formValues.subject,
|
|
90
|
+
message: formValues.message
|
|
91
|
+
}),
|
|
92
|
+
headers: {
|
|
93
|
+
"Content-Type": "application/json"
|
|
94
|
+
},
|
|
95
|
+
method: "POST"
|
|
96
|
+
});
|
|
97
|
+
const {
|
|
98
|
+
error
|
|
99
|
+
} = await res.json();
|
|
100
|
+
if (error) {
|
|
101
|
+
setShowFailureMessage(true);
|
|
102
|
+
console.log(error);
|
|
103
|
+
return;
|
|
104
|
+
} else {
|
|
105
|
+
setShowSuccessMessage(true);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const validate = values => {
|
|
110
|
+
console.log("values from validate", values);
|
|
111
|
+
let errors = {};
|
|
112
|
+
if (values.name === "") {
|
|
113
|
+
errors.name = "Name is required";
|
|
114
|
+
}
|
|
115
|
+
if (values.email === "") {
|
|
116
|
+
errors.email = "Email is required";
|
|
117
|
+
} else if (!isEmail(values.email)) {
|
|
118
|
+
errors.email = "Invalid email";
|
|
119
|
+
}
|
|
120
|
+
if (values.subject === "") {
|
|
121
|
+
errors.subject = "Subject is required";
|
|
122
|
+
}
|
|
123
|
+
if (values.message === "") {
|
|
124
|
+
errors.message = "Message is required";
|
|
125
|
+
}
|
|
126
|
+
console.log("errors from validate", errors);
|
|
127
|
+
return errors;
|
|
128
|
+
};
|
|
129
|
+
return /*#__PURE__*/React.createElement(material.Container, {
|
|
130
|
+
maxWidth: maxWidth ? maxWidth : "lg",
|
|
131
|
+
sx: {
|
|
132
|
+
my: 1
|
|
133
|
+
}
|
|
134
|
+
}, /*#__PURE__*/React.createElement(material.Stack, {
|
|
135
|
+
spacing: 2,
|
|
136
|
+
sx: {
|
|
137
|
+
width: "100%"
|
|
138
|
+
}
|
|
139
|
+
}, /*#__PURE__*/React.createElement(material.Typography, {
|
|
140
|
+
variant: "h6",
|
|
141
|
+
align: "center"
|
|
142
|
+
}, "Write us"), /*#__PURE__*/React.createElement(material.Typography, {
|
|
143
|
+
variant: "body1",
|
|
144
|
+
align: "center"
|
|
145
|
+
}, "We're open for any suggestion or just to have a chat"), showSuccessMessage && /*#__PURE__*/React.createElement(material.Paper, {
|
|
146
|
+
sx: {
|
|
147
|
+
p: 2
|
|
148
|
+
}
|
|
149
|
+
}, /*#__PURE__*/React.createElement(material.Stack, {
|
|
150
|
+
spacing: 2
|
|
151
|
+
}, /*#__PURE__*/React.createElement(material.Typography, {
|
|
152
|
+
variant: "h6"
|
|
153
|
+
}, "Thank you!"), /*#__PURE__*/React.createElement(material.Typography, null, "Your e-mail has been successfully sent!"))), showFailureMessage && /*#__PURE__*/React.createElement(material.Paper, {
|
|
154
|
+
sx: {
|
|
155
|
+
p: 2
|
|
156
|
+
}
|
|
157
|
+
}, /*#__PURE__*/React.createElement(material.Stack, {
|
|
158
|
+
spacing: 2
|
|
159
|
+
}, /*#__PURE__*/React.createElement(material.Typography, null, "I am sorry, something went wrong, you could email me directly on info@jellepaulus.nl"), /*#__PURE__*/React.createElement(material.Button, {
|
|
160
|
+
variant: "contained"
|
|
161
|
+
}, "try again")))), !showSuccessMessage && !showFailureMessage && /*#__PURE__*/React.createElement(material.Paper, {
|
|
162
|
+
sx: {
|
|
163
|
+
p: 2
|
|
164
|
+
}
|
|
165
|
+
}, /*#__PURE__*/React.createElement(material.Stack, {
|
|
166
|
+
spacing: 2
|
|
167
|
+
}, /*#__PURE__*/React.createElement(material.TextField, {
|
|
168
|
+
id: "name",
|
|
169
|
+
name: "name",
|
|
170
|
+
label: "Name",
|
|
171
|
+
value: formValues.name,
|
|
172
|
+
variant: "outlined",
|
|
173
|
+
onBlur: handleBlur,
|
|
174
|
+
onChange: handleChange,
|
|
175
|
+
error: formErrors.name != undefined ? true : false,
|
|
176
|
+
helperText: formErrors.name
|
|
177
|
+
}), /*#__PURE__*/React.createElement(material.TextField, {
|
|
178
|
+
id: "email",
|
|
179
|
+
name: "email",
|
|
180
|
+
label: "Email",
|
|
181
|
+
value: formValues.email,
|
|
182
|
+
variant: "outlined",
|
|
183
|
+
onBlur: handleBlur,
|
|
184
|
+
onChange: handleChange,
|
|
185
|
+
error: formErrors.email != undefined ? true : false,
|
|
186
|
+
helperText: formErrors.email
|
|
187
|
+
}), /*#__PURE__*/React.createElement(material.TextField, {
|
|
188
|
+
id: "subject",
|
|
189
|
+
name: "subject",
|
|
190
|
+
label: "Subject",
|
|
191
|
+
value: formValues.subject,
|
|
192
|
+
variant: "outlined",
|
|
193
|
+
onBlur: handleBlur,
|
|
194
|
+
onChange: handleChange,
|
|
195
|
+
error: formErrors.subject != undefined,
|
|
196
|
+
helperText: formErrors.subject
|
|
197
|
+
}), /*#__PURE__*/React.createElement(material.TextField, {
|
|
198
|
+
id: "message",
|
|
199
|
+
name: "message",
|
|
200
|
+
label: "Message",
|
|
201
|
+
value: formValues.message,
|
|
202
|
+
variant: "outlined",
|
|
203
|
+
multiline: true,
|
|
204
|
+
minRows: 5,
|
|
205
|
+
onBlur: handleBlur,
|
|
206
|
+
onChange: handleChange,
|
|
207
|
+
error: formErrors.message != undefined,
|
|
208
|
+
helperText: formErrors.message
|
|
209
|
+
}), /*#__PURE__*/React.createElement(material.Stack, {
|
|
210
|
+
direction: "row",
|
|
211
|
+
spacing: 2,
|
|
212
|
+
justifyContent: "end"
|
|
213
|
+
}, /*#__PURE__*/React.createElement(material.Button, {
|
|
214
|
+
variant: "outlined",
|
|
215
|
+
color: "primary",
|
|
216
|
+
onClick: handleClear
|
|
217
|
+
}, "Clear"), /*#__PURE__*/React.createElement(material.Button, {
|
|
218
|
+
variant: "contained",
|
|
219
|
+
onClick: handleSubmit
|
|
220
|
+
}, "Send")))));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
exports.default = ContactForm;
|