Component-First packages

Overview

Component-First

This repo contains code that aims to prove the Component-First Architecture Pattern described in the following article:
https://colum-ferry.medium.com/component-first-architecture-with-angular-and-standalone-components-f9fc6a6cbd11

Contents

What's in this repo?

In this repo, there are two things:

  • A Declarative Router (libs/router)
  • An Example App that implements the Component First Pattern (apps/example-app)

Why should we care about Component-First?

Component-First aims to create an architectural pattern that places Components as the source of truth for your Angular application.
Currently in the Angular ecosystem, NgModules act almost like orchestrators, wiring together your application. It's from the very existence of NgModules where we created the AppModule -> FeatureModules -> SharedModules -> CoreModules architecture.
This architecture is fine. It works. It scales. But is it overkill? Possibly.

While it does introduce a great separation of concerns within your app's structure, CoreModules and SharedModules often become overpopulated and difficult to maintain. SharedModules in particular can become a dumping ground. This often leads to a situation where we need to import the SharedModule into all our FeatureModules, even if we one need 1 thing from it.

With Component-First, our Components decide themselves what they need to perform. They can take Injectables via their constructor and they can import any component, directive or pipe they need to function. This increased level of granularity allows our Components to be hyper-focused on their function, reducing any additional bloat that might end up compiled with the Component.

Components in a Component-First Architecture will be completely tree-shakeable. If they aren't imported or routed to, they won't be included in the final bundle for our applications. Currently, to achieve the same effect with NgModules, we need to follow a pattern known as the SCAM (Single Component Angular Module) Pattern which was popularized by Lars Gyrup Brink Nielsen.

By following the Component-First Architecture Pattern, we also reduce the coupling between our Components and NgModules which paves the way to a truly NgModule-less Angular. We can still keep all the same composability that NgModules offered by simply following some best practices on code-organization; something Angular has us well trained to do already.

If components point to components, our mental mind map of our application becomes simpler. You can traverse the tree of components in your app and build out a pretty comprehensive map of your app, without having to worry about NgModules adding additional dependencies on your components that you may not be expecting. In Component-First, your components dictate their own dependencies. This massively reduces cognitive load, especially for newcomers to the codebase.

We can separate our Components by domain/feature and then finally by smart/dumb (container/presentation). If our domain/feature requires routing, then we can follow a pattern to have a Component act as a Route Entry Point, where we define the routes for that domain/feature.

If we look at the image below, we can see a separation of domains/features each with a route-entry.component. This builds consistency within our codebase. There's a Power in Constraints.

Folder Structure for Component-First

Component-First Router

The router in this repo is not intended for production use. It is simply to prove the Component-First Pattern.
That said, the following illustrates the state of the features that are expected to exist for the router.

  • Standard Routing (implemented)
  • Nested Routing (implemented)
  • Lazy Routing (implemented)
  • Deep Linking (implemented)
  • Route Guards
  • Route Resolvers

Usage

If you would like to see the pattern in action, follow the steps below:

  • Clone the repo
  • Run yarn install
  • Run yarn nx serve example-app
You might also like...

Isolated React component development environment with a living style guide

Isolated React component development environment with a living style guide

Isolated React component development environment with a living style guide React Styleguidist is a component development environment with hot reloaded

Jan 5, 2023

Markdown component for React

react-markdown Markdown component for React using remark. Learn markdown here and check out the demo here. Install npm: npm install react-markdown Why

Jan 4, 2023

React draggable component

React draggable component

React-Draggable A simple component for making elements draggable. Draggable divI can now be moved around!/div /Draggable Demo Changelog Vers

Jan 4, 2023

A React Component library implementing the Base design language

A React Component library implementing the Base design language

Base Web React Components Base is a design system comprised of modern, responsive, living components. Base Web is the React implementation of Base. Us

Dec 29, 2022

Accessible modal dialog component for React

react-modal Accessible modal dialog component for React.JS Table of Contents Installation API documentation Examples Demos Installation To install, yo

Jan 1, 2023

A small component based app library composing user interfaces and apps.

A small component based app library composing user interfaces and apps.

See https://vibejs.com for ongoing documentation and info. VibeJS A small component based JavaScript library to build user interfaces and apps. If you

Nov 16, 2022

JavaScript UI Component Library

Fancyapps UI Collection of task-oriented components that will make you more productive. Packed full of features that you and your clients will love. F

Dec 24, 2022

A Vue.js popover component based on PopperJS

vue3-popper A popover component for Vue 3 Documentation Check out the documentation Getting started Usage Install NPM npm install vue3-popper Yarn yar

Dec 30, 2022

Source code for my tutorial on how to build customizable table component with React Table and Tailwind CSS.

Source code for my tutorial on how to build customizable table component with React Table and Tailwind CSS.

React Table + Tailwind CSS = ❤️ Source code for my tutorial on how to build customizable table component with React Table and Tailwind CSS. Both parts

Jan 7, 2023
Owner
Colum Ferry
Senior Software Engineer @ Nrwl
Colum Ferry
👉 Built my first React JS project "ToDo" webapp using some Features and Icons from Material UI.

# Getting Started with Create React App This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). ## Avai

Vansh Chitlangia 2 Dec 15, 2021
Voler - The first Bootstrap 5 admin dashboard template

<<<<<<< HEAD Voler Voler is a Admin Dashboard Template that can help you develop faster. Made with Bootstrap 5 Alpha. No jQuery dependency. Installati

Ahmad Saugi 446 Dec 28, 2022
USA Covid-19 Tracker is a mobile-first application built with React and Redux to give precise information about the virus behavior in the United States. Great transitions and user feedback made with plain CSS.

React.js USA Covid-19 Tracker This application allows the public to keep track of the stadistics of the Covid-19 Pandemic in the United Stated. You wi

Rafael Echart 14 Oct 25, 2022
This app will share good first issues.

catsup A GitHub App built with Probot that This app alerts you of good first issues. Setup # Install dependencies npm install # Run the bot npm start

Open Sauced 6 Dec 5, 2022
Material-UI is a simple and customizable component library to build faster, beautiful, and more accessible React applications. Follow your own design system, or start with Material Design.

Material-UI Quickly build beautiful React apps. Material-UI is a simple and customizable component library to build faster, beautiful, and more access

Material-UI 83.6k Dec 30, 2022
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.8k Jan 4, 2023
The Select Component for React.js

React-Select The Select control for React. Initially built for use in KeystoneJS. See react-select.com for live demos and comprehensive docs. React Se

Jed Watson 25.6k Jan 3, 2023
:hourglass_flowing_sand: A higher order component for loading components with promises.

A higher order component for loading components with dynamic imports. Install yarn add react-loadable Example import Loadable from 'react-loadable'; i

Jamie Kyle 16.5k Jan 3, 2023
A Higher Order Component using react-redux to keep form state in a Redux store

redux-form You build great forms, but do you know HOW users use your forms? Find out with Form Nerd! Professional analytics from the creator of Redux

Redux Form 12.6k Jan 3, 2023
⚪ SVG-Powered component to easily create skeleton loadings.

SVG-Powered component to easily create placeholder loadings (like Facebook's cards loading). Features ⚙️ Customizable: Feel free to change the colors,

Danilo Woznica 12.7k Jan 4, 2023