Giter Site home page Giter Site logo

higgo36 / portable-react-next-component-library Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 311 KB

React Next.js Component Library built for user portability into other JavaScript Frameworks by abstracting the logic.

Home Page: https://portable-react-next-library.vercel.app

TypeScript 89.23% SCSS 9.54% JavaScript 1.24%
babel components-library jest lottie-react material-ui mui-material next-routes nextjs portability prettier

portable-react-next-component-library's Introduction

Portable Web Components with Next.js

This project demonstrates how to create and use React Next.js components with enhanced portability across various JavaScript frameworks. The project provides a comprehensive set of examples, showcasing best practices for creating and using these universal components.

The main goal is to offer a robust starting point for developers looking to leverage the power of React in diverse environments. It also serves as a resource for uniquely styled free-to-use web components designed by myself.

Web App Deployed on Vercel - https://portable-react-next-library-4bca8n9zi-higgo9339.vercel.app/

Installation

To install the project, you will need to have Node.js and npm installed on your machine. Once these prerequisites are met, follow the steps below:

  1. Clone the repository: git clone <repository-url>
  2. Move into the project directory: cd <project-directory>
  3. Install the dependencies: npm install --legacy-peer-deps

Usage

You can run the project in development mode with npm run dev. This will start the development server on http://localhost:3000.

To build the project for production, use npm run build.

Examples

PremiumTemplate

The PremiumTemplate component represents a premium template layout. It includes a header, various navigation sections, a main content body, an accordion section, and an ad case.

    import React from 'react';
    import { Typography, Box } from '@mui/material';

    interface PremiumTemplateProps {
    title?: string;
    customMetaTags?: React.ReactElement[];
    bodyClassName?: string;
    component: React.ReactNode;
    }

    const PremiumTemplate: React.FC<PremiumTemplateProps> = ({
    title,
    customMetaTags,
    bodyClassName,
    component
    }) => {
    return (
    <>
    <header>
    <!-- GlobalHeader code here -->
    </header>

    <div className="content">
    <div className="body-wrapper">
    <Box className={bodyClassName}>
    {component}

    <!-- GlobalAccordion code here -->
    <!-- GlobalAdCase code here -->
    </Box>
    </div>
    </div>

    <footer>
    <!-- GlobalFooter code here -->
    </footer>
    </>
    );
    };

    export default PremiumTemplate;

PremiumTemplateWrapper

The PremiumTemplateWrapper component is a wrapper that simplifies the usage of the PremiumTemplate. It takes title, customMetaTags, bodyClassName, and component as props.

    import React from 'react';
    import PremiumTemplate from '../templates/PremiumTemplate';

    interface PremiumTemplateWrapperProps {
    title: string;
    customMetaTags?: React.ReactElement[];
    bodyClassName?: string;
    component: React.ReactNode;
    }

    const PremiumTemplateWrapper: React.FC<PremiumTemplateWrapperProps> = ({
    title,
    customMetaTags,
    bodyClassName,
    component,
    }) => {
    return (
    <PremiumTemplate
    title={title}
    customMetaTags={customMetaTags}
    bodyClassName={bodyClassName}
    component={component}
    />
    );
    };

    export default PremiumTemplateWrapper;

To use the PremiumTemplateWrapper, import it and use it as follows:

    import React from 'react';
    import PremiumTemplateWrapper from '../wrappers/PremiumTemplateWrapper';

    const MyComponent: React.FC = () => {

    // Your component logic here

    return (
    <PremiumTemplateWrapper
    title="My Premium Template"
    customMetaTags={[<meta key="description" name="description" content="My custom meta description" />]}
    bodyClassName="my-custom-body-class"
    component={<div>My component
    return (
    <PremiumTemplateWrapper
    title="My Premium Template"
    customMetaTags={[<meta key="description" name="description" content="My custom meta description" />]}
    bodyClassName="my-custom-body-class"
    component={<div>My component content</div>}
    />
    );
    };

    export default MyComponent;

In the above example, the PremiumTemplateWrapper is used to wrap your component, providing the necessary props for the PremiumTemplate. Customize the props according to your needs.

Contributing

As this project is maintained solely by myself, it is currently not open to contributions. However, feel free to explore the codebase and use it as a reference for your own projects!

License

This project is open source and available under the MIT License.

portable-react-next-component-library's People

Contributors

higgo36 avatar higgo3636 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.