Skip to content

Template structure & usage

This page provides an in-depth explanation of the functionality and usage of GamefaceUI.

The boilerplate project is organized with the following structure:

  • Directorysrc
    • assets
    • Directorycomponents
      • DirectoryBasic/
      • DirectoryLayout/
      • DirectoryMedia/
    • Directorycustom-components/
    • Directoryviews
      • Directoryhud
        • index.html
        • index.css
        • index.tsx
        • Hud.tsx
        • Hud.module.css
      • Directorymenu
        • index.html
        • index.css
        • index.tsx
        • Menu.tsx
        • Menu.module.css
  • package.json
  • tsconfig.json
  • vite.config.mts

To provide a clearer understanding of the rationale behind this structure, we will explain it in greater detail.

Project Configuration

The project’s configuration is managed through three key files: package.json, tsconfig.json, and vite.config.mts.

  • package.json: Handles project dependencies and defines scripts for running various commands.
  • tsconfig.json: Specifies TypeScript rules and settings for the project.
  • vite.config.mts: Configures the Vite build tool, setting options and plugins to optimize and transform the source code for Gameface during the build process.

Assets

The /src/assets directory is designated for all UI assets used in the development process. This folder can include files such as .png, .svg, fonts, and other resources.

GamefaceUI Components

Predefined components for streamlined UI development are located in the /src/components directory. For detailed information about each component and its usage, refer to the components section of the documentation.

Custom Components

The /src/custom-components directory is reserved for components created during UI development.

Views

Gameface Views are standalone HTML5 pages paired with their respective JavaScript contexts. Each View represents a complete UI or a significant UI component. Since multiple Views can be instantiated, the /src/views directory is included in the boilerplate to help organize and manage them effectively. Each View resides in its own folder within /src/views and typically includes an index.html, index.css, and index.tsx file, which collectively define its structure, styling, and behavior. This setup allows developers to work on multiple Views efficiently.

Creating a View

To create a new View, follow the structure of src/views/hud or src/views/menu. Begin by creating a new folder src/views/${viewName} and include the following files: index.html, index.tsx, index.css, and ${viewName}.tsx.