@nodeblocks/frontend-footer-block 0.0.2
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/dist/blocks.d.ts +19 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/footer.d.ts +23 -0
- package/dist/footer.d.ts.map +1 -0
- package/dist/index.cjs.js +70 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +68 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/lib.d.ts +31 -0
- package/dist/lib.d.ts.map +1 -0
- package/package.json +34 -0
- package/readme.md +57 -0
package/dist/blocks.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type DefaultBlocks = {
|
|
3
|
+
FooterLogo: React.FC<{
|
|
4
|
+
src: string;
|
|
5
|
+
alt?: string;
|
|
6
|
+
}>;
|
|
7
|
+
FooterText: React.FC<{
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
FooterCopyright: React.FC<{
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
export type DefaultOptions = {
|
|
15
|
+
hideTitle?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const defaultOptions: DefaultOptions;
|
|
18
|
+
export declare const defaultBlocks: DefaultBlocks;
|
|
19
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;IACpD,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAE5B,CAAC;AAgBF,eAAO,MAAM,aAAa,EAAE,aAQ3B,CAAC"}
|
package/dist/footer.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DefaultBlocks } from "./blocks";
|
|
3
|
+
import "./footer.css";
|
|
4
|
+
export type FooterChildren = (props: {
|
|
5
|
+
defaultBlocks: DefaultBlocks;
|
|
6
|
+
settings?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
}) => {
|
|
10
|
+
blocks: Partial<DefaultBlocks>;
|
|
11
|
+
settings?: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const Footer: ({ logoSrc, items, className, children, copyright }: {
|
|
16
|
+
className: string;
|
|
17
|
+
logoSrc: string;
|
|
18
|
+
copyright: React.ReactNode | string;
|
|
19
|
+
items: Array<React.ReactNode>;
|
|
20
|
+
children?: FooterChildren;
|
|
21
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default Footer;
|
|
23
|
+
//# sourceMappingURL=footer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../src/footer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAiB,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,cAAc,CAAC;AAEtB,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CAClC,KACI;IACH,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CACnC,CAAC;AAEF,QAAA,MAAM,MAAM,GAAI,oDAKd;IACA,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;IACpC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,4CAaA,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
function setBlocks(defaultBlocks, defaultOptions, children) {
|
|
6
|
+
const results = children
|
|
7
|
+
? children({ defaultBlocks, ...defaultOptions })
|
|
8
|
+
: { blocks: {}, ...defaultOptions };
|
|
9
|
+
const { blocks: customBlocks = {} } = results;
|
|
10
|
+
return {
|
|
11
|
+
...results,
|
|
12
|
+
blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
|
|
13
|
+
key,
|
|
14
|
+
customBlocks[key] || defaultComponent,
|
|
15
|
+
])),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Utility function to join class names together, ignoring undefined or nil values.
|
|
20
|
+
* @param classes - The class names to join.
|
|
21
|
+
* @returns The joined class names.
|
|
22
|
+
*/
|
|
23
|
+
function classNames(...classes) {
|
|
24
|
+
return classes.flat().filter(Boolean).join(' ');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const defaultBlocks = {
|
|
28
|
+
FooterLogo: ({ src, alt }) => (jsxRuntime.jsx("img", { className: "nbb-footer-logo", src: src, alt: alt || 'Footer logo' })),
|
|
29
|
+
FooterText: ({ children }) => jsxRuntime.jsx("p", { className: "nbb-footer-text", children: children }),
|
|
30
|
+
FooterCopyright: ({ children }) => (jsxRuntime.jsx("p", { className: "nbb-footer-copyright", children: children })),
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function styleInject(css, ref) {
|
|
34
|
+
if ( ref === void 0 ) ref = {};
|
|
35
|
+
var insertAt = ref.insertAt;
|
|
36
|
+
|
|
37
|
+
if (typeof document === 'undefined') { return; }
|
|
38
|
+
|
|
39
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
40
|
+
var style = document.createElement('style');
|
|
41
|
+
style.type = 'text/css';
|
|
42
|
+
|
|
43
|
+
if (insertAt === 'top') {
|
|
44
|
+
if (head.firstChild) {
|
|
45
|
+
head.insertBefore(style, head.firstChild);
|
|
46
|
+
} else {
|
|
47
|
+
head.appendChild(style);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
head.appendChild(style);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (style.styleSheet) {
|
|
54
|
+
style.styleSheet.cssText = css;
|
|
55
|
+
} else {
|
|
56
|
+
style.appendChild(document.createTextNode(css));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var css_248z = "/* footer.css */\n.nbb-footer {\n --color-object-accent-primary: #006EAD;\n --color-text-on-primary: #fff;\n \n background-color: var(--color-object-accent-primary);\n color: var(--color-text-on-primary);\n padding: 16px; \n text-align: left;\n }\n \n .nbb-footer-title {\n font-size: 24px;\n font-weight: bold;\n margin-bottom: 16px;\n }\n \n .nbb-footer-text {\n font-size: 16px;\n margin-bottom: 8px;\n }\n .nbb-footer-text a {\n color: inherit\n }\n .nbb-footer-text a:hover {\n text-decoration: underline;\n }\n \n \n .nbb-footer-copyright {\n font-size: 14px;\n margin-top: 16px;\n }\n ";
|
|
61
|
+
styleInject(css_248z);
|
|
62
|
+
|
|
63
|
+
const Footer = ({ logoSrc, items = [], className, children, copyright }) => {
|
|
64
|
+
const { blocks } = setBlocks(defaultBlocks, {}, children);
|
|
65
|
+
const { FooterLogo, FooterText, FooterCopyright } = blocks;
|
|
66
|
+
return (jsxRuntime.jsxs("footer", { className: classNames("nbb-footer", className), children: [jsxRuntime.jsx(FooterLogo, { src: logoSrc }), items.map((item, index) => (jsxRuntime.jsx(FooterText, { children: item }, index))), jsxRuntime.jsx(FooterCopyright, { children: copyright })] }));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.Footer = Footer;
|
|
70
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/lib.ts","../src/blocks.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/footer.tsx"],"sourcesContent":["import { DefaultBlocks, DefaultOptions } from './blocks';\n\n/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param children - An optional function that returns custom blocks and arguments.\n * @param args - Additional unknown arguments.\n * @returns An object containing the merged blocks and additional arguments.\n */\n\n\ntype ChildrenProps = {\n defaultBlocks: DefaultBlocks;\n};\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n defaultOptions: DefaultOptions,\n children?: (props: ChildrenProps) => DefaultOptions & {\n blocks: { [x: string]: any };\n },\n) {\n const results = children\n ? children({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n const {\n blocks: customBlocks = {}\n } = results;\n return {\n ...results,\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n };\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import React from 'react';\n\nexport type DefaultBlocks = {\n FooterLogo: React.FC<{ src: string; alt?: string }>;\n FooterText: React.FC<{ children: React.ReactNode }>;\n FooterCopyright: React.FC<{ children: React.ReactNode }>;\n};\n\nexport type DefaultOptions = {\n hideTitle?: boolean;\n};\n\nexport const defaultOptions: DefaultOptions = {\n hideTitle: false,\n};\n\nfunction FooterTitle({ children }: { children: React.ReactNode }) {\n return <h2 className=\"nbb-footer-title\">{children}</h2>;\n}\n\nfunction FooterText({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-text\">{children}</p>;\n}\n\nfunction FooterCopyright({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-copyright\">{children}</p>;\n}\n\n\n\nexport const defaultBlocks: DefaultBlocks = {\n FooterLogo: ({ src, alt }) => (\n <img className=\"nbb-footer-logo\" src={src} alt={alt || 'Footer logo'} />\n ),\n FooterText: ({ children }) => <p className=\"nbb-footer-text\">{children}</p>,\n FooterCopyright: ({ children }) => (\n <p className=\"nbb-footer-copyright\">{children}</p>\n ),\n};","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React from \"react\";\nimport { setBlocks, classNames } from \"./lib\";\nimport { defaultBlocks, DefaultBlocks } from \"./blocks\";\nimport \"./footer.css\";\n\nexport type FooterChildren = (props: {\n defaultBlocks: DefaultBlocks,\n settings?: { [key: string]: any }\n}\n) => {\n blocks: Partial<DefaultBlocks>;\n settings?: { [key: string]: any };\n};\n\nconst Footer = ({\n logoSrc,\n items = [],\n className,\n children, copyright }:\n {\n className: string;\n logoSrc: string;\n copyright: React.ReactNode | string;\n items: Array<React.ReactNode>;\n children?: FooterChildren;\n}) => {\n const { blocks } = setBlocks(defaultBlocks, {}, children);\n const { FooterLogo, FooterText, FooterCopyright } = blocks;\n\n return (\n <footer className={classNames(\"nbb-footer\", className)}>\n <FooterLogo src={logoSrc} />\n {items.map((item, index) => (\n <FooterText key={index}>{item}</FooterText>\n ))}\n <FooterCopyright>{copyright}</FooterCopyright>\n </footer>\n );\n};\n\nexport default Footer;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;SAgBgB,SAAS,CACvB,aAA4B,EAC5B,cAA8B,EAC9B,QAEC,EAAA;IAED,MAAM,OAAO,GAAG;UACZ,QAAQ,CAAC,EAAE,aAAa,EAAE,GAAG,cAAc,EAAE;UAC7C,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,cAAc,EAAE;IACrC,MAAM,EACJ,MAAM,EAAE,YAAY,GAAG,EAAE,EAC1B,GAAG,OAAO;IACX,OAAO;AACL,QAAA,GAAG,OAAO;QACV,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,gBAAgB,CAAC,KAAK;YAC7D,GAAG;AACH,YAAA,YAAY,CAAC,GAAG,CAAC,IAAI,gBAAgB;AACtC,SAAA,CAAC,CACH;KACF;AACH;AAIA;;;;AAIG;AACa,SAAA,UAAU,CAAC,GAAG,OAAoB,EAAA;AAChD,IAAA,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GA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AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC3B;;AAEA,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG;AAClC,GAAG,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AACnD;AACA;;;;;ACXA,MAAM,MAAM,GAAG,CAAC,EACd,OAAO,EACP,KAAK,GAAG,EAAE,EACV,SAAS,EACT,QAAQ,EAAE,SAAS,EAOpB,KAAI;AACH,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,aAAa,EAAE,EAAE,EAAE,QAAQ,CAAC;IACzD,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM;IAE1D,QACEC,4BAAQ,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CACpDD,eAAC,UAAU,EAAA,EAAC,GAAG,EAAE,OAAO,GAAI,EAC3B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACrBA,cAAC,CAAA,UAAU,EAAc,EAAA,QAAA,EAAA,IAAI,EAAZ,EAAA,KAAK,CAAqB,CAC5C,CAAC,EACFA,cAAC,CAAA,eAAe,cAAE,SAAS,EAAA,CAAmB,CACvC,EAAA,CAAA;AAEb;;;;","x_google_ignoreList":[2]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
function setBlocks(defaultBlocks, defaultOptions, children) {
|
|
4
|
+
const results = children
|
|
5
|
+
? children({ defaultBlocks, ...defaultOptions })
|
|
6
|
+
: { blocks: {}, ...defaultOptions };
|
|
7
|
+
const { blocks: customBlocks = {} } = results;
|
|
8
|
+
return {
|
|
9
|
+
...results,
|
|
10
|
+
blocks: Object.fromEntries(Object.entries(defaultBlocks).map(([key, defaultComponent]) => [
|
|
11
|
+
key,
|
|
12
|
+
customBlocks[key] || defaultComponent,
|
|
13
|
+
])),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Utility function to join class names together, ignoring undefined or nil values.
|
|
18
|
+
* @param classes - The class names to join.
|
|
19
|
+
* @returns The joined class names.
|
|
20
|
+
*/
|
|
21
|
+
function classNames(...classes) {
|
|
22
|
+
return classes.flat().filter(Boolean).join(' ');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const defaultBlocks = {
|
|
26
|
+
FooterLogo: ({ src, alt }) => (jsx("img", { className: "nbb-footer-logo", src: src, alt: alt || 'Footer logo' })),
|
|
27
|
+
FooterText: ({ children }) => jsx("p", { className: "nbb-footer-text", children: children }),
|
|
28
|
+
FooterCopyright: ({ children }) => (jsx("p", { className: "nbb-footer-copyright", children: children })),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function styleInject(css, ref) {
|
|
32
|
+
if ( ref === void 0 ) ref = {};
|
|
33
|
+
var insertAt = ref.insertAt;
|
|
34
|
+
|
|
35
|
+
if (typeof document === 'undefined') { return; }
|
|
36
|
+
|
|
37
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
38
|
+
var style = document.createElement('style');
|
|
39
|
+
style.type = 'text/css';
|
|
40
|
+
|
|
41
|
+
if (insertAt === 'top') {
|
|
42
|
+
if (head.firstChild) {
|
|
43
|
+
head.insertBefore(style, head.firstChild);
|
|
44
|
+
} else {
|
|
45
|
+
head.appendChild(style);
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
head.appendChild(style);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (style.styleSheet) {
|
|
52
|
+
style.styleSheet.cssText = css;
|
|
53
|
+
} else {
|
|
54
|
+
style.appendChild(document.createTextNode(css));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var css_248z = "/* footer.css */\n.nbb-footer {\n --color-object-accent-primary: #006EAD;\n --color-text-on-primary: #fff;\n \n background-color: var(--color-object-accent-primary);\n color: var(--color-text-on-primary);\n padding: 16px; \n text-align: left;\n }\n \n .nbb-footer-title {\n font-size: 24px;\n font-weight: bold;\n margin-bottom: 16px;\n }\n \n .nbb-footer-text {\n font-size: 16px;\n margin-bottom: 8px;\n }\n .nbb-footer-text a {\n color: inherit\n }\n .nbb-footer-text a:hover {\n text-decoration: underline;\n }\n \n \n .nbb-footer-copyright {\n font-size: 14px;\n margin-top: 16px;\n }\n ";
|
|
59
|
+
styleInject(css_248z);
|
|
60
|
+
|
|
61
|
+
const Footer = ({ logoSrc, items = [], className, children, copyright }) => {
|
|
62
|
+
const { blocks } = setBlocks(defaultBlocks, {}, children);
|
|
63
|
+
const { FooterLogo, FooterText, FooterCopyright } = blocks;
|
|
64
|
+
return (jsxs("footer", { className: classNames("nbb-footer", className), children: [jsx(FooterLogo, { src: logoSrc }), items.map((item, index) => (jsx(FooterText, { children: item }, index))), jsx(FooterCopyright, { children: copyright })] }));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { Footer };
|
|
68
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/lib.ts","../src/blocks.tsx","../node_modules/style-inject/dist/style-inject.es.js","../src/footer.tsx"],"sourcesContent":["import { DefaultBlocks, DefaultOptions } from './blocks';\n\n/**\n * Sets the blocks by merging default blocks with custom blocks provided by the children function.\n *\n * @param defaultBlocks - The default blocks to be used.\n * @param children - An optional function that returns custom blocks and arguments.\n * @param args - Additional unknown arguments.\n * @returns An object containing the merged blocks and additional arguments.\n */\n\n\ntype ChildrenProps = {\n defaultBlocks: DefaultBlocks;\n};\n\nexport function setBlocks(\n defaultBlocks: DefaultBlocks,\n defaultOptions: DefaultOptions,\n children?: (props: ChildrenProps) => DefaultOptions & {\n blocks: { [x: string]: any };\n },\n) {\n const results = children\n ? children({ defaultBlocks, ...defaultOptions })\n : { blocks: {}, ...defaultOptions };\n const {\n blocks: customBlocks = {}\n } = results;\n return {\n ...results,\n blocks: Object.fromEntries(\n Object.entries(defaultBlocks).map(([key, defaultComponent]) => [\n key,\n customBlocks[key] || defaultComponent,\n ])\n ),\n };\n}\n\ntype ClassName = string | ClassName[] | undefined | null;\n\n/**\n * Utility function to join class names together, ignoring undefined or nil values.\n * @param classes - The class names to join.\n * @returns The joined class names.\n */\nexport function classNames(...classes: ClassName[]): string {\n return classes.flat().filter(Boolean).join(' ');\n}\n","import React from 'react';\n\nexport type DefaultBlocks = {\n FooterLogo: React.FC<{ src: string; alt?: string }>;\n FooterText: React.FC<{ children: React.ReactNode }>;\n FooterCopyright: React.FC<{ children: React.ReactNode }>;\n};\n\nexport type DefaultOptions = {\n hideTitle?: boolean;\n};\n\nexport const defaultOptions: DefaultOptions = {\n hideTitle: false,\n};\n\nfunction FooterTitle({ children }: { children: React.ReactNode }) {\n return <h2 className=\"nbb-footer-title\">{children}</h2>;\n}\n\nfunction FooterText({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-text\">{children}</p>;\n}\n\nfunction FooterCopyright({ children }: { children: React.ReactNode }) {\n return <p className=\"nbb-footer-copyright\">{children}</p>;\n}\n\n\n\nexport const defaultBlocks: DefaultBlocks = {\n FooterLogo: ({ src, alt }) => (\n <img className=\"nbb-footer-logo\" src={src} alt={alt || 'Footer logo'} />\n ),\n FooterText: ({ children }) => <p className=\"nbb-footer-text\">{children}</p>,\n FooterCopyright: ({ children }) => (\n <p className=\"nbb-footer-copyright\">{children}</p>\n ),\n};","function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React from \"react\";\nimport { setBlocks, classNames } from \"./lib\";\nimport { defaultBlocks, DefaultBlocks } from \"./blocks\";\nimport \"./footer.css\";\n\nexport type FooterChildren = (props: {\n defaultBlocks: DefaultBlocks,\n settings?: { [key: string]: any }\n}\n) => {\n blocks: Partial<DefaultBlocks>;\n settings?: { [key: string]: any };\n};\n\nconst Footer = ({\n logoSrc,\n items = [],\n className,\n children, copyright }:\n {\n className: string;\n logoSrc: string;\n copyright: React.ReactNode | string;\n items: Array<React.ReactNode>;\n children?: FooterChildren;\n}) => {\n const { blocks } = setBlocks(defaultBlocks, {}, children);\n const { FooterLogo, FooterText, FooterCopyright } = blocks;\n\n return (\n <footer className={classNames(\"nbb-footer\", className)}>\n <FooterLogo src={logoSrc} />\n {items.map((item, index) => (\n <FooterText key={index}>{item}</FooterText>\n ))}\n <FooterCopyright>{copyright}</FooterCopyright>\n </footer>\n );\n};\n\nexport default Footer;\n"],"names":["_jsx","_jsxs"],"mappings":";;SAgBgB,SAAS,CACvB,aAA4B,EAC5B,cAA8B,EAC9B,QAEC,EAAA;IAED,MAAM,OAAO,GAAG;UACZ,QAAQ,CAAC,EAAE,aAAa,EAAE,GAAG,cAAc,EAAE;UAC7C,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,cAAc,EAAE;IACrC,MAAM,EACJ,MAAM,EAAE,YAAY,GAAG,EAAE,EAC1B,GAAG,OAAO;IACX,OAAO;AACL,QAAA,GAAG,OAAO;QACV,MAAM,EAAE,MAAM,CA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B,CACvC,EAAA,CAAA;AAEb;;;;","x_google_ignoreList":[2]}
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DefaultBlocks, DefaultOptions } from './blocks';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the blocks by merging default blocks with custom blocks provided by the children function.
|
|
4
|
+
*
|
|
5
|
+
* @param defaultBlocks - The default blocks to be used.
|
|
6
|
+
* @param children - An optional function that returns custom blocks and arguments.
|
|
7
|
+
* @param args - Additional unknown arguments.
|
|
8
|
+
* @returns An object containing the merged blocks and additional arguments.
|
|
9
|
+
*/
|
|
10
|
+
type ChildrenProps = {
|
|
11
|
+
defaultBlocks: DefaultBlocks;
|
|
12
|
+
};
|
|
13
|
+
export declare function setBlocks(defaultBlocks: DefaultBlocks, defaultOptions: DefaultOptions, children?: (props: ChildrenProps) => DefaultOptions & {
|
|
14
|
+
blocks: {
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
};
|
|
17
|
+
}): {
|
|
18
|
+
blocks: {
|
|
19
|
+
[k: string]: any;
|
|
20
|
+
};
|
|
21
|
+
hideTitle?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type ClassName = string | ClassName[] | undefined | null;
|
|
24
|
+
/**
|
|
25
|
+
* Utility function to join class names together, ignoring undefined or nil values.
|
|
26
|
+
* @param classes - The class names to join.
|
|
27
|
+
* @returns The joined class names.
|
|
28
|
+
*/
|
|
29
|
+
export declare function classNames(...classes: ClassName[]): string;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEzD;;;;;;;GAOG;AAGH,KAAK,aAAa,GAAG;IACnB,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,wBAAgB,SAAS,CACvB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,cAAc,GAAG;IACpD,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC9B;;;;;EAiBF;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,CAE1D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nodeblocks/frontend-footer-block",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"module": "dist/index.esm.js",
|
|
6
|
+
"browser": "dist/index.iife.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/",
|
|
10
|
+
"dist/index.css"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rollup -c",
|
|
14
|
+
"watch": "rollup -c --watch"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"react": "^18.3.1",
|
|
18
|
+
"react-dom": "^18.0.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
22
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
23
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
24
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
25
|
+
"@types/react": "^18.3.12",
|
|
26
|
+
"@types/react-dom": "^18.3.1",
|
|
27
|
+
"rollup": "^4.28.0",
|
|
28
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
29
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
30
|
+
"rollup-plugin-serve": "^1.1.1",
|
|
31
|
+
"tslib": "^2.8.1",
|
|
32
|
+
"typescript": "^5.7.2"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
## ๐ Nodeblocks Frontend Starter Kit
|
|
2
|
+
|
|
3
|
+
Welcome to the Nodeblocks Frontend Starter Kit! ๐ This kit is designed to make building frontend libraries in React super easy, helping you streamline your development workflow with minimal fuss. Let's dive in! ๐คฟ
|
|
4
|
+
|
|
5
|
+
### โจ Features
|
|
6
|
+
- **๐ Bundling with Rollup:** Get a clean, minimalistic approach to bundling your JavaScript files for smoother frontend development.
|
|
7
|
+
- **๐ TypeScript Support:** We've included a pre-configured `tsconfig.json` to ensure your TypeScript setup is strict, efficient, and ready to go.
|
|
8
|
+
- **โ๏ธ Peer Dependencies:** Keep bundle sizes lean with React and React DOM set as peer dependencies.
|
|
9
|
+
- **๐จ CSS Support:** Easily import and process CSS files, giving you more control over your styles.
|
|
10
|
+
|
|
11
|
+
### ๐ ๏ธ How to Use
|
|
12
|
+
1. **Clone this repository** ๐:
|
|
13
|
+
```bash
|
|
14
|
+
git clone <repository-url>
|
|
15
|
+
cd <repository-directory>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. **Install dependencies** ๐ฆ:
|
|
19
|
+
```bash
|
|
20
|
+
npm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. **Start development** ๐ ๏ธ:
|
|
24
|
+
```bash
|
|
25
|
+
npm run watch
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
4. **Build for production** ๐๏ธ:
|
|
29
|
+
```bash
|
|
30
|
+
npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ๐งช How to Test
|
|
34
|
+
|
|
35
|
+
The `test` folder contains examples that demonstrate how to use the libraries you create with this starter kit. These examples show compatibility with various bundlers, such as:
|
|
36
|
+
|
|
37
|
+
- **Create React App** (Webpack)
|
|
38
|
+
- **Vite** โก
|
|
39
|
+
- **Rollup** (itself) (Coming soon) ๐
|
|
40
|
+
- **Parcel** (Coming soon) ๐ฆ
|
|
41
|
+
|
|
42
|
+
This ensures Nodeblocks libraries integrate seamlessly with different workflows. ๐ ๏ธโจ
|
|
43
|
+
|
|
44
|
+
**Before running each project make sure you run `npm link`:**
|
|
45
|
+
|
|
46
|
+
1. In the root of this project:
|
|
47
|
+
```bash
|
|
48
|
+
npm link
|
|
49
|
+
```
|
|
50
|
+
2. In the test project you want to run:
|
|
51
|
+
```bash
|
|
52
|
+
npm i
|
|
53
|
+
npm link @basaldev/frontend-starter-kit
|
|
54
|
+
```
|
|
55
|
+
(Note that in real life your library would not be called frontend-starter-kit.)
|
|
56
|
+
|
|
57
|
+
3. Then you can follow your usual workflow either with **Create React App** (`npm start`) or with Vite (`npm run dev`). This will give you a development environment where whenever you change your library it will be available in your test project.
|