Development

Development Guide

Project Structure

b2-sleeknotify/
β”œβ”€β”€ client/
β”‚   β”œβ”€β”€ main.lua
β”‚   └── config.lua
β”œβ”€β”€ server/
β”‚   └── main.lua
β”œβ”€β”€ ui/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   └── NotificationSystem.jsx
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── tailwind.config.js
└── fxmanifest.lua

Development Environment Setup

Prerequisites

  • Node.js 18 or higher

  • npm or yarn

  • Git

  • Code editor (VS Code recommended)

Initial Setup

  1. Clone the repository:

  1. Install UI dependencies:

Development Server

Start the development server with hot reload:

Building for Production

Create a production build:

UI Development

Tech Stack

  • React 18

  • Tailwind CSS

  • Vite

  • Lucide Icons

Key Components

NotificationSystem.jsx

The main component handling notifications. Key sections:

Styling Guide

Tailwind Configuration

The project uses Tailwind CSS for styling. Customize tailwind.config.js:

Color System

We use a consistent color system across notification types:

NUI Communication

Sending Messages to Lua

Receiving Messages from Lua

Building Custom Styles

Creating a New Style

  1. Add style option in config.lua:

  1. Create style component:

  1. Add to style renderer:

Production Build Process

1. Development and Testing

Test changes using the development server.

2. Production Build

This creates optimized files in ui/dist/.

3. Testing the Production Build

  • Copy the contents of ui/dist/ to your FiveM server

  • Ensure paths in fxmanifest.lua match your build output

4. Debugging

Enable development tools in FiveM:

Use browser dev tools to:

  • Monitor network requests

  • Debug React components

  • Check for console errors

Best Practices

  1. Performance

    • Use React.memo for pure components

    • Implement proper cleanup in useEffect

    • Optimize re-renders with proper state management

  2. Styling

    • Use Tailwind utility classes

    • Maintain consistent color schemes

    • Follow the established naming conventions

  3. Testing

    • Test all notification types

    • Verify position handling

    • Check animation performance

    • Test with different screen resolutions

  4. Error Handling

    • Implement proper error boundaries

    • Handle missing or invalid data gracefully

    • Provide fallback styles

Common Issues and Solutions

Issue: Notifications not showing

Issue: Styles not applying correctly

Last updated