The Frame-Pixels Web App is a dynamic, interactive web application designed using Next.js that allows users to navigate through different pages, interact with various UI elements, and perform actions such as moving coordinates and painting pixels. This application utilizes the @farcaster/hub-nodejs
library to integrate with Farcaster's decentralized social networking protocol, offering a unique blend of web functionality with decentralized features.
Before you begin, ensure you have the following installed:
- Node.js (version 12.x or later)
- npm (version 6.x or later)
To set up the project locally, follow these steps:
- Clone the repository to your local machine:
git clone <repository-url>
- Navigate to the project directory:
cd frame-pixels-web-app
- Install the necessary dependencies:
npm install
- Create a
.env.local
file in the root of your project and add the following environment variables:
HUB_URL=nemes.farcaster.xyz:2283 # The URL to the Farcaster Hub
BASE_URL=https://frame-pixels-6dnm.vercel.app # The base URL of your application
To run the application in development mode, use the following command:
npm run dev
Navigate to http://localhost:3000
to view the application in your browser.
The Frame-Pixels Web App includes the following features:
- Dynamic UI Navigation: Navigate through different UI pages such as home, coordinates, and paint pages.
- Interactive Elements: Interact with buttons to move coordinates, select colors, and paint pixels.
- Decentralized Integration: Utilize Farcaster's decentralized protocol for unique web interactions.
Handles POST requests to dynamically render UI based on user interactions.
Request Body:
untrustedData
: Contains thefid
(frame ID) andbuttonIndex
indicating which button was pressed.
Response:
- A dynamic HTML response with updated UI elements based on the request.
The setup()
function initializes the user interface for a dynamic web application, creating a structured navigation system through various pages, each with specific functionality and interactive elements. This setup is crucial for managing the application's user flow and ensuring a cohesive interaction experience.
- Initializes the
FrameUI
object. - Configures navigation through the creation of
FramePage
objects for each distinct page (start
,home
,coords
,paint
). - Adds interactive
FrameButton
and specialized buttons (RouteButton
,ColorPickerButton
) to pages for navigation and functionality. - Establishes connections between pages and actions, defining the application's navigational logic and interactive capabilities.
-
FrameUI Initialization:
- A new instance of
FrameUI
is created, serving as the central management system for all UI pages and their routing.
- A new instance of
-
Page Setup:
- Start Page: A basic entry point where users begin their interaction.
- A
RouteButton
is added to navigate from thestart
page to thehome
page.
- A
- Home Page: Serves as the central hub, directing to different functionalities.
- Includes
RouteButton
s for navigation to thecoords
andpaint
pages.
- Includes
- Coords Page: Allows users to adjust their coordinates within the application.
- Utilizes
FrameButton
s for directional movement and checks boundaries to prevent out-of-bounds errors.
- Utilizes
- Paint Page: Provides users with color selection and painting capabilities.
- Integrates
ColorPickerButton
s for color selection and aFrameButton
for applying the selected color to the canvas.
- Integrates
- Start Page: A basic entry point where users begin their interaction.
-
Interactive Elements:
- Buttons are added to pages with specific callbacks for interactions, such as moving the user's position or changing colors.
RouteButton
s are used for page navigation, changing the current page within theFrameUI
.ColorPickerButton
s extendFrameButton
functionality, allowing users to select colors for application within the app's functionality.
-
Return Value:
- The fully initialized
FrameUI
instance is returned, ready for use in managing the application's user interface and interactions.
- The fully initialized
To utilize the setup()
function within the application:
- Call
setup()
during the initial loading phase of your application to prepare the user interface. - The returned
FrameUI
instance should be integrated with the application's main event loop or interaction handler to respond to user actions and navigate between different pages based on interactions.
Contributions are welcome! If you'd like to contribute, please fork the repository and create a pull request with your changes. For major changes, please open an issue first to discuss what you would like to change.
MIT - See the LICENSE file for details.
This README provides a basic overview of the Frame-Pixels Web App's setup, features, and contribution guidelines. Adjustments may be necessary to fit the exact requirements of your project or environment.