Skip to content

Jeffrey0117/JQX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JQX

The instant JSX-to-jQuery transformation engine.

npm package


Features

  • πŸš€ Instant - Zero configuration, works out of the box
  • ⚑ Fast - Leverages Vite's lightning-fast HMR
  • πŸ”§ jQuery Compatible - Full compatibility with jQuery ecosystem
  • πŸ“¦ Modular - Component-based architecture with ES6 modules
  • πŸ’‘ Intuitive - Familiar JSX syntax for jQuery DOM manipulation
  • 🎨 Flexible - Easy to extend and customize
  • πŸ“± Responsive - Built-in responsive design support

Installation

npm install jqx

Quick Start

/** @jsx jCreateElement */
import $ from 'jquery';
import { jCreateElement } from './createElement.js';

const App = () => (
  <div className="container">
    <h1>Hello JQX!</h1>
    <button onClick={() => alert('It works!')}>
      Click me
    </button>
  </div>
);

$('#root').append(<App />);

Why JQX?

JQX React Vue Vanilla JS
Bundle Size ~5kb ~40kb ~35kb 0kb
Learning Curve πŸ“— Easy πŸ“™ Medium πŸ“™ Medium πŸ“• Hard
jQuery Compatible βœ… ❌ ❌ βœ…
Component Based βœ… βœ… βœ… ❌

Examples

Basic Component

/** @jsx jCreateElement */
import { jCreateElement } from './createElement.js';

const Button = ({ text, onClick }) => (
  <button className="btn btn-primary" onClick={onClick}>
    {text}
  </button>
);

export default Button;

Interactive Component with State

/** @jsx jCreateElement */
import $ from 'jquery';
import { jCreateElement } from './createElement.js';

let count = 0;

const Counter = () => (
  <div className="counter">
    <p>Count: <span id="count">{count}</span></p>
    <button onClick={() => {
      count++;
      $('#count').text(count);
    }}>
      Increment
    </button>
  </div>
);

export default Counter;

Using jQuery Plugins

/** @jsx jCreateElement */
import $ from 'jquery';
import 'jquery-ui/ui/widgets/draggable';
import { jCreateElement } from './createElement.js';

const DraggableBox = () => {
  const handleMount = (element) => {
    $(element).draggable();
  };

  return (
    <div 
      className="draggable-box"
      ref={handleMount}
    >
      Drag me around!
    </div>
  );
};

export default DraggableBox;

Project Structure

jqx/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/           # Component files
β”‚   β”‚   β”œβ”€β”€ App.jsx          # Main application
β”‚   β”‚   β”œβ”€β”€ Header.jsx       # Navigation header
β”‚   β”‚   β”œβ”€β”€ Hero.jsx         # Hero section
β”‚   β”‚   β”œβ”€β”€ Features.jsx     # Features showcase
β”‚   β”‚   β”œβ”€β”€ Demo.jsx         # Interactive demo
β”‚   β”‚   └── Footer.jsx       # Page footer
β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”‚   └── appUtils.js      # App utilities
β”‚   β”œβ”€β”€ createElement.js     # JSX transformation core
β”‚   β”œβ”€β”€ main.jsx            # Application entry point
β”‚   └── styles.css          # Global styles
β”œβ”€β”€ index.html              # HTML entry
β”œβ”€β”€ vite.config.js         # Vite configuration
└── package.json           # Project configuration

CLI Commands

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

# Run tests
npm test

Configuration

Vite Configuration

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [
    react({
      jsxRuntime: 'classic',
      babel: {
        presets: [['@babel/preset-react', { pragma: 'jCreateElement' }]],
      },
    }),
  ],
});

JSX Pragma

Make sure to include the JSX pragma at the top of your components:

/** @jsx jCreateElement */

API Reference

jCreateElement(tag, props, ...children)

The core function that transforms JSX into jQuery elements.

Parameters:

  • tag - HTML tag name or component function
  • props - Element properties and attributes
  • children - Child elements

Returns: jQuery object

Component Props

Prop Type Description
className string CSS class names
id string Element ID
style object Inline styles
onClick function Click event handler
onMouseOver function Mouse over event handler
ref function Element reference callback

Ecosystem

Official Plugins

Community

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/Jeffrey0117/JQX.git

# Install dependencies
cd JQX
npm install

# Start development
npm run dev

License

MIT License Β© 2024-PRESENT Jeffrey0117


Made with ❀️ by the JQX team

About

The instant JSX-to-jQuery transformation engine.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors