@ttoss/landing-pages 0.0.2 → 0.1.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/README.md CHANGED
@@ -14,4 +14,4 @@ TODO
14
14
 
15
15
  ## Components
16
16
 
17
- You can check all the components of the library `@ttoss/ui` on the [Storybook](https://storybook.ttoss.dev/?path=/story/landing-pages).
17
+ You can check all the components of the library `@ttoss/landing-pages` on the [Storybook](https://storybook.ttoss.dev/?path=/story/landing-pages).
package/dist/esm/index.js CHANGED
@@ -4,15 +4,167 @@
4
4
  import * as React from "react";
5
5
 
6
6
  // src/Hero/Hero.tsx
7
- import { Box } from "@ttoss/ui";
8
- import { jsx } from "react/jsx-runtime";
9
- var Hero = () => {
10
- return /* @__PURE__ */ jsx(Box, {
11
- children: /* @__PURE__ */ jsx("h1", {
12
- children: "Hero"
7
+ import { Button, Flex, Heading, Image, Text } from "@ttoss/ui";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ var Hero = ({
10
+ alignment,
11
+ headerText,
12
+ subHeaderText,
13
+ imageSrc,
14
+ imageAlt,
15
+ ctaLabel
16
+ }) => {
17
+ const isCentered = alignment === "center";
18
+ return /* @__PURE__ */ jsxs(Flex, {
19
+ sx: {
20
+ justifyContent: "space-between",
21
+ paddingY: "10vh",
22
+ paddingX: "186px"
23
+ },
24
+ children: [
25
+ /* @__PURE__ */ jsxs(Flex, {
26
+ sx: {
27
+ flexDirection: "column",
28
+ alignItems: isCentered ? "center" : "start",
29
+ backgroundImage: isCentered ? `url(${imageSrc})` : void 0,
30
+ width: isCentered ? "100%" : void 0,
31
+ minHeight: isCentered ? "80vh" : void 0,
32
+ justifyContent: isCentered ? "center" : void 0
33
+ },
34
+ children: [
35
+ /* @__PURE__ */ jsx(Heading, {
36
+ sx: { fontSize: "48px", color: isCentered ? "white" : void 0 },
37
+ as: "h1",
38
+ children: headerText
39
+ }),
40
+ /* @__PURE__ */ jsx(Text, {
41
+ sx: {
42
+ fontSize: "24px",
43
+ color: isCentered ? "white" : void 0,
44
+ marginTop: "54px",
45
+ marginBottom: "71px"
46
+ },
47
+ as: "h2",
48
+ children: subHeaderText
49
+ }),
50
+ /* @__PURE__ */ jsx(Button, {
51
+ sx: {
52
+ background: isCentered ? "white" : "black",
53
+ color: isCentered ? "black" : void 0,
54
+ borderRadius: "10px",
55
+ fontSize: "16px"
56
+ },
57
+ children: ctaLabel
58
+ })
59
+ ]
60
+ }),
61
+ !isCentered && /* @__PURE__ */ jsx(Flex, {
62
+ children: /* @__PURE__ */ jsx(Image, {
63
+ sx: {
64
+ maxWidth: "60vw",
65
+ maxHeight: "623px"
66
+ },
67
+ src: imageSrc,
68
+ alt: imageAlt
69
+ })
70
+ })
71
+ ]
72
+ });
73
+ };
74
+
75
+ // src/HeroCarousel/HeroCarousel.tsx
76
+ import { Box, Flex as Flex2, Image as Image2 } from "@ttoss/ui";
77
+ import { Icon } from "@iconify/react";
78
+ import React2 from "react";
79
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
80
+ var HeroCarousel = ({ images = [] }) => {
81
+ const [selectedImage, setSelectedImage] = React2.useState(images[0].id);
82
+ const handleRight = () => {
83
+ const currentIndex = images.findIndex((item) => item.id === selectedImage);
84
+ const isLast = currentIndex === images.length - 1;
85
+ if (isLast) {
86
+ return setSelectedImage(images[0].id);
87
+ }
88
+ setSelectedImage(images[currentIndex + 1].id);
89
+ };
90
+ const handleLeft = () => {
91
+ const currentIndex = images.findIndex((item) => item.id === selectedImage);
92
+ const isFirst = currentIndex === 0;
93
+ if (isFirst) {
94
+ return setSelectedImage(images[images.length - 1].id);
95
+ }
96
+ setSelectedImage(images[currentIndex - 1].id);
97
+ };
98
+ const image = React2.useMemo(() => {
99
+ const result = images.find((item) => item.id === selectedImage);
100
+ return result;
101
+ }, [selectedImage, images]);
102
+ return /* @__PURE__ */ jsx2(Flex2, {
103
+ sx: { width: "100%", height: "100%", maxHeight: "70vh", paddingX: 5 },
104
+ children: /* @__PURE__ */ jsxs2(Flex2, {
105
+ sx: {
106
+ width: "100%",
107
+ height: "50vw",
108
+ position: "relative",
109
+ flexDirection: "column"
110
+ },
111
+ children: [
112
+ /* @__PURE__ */ jsxs2(Flex2, {
113
+ sx: { height: "100%", alignItems: "center", gap: 3 },
114
+ children: [
115
+ /* @__PURE__ */ jsx2(Flex2, {
116
+ sx: {
117
+ cursor: "pointer",
118
+ height: "100%",
119
+ alignItems: "center"
120
+ },
121
+ onClick: handleLeft,
122
+ children: /* @__PURE__ */ jsx2(Icon, {
123
+ icon: "akar-icons:chevron-left"
124
+ })
125
+ }),
126
+ image && /* @__PURE__ */ jsx2(Image2, {
127
+ sx: { height: "100%", width: "100%" },
128
+ src: image.src
129
+ }),
130
+ /* @__PURE__ */ jsx2(Flex2, {
131
+ sx: {
132
+ cursor: "pointer",
133
+ height: "100%",
134
+ alignItems: "center"
135
+ },
136
+ onClick: handleRight,
137
+ children: /* @__PURE__ */ jsx2(Icon, {
138
+ icon: "akar-icons:chevron-right"
139
+ })
140
+ })
141
+ ]
142
+ }),
143
+ /* @__PURE__ */ jsx2(Flex2, {
144
+ sx: {
145
+ marginTop: 2,
146
+ alignSelf: "center",
147
+ gap: 3
148
+ },
149
+ children: images.map((image2) => {
150
+ return /* @__PURE__ */ jsx2(Box, {
151
+ role: "button",
152
+ onClick: () => setSelectedImage(image2.id),
153
+ sx: {
154
+ background: image2.id === selectedImage ? "gray" : "black",
155
+ width: 10,
156
+ height: 10,
157
+ borderRadius: "50%",
158
+ cursor: "pointer"
159
+ }
160
+ }, image2.id);
161
+ })
162
+ })
163
+ ]
13
164
  })
14
165
  });
15
166
  };
16
167
  export {
17
- Hero
168
+ Hero,
169
+ HeroCarousel
18
170
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,20 @@
1
- declare const Hero: () => JSX.Element;
1
+ declare type HeroProps = {
2
+ headerText: string;
3
+ subHeaderText: string;
4
+ alignment: 'left' | 'center';
5
+ imageSrc: string;
6
+ imageAlt?: string;
7
+ ctaLabel?: string;
8
+ };
9
+ declare const Hero: ({ alignment, headerText, subHeaderText, imageSrc, imageAlt, ctaLabel, }: HeroProps) => JSX.Element;
2
10
 
3
- export { Hero };
11
+ declare type HeroCarouselProps = {
12
+ images: {
13
+ id: string;
14
+ alt: string;
15
+ src: string;
16
+ }[];
17
+ };
18
+ declare const HeroCarousel: ({ images }: HeroCarouselProps) => JSX.Element;
19
+
20
+ export { Hero, HeroCarousel, HeroCarouselProps, HeroProps };
package/dist/index.js CHANGED
@@ -27,7 +27,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
27
27
  // src/index.ts
28
28
  var src_exports = {};
29
29
  __export(src_exports, {
30
- Hero: () => Hero
30
+ Hero: () => Hero,
31
+ HeroCarousel: () => HeroCarousel
31
32
  });
32
33
  module.exports = __toCommonJS(src_exports);
33
34
 
@@ -37,14 +38,166 @@ var React = __toESM(require("react"));
37
38
  // src/Hero/Hero.tsx
38
39
  var import_ui = require("@ttoss/ui");
39
40
  var import_jsx_runtime = require("react/jsx-runtime");
40
- var Hero = () => {
41
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Box, {
42
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
43
- children: "Hero"
41
+ var Hero = ({
42
+ alignment,
43
+ headerText,
44
+ subHeaderText,
45
+ imageSrc,
46
+ imageAlt,
47
+ ctaLabel
48
+ }) => {
49
+ const isCentered = alignment === "center";
50
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Flex, {
51
+ sx: {
52
+ justifyContent: "space-between",
53
+ paddingY: "10vh",
54
+ paddingX: "186px"
55
+ },
56
+ children: [
57
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Flex, {
58
+ sx: {
59
+ flexDirection: "column",
60
+ alignItems: isCentered ? "center" : "start",
61
+ backgroundImage: isCentered ? `url(${imageSrc})` : void 0,
62
+ width: isCentered ? "100%" : void 0,
63
+ minHeight: isCentered ? "80vh" : void 0,
64
+ justifyContent: isCentered ? "center" : void 0
65
+ },
66
+ children: [
67
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Heading, {
68
+ sx: { fontSize: "48px", color: isCentered ? "white" : void 0 },
69
+ as: "h1",
70
+ children: headerText
71
+ }),
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Text, {
73
+ sx: {
74
+ fontSize: "24px",
75
+ color: isCentered ? "white" : void 0,
76
+ marginTop: "54px",
77
+ marginBottom: "71px"
78
+ },
79
+ as: "h2",
80
+ children: subHeaderText
81
+ }),
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Button, {
83
+ sx: {
84
+ background: isCentered ? "white" : "black",
85
+ color: isCentered ? "black" : void 0,
86
+ borderRadius: "10px",
87
+ fontSize: "16px"
88
+ },
89
+ children: ctaLabel
90
+ })
91
+ ]
92
+ }),
93
+ !isCentered && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Flex, {
94
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Image, {
95
+ sx: {
96
+ maxWidth: "60vw",
97
+ maxHeight: "623px"
98
+ },
99
+ src: imageSrc,
100
+ alt: imageAlt
101
+ })
102
+ })
103
+ ]
104
+ });
105
+ };
106
+
107
+ // src/HeroCarousel/HeroCarousel.tsx
108
+ var import_ui2 = require("@ttoss/ui");
109
+ var import_react = require("@iconify/react");
110
+ var import_react2 = __toESM(require("react"));
111
+ var import_jsx_runtime2 = require("react/jsx-runtime");
112
+ var HeroCarousel = ({ images = [] }) => {
113
+ const [selectedImage, setSelectedImage] = import_react2.default.useState(images[0].id);
114
+ const handleRight = () => {
115
+ const currentIndex = images.findIndex((item) => item.id === selectedImage);
116
+ const isLast = currentIndex === images.length - 1;
117
+ if (isLast) {
118
+ return setSelectedImage(images[0].id);
119
+ }
120
+ setSelectedImage(images[currentIndex + 1].id);
121
+ };
122
+ const handleLeft = () => {
123
+ const currentIndex = images.findIndex((item) => item.id === selectedImage);
124
+ const isFirst = currentIndex === 0;
125
+ if (isFirst) {
126
+ return setSelectedImage(images[images.length - 1].id);
127
+ }
128
+ setSelectedImage(images[currentIndex - 1].id);
129
+ };
130
+ const image = import_react2.default.useMemo(() => {
131
+ const result = images.find((item) => item.id === selectedImage);
132
+ return result;
133
+ }, [selectedImage, images]);
134
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Flex, {
135
+ sx: { width: "100%", height: "100%", maxHeight: "70vh", paddingX: 5 },
136
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui2.Flex, {
137
+ sx: {
138
+ width: "100%",
139
+ height: "50vw",
140
+ position: "relative",
141
+ flexDirection: "column"
142
+ },
143
+ children: [
144
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_ui2.Flex, {
145
+ sx: { height: "100%", alignItems: "center", gap: 3 },
146
+ children: [
147
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Flex, {
148
+ sx: {
149
+ cursor: "pointer",
150
+ height: "100%",
151
+ alignItems: "center"
152
+ },
153
+ onClick: handleLeft,
154
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Icon, {
155
+ icon: "akar-icons:chevron-left"
156
+ })
157
+ }),
158
+ image && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Image, {
159
+ sx: { height: "100%", width: "100%" },
160
+ src: image.src
161
+ }),
162
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Flex, {
163
+ sx: {
164
+ cursor: "pointer",
165
+ height: "100%",
166
+ alignItems: "center"
167
+ },
168
+ onClick: handleRight,
169
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.Icon, {
170
+ icon: "akar-icons:chevron-right"
171
+ })
172
+ })
173
+ ]
174
+ }),
175
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Flex, {
176
+ sx: {
177
+ marginTop: 2,
178
+ alignSelf: "center",
179
+ gap: 3
180
+ },
181
+ children: images.map((image2) => {
182
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_ui2.Box, {
183
+ role: "button",
184
+ onClick: () => setSelectedImage(image2.id),
185
+ sx: {
186
+ background: image2.id === selectedImage ? "gray" : "black",
187
+ width: 10,
188
+ height: 10,
189
+ borderRadius: "50%",
190
+ cursor: "pointer"
191
+ }
192
+ }, image2.id);
193
+ })
194
+ })
195
+ ]
44
196
  })
45
197
  });
46
198
  };
47
199
  // Annotate the CommonJS export names for ESM import in node:
48
200
  0 && (module.exports = {
49
- Hero
201
+ Hero,
202
+ HeroCarousel
50
203
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/landing-pages",
3
- "version": "0.0.2",
3
+ "version": "0.1.1",
4
4
  "description": "Package for creating landing pages.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -19,6 +19,9 @@
19
19
  "test": "echo jest"
20
20
  },
21
21
  "typings": "dist/index.d.ts",
22
+ "dependencies": {
23
+ "@iconify/react": "^4.0.0"
24
+ },
22
25
  "peerDependencies": {
23
26
  "@ttoss/ui": "^1.21.0",
24
27
  "react": ">=18.0.0"
@@ -38,5 +41,5 @@
38
41
  "publishConfig": {
39
42
  "access": "public"
40
43
  },
41
- "gitHead": "adca3912e3a374a32cd7b5bd7733d2cdc9cd1a45"
44
+ "gitHead": "35f6fab94a939017e8ef17b6c29b570bb4f2f258"
42
45
  }
package/src/Hero/Hero.tsx CHANGED
@@ -1,9 +1,83 @@
1
- import { Box } from '@ttoss/ui';
1
+ import { Button, Flex, Heading, Image, Text } from '@ttoss/ui';
2
+
3
+ export type HeroProps = {
4
+ headerText: string;
5
+ subHeaderText: string;
6
+ alignment: 'left' | 'center';
7
+ imageSrc: string;
8
+ imageAlt?: string;
9
+ ctaLabel?: string;
10
+ };
11
+
12
+ export const Hero = ({
13
+ alignment,
14
+ headerText,
15
+ subHeaderText,
16
+ imageSrc,
17
+ imageAlt,
18
+ ctaLabel,
19
+ }: HeroProps) => {
20
+ const isCentered = alignment === 'center';
2
21
 
3
- export const Hero = () => {
4
22
  return (
5
- <Box>
6
- <h1>Hero</h1>
7
- </Box>
23
+ <Flex
24
+ sx={{
25
+ justifyContent: 'space-between',
26
+ paddingY: '10vh',
27
+ paddingX: '186px',
28
+ }}
29
+ >
30
+ <Flex
31
+ sx={{
32
+ flexDirection: 'column',
33
+ alignItems: isCentered ? 'center' : 'start',
34
+ backgroundImage: isCentered ? `url(${imageSrc})` : undefined,
35
+ width: isCentered ? '100%' : undefined,
36
+ minHeight: isCentered ? '80vh' : undefined,
37
+ justifyContent: isCentered ? 'center' : undefined,
38
+ }}
39
+ >
40
+ <Heading
41
+ sx={{ fontSize: '48px', color: isCentered ? 'white' : undefined }}
42
+ as="h1"
43
+ >
44
+ {headerText}
45
+ </Heading>
46
+ <Text
47
+ sx={{
48
+ fontSize: '24px',
49
+ color: isCentered ? 'white' : undefined,
50
+ marginTop: '54px',
51
+ marginBottom: '71px',
52
+ }}
53
+ as="h2"
54
+ >
55
+ {subHeaderText}
56
+ </Text>
57
+ <Button
58
+ sx={{
59
+ background: isCentered ? 'white' : 'black',
60
+ color: isCentered ? 'black' : undefined,
61
+ borderRadius: '10px',
62
+ fontSize: '16px',
63
+ }}
64
+ >
65
+ {ctaLabel}
66
+ </Button>
67
+ </Flex>
68
+
69
+ {!isCentered && (
70
+ <Flex>
71
+ <Image
72
+ sx={{
73
+ maxWidth: '60vw',
74
+ maxHeight: '623px',
75
+ }}
76
+ src={imageSrc}
77
+ alt={imageAlt}
78
+ />
79
+ </Flex>
80
+ )}
81
+ </Flex>
8
82
  );
9
83
  };
@@ -0,0 +1,111 @@
1
+ import { Box, Flex, Image } from '@ttoss/ui';
2
+ import { Icon } from '@iconify/react';
3
+ import React from 'react';
4
+
5
+ export type HeroCarouselProps = {
6
+ images: {
7
+ id: string;
8
+ alt: string;
9
+ src: string;
10
+ }[];
11
+ };
12
+
13
+ export const HeroCarousel = ({ images = [] }: HeroCarouselProps) => {
14
+ const [selectedImage, setSelectedImage] = React.useState(images[0].id);
15
+
16
+ const handleRight = () => {
17
+ const currentIndex = images.findIndex((item) => item.id === selectedImage);
18
+ const isLast = currentIndex === images.length - 1;
19
+
20
+ if (isLast) {
21
+ return setSelectedImage(images[0].id);
22
+ }
23
+
24
+ setSelectedImage(images[currentIndex + 1].id);
25
+ };
26
+
27
+ const handleLeft = () => {
28
+ const currentIndex = images.findIndex((item) => item.id === selectedImage);
29
+ const isFirst = currentIndex === 0;
30
+
31
+ if (isFirst) {
32
+ return setSelectedImage(images[images.length - 1].id);
33
+ }
34
+
35
+ setSelectedImage(images[currentIndex - 1].id);
36
+ };
37
+
38
+ const image = React.useMemo(() => {
39
+ const result = images.find((item) => item.id === selectedImage);
40
+
41
+ return result;
42
+ }, [selectedImage, images]);
43
+
44
+ return (
45
+ <Flex
46
+ sx={{ width: '100%', height: '100%', maxHeight: '70vh', paddingX: 5 }}
47
+ >
48
+ <Flex
49
+ sx={{
50
+ width: '100%',
51
+ height: '50vw',
52
+ position: 'relative',
53
+ flexDirection: 'column',
54
+ }}
55
+ >
56
+ <Flex sx={{ height: '100%', alignItems: 'center', gap: 3 }}>
57
+ <Flex
58
+ sx={{
59
+ cursor: 'pointer',
60
+ height: '100%',
61
+ alignItems: 'center',
62
+ }}
63
+ onClick={handleLeft}
64
+ >
65
+ <Icon icon="akar-icons:chevron-left" />
66
+ </Flex>
67
+
68
+ {image && (
69
+ <Image sx={{ height: '100%', width: '100%' }} src={image.src} />
70
+ )}
71
+
72
+ <Flex
73
+ sx={{
74
+ cursor: 'pointer',
75
+ height: '100%',
76
+ alignItems: 'center',
77
+ }}
78
+ onClick={handleRight}
79
+ >
80
+ <Icon icon="akar-icons:chevron-right" />
81
+ </Flex>
82
+ </Flex>
83
+
84
+ <Flex
85
+ sx={{
86
+ marginTop: 2,
87
+ alignSelf: 'center',
88
+ gap: 3,
89
+ }}
90
+ >
91
+ {images.map((image) => {
92
+ return (
93
+ <Box
94
+ key={image.id}
95
+ role="button"
96
+ onClick={() => setSelectedImage(image.id)}
97
+ sx={{
98
+ background: image.id === selectedImage ? 'gray' : 'black',
99
+ width: 10,
100
+ height: 10,
101
+ borderRadius: '50%',
102
+ cursor: 'pointer',
103
+ }}
104
+ />
105
+ );
106
+ })}
107
+ </Flex>
108
+ </Flex>
109
+ </Flex>
110
+ );
111
+ };
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
- export { Hero } from './Hero/Hero';
1
+ export { Hero, HeroProps } from './Hero/Hero';
2
+ export { HeroCarousel, HeroCarouselProps } from './HeroCarousel/HeroCarousel';