umwd-components 0.1.95 → 0.1.97

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.
@@ -10,6 +10,7 @@ var React = require('react');
10
10
  var Link = require('next/link');
11
11
  var material = require('@mui/material');
12
12
  var StrapiImage = require('./StrapiImage.js');
13
+ var utils = require('../lib/utils.js');
13
14
 
14
15
  function HeroSection(_ref) {
15
16
  let {
@@ -20,8 +21,12 @@ function HeroSection(_ref) {
20
21
  subHeading,
21
22
  bgImage,
22
23
  logoImage,
23
- link
24
+ link,
25
+ maxWidth
24
26
  } = data;
27
+ const theme = material.useTheme();
28
+ console.log(theme.palette.background.paper);
29
+ const glassColor = utils.setOpacity(theme.palette.background.paper, 0.45);
25
30
  return /*#__PURE__*/React.createElement("header", {
26
31
  style: {
27
32
  position: "relative",
@@ -36,7 +41,8 @@ function HeroSection(_ref) {
36
41
  justifyContent: "center",
37
42
  width: "100%",
38
43
  overflow: "hidden",
39
- minHeight: "600px"
44
+ minHeight: "600px",
45
+ py: 6
40
46
  }
41
47
  }, bgImage && /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
42
48
  alt: "Background",
@@ -50,26 +56,36 @@ function HeroSection(_ref) {
50
56
  height: bgImage.height || 1080,
51
57
  src: bgImage.url,
52
58
  width: bgImage.width || 1920
53
- }), /*#__PURE__*/React.createElement(material.Stack, {
54
- spacing: 2,
55
- alignItems: "center",
56
- justifyContent: "center",
59
+ }), /*#__PURE__*/React.createElement(material.Container, {
60
+ maxWidth: maxWidth || "lg",
57
61
  sx: {
58
- width: "max-content",
59
- maxWidth: "600px",
62
+ my: 1,
60
63
  zIndex: 1
61
64
  }
65
+ }, /*#__PURE__*/React.createElement(material.Paper, {
66
+ sx: {
67
+ px: 2,
68
+ py: 7,
69
+ backdropFilter: "blur(4px)",
70
+ backgroundColor: glassColor
71
+ }
72
+ }, /*#__PURE__*/React.createElement(material.Stack, {
73
+ spacing: 5,
74
+ alignItems: "center",
75
+ justifyContent: "center"
62
76
  }, logoImage && /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
63
77
  alt: logoImage.alternativeText,
64
78
  height: logoImage.height || 100,
65
79
  src: logoImage.url,
66
80
  width: logoImage.width || 100
67
81
  }), /*#__PURE__*/React.createElement(material.Typography, {
68
- variant: "h1",
69
- align: "center"
82
+ variant: "h2",
83
+ align: "center",
84
+ component: "h1"
70
85
  }, heading), /*#__PURE__*/React.createElement(material.Typography, {
71
- variant: "body1",
72
- align: "center"
86
+ variant: "h4",
87
+ align: "center",
88
+ component: "h2"
73
89
  }, subHeading), /*#__PURE__*/React.createElement(Link, {
74
90
  href: link.url
75
91
  }, /*#__PURE__*/React.createElement(material.Button, {
@@ -78,7 +94,7 @@ function HeroSection(_ref) {
78
94
  width: "100%",
79
95
  fontSize: "1.5rem"
80
96
  }
81
- }, link.text)))));
97
+ }, link.text)))))));
82
98
  }
83
99
 
84
100
  exports.HeroSection = HeroSection;
@@ -23,6 +23,35 @@ function getStrapiMedia(url) {
23
23
  if (url.startsWith("http") || url.startsWith("//")) return url;
24
24
  return "".concat(getStrapiURL()).concat(url);
25
25
  }
26
+ function setOpacity(color, opacity) {
27
+ // Clamp opacity between 0 and 1
28
+ opacity = Math.min(Math.max(opacity, 0), 1);
29
+
30
+ // Regex to match various color formats (hex, rgb, rgba)
31
+ const match = color.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i);
32
+ if (match) {
33
+ // Hex color
34
+ const [, r, g, b, alpha = "FF"] = match;
35
+ return "rgba(".concat(parseInt(r, 16), ", ").concat(parseInt(g, 16), ", ").concat(parseInt(b, 16), ", ").concat(parseInt(alpha, 16) / 255 * opacity, ")");
36
+ } else {
37
+ // Parse RGB or RGBA manually
38
+ const rgbMatch = color.match(/^rgb\((\d+)(?:,(\d+))?(?:,(\d+))?\)$/i);
39
+ const rgbaMatch = color.match(/^rgba\((\d+)(?:,(\d+))?(?:,(\d+))?(?:,([.\d]+))?\)$/i);
40
+ if (rgbMatch) {
41
+ // RGB format
42
+ const [, red, green, blue] = rgbMatch;
43
+ return "rgba(".concat(red, ", ").concat(green, ", ").concat(blue, ", ").concat(opacity, ")");
44
+ } else if (rgbaMatch) {
45
+ // RGBA format
46
+ const [, red, green, blue, alpha] = rgbaMatch;
47
+ return "rgba(".concat(red, ", ").concat(green, ", ").concat(blue, ", ").concat(alpha || opacity, ")"); // Use provided opacity if alpha is missing
48
+ }
49
+ }
50
+
51
+ // If parsing fails, return original color
52
+ return color;
53
+ }
26
54
 
27
55
  exports.getStrapiMedia = getStrapiMedia;
28
56
  exports.getStrapiURL = getStrapiURL;
57
+ exports.setOpacity = setOpacity;
@@ -6,8 +6,9 @@
6
6
 
7
7
  import React__default from 'react';
8
8
  import Link from 'next/link';
9
- import { Box, Stack, Typography, Button } from '@mui/material';
9
+ import { useTheme, Box, Container, Paper, Stack, Typography, Button } from '@mui/material';
10
10
  import { StrapiImage } from './StrapiImage.js';
11
+ import { setOpacity } from '../lib/utils.js';
11
12
 
12
13
  function HeroSection(_ref) {
13
14
  let {
@@ -18,8 +19,12 @@ function HeroSection(_ref) {
18
19
  subHeading,
19
20
  bgImage,
20
21
  logoImage,
21
- link
22
+ link,
23
+ maxWidth
22
24
  } = data;
25
+ const theme = useTheme();
26
+ console.log(theme.palette.background.paper);
27
+ const glassColor = setOpacity(theme.palette.background.paper, 0.45);
23
28
  return /*#__PURE__*/React__default.createElement("header", {
24
29
  style: {
25
30
  position: "relative",
@@ -34,7 +39,8 @@ function HeroSection(_ref) {
34
39
  justifyContent: "center",
35
40
  width: "100%",
36
41
  overflow: "hidden",
37
- minHeight: "600px"
42
+ minHeight: "600px",
43
+ py: 6
38
44
  }
39
45
  }, bgImage && /*#__PURE__*/React__default.createElement(StrapiImage, {
40
46
  alt: "Background",
@@ -48,26 +54,36 @@ function HeroSection(_ref) {
48
54
  height: bgImage.height || 1080,
49
55
  src: bgImage.url,
50
56
  width: bgImage.width || 1920
51
- }), /*#__PURE__*/React__default.createElement(Stack, {
52
- spacing: 2,
53
- alignItems: "center",
54
- justifyContent: "center",
57
+ }), /*#__PURE__*/React__default.createElement(Container, {
58
+ maxWidth: maxWidth || "lg",
55
59
  sx: {
56
- width: "max-content",
57
- maxWidth: "600px",
60
+ my: 1,
58
61
  zIndex: 1
59
62
  }
63
+ }, /*#__PURE__*/React__default.createElement(Paper, {
64
+ sx: {
65
+ px: 2,
66
+ py: 7,
67
+ backdropFilter: "blur(4px)",
68
+ backgroundColor: glassColor
69
+ }
70
+ }, /*#__PURE__*/React__default.createElement(Stack, {
71
+ spacing: 5,
72
+ alignItems: "center",
73
+ justifyContent: "center"
60
74
  }, logoImage && /*#__PURE__*/React__default.createElement(StrapiImage, {
61
75
  alt: logoImage.alternativeText,
62
76
  height: logoImage.height || 100,
63
77
  src: logoImage.url,
64
78
  width: logoImage.width || 100
65
79
  }), /*#__PURE__*/React__default.createElement(Typography, {
66
- variant: "h1",
67
- align: "center"
80
+ variant: "h2",
81
+ align: "center",
82
+ component: "h1"
68
83
  }, heading), /*#__PURE__*/React__default.createElement(Typography, {
69
- variant: "body1",
70
- align: "center"
84
+ variant: "h4",
85
+ align: "center",
86
+ component: "h2"
71
87
  }, subHeading), /*#__PURE__*/React__default.createElement(Link, {
72
88
  href: link.url
73
89
  }, /*#__PURE__*/React__default.createElement(Button, {
@@ -76,7 +92,7 @@ function HeroSection(_ref) {
76
92
  width: "100%",
77
93
  fontSize: "1.5rem"
78
94
  }
79
- }, link.text)))));
95
+ }, link.text)))))));
80
96
  }
81
97
 
82
98
  export { HeroSection };
@@ -21,5 +21,33 @@ function getStrapiMedia(url) {
21
21
  if (url.startsWith("http") || url.startsWith("//")) return url;
22
22
  return "".concat(getStrapiURL()).concat(url);
23
23
  }
24
+ function setOpacity(color, opacity) {
25
+ // Clamp opacity between 0 and 1
26
+ opacity = Math.min(Math.max(opacity, 0), 1);
24
27
 
25
- export { getStrapiMedia, getStrapiURL };
28
+ // Regex to match various color formats (hex, rgb, rgba)
29
+ const match = color.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i);
30
+ if (match) {
31
+ // Hex color
32
+ const [, r, g, b, alpha = "FF"] = match;
33
+ return "rgba(".concat(parseInt(r, 16), ", ").concat(parseInt(g, 16), ", ").concat(parseInt(b, 16), ", ").concat(parseInt(alpha, 16) / 255 * opacity, ")");
34
+ } else {
35
+ // Parse RGB or RGBA manually
36
+ const rgbMatch = color.match(/^rgb\((\d+)(?:,(\d+))?(?:,(\d+))?\)$/i);
37
+ const rgbaMatch = color.match(/^rgba\((\d+)(?:,(\d+))?(?:,(\d+))?(?:,([.\d]+))?\)$/i);
38
+ if (rgbMatch) {
39
+ // RGB format
40
+ const [, red, green, blue] = rgbMatch;
41
+ return "rgba(".concat(red, ", ").concat(green, ", ").concat(blue, ", ").concat(opacity, ")");
42
+ } else if (rgbaMatch) {
43
+ // RGBA format
44
+ const [, red, green, blue, alpha] = rgbaMatch;
45
+ return "rgba(".concat(red, ", ").concat(green, ", ").concat(blue, ", ").concat(alpha || opacity, ")"); // Use provided opacity if alpha is missing
46
+ }
47
+ }
48
+
49
+ // If parsing fails, return original color
50
+ return color;
51
+ }
52
+
53
+ export { getStrapiMedia, getStrapiURL, setOpacity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umwd-components",
3
- "version": "0.1.95",
3
+ "version": "0.1.97",
4
4
  "description": "UMWD Component library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,7 +1,16 @@
1
1
  import React from "react";
2
2
  import Link from "next/link";
3
- import { Box, Button, Stack, Typography } from "@mui/material";
3
+ import {
4
+ Box,
5
+ Button,
6
+ Stack,
7
+ Typography,
8
+ Container,
9
+ Paper,
10
+ useTheme,
11
+ } from "@mui/material";
4
12
  import { StrapiImage } from "./StrapiImage.tsx";
13
+ import { setOpacity } from "../lib/utils.ts";
5
14
 
6
15
  interface ImageProps {
7
16
  id: number;
@@ -27,11 +36,18 @@ interface HeroSectionProps {
27
36
  bgImage?: ImageProps;
28
37
  logoImage?: ImageProps;
29
38
  link: LinkProps;
39
+ maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | false | undefined;
30
40
  };
31
41
  }
32
42
 
33
43
  export function HeroSection({ data }: Readonly<HeroSectionProps>) {
34
- const { heading, subHeading, bgImage, logoImage, link } = data;
44
+ const { heading, subHeading, bgImage, logoImage, link, maxWidth } = data;
45
+
46
+ const theme = useTheme();
47
+
48
+ console.log(theme.palette.background.paper);
49
+
50
+ const glassColor = setOpacity(theme.palette.background.paper, 0.45);
35
51
 
36
52
  return (
37
53
  <header style={{ position: "relative", padding: 0, margin: 0 }}>
@@ -44,6 +60,7 @@ export function HeroSection({ data }: Readonly<HeroSectionProps>) {
44
60
  width: "100%",
45
61
  overflow: "hidden",
46
62
  minHeight: "600px",
63
+ py: 6,
47
64
  }}
48
65
  >
49
66
  {bgImage && (
@@ -61,35 +78,42 @@ export function HeroSection({ data }: Readonly<HeroSectionProps>) {
61
78
  width={bgImage.width || 1920}
62
79
  />
63
80
  )}
64
- <Stack
65
- spacing={2}
66
- alignItems="center"
67
- justifyContent="center"
68
- sx={{ width: "max-content", maxWidth: "600px", zIndex: 1 }}
69
- >
70
- {logoImage && (
71
- <StrapiImage
72
- alt={logoImage.alternativeText}
73
- height={logoImage.height || 100}
74
- src={logoImage.url}
75
- width={logoImage.width || 100}
76
- />
77
- )}
78
- <Typography variant="h1" align="center">
79
- {heading}
80
- </Typography>
81
- <Typography variant="body1" align="center">
82
- {subHeading}
83
- </Typography>
84
- <Link href={link.url}>
85
- <Button
86
- variant="contained"
87
- sx={{ width: "100%", fontSize: "1.5rem" }}
88
- >
89
- {link.text}
90
- </Button>
91
- </Link>
92
- </Stack>
81
+ <Container maxWidth={maxWidth || "lg"} sx={{ my: 1, zIndex: 1 }}>
82
+ <Paper
83
+ sx={{
84
+ px: 2,
85
+ py: 7,
86
+ backdropFilter: "blur(4px)",
87
+ backgroundColor: glassColor,
88
+ }}
89
+ >
90
+ <Stack spacing={5} alignItems="center" justifyContent="center">
91
+ {logoImage && (
92
+ <StrapiImage
93
+ alt={logoImage.alternativeText}
94
+ height={logoImage.height || 100}
95
+ src={logoImage.url}
96
+ width={logoImage.width || 100}
97
+ />
98
+ )}
99
+
100
+ <Typography variant="h2" align="center" component={"h1"}>
101
+ {heading}
102
+ </Typography>
103
+ <Typography variant="h4" align="center" component={"h2"}>
104
+ {subHeading}
105
+ </Typography>
106
+ <Link href={link.url}>
107
+ <Button
108
+ variant="contained"
109
+ sx={{ width: "100%", fontSize: "1.5rem" }}
110
+ >
111
+ {link.text}
112
+ </Button>
113
+ </Link>
114
+ </Stack>
115
+ </Paper>
116
+ </Container>
93
117
  </Box>
94
118
  </header>
95
119
  );
package/src/lib/utils.ts CHANGED
@@ -55,3 +55,38 @@ export function getStrapiMedia(url: string | null) {
55
55
  if (url.startsWith("http") || url.startsWith("//")) return url;
56
56
  return `${getStrapiURL()}${url}`;
57
57
  }
58
+
59
+ export function setOpacity(color: string, opacity: number): string {
60
+ // Clamp opacity between 0 and 1
61
+ opacity = Math.min(Math.max(opacity, 0), 1);
62
+
63
+ // Regex to match various color formats (hex, rgb, rgba)
64
+ const match = color.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i);
65
+
66
+ if (match) {
67
+ // Hex color
68
+ const [, r, g, b, alpha = "FF"] = match;
69
+ return `rgba(${parseInt(r, 16)}, ${parseInt(g, 16)}, ${parseInt(b, 16)}, ${
70
+ (parseInt(alpha, 16) / 255) * opacity
71
+ })`;
72
+ } else {
73
+ // Parse RGB or RGBA manually
74
+ const rgbMatch = color.match(/^rgb\((\d+)(?:,(\d+))?(?:,(\d+))?\)$/i);
75
+ const rgbaMatch = color.match(
76
+ /^rgba\((\d+)(?:,(\d+))?(?:,(\d+))?(?:,([.\d]+))?\)$/i
77
+ );
78
+
79
+ if (rgbMatch) {
80
+ // RGB format
81
+ const [, red, green, blue] = rgbMatch;
82
+ return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
83
+ } else if (rgbaMatch) {
84
+ // RGBA format
85
+ const [, red, green, blue, alpha] = rgbaMatch;
86
+ return `rgba(${red}, ${green}, ${blue}, ${alpha || opacity})`; // Use provided opacity if alpha is missing
87
+ }
88
+ }
89
+
90
+ // If parsing fails, return original color
91
+ return color;
92
+ }
@@ -56,9 +56,9 @@ AMH.args = {
56
56
  data: {
57
57
  id: 1,
58
58
  __component: "layout.hero-section",
59
- heading: null,
59
+ heading: "We offer world-wide, 24 / 7 patient transport by air ambulance. ",
60
60
  subHeading:
61
- "We offer world wide, around the clock patient transport by air ambulance. Our aircrafts are equipped with state of the art medical equipment and staffed with highly qualified flying crews and medical teams. We will bring the patient back home, reliable and safely for affordable pricing.",
61
+ "Our aircrafts are equipped with state of the art medical equipment and staffed with highly qualified flying crews and medical teams. We will bring the patient back home, reliable and safely for affordable pricing.",
62
62
  bgImage: {
63
63
  id: 2,
64
64
  name: "dm_masked@2x.png",
@@ -69,11 +69,11 @@ AMH.args = {
69
69
  },
70
70
  logoImage: {
71
71
  id: 9,
72
- name: "Airplane Cover-07.png",
72
+ name: "Asset 2.png",
73
73
  alternativeText: null,
74
- width: 1280,
75
- height: 720,
76
- url: "/uploads/Airplane_Cover_07_f71759b898.png",
74
+ width: 1000,
75
+ height: 311,
76
+ url: "/uploads/Asset_2_c4a9c4a5d1.png",
77
77
  },
78
78
  link: { id: 1, url: "/contact", text: "Contact us", isExternal: false },
79
79
  },
@@ -162,30 +162,32 @@ AMH.args = {
162
162
  },
163
163
  },
164
164
  },
165
- title: "Hello Cruel World",
165
+ title: "AeroMedical Holland",
166
166
  blocks: [
167
167
  {
168
- id: 3,
168
+ id: 1,
169
169
  __component: "layout.hero-section",
170
- heading: "UMWD",
171
- subHeading: "A place for all your resources",
170
+ heading:
171
+ "We offer world-wide, 24 / 7 patient transport by air ambulance. ",
172
+ subHeading:
173
+ "Our aircrafts are equipped with state of the art medical equipment and staffed with highly qualified flying crews and medical teams. We will bring the patient back home, reliable and safely for affordable pricing.",
172
174
  bgImage: {
173
- id: 3,
174
- url: "https://via.placeholder.com/100",
175
- alternativeText: "UMWD",
175
+ id: 2,
176
+ name: "dm_masked@2x.png",
177
+ alternativeText: null,
178
+ width: 3841,
179
+ height: 2161,
180
+ url: "/uploads/dm_masked_2x_3eabdcd56c.png",
176
181
  },
177
182
  logoImage: {
178
- id: 3,
179
- url: "/uploads/logo_decorated_ad284d33ef.png",
180
- alternativeText: "UMWD",
181
- width: 250,
182
- height: 250,
183
- },
184
- link: {
185
- id: 3,
186
- url: "/resources",
187
- text: "Resources",
183
+ id: 9,
184
+ name: "Asset 2.png",
185
+ alternativeText: null,
186
+ width: 1000,
187
+ height: 311,
188
+ url: "/uploads/Asset_2_c4a9c4a5d1.png",
188
189
  },
190
+ link: { id: 1, url: "/contact", text: "Contact us", isExternal: false },
189
191
  },
190
192
  {
191
193
  id: 2,