eed-web-application / elog-plus-frontend

2 stars 2 forks source link

ELog Plus Frontend

This is a pretty run of the mill React app. It's written in TypeScript with Vite for bundling and uses React Router for routing.

Start development server

# Install dependencies
$ npm install # or yarn or pnpm install

# Start dev server
$ npm run dev # or yarn dev or pnpm dev

Philosophy

Keep it simple until it needs to be complicated! Don't over-engineer things, but don't be afraid to refactor when things get messy.

Components

Few component libraries are used, because they cause a lot of bloat and most of the time don't integrate well with each other (UI/UX wise). For these reasons, most components are custom built. If complex functionality is needed, a lightweight hook is preferred over a component library. For example, Floating UI is used as a floating primitive that is used for all floating functionality, such as dialogs, tooltips, dropdowns, etc.

Most components expose the props of their root element, so that the component can be styled with className and also helps to reduce the number of elements in the DOM (see styling section).

Styling

Styling is done with Tailwind. Right now, there are little reusable abstractions and most of the styling is done inline. This is because the app is still in active development and it's hard to know what will be reused and what won't. As the app grows, more abstractions will be made. However, for the few necessary reusable styles base.ts contains a few styles that are used throughout the app (though see #40). Most components expose and merge (using tailwind-merge) className, which should be used over wrapping in a div and styling that.

Icons

Besides the following exceptions, all icons are from Hero Icons and are just used as inlined SVGs:

State Management

State is saved where ever it is most convenient (i.e., no big nasty Redux store 🎉):

Routing

Routing is done with React Router. There are two main pages: Home and Admin. However, within these pages there are different routes that change the SideSheet. For example, the route /:entryId shows the entry with id entryId in the side sheet along side the the main Home entry list as well as the navbar.

Error Handling

There are two types of errors: critical and noncritical. Critical errors cause the page to crash and shows an error page. Noncritical errors are recoverable and thus just display a toast. All unhandled errors are critical and cause the page to crash.