|
| 1 | +# RecyThing - Website (Admin) |
| 2 | + |
| 3 | +## Table of Contents |
| 4 | + |
| 5 | +- [RecyThing - Website (Admin)](#recything---website-admin) |
| 6 | + - [Table of Contents](#table-of-contents) |
| 7 | + - [How To Export Your Modules (Re-exporting)](#how-to-export-your-modules-re-exporting) |
| 8 | + - [Naming Conventions](#naming-conventions) |
| 9 | + - [Project Documents](#project-documents) |
| 10 | + - [References](#references) |
| 11 | + |
| 12 | +## How To Export Your Modules (Re-exporting) |
| 13 | + |
| 14 | +_Why do we need to re-export our modules?_ |
| 15 | + |
| 16 | +> We need to re-export our modules so that we can import them from a single file instead of importing them from multiple files. |
| 17 | +
|
| 18 | +_How to re-export our modules?_ |
| 19 | + |
| 20 | +1. create a folder named `button` in `src/components` |
| 21 | +2. create a file named `index.js` in `src/components/button` for re-exporting your button component |
| 22 | +3. create a file named `YourButton.js` in `src/components/button` for your button component |
| 23 | +4. in `src/components/button/YourButton.js`: |
| 24 | + |
| 25 | + > this file will act as your button component |
| 26 | +
|
| 27 | + ```js |
| 28 | + import React from "react"; |
| 29 | + |
| 30 | + export function YourButton() { |
| 31 | + return <button>Your Button</button>; |
| 32 | + } |
| 33 | + ``` |
| 34 | + |
| 35 | +5. in `src/components/button/index.js`: |
| 36 | + |
| 37 | + > this file will act as a re-exporter for your button component |
| 38 | +
|
| 39 | + ```js |
| 40 | + export { YourButton } from "./YourButton"; |
| 41 | + // or if you have multiple components in this folder |
| 42 | + export * from "./YourButton"; |
| 43 | + ``` |
| 44 | + |
| 45 | +6. lastly, in `src/components/index.js`: |
| 46 | + |
| 47 | + > this file will act as a re-exporter for all your other components |
| 48 | +
|
| 49 | + ```js |
| 50 | + export * from "./button"; |
| 51 | + ``` |
| 52 | + |
| 53 | +7. now you can import your button component from `src/components` in any file: |
| 54 | + |
| 55 | + > example: we want to import our button component in `src/pages/Page.js` |
| 56 | +
|
| 57 | + ```js |
| 58 | + import { YourButton } from "../components"; |
| 59 | + |
| 60 | + export function Page() { |
| 61 | + return <YourButton />; |
| 62 | + } |
| 63 | + ``` |
| 64 | + |
| 65 | +8. file structure will look like this: |
| 66 | + |
| 67 | + ```bash |
| 68 | + src |
| 69 | + ├── components |
| 70 | + │ ├── button |
| 71 | + │ │ ├── YourButton.js # your button component |
| 72 | + │ │ ├── YourOtherButton.js |
| 73 | + │ │ ├── ... |
| 74 | + │ │ └── index.js # re-exporter for your button components |
| 75 | + │ ├── other-component |
| 76 | + │ │ ├── ... |
| 77 | + │ └── index.js # we will import our components from this file |
| 78 | + └── pages |
| 79 | + └── Page.js |
| 80 | + ``` |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## Naming Conventions |
| 85 | + |
| 86 | +> In this project, we use [PascalCase](https://en.wikipedia.org/wiki/PascalCase) for naming our files and we use [kebab-case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for naming our folders. |
| 87 | +
|
| 88 | +--- |
| 89 | + |
| 90 | +## Project Documents |
| 91 | + |
| 92 | +- [Figma](https://www.figma.com/file/MNMdvvfmCZVFc6HRsjrcCy/Recything-Design?type=design&node-id=1-3&mode=design&t=pimRrZcLkCqLhSpF-0) |
| 93 | +- [Trello](https://trello.com/b/QBUvaFOh/recything-web) |
| 94 | +- [Software Requirement Specification](https://docs.google.com/document/d/1xQdsNs_42wmlnQ73Ue3aHJNr0KqgJbSCxgM5B0stt7k/edit#heading=h.1erwhldcnuec) |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## References |
| 99 | + |
| 100 | +- [Chakra UI](https://chakra-ui.com/) |
| 101 | +- [Tailwind CSS](https://tailwindcss.com/) |
0 commit comments