|
| 1 | +# HM Modal Block |
| 2 | + |
| 3 | +Simple modal block for the WordPress block editor. |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +This plugin provides a modal component with two blocks: |
| 8 | +- **Modal Trigger**: Container block where you add your trigger element (button, image, etc.) |
| 9 | +- **Modal Content**: Renders the modal overlay with your content |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- Accessible keyboard navigation with focus trapping |
| 14 | +- Auto-pause videos/iframes when modal closes |
| 15 | +- Overlay click and Escape key to close |
| 16 | +- Customizable trigger and content using any WordPress blocks |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +### For Development |
| 21 | +1. Clone or download to `/wp-content/plugins/hm-modal-block/` |
| 22 | +2. Run `npm install && npm run build` |
| 23 | +3. Activate the plugin in WordPress |
| 24 | + |
| 25 | +### For Production |
| 26 | +1. Download from the `dist` branch or release |
| 27 | +2. Upload to `/wp-content/plugins/hm-modal-block/` |
| 28 | +3. Activate the plugin in WordPress |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +1. Add the **Modal Trigger** block to your page |
| 33 | +2. Inside it, you'll see: |
| 34 | + - A placeholder paragraph (replace this with your trigger: button, image, text, etc.) |
| 35 | + - A **Modal Content** block (automatically added) |
| 36 | +3. Add your modal content inside the "Modal Content" block |
| 37 | +4. On the front-end, clicking the trigger opens the modal overlay |
| 38 | + |
| 39 | +**Tip:** Add the class `modal-trigger` to your trigger element for explicit targeting, or the first block before Modal Content will automatically become the trigger. |
| 40 | + |
| 41 | +## Development |
| 42 | + |
| 43 | +### Setup |
| 44 | +```bash |
| 45 | +npm install |
| 46 | +composer install |
| 47 | +``` |
| 48 | + |
| 49 | +### Build |
| 50 | +```bash |
| 51 | +npm run build |
| 52 | +``` |
| 53 | + |
| 54 | +### Development Mode |
| 55 | +```bash |
| 56 | +npm start |
| 57 | +``` |
| 58 | + |
| 59 | +## Requirements |
| 60 | + |
| 61 | +- WordPress 5.8+ |
| 62 | +- PHP 7.4+ |
| 63 | +- Node.js 20.10+ |
| 64 | + |
| 65 | +## License |
| 66 | + |
| 67 | +GPL-2.0-or-later |
| 68 | + |
| 69 | +## Author |
| 70 | + |
| 71 | +Human Made Limited - https://humanmade.com |
0 commit comments