Skip to content

Latest commit

Β 

History

50 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Perspective LogoΒ  Perspective Funnel Preview

Perspective Funnel Preview is a tool for customers to preview their funnel designs. It works smoothly on both mobile and desktop platforms.

πŸ“Έ Demo

desktop.mp4
mobile.mov

πŸ“Œ Process

When I started this project, I focused on creating the schemas and types for the funnel data first. Once that was solid, I built the components for each block type and used Storybook to view them visually. Also this makes it easier for designers, product managers, and other developers to see how the components looked in different scenarios.

Next, I sketched the UI using Excalidraw, focusing on mobile first design and then adapting it for desktop. From there, I started building the components and pages in the app.

When it came to uploading a JSON file, I wanted to ensure users have the flexibility to choose what works best for them. Whether it’s drag and drop, uploading via URL, or using a file input. The more options, the better.

I used Dummy JSON to generate a JSON URL for testing in the input field.

A big challenge was handling validation. I had to create a custom schema for checking data and providing clear error messages. I took inspiration from how VS Code and React show errors.

🎨 Design Idea

The goal is to create a preview tool that doesn’t just showcase the funnel but also gives a sense of how smooth and easy it is to use Perspective. I signed up for Perspective's 14 day free trial to explore and play around with it. That’s when I got the idea.

✨ It should resemble Perspective's own design system. ✨

While this tool is just a preview, it gives customers a glimpse of how their funnels could look in the actual Perspective app when creating them.

First impressions are really important. When you see something sleek, polished, and outstanding, you’re less likely to leave the page immediately, you’ll want to stay and explore more.

  • Mobile Design:

    Mobile Design

  • Desktop Design:

    Desktop Design

πŸš€ Features

πŸ“‚ JSON Upload & Validation

  • Drag and drop JSON files or upload via a URL.
  • Validates the JSON against a custom schema.
  • Clear error messages with line numbers and code snippets.

🧩 Block Rendering

  • Supports multiple block types:
    • Text Block: Customizable text, alignment, color, size, and weight.
    • Image Block: Supports alt text, radius, and source URL.
    • Button Block: Configurable text, colors, and corner styles.
    • List Block: Styles include numbered, bullet, or no list at all.

πŸ“‚ Upload & URL

  • Upload via a URL
  • Upload via a file input
  • Drag and drop JSON files

πŸ’» Real Time Preview

  • Live rendering of JSON funnels in mobile and desktop views.
  • Toggle between views to test responsiveness.

πŸ” Error Handling

  • Detailed validation errors in an easy to read accordion.
  • Code snippets with highlighted lines to quickly spot problems.

πŸ“‹ Intuitive Sidebar

  • Lists all funnel pages for quick navigation.
  • Tabs to switch between pages and JSON upload view.

βœ… Currently Validating

Root Level

  • Has required fields (name, bgColor, pages)
  • Name is a string
  • Pages is an array
  • Background color is valid format (hex, rgb, rgba, "white", CSS names, HSL/HSLA)

Pages

  • Each page has id and blocks
  • Blocks is an array
  • Page ID is string
  • Page order validation (first page starts with text, no empty pages)
  • Navigation flow validation (buttons between pages)

Blocks (Common)

  • Each block has id and type
  • Type is one of: text, image, button, list
  • Block ID is string
  • Unique IDs across all blocks validation
  • Block order validation per page

Text Block

  • Has text, color, align properties
  • Color is valid format (including all CSS colors & HSL)

Image Block

  • Has src property
  • Src is string

Button Block

  • Has text, color, bgColor
  • Colors are valid formats (including all CSS colors & HSL)

List Block

  • Has items array
  • Each item has id, title
  • Optional description and src for items
  • Unique IDs across list items

Error Handling

  • Basic error grouping by type (ID, Page Structure, etc.)
  • Detailed error messages with paths

πŸ› οΈ Tech Stack

  • Next.js (Framework)
  • Zod (For schema validation)
  • Framer Motion (For animations)
  • Storybook (For component visualization)
  • Tailwind CSS (For styling)
  • TypeScript (For type safety)
  • React Dropzone (For file uploads)
  • Lucide Icons (For UI icons)

πŸ§ͺ Testing

I haven’t added testing to this project yet, but here’s how I would approach it:

What to Test:

  1. Validation:

    • Check if the validation function works for both valid and invalid JSON files.
    • Test edge cases like missing fields, duplicate IDs, or invalid color formats.
  2. Error Messages:

    • Make sure error messages are clear and point to the correct paths and line numbers.
    • Verify that code snippets highlight the correct lines for each error.
  3. UI Components:

    • Test if components render properly with different data.
    • Check how the app handles edge cases, like empty pages or unsupported block types.
    • Ensure the app works well on both mobile and desktop.
  4. File and URL Uploads:

    • Test drag and drop JSON file uploads.
    • Make sure errors are handled correctly for invalid JSON or unsupported URLs.

πŸ“¦ Tools & Libraries

  • Jest: For testing validation functions and other logic.
  • React Testing Library: For testing UI components and user interactions.
  • Cypress: For E2E testing, like uploading JSON, rendering funnels, and navigating between pages.

This would make the project more reliable and give more confidence when shipping it to customers.

πŸ’» How to Run It

  1. Clone the repo:
    git clone https://github.com/your-repo/perspective-funnel-preview.git
  2. Install dependencies:
    npm install
  3. Run the app in development mode:
    npm run dev
  4. To preview components in Storybook:
    npm run storybook

⚑️ There's Always Room for Improvement

If I had more time, I would take my time to improve the following:

🚨 Validation

  • Add maximum JSON file size limit.
  • XSS prevention in text fields.
  • Stricter URL format validation.
  • Whitelist of allowed domains.
  • Protocol validation (http/https only).
  • Image URL format validation.
  • Add validation suggestions.

πŸ¦„ UI

  • Add a loading skeleton for blocks.
  • Add a copy button for validation errors.
  • Improve transitions between mobile and desktop views.
  • Provide more visual feedback for errors or empty states.
  • Simplify the validation error UI for better clarity and ease of use.
  • Add suggestions for validation errors, like what can be changed or fixed.

About

πŸš€ It's a tool for customers to preview their funnel designs.

Topics

Resources

Stars

3 stars

Watchers

2 watching

Forks

Used by

Contributors

Languages