Components
Components should be php partials that are utilized in multiple places and / or require its own additional assets.
Components should live within the /components/ directory. The reason that this directory does not live inside of /src is because the partials will be utilized in blocks, classes, templates, etc.
The CSS and JS assets inside of the component's directory will be globbed and compiled and then outputted in the /build directory. These will be apart of the global frontend assets (index.js).
Consolidating a component's assets in a single directory streamlines maintenance and organization. When a component becomes obsolete, deleting its directory ensures all associated assets disappear. Simply check areas featuring this component for any additional JS/CSS adjustments, and that's all there is to it.
Example:
📦 components
├─ component-name
│ ├─ partials - PHP partials that relate to this component
│ ├─ component-name.scss
│ ├─ script.js
│ ├─ component-name.php
The scss and js need to be named _component-name.scss and script.js respectively. This is so that the build tools know what to look for and compile.
If there are multiple components that need to be grouped together, then create a directory for them and place them inside of that directory. e.g. /components/cards/card.php, /components/cards/card-person.php, /components/cards/card-project.php.