ui-humix-lib
Version:
A simple package for implementinghumix design components in react-based or node.js based projects.
35 lines (26 loc) • 1.63 kB
JavaScript
// index.js
// Assuming you have JavaScript components in the /components directory
// and you want to export them for use in other projects.
// Importing components from the components directory
// Replace `ComponentName` with actual component file names
import ComponentName from "./components/ComponentName";
// Assuming HTML files in the _html directory are to be used as templates or strings
// You might need a build step to import HTML content as strings, depending on your setup
// For demonstration, this will just point to how it could be structured
// A function to require all HTML files from a directory (Node.js context)
// This requires a build step or runtime capable of handling dynamic requires, like webpack or Node.js with a specific loader
const requireHTML = (context) => {
return context.keys().map(context);
};
// Importing HTML files as strings (this is conceptual and might need adjustment based on your build tool)
const htmlTemplates = requireHTML(
require.context("./components/html", false, /\.html$/)
);
// Exporting components and HTML templates
export { ComponentName, htmlTemplates };
// If you have multiple components, you can export them in a similar manner
// Just make sure to import them at the top and then add them to the export statement
// Note: This approach assumes a build system capable of handling ES6 imports/exports,
// and dynamic requires for HTML files. If you're using a different module system (like CommonJS),
// or if your project setup doesn't support dynamic requires without additional configuration,
// you'll need to adjust the implementation accordingly.