|
| 1 | +# Desktop Download Component |
| 2 | + |
| 3 | +A React component for downloading the latest Remix Desktop application from GitHub releases. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Auto OS Detection**: Automatically detects the user's operating system (Windows, macOS, Linux) and suggests the appropriate download |
| 8 | +- **Architecture Support**: Detects Apple Silicon Macs and provides ARM64 builds when available |
| 9 | +- **Smart Caching**: Caches release data for 30 minutes to reduce API calls |
| 10 | +- **Internationalization**: Fully supports i18n with FormattedMessage components |
| 11 | +- **Responsive Design**: Works on both desktop and mobile devices |
| 12 | +- **Error Handling**: Graceful fallback when GitHub API is unavailable |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +```tsx |
| 17 | +import { DesktopDownload } from '@remix-ui/desktop-download' |
| 18 | + |
| 19 | +function MyComponent() { |
| 20 | + return ( |
| 21 | + <div> |
| 22 | + {/* Compact layout with tracking */} |
| 23 | + <DesktopDownload trackingContext="navbar" /> |
| 24 | + |
| 25 | + {/* Full layout */} |
| 26 | + <DesktopDownload compact={false} trackingContext="home" /> |
| 27 | + |
| 28 | + {/* Span variant for dropdowns */} |
| 29 | + <DesktopDownload variant="span" trackingContext="dropdown" /> |
| 30 | + </div> |
| 31 | + ) |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +### Compact Layout (Default) |
| 36 | +Perfect for navigation bars, toolbars, or anywhere space is limited. Shows a button with "Download Remix Desktop {OS} {version}" and a small muted link to other releases below. |
| 37 | + |
| 38 | +```tsx |
| 39 | +<DesktopDownload /> |
| 40 | +<DesktopDownload compact={true} /> |
| 41 | +``` |
| 42 | + |
| 43 | +### Full Layout |
| 44 | +Great for landing pages, cards, or dedicated download sections. Shows detailed information including release date, file size, and platform-specific icons. |
| 45 | + |
| 46 | +```tsx |
| 47 | +<DesktopDownload compact={false} /> |
| 48 | +``` |
| 49 | + |
| 50 | +### Span Variant |
| 51 | +Perfect for dropdown items or anywhere you need a simple link without button styling. |
| 52 | + |
| 53 | +```tsx |
| 54 | +<DesktopDownload variant="span" /> |
| 55 | +``` |
| 56 | + |
| 57 | +### With custom styling |
| 58 | + |
| 59 | +```tsx |
| 60 | +<DesktopDownload className="my-custom-class" compact={false} /> |
| 61 | +<DesktopDownload style={{ color: '#007bff', fontSize: '14px' }} /> |
| 62 | +<DesktopDownload variant="span" style={{ fontWeight: 'bold' }} /> |
| 63 | +``` |
| 64 | + |
| 65 | +## Props |
| 66 | + |
| 67 | +| Prop | Type | Default | Description | |
| 68 | +|------|------|---------|-------------| |
| 69 | +| `className` | `string` | `''` | Additional CSS classes | |
| 70 | +| `compact` | `boolean` | `true` | Use compact layout | |
| 71 | +| `variant` | `'button' \| 'span'` | `'button'` | Display variant | |
| 72 | +| `style` | `CSSProperties` | `{}` | Inline styles | |
| 73 | +| `trackingContext` | `string` | `'unknown'` | Context for Matomo analytics (e.g., 'hometab', 'dropdown', 'navbar') | |
| 74 | + |
| 75 | +## Analytics Tracking |
| 76 | + |
| 77 | +The component includes automatic Matomo analytics tracking for all download interactions. Set the `trackingContext` prop to identify where the component is used: |
| 78 | + |
| 79 | +```tsx |
| 80 | +<DesktopDownload trackingContext="hometab" /> |
| 81 | +``` |
| 82 | + |
| 83 | +**Tracking Events:** |
| 84 | +- Category: `desktopDownload` |
| 85 | +- Action: `{context}-{variant}` (e.g., `hometab-compact`, `dropdown-span`) |
| 86 | +- Name: `{platform}-{filename}` or `releases-page` for fallbacks |
| 87 | + |
| 88 | +**Examples:** |
| 89 | +- `['trackEvent', 'desktopDownload', 'hometab-compact', 'linux-remix-desktop_1.1.0_amd64.deb']` |
| 90 | +- `['trackEvent', 'desktopDownload', 'dropdown-span', 'windows-remix-desktop-1.1.0-setup.exe']` |
| 91 | +- `['trackEvent', 'desktopDownload', 'navbar-full-fallback', 'releases-page']` |
| 92 | + |
| 93 | +## Platform Support |
| 94 | + |
| 95 | +The component automatically detects and provides downloads for: |
| 96 | + |
| 97 | +- **Windows**: `.exe` installer |
| 98 | +- **macOS**: `.dmg` disk image (ARM64 for Apple Silicon, Intel for older Macs) |
| 99 | +- **Linux**: `.deb` package (with `.AppImage` fallback) |
| 100 | + |
| 101 | +## API |
| 102 | + |
| 103 | +The component fetches release data from: |
| 104 | +`https://api.github.com/repos/remix-project-org/remix-desktop/releases/latest` |
| 105 | + |
| 106 | +## Caching |
| 107 | + |
| 108 | +Release data is cached in localStorage for 30 minutes to reduce GitHub API calls and improve performance. |
| 109 | + |
| 110 | +## Dependencies |
| 111 | + |
| 112 | +- React 18+ |
| 113 | +- @remix-ui/helper (for CustomTooltip) |
| 114 | +- react-intl (for internationalization) |
| 115 | +- Bootstrap CSS classes (for styling) |
| 116 | +- FontAwesome icons (for platform icons) |
| 117 | + |
| 118 | +## Internationalization |
| 119 | + |
| 120 | +The component is fully internationalized using react-intl. Translation strings are located in: |
| 121 | + |
| 122 | +- `apps/remix-ide/src/app/tabs/locales/en/desktopDownload.json` - All translation keys for the component |
| 123 | + |
| 124 | +### Translation Keys |
| 125 | + |
| 126 | +| Key | Default Message | Description | |
| 127 | +|-----|-----------------|-------------| |
| 128 | +| `desktopDownload.loading` | "Loading desktop app info..." | Loading state message | |
| 129 | +| `desktopDownload.error` | "Unable to load desktop app. Check the {link} for downloads." | Error fallback message | |
| 130 | +| `desktopDownload.title` | "Remix Desktop" | Main title in full layout | |
| 131 | +| `desktopDownload.releaseDate` | "Released {date}" | Release date display | |
| 132 | +| `desktopDownload.downloadSpan` | "Download Remix Desktop {platform} {version}" | Span variant with platform | |
| 133 | +| `desktopDownload.downloadSpanGeneric` | "Download Remix Desktop {version}" | Span variant without platform | |
| 134 | +| `desktopDownload.downloadCompactFull` | "Download Remix Desktop {platform} {version}" | Compact button with platform | |
| 135 | +| `desktopDownload.downloadCompactGeneric` | "Download Remix Desktop {version}" | Compact button without platform | |
| 136 | +| `desktopDownload.downloadButton` | "Download for {platform}" | Full layout button text | |
| 137 | +| `desktopDownload.viewReleases` | "View Downloads" | Fallback button text | |
| 138 | +| `desktopDownload.otherVersions` | "Other versions and platforms" | Link to releases page | |
| 139 | +| `desktopDownload.noAutoDetect` | "Available for Windows, macOS, and Linux" | Platform availability message | |
0 commit comments