umwd-components 0.1.136 → 0.1.138

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.
@@ -12,6 +12,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  var React = require('react');
13
13
  var material = require('@mui/material');
14
14
  var isEmail = require('validator/lib/isEmail');
15
+ var utils = require('../lib/utils.js');
16
+ var styles = require('@mui/material/styles');
15
17
 
16
18
  function ContactForm(_ref) {
17
19
  let {
@@ -19,7 +21,8 @@ function ContactForm(_ref) {
19
21
  } = _ref;
20
22
  const {
21
23
  maxWidth,
22
- sx = {}
24
+ sx = {},
25
+ glass = false
23
26
  } = data;
24
27
  const [formValues, setFormValues] = React.useState({
25
28
  name: "",
@@ -127,6 +130,7 @@ function ContactForm(_ref) {
127
130
  console.log("errors from validate", errors);
128
131
  return errors;
129
132
  };
133
+ const theme = styles.useTheme();
130
134
  return /*#__PURE__*/React.createElement(material.Container, {
131
135
  maxWidth: maxWidth ? maxWidth : "lg",
132
136
  sx: {
@@ -162,7 +166,10 @@ function ContactForm(_ref) {
162
166
  variant: "contained"
163
167
  }, "try again")))), !showSuccessMessage && !showFailureMessage && /*#__PURE__*/React.createElement(material.Paper, {
164
168
  sx: {
165
- p: 2
169
+ p: 2,
170
+ backdropFilter: "blur(3px)",
171
+ backgroundColor: utils.setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
172
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none"
166
173
  }
167
174
  }, /*#__PURE__*/React.createElement(material.Stack, {
168
175
  spacing: 2
@@ -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 {
@@ -22,8 +23,11 @@ function HeroSection(_ref) {
22
23
  logoImage,
23
24
  link,
24
25
  maxWidth,
25
- sx = {}
26
+ sx = {},
27
+ glass = false
26
28
  } = data;
29
+ const theme = material.useTheme();
30
+ utils.setOpacity(theme.palette.background.paper, 0.1);
27
31
  return /*#__PURE__*/React.createElement("header", {
28
32
  style: {
29
33
  position: "relative",
@@ -63,7 +67,10 @@ function HeroSection(_ref) {
63
67
  }, /*#__PURE__*/React.createElement(material.Paper, {
64
68
  sx: {
65
69
  px: 2,
66
- py: 2
70
+ py: 7,
71
+ backdropFilter: "blur(3px)",
72
+ backgroundColor: utils.setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
73
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none"
67
74
  }
68
75
  }, /*#__PURE__*/React.createElement(material.Stack, {
69
76
  spacing: 5,
@@ -12,6 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  var React = require('react');
13
13
  var material = require('@mui/material');
14
14
  var StrapiImage = require('./StrapiImage.js');
15
+ var utils = require('../lib/utils.js');
15
16
 
16
17
  const MuiMarkdown = /*#__PURE__*/React.lazy(() => import( /* webpackChunkName: "mui-markdown" */'mui-markdown'));
17
18
 
@@ -37,7 +38,8 @@ function TextImageSection(_ref) {
37
38
  image,
38
39
  reverse = false,
39
40
  maxWidth,
40
- sx = {}
41
+ sx = {},
42
+ glass = false
41
43
  } = data;
42
44
 
43
45
  /* TODO Text_content should deal with linebreaks,
@@ -54,7 +56,10 @@ function TextImageSection(_ref) {
54
56
  }
55
57
  }, /*#__PURE__*/React.createElement(material.Paper, {
56
58
  sx: {
57
- p: 2
59
+ p: 2,
60
+ backdropFilter: "blur(3px)",
61
+ backgroundColor: utils.setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
62
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none"
58
63
  }
59
64
  }, title && /*#__PURE__*/React.createElement(material.Typography, {
60
65
  variant: "h1",
@@ -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;
@@ -8,6 +8,8 @@
8
8
  import React__default from 'react';
9
9
  import { Container, Stack, Typography, Paper, Button, TextField } from '@mui/material';
10
10
  import isEmail from 'validator/lib/isEmail';
11
+ import { setOpacity } from '../lib/utils.js';
12
+ import { useTheme } from '@mui/material/styles';
11
13
 
12
14
  function ContactForm(_ref) {
13
15
  let {
@@ -15,7 +17,8 @@ function ContactForm(_ref) {
15
17
  } = _ref;
16
18
  const {
17
19
  maxWidth,
18
- sx = {}
20
+ sx = {},
21
+ glass = false
19
22
  } = data;
20
23
  const [formValues, setFormValues] = React__default.useState({
21
24
  name: "",
@@ -123,6 +126,7 @@ function ContactForm(_ref) {
123
126
  console.log("errors from validate", errors);
124
127
  return errors;
125
128
  };
129
+ const theme = useTheme();
126
130
  return /*#__PURE__*/React__default.createElement(Container, {
127
131
  maxWidth: maxWidth ? maxWidth : "lg",
128
132
  sx: {
@@ -158,7 +162,10 @@ function ContactForm(_ref) {
158
162
  variant: "contained"
159
163
  }, "try again")))), !showSuccessMessage && !showFailureMessage && /*#__PURE__*/React__default.createElement(Paper, {
160
164
  sx: {
161
- p: 2
165
+ p: 2,
166
+ backdropFilter: "blur(3px)",
167
+ backgroundColor: setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
168
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none"
162
169
  }
163
170
  }, /*#__PURE__*/React__default.createElement(Stack, {
164
171
  spacing: 2
@@ -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 {
@@ -20,8 +21,11 @@ function HeroSection(_ref) {
20
21
  logoImage,
21
22
  link,
22
23
  maxWidth,
23
- sx = {}
24
+ sx = {},
25
+ glass = false
24
26
  } = data;
27
+ const theme = useTheme();
28
+ setOpacity(theme.palette.background.paper, 0.1);
25
29
  return /*#__PURE__*/React__default.createElement("header", {
26
30
  style: {
27
31
  position: "relative",
@@ -61,7 +65,10 @@ function HeroSection(_ref) {
61
65
  }, /*#__PURE__*/React__default.createElement(Paper, {
62
66
  sx: {
63
67
  px: 2,
64
- py: 2
68
+ py: 7,
69
+ backdropFilter: "blur(3px)",
70
+ backgroundColor: setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
71
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none"
65
72
  }
66
73
  }, /*#__PURE__*/React__default.createElement(Stack, {
67
74
  spacing: 5,
@@ -8,6 +8,7 @@
8
8
  import React__default from 'react';
9
9
  import { useTheme, Container, Paper, Typography, Stack, Box } from '@mui/material';
10
10
  import { StrapiImage } from './StrapiImage.js';
11
+ import { setOpacity } from '../lib/utils.js';
11
12
 
12
13
  const MuiMarkdown = /*#__PURE__*/React__default.lazy(() => import( /* webpackChunkName: "mui-markdown" */'mui-markdown'));
13
14
 
@@ -33,7 +34,8 @@ function TextImageSection(_ref) {
33
34
  image,
34
35
  reverse = false,
35
36
  maxWidth,
36
- sx = {}
37
+ sx = {},
38
+ glass = false
37
39
  } = data;
38
40
 
39
41
  /* TODO Text_content should deal with linebreaks,
@@ -50,7 +52,10 @@ function TextImageSection(_ref) {
50
52
  }
51
53
  }, /*#__PURE__*/React__default.createElement(Paper, {
52
54
  sx: {
53
- p: 2
55
+ p: 2,
56
+ backdropFilter: "blur(3px)",
57
+ backgroundColor: setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
58
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none"
54
59
  }
55
60
  }, title && /*#__PURE__*/React__default.createElement(Typography, {
56
61
  variant: "h1",
@@ -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.136",
3
+ "version": "0.1.138",
4
4
  "description": "UMWD Component library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -13,6 +13,8 @@ import {
13
13
  } from "@mui/material";
14
14
  import isEmail from "validator/lib/isEmail";
15
15
  import { SxProps, Theme } from "@mui/material/styles";
16
+ import { setOpacity } from "../lib/utils.ts";
17
+ import { useTheme } from "@mui/material/styles";
16
18
 
17
19
  type MaxWidth = "xs" | "sm" | "md" | "lg" | "xl" | false | undefined;
18
20
 
@@ -22,10 +24,11 @@ interface ContactFormProps {
22
24
  title: string;
23
25
  maxWidth: MaxWidth;
24
26
  sx?: SxProps<Theme>;
27
+ glass?: boolean;
25
28
  }
26
29
 
27
30
  function ContactForm({ data }: { readonly data: ContactFormProps }) {
28
- const { maxWidth, sx = {} } = data;
31
+ const { maxWidth, sx = {}, glass = false } = data;
29
32
 
30
33
  type FormValues = {
31
34
  name: string;
@@ -150,6 +153,8 @@ function ContactForm({ data }: { readonly data: ContactFormProps }) {
150
153
  return errors;
151
154
  };
152
155
 
156
+ const theme = useTheme();
157
+
153
158
  return (
154
159
  <Container maxWidth={maxWidth ? maxWidth : "lg"} sx={{ my: 1, ...sx }}>
155
160
  <Stack spacing={2} sx={{ width: "100%" }}>
@@ -180,7 +185,17 @@ function ContactForm({ data }: { readonly data: ContactFormProps }) {
180
185
  )}
181
186
  </Stack>
182
187
  {!showSuccessMessage && !showFailureMessage && (
183
- <Paper sx={{ p: 2 }}>
188
+ <Paper
189
+ sx={{
190
+ p: 2,
191
+ backdropFilter: "blur(3px)",
192
+ backgroundColor: setOpacity(
193
+ theme.palette.background.paper,
194
+ glass ? 0.1 : 1
195
+ ),
196
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none",
197
+ }}
198
+ >
184
199
  <Stack spacing={2}>
185
200
  <TextField
186
201
  id="name"
@@ -10,8 +10,11 @@ import {
10
10
  useTheme,
11
11
  } from "@mui/material";
12
12
  import { StrapiImage } from "./StrapiImage.tsx";
13
+ import { setOpacity } from "../lib/utils.ts";
13
14
  import { SxProps, Theme } from "@mui/material/styles";
14
15
 
16
+ type MaxWidth = "xs" | "sm" | "md" | "lg" | "xl" | false | undefined;
17
+
15
18
  interface ImageProps {
16
19
  id: number;
17
20
  url: string;
@@ -36,8 +39,9 @@ interface HeroSectionProps {
36
39
  bgImage?: ImageProps;
37
40
  logoImage?: ImageProps;
38
41
  link: LinkProps;
39
- maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | false | undefined;
42
+ maxWidth?: MaxWidth;
40
43
  sx?: SxProps<Theme>;
44
+ glass?: boolean;
41
45
  };
42
46
  }
43
47
 
@@ -50,8 +54,13 @@ export function HeroSection({ data }: Readonly<HeroSectionProps>) {
50
54
  link,
51
55
  maxWidth,
52
56
  sx = {},
57
+ glass = false,
53
58
  } = data;
54
59
 
60
+ const theme = useTheme();
61
+
62
+ const glassColor = setOpacity(theme.palette.background.paper, 0.1);
63
+
55
64
  return (
56
65
  <header style={{ position: "relative", padding: 0, margin: 0 }}>
57
66
  <Box
@@ -86,7 +95,13 @@ export function HeroSection({ data }: Readonly<HeroSectionProps>) {
86
95
  <Paper
87
96
  sx={{
88
97
  px: 2,
89
- py: 2,
98
+ py: 7,
99
+ backdropFilter: "blur(3px)",
100
+ backgroundColor: setOpacity(
101
+ theme.palette.background.paper,
102
+ glass ? 0.1 : 1
103
+ ),
104
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none",
90
105
  }}
91
106
  >
92
107
  <Stack spacing={5} alignItems="center" justifyContent="center">
@@ -14,6 +14,7 @@ const MuiMarkdown = React.lazy(
14
14
  );
15
15
  import { StrapiImage } from "./StrapiImage.tsx";
16
16
  import { SxProps, Theme } from "@mui/material/styles";
17
+ import { setOpacity } from "../lib/utils.ts";
17
18
 
18
19
  /*
19
20
  TODO intregrate this interface into StrapiImage.tsx
@@ -43,11 +44,20 @@ interface TextImageSectionProps {
43
44
  maxWidth?: MaxWidth;
44
45
  minHeight: string;
45
46
  sx?: SxProps<Theme>;
47
+ glass?: boolean;
46
48
  };
47
49
  }
48
50
 
49
51
  function TextImageSection({ data }: Readonly<TextImageSectionProps>) {
50
- const { title, text, image, reverse = false, maxWidth, sx = {} } = data;
52
+ const {
53
+ title,
54
+ text,
55
+ image,
56
+ reverse = false,
57
+ maxWidth,
58
+ sx = {},
59
+ glass = false,
60
+ } = data;
51
61
 
52
62
  /* TODO Text_content should deal with linebreaks,
53
63
  reading up upon mui-markdown docs is advised */
@@ -58,7 +68,17 @@ function TextImageSection({ data }: Readonly<TextImageSectionProps>) {
58
68
 
59
69
  return (
60
70
  <Container maxWidth={maxWidth ? maxWidth : "lg"} sx={{ my: 1, ...sx }}>
61
- <Paper sx={{ p: 2 }}>
71
+ <Paper
72
+ sx={{
73
+ p: 2,
74
+ backdropFilter: "blur(3px)",
75
+ backgroundColor: setOpacity(
76
+ theme.palette.background.paper,
77
+ glass ? 0.1 : 1
78
+ ),
79
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none",
80
+ }}
81
+ >
62
82
  {title && (
63
83
  <Typography variant="h1" textAlign="center" sx={{ pb: 2 }}>
64
84
  {title}
@@ -188,14 +188,7 @@ AMH.args = {
188
188
  url: "/uploads/Asset_2_c4a9c4a5d1.png",
189
189
  },
190
190
  link: { id: 1, url: "/contact", text: "Contact us", isExternal: false },
191
- sx: {
192
- ".MuiPaper-root": {
193
- py: 7,
194
- backdropFilter: "blur(3px)",
195
- backgroundColor: "rgba(255, 255, 255, 0.15)",
196
- border: "1px solid rgba(255, 255, 255, 0.15)",
197
- },
198
- },
191
+ glass: true,
199
192
  },
200
193
  {
201
194
  id: 2,
@@ -380,6 +373,7 @@ AMH.args = {
380
373
  },
381
374
  text: "**Hello Mars,** \n a distant red planet that has captured the imagination of humanity for centuries. As we gaze upon your mysterious surface from Earth, we can't help but wonder about the secrets you hold. Hello to the vast landscapes of rust-colored terrain, the towering volcanoes, and the enigmatic canyons that weave across your surface. *Hello Mars,* a planet that has been the focus of numerous space missions, each one aiming to unveil the mysteries of your past and present. From the iconic rovers tirelessly traversing your rocky landscapes to the orbiters capturing breathtaking images from above, we extend our greetings to the scientific endeavors that seek to understand your geology, climate, and potential for life. <br /> <br /> *Hello Mars,* a beacon of human exploration and curiosity. The dreams of setting foot on your soil have fueled the aspirations of generations, and with each technological leap, the possibility of humans visiting you becomes more tangible. The prospect of a human settlement on Mars brings excitement, challenges, and the promise of a new chapter in our interplanetary journey. <br /> <br /> *Hello Mars,* a testament to the indomitable human spirit that constantly seeks to push the boundaries of what is possible. As we continue to study, explore, and dream about the mysteries you hold, we are reminded of the vastness of the cosmos and the endless opportunities for discovery that lie beyond our home planet.",
382
375
  reverse: true,
376
+ glass: true,
383
377
  },
384
378
  {
385
379
  id: 1,
@@ -463,6 +457,7 @@ AMH.args = {
463
457
  id: 1,
464
458
  __component: "layout.contact-section",
465
459
  title: "Contact us",
460
+ glass: true,
466
461
  },
467
462
  ],
468
463
  };