Skip to content

Commit 240b31b

Browse files
Changed: components heirarchy
1 parent 442e8db commit 240b31b

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

content/3.web/guide.md

+35-21
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ apps/
3131
├── ...
3232
├── assets/ # Static assets
3333
├── components/
34-
│ ├── ecommerce/ # Ecommerce-specific components (ProductCard)
35-
│ ├── ...
36-
│ └── ui/ # UI components (Header, Footer)
34+
│ ├── atoms/ # Atomic components related to feature (e.g atoms/cart/NsAddToCartButton.vue)
35+
│ ├── molecules/ # Molecular components made using atoms (e.g molecules/form/NsEmailInput.vue)
36+
│ └── organisms/ # Large components made using atoms and molecules (e.g organisms/address/NsAddressCard.vue)
3737
├── composables/ # Custom hooks composing reactive logic
3838
├── constants/
3939
│ ├── api.ts # API-related constants (HTTP methods)
4040
│ └── ui.ts # UI-related constants (colors, breakpoints)
4141
├── data/ # Static data or JSON files
42-
├── layouts/ # Layouts
43-
├── middleware/ # Client route middleware (e.g auth)
42+
├── layouts/ # Nuxt Layouts
43+
├── middleware/ # Client side route middlewares
4444
│ ├── auth.ts
4545
│ └── ...
4646
├── pages/ # Pages
@@ -61,7 +61,7 @@ apps/
6161
├── app.vue # Application entry point
6262
├── nuxt.config.ts # Nuxt.js configuration
6363
├── package.json # Package entry point
64-
├── tailwind.config.js # TailwindCSS configuration
64+
├── tailwind.config.ts # TailwindCSS configuration
6565
├── tsconfig.json # TypeScript configuration
6666
├── vitest.config.ts # Vitest configuration
6767
└── ...
@@ -70,18 +70,18 @@ apps/
7070

7171
List of essential directories:
7272

73-
- `components/ecommerce` NuxtStore UI components, like `ProductCard` or `Review`
73+
- `components` NuxtStore UI components, like `ProductCard` or `Review`
7474
- `stores` Pinia store containing global state, getters and mutators
7575
- `composables` Contains reusable composition functions, e.g. data fetchers and stateful helpers
7676
- `shared` Contains types and utilities [shared](https://github.com/nuxt/nuxt/releases/tag/v3.14.0) across client and server e.g `product.type.ts`. Auto-import support will follow in next major release.
7777
- `tests` Contains mocks for components, composables and store actions
7878

79-
## Guide
79+
## Project Guide
8080

8181
This project follows a few conventions to help with organizing your code:
8282

8383
- Each function is located in a dedicated module and exported from the `index.ts` file.
84-
- In this nuxt application, avoid importing auto-imported APIs (ref, onMounted etc.) and PrimeVue components (Dialog, Carousel etc.)
84+
- In this nuxt application, avoid importing auto-imported APIs (ref, onMounted etc.) or compiler macros (defineProps, defineEmits etc.) and PrimeVue components (Button, InputText, Dialog, Carousel etc.)
8585
- Names are short, descriptive and must follow our consistent naming convention ([guide](https://docs.vaah.dev/guide/code))
8686
- Follow this [nuxt guide](https://docs.vaah.dev/guide/nuxt) to avoid common mistakes and comply with industry standard practices
8787
- Functions (including composables and utils) are exported using explicit named exports instead of anonymous exports
@@ -96,37 +96,51 @@ This project follows a few conventions to help with organizing your code:
9696
9797
### Components
9898

99-
NuxtStore UI leverages [PrimeVue](https://primevue.org/) as the building blocks of storefront components. All components are auto-imported by their name (no path-prefix) and are located inside subfolders in the `components` directory.
99+
NuxtStore UI follows [atomic design principle](https://atomicdesign.bradfrost.com/chapter-2/) to develop components and it leverages [PrimeVue](https://primevue.org/) as the building blocks of storefront components. All components are auto-imported by their name (no path-prefix) and are located inside subfolders in the `components` directory.
100100

101101
- Introduction to project components:
102102

103-
- Representational components that are designed to fulfill project requirements
103+
- Consists of representational components that are designed to fulfill project requirements
104+
- Components should be placed in dedicated folders inside components directory
105+
- Root of the component folder has `atoms`, `molecules` and `organisms`
104106
- Each component name must be prefixed with **"Ns"** (e.g **NsProductCard**)
105107
- TypeScript types are located inside the SFC for ease of access and coupling
106108
- Tests for components are located in the `/tests/components` folder (e.g **NsUserAddress.spec.ts**)
107-
- Folders inside /components must follow their purpose
109+
- Folders inside /atoms, /molecules and /organisms must follow their purpose
108110

109-
Expected file/folder structure:
111+
Expected directory structure:
110112

111113
```shell
112114
components/
113-
└── ui/
114-
└── NsHeader.vue
115+
└── atoms/
116+
└── cart/
117+
└── NsAddToCartButton.vue
118+
└── NsCartIcon.vue
119+
└── ui/
120+
└── NsHeader.vue
121+
└── NsFooter.vue
115122
└── ...
116-
└── ecommerce/
117-
└── NsCartItem.vue
123+
└── molecules/
124+
└── form/
125+
└── NsEmailInput.vue
126+
└── NsPasswordInput.vue
118127
└── ...
119-
└── forms/
120-
└── NsSignUpForm.vue
128+
└── organisms/
129+
└── address/
130+
└── NsAddressCard.vue
131+
└── cart/
132+
└── NsCartOverview.vue
133+
└── forms/
134+
└── NsSignUpForm.vue
135+
└── NsAddressForm.vue
121136
└── ...
122-
└── ...
123137
```
124138

125139
For more information about available NuxtStore components for Vue (Nuxt), check out [documentation]().
126140

127141
- **Convention:**
128142

129-
- Vue (Nuxt) components should follow `Pascal case` pattern (`CategoryFilters`, `Heading`)
143+
- Vue (Nuxt) components should follow `PascalCase` pattern (`CategoryFilters`, `Heading`)
130144
- The types for component's props should be named `{Component}Props` and exist in the same SFC as the component. For example, `GalleryProps` or `HeadingProps`
131145
- Line of code in a single file component must not exceed 200 (formatted)
132146

0 commit comments

Comments
 (0)