umwd-components 0.1.96 → 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 {
@@ -23,6 +24,9 @@ function HeroSection(_ref) {
23
24
  link,
24
25
  maxWidth
25
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);
26
30
  return /*#__PURE__*/React.createElement("header", {
27
31
  style: {
28
32
  position: "relative",
@@ -60,7 +64,10 @@ function HeroSection(_ref) {
60
64
  }
61
65
  }, /*#__PURE__*/React.createElement(material.Paper, {
62
66
  sx: {
63
- p: 2
67
+ px: 2,
68
+ py: 7,
69
+ backdropFilter: "blur(4px)",
70
+ backgroundColor: glassColor
64
71
  }
65
72
  }, /*#__PURE__*/React.createElement(material.Stack, {
66
73
  spacing: 5,
@@ -72,11 +79,13 @@ function HeroSection(_ref) {
72
79
  src: logoImage.url,
73
80
  width: logoImage.width || 100
74
81
  }), /*#__PURE__*/React.createElement(material.Typography, {
75
- variant: "h1",
76
- align: "center"
82
+ variant: "h2",
83
+ align: "center",
84
+ component: "h1"
77
85
  }, heading), /*#__PURE__*/React.createElement(material.Typography, {
78
- variant: "h3",
79
- align: "center"
86
+ variant: "h4",
87
+ align: "center",
88
+ component: "h2"
80
89
  }, subHeading), /*#__PURE__*/React.createElement(Link, {
81
90
  href: link.url
82
91
  }, /*#__PURE__*/React.createElement(material.Button, {
@@ -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, Container, Paper, 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 {
@@ -21,6 +22,9 @@ function HeroSection(_ref) {
21
22
  link,
22
23
  maxWidth
23
24
  } = data;
25
+ const theme = useTheme();
26
+ console.log(theme.palette.background.paper);
27
+ const glassColor = setOpacity(theme.palette.background.paper, 0.45);
24
28
  return /*#__PURE__*/React__default.createElement("header", {
25
29
  style: {
26
30
  position: "relative",
@@ -58,7 +62,10 @@ function HeroSection(_ref) {
58
62
  }
59
63
  }, /*#__PURE__*/React__default.createElement(Paper, {
60
64
  sx: {
61
- p: 2
65
+ px: 2,
66
+ py: 7,
67
+ backdropFilter: "blur(4px)",
68
+ backgroundColor: glassColor
62
69
  }
63
70
  }, /*#__PURE__*/React__default.createElement(Stack, {
64
71
  spacing: 5,
@@ -70,11 +77,13 @@ function HeroSection(_ref) {
70
77
  src: logoImage.url,
71
78
  width: logoImage.width || 100
72
79
  }), /*#__PURE__*/React__default.createElement(Typography, {
73
- variant: "h1",
74
- align: "center"
80
+ variant: "h2",
81
+ align: "center",
82
+ component: "h1"
75
83
  }, heading), /*#__PURE__*/React__default.createElement(Typography, {
76
- variant: "h3",
77
- align: "center"
84
+ variant: "h4",
85
+ align: "center",
86
+ component: "h2"
78
87
  }, subHeading), /*#__PURE__*/React__default.createElement(Link, {
79
88
  href: link.url
80
89
  }, /*#__PURE__*/React__default.createElement(Button, {
@@ -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.96",
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",
@@ -7,8 +7,10 @@ import {
7
7
  Typography,
8
8
  Container,
9
9
  Paper,
10
+ useTheme,
10
11
  } from "@mui/material";
11
12
  import { StrapiImage } from "./StrapiImage.tsx";
13
+ import { setOpacity } from "../lib/utils.ts";
12
14
 
13
15
  interface ImageProps {
14
16
  id: number;
@@ -41,6 +43,12 @@ interface HeroSectionProps {
41
43
  export function HeroSection({ data }: Readonly<HeroSectionProps>) {
42
44
  const { heading, subHeading, bgImage, logoImage, link, maxWidth } = data;
43
45
 
46
+ const theme = useTheme();
47
+
48
+ console.log(theme.palette.background.paper);
49
+
50
+ const glassColor = setOpacity(theme.palette.background.paper, 0.45);
51
+
44
52
  return (
45
53
  <header style={{ position: "relative", padding: 0, margin: 0 }}>
46
54
  <Box
@@ -71,7 +79,14 @@ export function HeroSection({ data }: Readonly<HeroSectionProps>) {
71
79
  />
72
80
  )}
73
81
  <Container maxWidth={maxWidth || "lg"} sx={{ my: 1, zIndex: 1 }}>
74
- <Paper sx={{ p: 2 }}>
82
+ <Paper
83
+ sx={{
84
+ px: 2,
85
+ py: 7,
86
+ backdropFilter: "blur(4px)",
87
+ backgroundColor: glassColor,
88
+ }}
89
+ >
75
90
  <Stack spacing={5} alignItems="center" justifyContent="center">
76
91
  {logoImage && (
77
92
  <StrapiImage
@@ -82,10 +97,10 @@ export function HeroSection({ data }: Readonly<HeroSectionProps>) {
82
97
  />
83
98
  )}
84
99
 
85
- <Typography variant="h1" align="center">
100
+ <Typography variant="h2" align="center" component={"h1"}>
86
101
  {heading}
87
102
  </Typography>
88
- <Typography variant="h3" align="center">
103
+ <Typography variant="h4" align="center" component={"h2"}>
89
104
  {subHeading}
90
105
  </Typography>
91
106
  <Link href={link.url}>
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",
@@ -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,