zuljaman-banner-components 1.0.0

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.
Files changed (68) hide show
  1. package/README.md +242 -0
  2. package/dist/adapters/NextJSAdapter.d.ts +17 -0
  3. package/dist/adapters/NextJSAdapter.d.ts.map +1 -0
  4. package/dist/adapters/NextJSAdapter.js +7 -0
  5. package/dist/adapters/SSRAdapter.d.ts +8 -0
  6. package/dist/adapters/SSRAdapter.d.ts.map +1 -0
  7. package/dist/adapters/SSRAdapter.js +2 -0
  8. package/dist/adapters/index.d.ts +6 -0
  9. package/dist/adapters/index.d.ts.map +1 -0
  10. package/dist/adapters/index.js +5 -0
  11. package/dist/components/BannerVisor.d.ts +12 -0
  12. package/dist/components/BannerVisor.d.ts.map +1 -0
  13. package/dist/components/BannerVisor.js +99 -0
  14. package/dist/components/Style1/BannerStyle1.d.ts +18 -0
  15. package/dist/components/Style1/BannerStyle1.d.ts.map +1 -0
  16. package/dist/components/Style1/BannerStyle1.js +22 -0
  17. package/dist/components/Style1/substyles/BannerSubstyle1.d.ts +12 -0
  18. package/dist/components/Style1/substyles/BannerSubstyle1.d.ts.map +1 -0
  19. package/dist/components/Style1/substyles/BannerSubstyle1.js +44 -0
  20. package/dist/components/Style1/substyles/BannerSubstyle2.d.ts +12 -0
  21. package/dist/components/Style1/substyles/BannerSubstyle2.d.ts.map +1 -0
  22. package/dist/components/Style1/substyles/BannerSubstyle2.js +44 -0
  23. package/dist/components/Style1/substyles/BannerSubstyle3.d.ts +12 -0
  24. package/dist/components/Style1/substyles/BannerSubstyle3.d.ts.map +1 -0
  25. package/dist/components/Style1/substyles/BannerSubstyle3.js +53 -0
  26. package/dist/components/Style1/substyles/index.d.ts +7 -0
  27. package/dist/components/Style1/substyles/index.d.ts.map +1 -0
  28. package/dist/components/Style1/substyles/index.js +6 -0
  29. package/dist/components/Style2/BannerStyle2.d.ts +18 -0
  30. package/dist/components/Style2/BannerStyle2.d.ts.map +1 -0
  31. package/dist/components/Style2/BannerStyle2.js +27 -0
  32. package/dist/components/Style2/substyles/BannerSubstyle1.d.ts +12 -0
  33. package/dist/components/Style2/substyles/BannerSubstyle1.d.ts.map +1 -0
  34. package/dist/components/Style2/substyles/BannerSubstyle1.js +27 -0
  35. package/dist/components/Style2/substyles/BannerSubstyle2.d.ts +12 -0
  36. package/dist/components/Style2/substyles/BannerSubstyle2.d.ts.map +1 -0
  37. package/dist/components/Style2/substyles/BannerSubstyle2.js +27 -0
  38. package/dist/components/Style2/substyles/BannerSubstyle3.d.ts +12 -0
  39. package/dist/components/Style2/substyles/BannerSubstyle3.d.ts.map +1 -0
  40. package/dist/components/Style2/substyles/BannerSubstyle3.js +27 -0
  41. package/dist/components/Style2/substyles/index.d.ts +7 -0
  42. package/dist/components/Style2/substyles/index.d.ts.map +1 -0
  43. package/dist/components/Style2/substyles/index.js +6 -0
  44. package/dist/components/index.d.ts +7 -0
  45. package/dist/components/index.d.ts.map +1 -0
  46. package/dist/components/index.js +6 -0
  47. package/dist/constants/index.d.ts +5 -0
  48. package/dist/constants/index.d.ts.map +1 -0
  49. package/dist/constants/index.js +4 -0
  50. package/dist/constants/styleConfigs.d.ts +11 -0
  51. package/dist/constants/styleConfigs.d.ts.map +1 -0
  52. package/dist/constants/styleConfigs.js +24 -0
  53. package/dist/index.d.ts +13 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +18 -0
  56. package/dist/styles/index.d.ts +5 -0
  57. package/dist/styles/index.d.ts.map +1 -0
  58. package/dist/styles/index.js +4 -0
  59. package/dist/styles/shadowUtils.d.ts +21 -0
  60. package/dist/styles/shadowUtils.d.ts.map +1 -0
  61. package/dist/styles/shadowUtils.js +107 -0
  62. package/dist/types.d.ts +98 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +20 -0
  65. package/dist/utils.d.ts +16 -0
  66. package/dist/utils.d.ts.map +1 -0
  67. package/dist/utils.js +29 -0
  68. package/package.json +62 -0
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Consolidated types for banner components shared package
3
+ * Based on Next.js app types with AWS Lambda compatibility
4
+ */
5
+ import React from 'react';
6
+ /**
7
+ * Shared interface for all banner substyle components
8
+ */
9
+ export interface BannerSubstyleProps {
10
+ copy1?: string;
11
+ copy2?: string;
12
+ fontSize_01?: string;
13
+ fontSize_02?: string;
14
+ logoUrl?: string;
15
+ backgroundImageUrl?: string;
16
+ }
17
+ /**
18
+ * Post type enumeration for different banner formats
19
+ */
20
+ export declare enum PostType {
21
+ POST = "POST",
22
+ STORY = "STORY"
23
+ }
24
+ /**
25
+ * Banner style enumeration for different design templates
26
+ */
27
+ export declare enum BannerStyle {
28
+ CANVA_STYLE_01 = "CANVA_STYLE_01",
29
+ CANVA_STYLE_02 = "CANVA_STYLE_02"
30
+ }
31
+ /**
32
+ * Font configuration interface for style-specific sizing
33
+ */
34
+ export interface StyleFontConfig {
35
+ baseSizeRem1: number;
36
+ baseSizeRem2: number;
37
+ maxLengthThreshold: number;
38
+ reductionFactor: number;
39
+ }
40
+ /**
41
+ * Font size calculation result
42
+ */
43
+ export interface FontSizeResult {
44
+ fontSize_01: string;
45
+ fontSize_02: string;
46
+ }
47
+ /**
48
+ * Image component props for platform adapters
49
+ */
50
+ export interface ImageProps {
51
+ src: string;
52
+ alt: string;
53
+ width?: number;
54
+ height?: number;
55
+ className?: string;
56
+ style?: React.CSSProperties;
57
+ [key: string]: any;
58
+ }
59
+ /**
60
+ * Post image interface for banner generation
61
+ */
62
+ export interface PostImage {
63
+ id?: string;
64
+ rawImage: string;
65
+ rawCopy?: string;
66
+ bannerImage?: string;
67
+ height: number;
68
+ width: number;
69
+ postId?: string;
70
+ createdAt?: Date;
71
+ bannerCopy1?: string;
72
+ bannerCopy2?: string;
73
+ /** An identifier for the style of the banner, expected range 1-3 */
74
+ bannerStyle?: number;
75
+ /** An identifier for the substyle of the banner, expected range 1-3 */
76
+ bannerSubstyle?: number;
77
+ logoUrl?: string;
78
+ }
79
+ /**
80
+ * Banner visor component props
81
+ */
82
+ export interface BannerVisorProps {
83
+ postType: PostType;
84
+ bannerStyle: number;
85
+ bannerSubstyle: number;
86
+ copy1?: string;
87
+ copy2?: string;
88
+ logoUrl?: string;
89
+ backgroundImageUrl?: string;
90
+ sizeMultiplier?: number;
91
+ }
92
+ /**
93
+ * Platform adapter interface
94
+ */
95
+ export interface PlatformAdapter {
96
+ ImageComponent: React.ComponentType<ImageProps>;
97
+ }
98
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,oBAAY,WAAW;IACrB,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;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.js app types with AWS Lambda compatibility
4
+ */
5
+ /**
6
+ * Post type enumeration for different banner formats
7
+ */
8
+ export var PostType;
9
+ (function (PostType) {
10
+ PostType["POST"] = "POST";
11
+ PostType["STORY"] = "STORY";
12
+ })(PostType || (PostType = {}));
13
+ /**
14
+ * Banner style enumeration for different design templates
15
+ */
16
+ export var BannerStyle;
17
+ (function (BannerStyle) {
18
+ BannerStyle["CANVA_STYLE_01"] = "CANVA_STYLE_01";
19
+ BannerStyle["CANVA_STYLE_02"] = "CANVA_STYLE_02";
20
+ })(BannerStyle || (BannerStyle = {}));
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Enhanced font size calculation for banner styles with separate sizing for copy1 and copy2
3
+ * Extracted from Next.js app implementation
4
+ */
5
+ import type { StyleFontConfig, FontSizeResult } from './types';
6
+ /**
7
+ * Calculates dynamic font sizes for both copy1 and copy2 based on content length
8
+ * and style-specific constraints.
9
+ *
10
+ * @param copy1 - Primary text content
11
+ * @param copy2 - Secondary text content
12
+ * @param config - Style-specific font configuration
13
+ * @returns Object with fontSize_01 and fontSize_02 strings
14
+ */
15
+ export declare const calculateStyleFontSizes: (copy1: string | null | undefined, copy2: string | null | undefined, config: StyleFontConfig) => FontSizeResult;
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ,eAAe,KACtB,cAmBF,CAAC"}
package/dist/utils.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Enhanced font size calculation for banner styles with separate sizing for copy1 and copy2
3
+ * Extracted from Next.js app implementation
4
+ */
5
+ /**
6
+ * Calculates dynamic font sizes for both copy1 and copy2 based on content length
7
+ * and style-specific constraints.
8
+ *
9
+ * @param copy1 - Primary text content
10
+ * @param copy2 - Secondary text content
11
+ * @param config - Style-specific font configuration
12
+ * @returns Object with fontSize_01 and fontSize_02 strings
13
+ */
14
+ export const calculateStyleFontSizes = (copy1, copy2, config) => {
15
+ const { baseSizeRem1, baseSizeRem2, maxLengthThreshold, reductionFactor } = config;
16
+ // Calculate length excluding spaces for each copy
17
+ const len1 = copy1?.replace(/\s/g, "").length ?? 0;
18
+ const len2 = copy2?.replace(/\s/g, "").length ?? 0;
19
+ // Calculate font size for copy1
20
+ const calculationLength1 = len1 === 0 ? 1 : len1;
21
+ const size1 = baseSizeRem1 + Math.max(0, maxLengthThreshold - calculationLength1) * reductionFactor;
22
+ // Calculate font size for copy2
23
+ const calculationLength2 = len2 === 0 ? 1 : len2;
24
+ const size2 = baseSizeRem2 + Math.max(0, maxLengthThreshold - calculationLength2) * reductionFactor;
25
+ return {
26
+ fontSize_01: `${size1}rem`,
27
+ fontSize_02: `${size2}rem`
28
+ };
29
+ };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "zuljaman-banner-components",
3
+ "version": "1.0.0",
4
+ "description": "Shared banner components package for Next.js and AWS Lambda platforms",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "rm -rf dist tsconfig.tsbuildinfo && tsc",
12
+ "dev": "tsc --watch",
13
+ "clean": "rm -rf dist",
14
+ "prepack": "npm run build",
15
+ "pack:test": "npm pack",
16
+ "pack:dry": "npm pack --dry-run",
17
+ "prepublishOnly": "npm run clean && npm run build",
18
+ "version": "npm run build",
19
+ "postversion": "git push && git push --tags",
20
+ "test": "jest",
21
+ "test:watch": "jest --watch",
22
+ "lint": "eslint src --ext .ts,.tsx",
23
+ "lint:fix": "eslint src --ext .ts,.tsx --fix"
24
+ },
25
+ "dependencies": {
26
+ "react": "^19.0.0",
27
+ "react-dom": "^19.0.0",
28
+ "clsx": "^2.1.1"
29
+ },
30
+ "peerDependencies": {
31
+ "next": ">=14.0.0"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "next": {
35
+ "optional": true
36
+ }
37
+ },
38
+ "devDependencies": {
39
+ "@types/react": "^19.0.0",
40
+ "@types/react-dom": "^19.0.0",
41
+ "typescript": "^5.0.0",
42
+ "@types/jest": "^29.5.0",
43
+ "jest": "^29.5.0",
44
+ "jest-environment-jsdom": "^29.5.0",
45
+ "ts-jest": "^29.1.0",
46
+ "@testing-library/react": "^16.0.0",
47
+ "@testing-library/jest-dom": "^6.0.0",
48
+ "eslint": "^8.0.0",
49
+ "@typescript-eslint/parser": "^6.0.0",
50
+ "@typescript-eslint/eslint-plugin": "^6.0.0"
51
+ },
52
+ "keywords": [
53
+ "react",
54
+ "nextjs",
55
+ "banner",
56
+ "components",
57
+ "shared",
58
+ "typescript"
59
+ ],
60
+ "author": "Zuljaman Team",
61
+ "license": "MIT"
62
+ }