BootstrapBlocks is a React project that provides a collection of Bootstrap components and code snippets for easy integration into your web projects.
- Introduction
- Features
- Installation
- Usage
- Screenshots
- Reusable Components
- Topics Covered
- Contributing
- Contributor Guidelines
- License
- CDN Used
BootstrapBlocks is a React-based project designed to simplify the integration of Bootstrap components and code snippets into your web applications. It offers a range of pre-built components and responsive designs to enhance your development workflow.
- Ready-to-use Bootstrap components
- React-based architecture for easy customization
- Streamlined development with pre-made code snippets
- Responsive design for diverse screen sizes
To get started with BootstrapBlocks, follow these steps:
-
Clone the repository:
git clone https://github.com/sangamprashant/bootstrap-blocks.git
-
Navigate to the project directory:
cd bootstrap-blocks
-
Install dependencies:
npm install
To run the project locally:
- Start the development server:
npm start
- Open your browser and visit
http://localhost:3000
to view the project.
Here are some of the reusable components included in the project:
A customizable primary button that adapts to the current theme.
import React, { useContext } from "react";
import { AppContext } from "../../context/AppContext";
const PrimaryButton = ({ label, c, onClick }) => {
const { themePrimary, themePrimaryR } = useContext(AppContext);
return (
<button
type="button"
className={`btn btn-${
themePrimaryR ? "outline-" : ""
}${themePrimary} btn-lg px-4 ${c}`}
onClick={onClick}
>
{label}
</button>
);
};
export default PrimaryButton;
A customizable secondary button with theme support.
import React, { useContext } from "react";
import { AppContext } from "../../context/AppContext";
const SecondaryButton = ({ label, c, onClick }) => {
const { secondaryPrimary, secondaryPrimaryR } = useContext(AppContext);
return (
<button
type="button"
className={`btn btn-${
secondaryPrimaryR ? "outline-" : ""
}${secondaryPrimary} btn-lg px-4 ${c}`}
onClick={onClick}
>
{label}
</button>
);
};
export default SecondaryButton;
This application covers the following topics:
-
Bootstrap Integration:
- Usage of Bootstrap for responsive and styled components.
-
Reusable React Components:
- Creation and use of reusable React components like
PrimaryButton
andSecondaryButton
.
- Creation and use of reusable React components like
-
React Context API:
- Implementation of the Context API for managing theme colors and other global state.
-
Component Customization:
- Customizing components based on the current theme and user preferences.
-
Component Preview and Templates:
- How to add new components to the preview and template sections of the application.
-
Development Setup:
- Instructions for cloning the repository, installing dependencies, and running the development server.
-
Contribution Guidelines:
- Detailed steps for contributing to the project, including adding new components and updating the preview and template functions.
-
Image Handling:
- Guidelines for managing images in the project, including saving them in the
public
folder and referencing them correctly in documentation.
- Guidelines for managing images in the project, including saving them in the
-
Testing and Quality Assurance:
- Suggestions for testing new components and ensuring code quality before submission. Consider using tools like Jest for unit testing and ESLint for linting.
-
Project Structure:
- Overview of the project structure, including directories and key files, to help new developers understand the layout and organization.
We welcome contributions to BootstrapBlocks! To contribute:
-
Fork the repository.
-
Create a new branch for your feature:
git checkout -b feature-name
-
Make your changes and commit them:
git commit -m 'Add new feature'
-
Add a new component:
- Create a new file for your component in the appropriate directory (
./src/components/tamplate
). - Follow the existing component structure and naming conventions.
- Export the component from your file.
- Create a new file for your component in the appropriate directory (
-
Attach the component to the preview array:
- Open
src/components/Preview/index.js
. - Import your new component at the top of the file.
- Add your component to the relevant section of the
getPreview
function.
import NewComponentDayA from "./NewComponent/NewComponentDay/A"; import NewComponentNightA from "./NewComponent/NewComponentNight/A"; export default function getPreview({ darkMode = false }) { return { // other sections... NewComponent: { NewComponentA: darkMode ? ( <NewComponentNightA height="100" width="100%" /> ) : ( <NewComponentDayA height="100" width="100%" /> ), }, }; }
- Open
-
Update the
getTemplate
function:- Open
src/components/tamplate/index.js
. - Import your new component at the top of the file.
- Add your component to the appropriate section in the
getTemplate
function to ensure it's available for use in templates.
import NewComponentTemplateA from "./NewComponentTemplate/A"; import NewComponentTemplateB from "./NewComponentTemplate/B"; export default function getTemplate() { return { // other sections... NewComponent: { NewComponentA: <NewComponentTemplateA height="100" width="100%" />, NewComponentB: <NewComponentTemplateB height="100" width="100%" />, }, }; }
- Open
-
Push to the branch:
git push origin feature-name
-
Submit a pull request.
To ensure a smooth contribution process:
-
Name and Image:
- Contributors are encouraged to use their names in the documentation and contributions.
- If including images in documentation, save them in the
public
folder of the project. - When referencing images in the documentation, use the following format:
Avoid using
<img src="imagename.extension" alt="description" />
./
or/
in thesrc
attribute.
-
Code Quality:
- Ensure your code adheres to the project's coding standards and best practices.
- Include comments and documentation where necessary.
-
Testing:
- Write tests for new components and functionality where applicable.
- Ensure all tests pass before submitting a pull request.
This project is licensed under the MIT License. You are free to use and modify the code for your own projects.
CDN Used: Bootstrap CDN
https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css