Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions browser-vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Dependencies
node_modules/

# Build output
dist/

# Generated files
src/samples/
src/samples-metadata.json

# Logs
*.log
npm-debug.log*

# IDE
.vscode/
.idea/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db
118 changes: 118 additions & 0 deletions browser-vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Vite-Based Samples Browser

This is a Vite-powered samples browser for Ignite UI Web Components. It provides a fast development experience with hot module replacement (HMR) and efficient builds.

## Features

- **Fast Development**: Powered by Vite for instant server start and lightning-fast HMR
- **Sample Navigation**: Browse samples organized by component groups and categories
- **Standalone Sample View**: Each sample can be accessed via a direct URL
- **Simple Copy Process**: No complex build tools - samples are copied from the `/samples` folder using a simple Node.js script

## Getting Started

### Prerequisites

- Node.js 16+ and npm

### Installation

```bash
cd browser-vite
npm install
```

### Development

Run the development server:

```bash
npm run dev
```

This will:
1. Copy samples from the `/samples` folder
2. Start the Vite development server
3. Open the browser at `http://localhost:3000`

### Building for Production

Build the application:

```bash
npm run build
```

Preview the production build:

```bash
npm run preview
```

## How It Works

### Sample Copying

The `scripts/copy-samples.js` script:
1. Scans the `/samples` directory for all sample folders (identified by `package.json`)
2. Copies the `src` directory from each sample to `browser-vite/src/samples`
3. Extracts HTML content from each sample's `index.html` file
4. Generates a `samples-metadata.json` file with sample information including HTML structure

### Routing

The browser supports two routing modes:

1. **Browser View**: Access samples with navigation sidebar at `http://localhost:3000/`
2. **Standalone Sample View**: Access individual samples directly at `http://localhost:3000/{group}/{category}/{sample-name}`

Examples:
- `http://localhost:3000/grids/tree-grid/custom-filtering`
- `http://localhost:3000/charts/category-chart/overview`

### Structure

```
browser-vite/
├── scripts/
│ └── copy-samples.js # Simple script to copy samples
├── src/
│ ├── main.ts # Main application entry point
│ ├── samples/ # Copied samples (generated)
│ └── samples-metadata.json # Sample metadata (generated)
├── public/ # Static assets
├── index.html # Main HTML file
├── vite.config.js # Vite configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Dependencies and scripts
```

## Sample Requirements

Samples work with their original structure:
- Each sample must have a `src` directory with TypeScript files
- The main entry point should be `src/index.ts`
- Each sample's `index.html` provides the component structure (extracted automatically)
- Samples are self-contained with all dependencies imported

## Development Notes

- The copy script runs automatically before `dev` and `build` commands
- To manually copy samples: `npm run copy-samples`
- Samples are copied as-is from the `/samples` folder with HTML structure extracted
- Navigation and routing work in both development and production builds
- The browser successfully displays 936 samples organized by component groups

## Current Limitations

This is an initial implementation focusing on the browser structure and navigation. The sample loading mechanism uses dynamic imports which work well in development mode but may require additional configuration for production deployments. The core functionality (navigation, routing, sample organization) is fully operational.

## Comparison with Original Browser

This Vite-based browser:
- ✅ Uses a simple Node.js script instead of Gulp for copying samples
- ✅ Provides the same navigation structure with collapsible categories
- ✅ Supports both browser view and standalone sample URLs
- ✅ Extracts and uses HTML content from original samples
- ✅ Maintains the same sample organization (by group/category/name)
- ✅ Requires minimal or no changes to sample source files
212 changes: 212 additions & 0 deletions browser-vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ignite UI Web Components - Samples Browser (Vite)</title>
<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/wc.png">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit&display=swap">
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css">
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
font-family: 'Kanit', sans-serif;
display: flex;
height: 100vh;
overflow: hidden;
}

#nav-sidebar {
width: 280px;
background: #1e1e1e;
color: #fff;
overflow-y: auto;
flex-shrink: 0;
transition: margin-left 0.3s;
}

#nav-sidebar.hidden {
margin-left: -280px;
}

#nav-header {
padding: 20px;
background: #252526;
border-bottom: 1px solid #333;
}

#nav-header h1 {
font-size: 18px;
margin-bottom: 5px;
}

#nav-header p {
font-size: 12px;
color: #888;
}

.nav-group {
padding: 15px 20px 5px;
font-size: 12px;
text-transform: uppercase;
color: #888;
font-weight: bold;
}

.nav-category {
padding: 10px 20px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
border-left: 3px solid transparent;
transition: all 0.2s;
}

.nav-category:hover {
background: #2a2a2a;
border-left-color: #0078d4;
}

.nav-category.expanded {
background: #2a2a2a;
border-left-color: #0078d4;
}

.nav-samples {
display: none;
background: #252526;
}

.nav-samples.visible {
display: block;
}

.nav-sample {
padding: 8px 20px 8px 40px;
cursor: pointer;
font-size: 13px;
color: #ccc;
transition: all 0.2s;
}

.nav-sample:hover {
background: #2a2a2a;
color: #fff;
}

.nav-sample.active {
background: #0078d4;
color: #fff;
}

#main-content {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}

#toolbar {
height: 50px;
background: #f5f5f5;
border-bottom: 1px solid #ddd;
display: flex;
align-items: center;
padding: 0 20px;
gap: 10px;
}

#toggle-nav {
padding: 8px 16px;
background: #0078d4;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}

#toggle-nav:hover {
background: #006cc1;
}

#sample-title {
font-size: 16px;
font-weight: 500;
color: #333;
}

#sample-container {
flex: 1;
overflow: auto;
background: #fff;
position: relative;
}

#welcome-message {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: #666;
text-align: center;
padding: 40px;
}

#welcome-message h2 {
font-size: 32px;
margin-bottom: 20px;
color: #333;
}

#welcome-message p {
font-size: 16px;
max-width: 600px;
line-height: 1.6;
}

.loader {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: 18px;
color: #666;
}
</style>
</head>
<body>
<div id="nav-sidebar">
<div id="nav-header">
<h1>Samples Browser</h1>
<p>Vite Edition</p>
</div>
<div id="nav-content"></div>
</div>

<div id="main-content">
<div id="toolbar">
<button id="toggle-nav">☰ Toggle Nav</button>
<span id="sample-title">Select a sample from the sidebar</span>
</div>
<div id="sample-container">
<div id="welcome-message">
<h2>Welcome to Ignite UI Web Components Samples</h2>
<p>
Select a sample from the sidebar to view it. This browser is powered by Vite
for fast development and hot module replacement.
</p>
</div>
</div>
</div>

<script type="module" src="/src/main.ts"></script>
</body>
</html>
Loading
Loading