@uppy/examples: Add new examples (#5942)
Had to create a new PR since after the 5.0 merge, #5818 was throwing errors. ## Examples Added - **React Router v7** - Uppy Dashboard with Tus, XHR, and Transloadit , tus server implemented using react-router/express adapter , rest using regular resource routes - This still doesn't have hot reloading in the dev server though , can be added through nodemon - **Next.js** - Uppy Dashboard with Tus, XHR, and Transloadit - **Angular** - Uppy Dashboard and Dashboard Modal with Tus
7
.changeset/salty-experts-yawn.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
"example-reactrouter": major
|
||||
"example-nextjs": major
|
||||
"example-angular": major
|
||||
---
|
||||
|
||||
New example added for nextjs and react router and updated example for angular using latest CLI
|
||||
|
|
@ -10,6 +10,7 @@ trim_trailing_whitespace = true
|
|||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
ij_typescript_use_double_quotes = false
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
{
|
||||
"ignorePatterns": ["projects/**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@angular-eslint/recommended",
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"rules": {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "attribute",
|
||||
"prefix": "app",
|
||||
"style": "camelCase"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"import/no-unresolved": "off",
|
||||
"import/prefer-default-export": "off",
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
{
|
||||
"type": "element",
|
||||
"prefix": "app",
|
||||
"style": "kebab-case"
|
||||
}
|
||||
],
|
||||
"semi": ["error", "never"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["star.html"],
|
||||
"extends": [
|
||||
"plugin:@angular-eslint/template/recommended",
|
||||
"plugin:@angular-eslint/template/accessibility"
|
||||
],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
2
examples/angular/.gitignore
vendored
|
|
@ -1,4 +1,4 @@
|
|||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
|
||||
|
||||
# Compiled output
|
||||
/dist
|
||||
|
|
|
|||
|
|
@ -1,36 +1,59 @@
|
|||
# AngularExample
|
||||
# AngularModernExamples
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.2.0.
|
||||
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.6.
|
||||
|
||||
## Development server
|
||||
|
||||
```
|
||||
corepack yarn install
|
||||
corepack yarn build:clean
|
||||
corepack yarn build
|
||||
rm packages/@uppy/*/tsconfig.json
|
||||
corepack yarn workspace @uppy/angular prepublishOnly
|
||||
corepack yarn workspace @uppy-example/angular start
|
||||
To start a local development server, run:
|
||||
|
||||
```bash
|
||||
ng serve
|
||||
```
|
||||
|
||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
|
||||
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
||||
|
||||
## Build
|
||||
```bash
|
||||
ng generate component component-name
|
||||
```
|
||||
|
||||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
||||
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
||||
|
||||
```bash
|
||||
ng generate --help
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To build the project run:
|
||||
|
||||
```bash
|
||||
ng build
|
||||
```
|
||||
|
||||
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
||||
|
||||
```bash
|
||||
ng test
|
||||
```
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
||||
For end-to-end (e2e) testing, run:
|
||||
|
||||
## Further help
|
||||
```bash
|
||||
ng e2e
|
||||
```
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
||||
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
||||
|
||||
## Additional Resources
|
||||
|
||||
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
||||
|
|
|
|||
|
|
@ -3,22 +3,37 @@
|
|||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"angular-example": {
|
||||
"angular-modern-examples": {
|
||||
"projectType": "application",
|
||||
"schematics": {},
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"standalone": false
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"standalone": false
|
||||
},
|
||||
"@schematics/angular:pipe": {
|
||||
"standalone": false
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"outputPath": "dist/angular-example",
|
||||
"outputPath": "dist/angular-modern-examples",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"assets": ["src/favicon.ico", "src/assets"],
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
}
|
||||
],
|
||||
"styles": ["src/styles.css"],
|
||||
"scripts": []
|
||||
},
|
||||
|
|
@ -27,24 +42,21 @@
|
|||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
"maximumWarning": "500kB",
|
||||
"maximumError": "1MB"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
"maximumWarning": "4kB",
|
||||
"maximumError": "8kB"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"optimization": false,
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true,
|
||||
"namedChunks": true
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
|
|
@ -53,40 +65,33 @@
|
|||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "angular-example:build:production"
|
||||
"buildTarget": "angular-modern-examples:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "angular-example:build:development"
|
||||
"buildTarget": "angular-modern-examples:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "angular-example:build"
|
||||
}
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n"
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": ["zone.js", "zone.js/testing"],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"assets": ["src/favicon.ico", "src/assets"],
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "public"
|
||||
}
|
||||
],
|
||||
"styles": ["src/styles.css"],
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-eslint/builder:lint",
|
||||
"options": {
|
||||
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"schematicCollections": ["@angular-eslint/schematics"]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,33 +5,31 @@
|
|||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development"
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^18.0.0",
|
||||
"@angular/common": "^18.0.0",
|
||||
"@angular/compiler": "^18.0.0",
|
||||
"@angular/core": "^18.0.0",
|
||||
"@angular/forms": "^18.0.0",
|
||||
"@angular/platform-browser": "^18.0.0",
|
||||
"@angular/platform-browser-dynamic": "^18.0.0",
|
||||
"@angular/router": "^18.0.0",
|
||||
"@angular/common": "^19.2.0",
|
||||
"@angular/compiler": "^19.2.0",
|
||||
"@angular/core": "^19.2.0",
|
||||
"@angular/forms": "^19.2.0",
|
||||
"@angular/platform-browser": "^19.2.0",
|
||||
"@angular/platform-browser-dynamic": "^19.2.0",
|
||||
"@angular/router": "^19.2.0",
|
||||
"@uppy/angular": "workspace:*",
|
||||
"@uppy/core": "workspace:*",
|
||||
"@uppy/dashboard": "workspace:*",
|
||||
"@uppy/google-drive": "workspace:*",
|
||||
"@uppy/tus": "workspace:*",
|
||||
"@uppy/utils": "workspace:*",
|
||||
"@uppy/webcam": "workspace:*",
|
||||
"rxjs": "~7.8.0",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.14.3"
|
||||
"zone.js": "~0.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^18.0.2",
|
||||
"@angular/cli": "^18.0.2",
|
||||
"@angular/compiler-cli": "^18.0.0",
|
||||
"typescript": "~5.4"
|
||||
"@angular-devkit/build-angular": "^19.2.6",
|
||||
"@angular/cli": "^19.2.6",
|
||||
"@angular/compiler-cli": "^19.2.0",
|
||||
"typescript": "~5.7.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
examples/angular/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -0,0 +1,181 @@
|
|||
/* Light theme with stealthy button and heading */
|
||||
.app-container {
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
|
||||
.app-header {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
padding: 30px 20px;
|
||||
background: linear-gradient(135deg, #718096 0%, #4a5568 50%, #2d3748 100%);
|
||||
color: #e2e8f0;
|
||||
border-radius: 12px;
|
||||
box-shadow:
|
||||
0 8px 32px rgba(0, 0, 0, 0.3),
|
||||
0 0 0 1px rgba(113, 128, 150, 0.4),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.15);
|
||||
border: 1px solid #718096;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app-header::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 1px;
|
||||
background: linear-gradient(90deg, transparent, #a0aec0, transparent);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.app-header h1 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 2.5rem;
|
||||
font-weight: 700;
|
||||
background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
text-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.app-header p {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
opacity: 0.9;
|
||||
color: #e2e8f0;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.app-main {
|
||||
display: grid;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
.dashboard-section,
|
||||
.modal-section {
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
border: 1px solid #e1e5e9;
|
||||
}
|
||||
|
||||
.dashboard-section h2,
|
||||
.modal-section h2 {
|
||||
margin: 0 0 20px 0;
|
||||
color: #2c3e50;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-section p {
|
||||
color: #7f8c8d;
|
||||
margin-bottom: 20px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.toggle-button {
|
||||
background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
|
||||
color: #e2e8f0;
|
||||
border: 1px solid #4a5568;
|
||||
padding: 15px 30px;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow:
|
||||
0 4px 16px rgba(0, 0, 0, 0.2),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.toggle-button::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(160, 174, 192, 0.3),
|
||||
transparent
|
||||
);
|
||||
transition: left 0.5s ease;
|
||||
}
|
||||
|
||||
.toggle-button:hover::before {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
.toggle-button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow:
|
||||
0 8px 25px rgba(0, 0, 0, 0.3),
|
||||
0 0 0 1px rgba(160, 174, 192, 0.6),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.2);
|
||||
border-color: #a0aec0;
|
||||
color: #f7fafc;
|
||||
background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
|
||||
}
|
||||
|
||||
.toggle-button.active {
|
||||
background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
|
||||
border-color: #fc8181;
|
||||
box-shadow:
|
||||
0 4px 16px rgba(229, 62, 62, 0.3),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.toggle-button.active::before {
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(255, 255, 255, 0.2),
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
.toggle-button.active:hover {
|
||||
box-shadow:
|
||||
0 8px 25px rgba(229, 62, 62, 0.4),
|
||||
0 0 0 1px rgba(229, 62, 62, 0.8),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.2);
|
||||
border-color: #feb2b2;
|
||||
}
|
||||
|
||||
/* Responsive design */
|
||||
@media (max-width: 768px) {
|
||||
.app-container {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.app-header {
|
||||
padding: 20px 15px;
|
||||
}
|
||||
|
||||
.app-header h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.dashboard-section,
|
||||
.modal-section {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.toggle-button {
|
||||
width: 100%;
|
||||
padding: 18px;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,838 +1,37 @@
|
|||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * The content below * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * Delete the template below * * * * * * * * * * -->
|
||||
<!-- * * * * * * * to get started with your project! * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<div class="app-container">
|
||||
<header class="app-header">
|
||||
<h1>{{ title }}</h1>
|
||||
<!-- <p>Upload images and videos using the Uppy Dashboard modal</p> -->
|
||||
</header>
|
||||
|
||||
<style>
|
||||
:host {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
||||
Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
||||
'Segoe UI Symbol';
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
box-sizing: border-box;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
<main class="app-main">
|
||||
<!-- Inline Dashboard (always visible) -->
|
||||
<section class="dashboard-section">
|
||||
<h2>📁 File Upload Dashboard</h2>
|
||||
<uppy-dashboard
|
||||
[uppy]="uppy"
|
||||
[props]="dashboardProps"
|
||||
></uppy-dashboard>
|
||||
</section>
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin: 8px 0;
|
||||
}
|
||||
<!-- Toggle Button for Modal -->
|
||||
<section class="modal-section">
|
||||
<h2>🚀 Modal Dashboard</h2>
|
||||
<p>You can also open the dashboard in a modal overlay:</p>
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
<button
|
||||
class="toggle-button"
|
||||
(click)="toggleModal()"
|
||||
[class.active]="showModal">
|
||||
{{ showModal ? '✕ Close Modal Dashboard' : '📤 Open Modal Dashboard' }}
|
||||
</button>
|
||||
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #1976d2;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.toolbar img {
|
||||
margin: 0 16px;
|
||||
}
|
||||
|
||||
.toolbar #twitter-logo {
|
||||
height: 40px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
|
||||
.toolbar #youtube-logo {
|
||||
height: 40px;
|
||||
margin: 0 16px;
|
||||
}
|
||||
|
||||
.toolbar #twitter-logo:hover,
|
||||
.toolbar #youtube-logo:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
margin: 82px auto 32px;
|
||||
padding: 0 16px;
|
||||
max-width: 960px;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
svg.material-icons {
|
||||
height: 24px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
svg.material-icons:not(:last-child) {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.card svg.material-icons path {
|
||||
fill: #888;
|
||||
}
|
||||
|
||||
.card-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.card {
|
||||
all: unset;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #eee;
|
||||
background-color: #fafafa;
|
||||
height: 40px;
|
||||
width: 200px;
|
||||
margin: 0 8px 16px;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
transition: all 0.2s ease-in-out;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.card-container .card:not(:last-child) {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.card.card-small {
|
||||
height: 16px;
|
||||
width: 168px;
|
||||
}
|
||||
|
||||
.card-container .card:not(.highlight-card) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.card-container .card:not(.highlight-card):hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 4px 17px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.card-container .card:not(.highlight-card):hover .material-icons path {
|
||||
fill: rgb(105, 103, 103);
|
||||
}
|
||||
|
||||
.card.highlight-card {
|
||||
background-color: #1976d2;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
width: auto;
|
||||
min-width: 30%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.card.card.highlight-card span {
|
||||
margin-left: 60px;
|
||||
}
|
||||
|
||||
svg#rocket {
|
||||
width: 80px;
|
||||
position: absolute;
|
||||
left: -10px;
|
||||
top: -24px;
|
||||
}
|
||||
|
||||
svg#rocket-smoke {
|
||||
height: calc(100vh - 95px);
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 180px;
|
||||
z-index: -10;
|
||||
}
|
||||
|
||||
a,
|
||||
a:visited,
|
||||
a:hover {
|
||||
color: #1976d2;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #125699;
|
||||
}
|
||||
|
||||
.terminal {
|
||||
position: relative;
|
||||
width: 80%;
|
||||
max-width: 600px;
|
||||
border-radius: 6px;
|
||||
padding-top: 45px;
|
||||
margin-top: 8px;
|
||||
overflow: hidden;
|
||||
background-color: rgb(15, 15, 16);
|
||||
}
|
||||
|
||||
.terminal::before {
|
||||
content: '\2022 \2022 \2022';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 4px;
|
||||
background: rgb(58, 58, 58);
|
||||
color: #c2c3c4;
|
||||
width: 100%;
|
||||
font-size: 2rem;
|
||||
line-height: 0;
|
||||
padding: 14px 0;
|
||||
text-indent: 4px;
|
||||
}
|
||||
|
||||
.terminal pre {
|
||||
font-family:
|
||||
SFMono-Regular,
|
||||
Consolas,
|
||||
Liberation Mono,
|
||||
Menlo,
|
||||
monospace;
|
||||
color: white;
|
||||
padding: 0 1rem 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.circle-link {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
border-radius: 40px;
|
||||
margin: 8px;
|
||||
background-color: white;
|
||||
border: 1px solid #eeeeee;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
box-shadow:
|
||||
0 1px 3px rgba(0, 0, 0, 0.12),
|
||||
0 1px 2px rgba(0, 0, 0, 0.24);
|
||||
transition: 1s ease-out;
|
||||
}
|
||||
|
||||
.circle-link:hover {
|
||||
transform: translateY(-0.25rem);
|
||||
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
footer a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.github-star-badge {
|
||||
color: #24292e;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
padding: 3px 10px;
|
||||
border: 1px solid rgba(27, 31, 35, 0.2);
|
||||
border-radius: 3px;
|
||||
background-image: linear-gradient(-180deg, #fafbfc, #eff3f6 90%);
|
||||
margin-left: 4px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.github-star-badge:hover {
|
||||
background-image: linear-gradient(-180deg, #f0f3f6, #e6ebf1 90%);
|
||||
border-color: rgba(27, 31, 35, 0.35);
|
||||
background-position: -0.5em;
|
||||
}
|
||||
|
||||
.github-star-badge .material-icons {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
svg#clouds {
|
||||
position: fixed;
|
||||
bottom: -160px;
|
||||
left: -230px;
|
||||
z-index: -10;
|
||||
width: 1920px;
|
||||
}
|
||||
|
||||
/* Responsive Styles */
|
||||
@media screen and (max-width: 767px) {
|
||||
.card-container > *:not(.circle-link),
|
||||
.terminal {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.card:not(.highlight-card) {
|
||||
height: 16px;
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.card.highlight-card span {
|
||||
margin-left: 72px;
|
||||
}
|
||||
|
||||
svg#rocket-smoke {
|
||||
right: 120px;
|
||||
transform: rotate(-5deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 575px) {
|
||||
svg#rocket-smoke {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Toolbar -->
|
||||
<div class="toolbar" role="banner">
|
||||
<img
|
||||
width="40"
|
||||
alt="Angular Logo"
|
||||
src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="
|
||||
/>
|
||||
<span>Welcome</span>
|
||||
<div class="spacer"></div>
|
||||
<a
|
||||
aria-label="Angular on twitter"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://twitter.com/angular"
|
||||
title="Twitter"
|
||||
>
|
||||
<svg
|
||||
id="twitter-logo"
|
||||
height="24"
|
||||
data-name="Logo"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 400 400"
|
||||
>
|
||||
<rect width="400" height="400" fill="none" />
|
||||
<path
|
||||
d="M153.62,301.59c94.34,0,145.94-78.16,145.94-145.94,0-2.22,0-4.43-.15-6.63A104.36,104.36,0,0,0,325,122.47a102.38,102.38,0,0,1-29.46,8.07,51.47,51.47,0,0,0,22.55-28.37,102.79,102.79,0,0,1-32.57,12.45,51.34,51.34,0,0,0-87.41,46.78A145.62,145.62,0,0,1,92.4,107.81a51.33,51.33,0,0,0,15.88,68.47A50.91,50.91,0,0,1,85,169.86c0,.21,0,.43,0,.65a51.31,51.31,0,0,0,41.15,50.28,51.21,51.21,0,0,1-23.16.88,51.35,51.35,0,0,0,47.92,35.62,102.92,102.92,0,0,1-63.7,22A104.41,104.41,0,0,1,75,278.55a145.21,145.21,0,0,0,78.62,23"
|
||||
fill="#fff"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<a
|
||||
aria-label="Angular on YouTube"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://youtube.com/angular"
|
||||
title="YouTube"
|
||||
>
|
||||
<svg
|
||||
id="youtube-logo"
|
||||
height="24"
|
||||
width="24"
|
||||
data-name="Logo"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
fill="#fff"
|
||||
>
|
||||
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||
<path
|
||||
d="M21.58 7.19c-.23-.86-.91-1.54-1.77-1.77C18.25 5 12 5 12 5s-6.25 0-7.81.42c-.86.23-1.54.91-1.77 1.77C2 8.75 2 12 2 12s0 3.25.42 4.81c.23.86.91 1.54 1.77 1.77C5.75 19 12 19 12 19s6.25 0 7.81-.42c.86-.23 1.54-.91 1.77-1.77C22 15.25 22 12 22 12s0-3.25-.42-4.81zM10 15V9l5.2 3-5.2 3z"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<!-- Dashboard Modal -->
|
||||
<uppy-dashboard-modal
|
||||
[uppy]="uppy"
|
||||
[open]="showModal"
|
||||
[props]="dashboardModalProps"
|
||||
></uppy-dashboard-modal>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<div class="content" role="main">
|
||||
<!-- Highlight Card -->
|
||||
<div class="card highlight-card card-small">
|
||||
<svg
|
||||
id="rocket"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="101.678"
|
||||
height="101.678"
|
||||
viewBox="0 0 101.678 101.678"
|
||||
>
|
||||
<title>Rocket Ship</title>
|
||||
<g id="Group_83" data-name="Group 83" transform="translate(-141 -696)">
|
||||
<circle
|
||||
id="Ellipse_8"
|
||||
data-name="Ellipse 8"
|
||||
cx="50.839"
|
||||
cy="50.839"
|
||||
r="50.839"
|
||||
transform="translate(141 696)"
|
||||
fill="#dd0031"
|
||||
/>
|
||||
<g
|
||||
id="Group_47"
|
||||
data-name="Group 47"
|
||||
transform="translate(165.185 720.185)"
|
||||
>
|
||||
<path
|
||||
id="Path_33"
|
||||
data-name="Path 33"
|
||||
d="M3.4,42.615a3.084,3.084,0,0,0,3.553,3.553,21.419,21.419,0,0,0,12.215-6.107L9.511,30.4A21.419,21.419,0,0,0,3.4,42.615Z"
|
||||
transform="translate(0.371 3.363)"
|
||||
fill="#fff"
|
||||
/>
|
||||
<path
|
||||
id="Path_34"
|
||||
data-name="Path 34"
|
||||
d="M53.3,3.221A3.09,3.09,0,0,0,50.081,0,48.227,48.227,0,0,0,18.322,13.437c-6-1.666-14.991-1.221-18.322,7.218A33.892,33.892,0,0,1,9.439,25.1l-.333.666a3.013,3.013,0,0,0,.555,3.553L23.985,43.641a2.9,2.9,0,0,0,3.553.555l.666-.333A33.892,33.892,0,0,1,32.647,53.3c8.55-3.664,8.884-12.326,7.218-18.322A48.227,48.227,0,0,0,53.3,3.221ZM34.424,9.772a6.439,6.439,0,1,1,9.106,9.106,6.368,6.368,0,0,1-9.106,0A6.467,6.467,0,0,1,34.424,9.772Z"
|
||||
transform="translate(0 0.005)"
|
||||
fill="#fff"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
<span>{{ title }} app is running!</span>
|
||||
|
||||
<svg
|
||||
id="rocket-smoke"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="516.119"
|
||||
height="1083.632"
|
||||
viewBox="0 0 516.119 1083.632"
|
||||
>
|
||||
<title>Rocket Ship Smoke</title>
|
||||
<path
|
||||
id="Path_40"
|
||||
data-name="Path 40"
|
||||
d="M644.6,141S143.02,215.537,147.049,870.207s342.774,201.755,342.774,201.755S404.659,847.213,388.815,762.2c-27.116-145.51-11.551-384.124,271.9-609.1C671.15,139.365,644.6,141,644.6,141Z"
|
||||
transform="translate(-147.025 -140.939)"
|
||||
fill="#f5f5f5"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<!-- Resources -->
|
||||
<h2>Resources</h2>
|
||||
<p>Here are some links to help you get started:</p>
|
||||
|
||||
<div class="card-container">
|
||||
<a
|
||||
class="card"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://angular.io/tutorial"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82zM12 3L1 9l11 6 9-4.91V17h2V9L12 3z"
|
||||
/>
|
||||
</svg>
|
||||
<span>Learn Angular</span>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" />
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a
|
||||
class="card"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://angular.io/cli"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"
|
||||
/>
|
||||
</svg>
|
||||
<span>CLI Documentation</span>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" />
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a
|
||||
class="card"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://material.angular.io"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
style="margin-right: 8px"
|
||||
width="21.813"
|
||||
height="23.453"
|
||||
viewBox="0 0 179.2 192.7"
|
||||
>
|
||||
<path
|
||||
fill="#ffa726"
|
||||
d="M89.4 0 0 32l13.5 118.4 75.9 42.3 76-42.3L179.2 32 89.4 0z"
|
||||
/>
|
||||
<path fill="#fb8c00" d="M89.4 0v192.7l76-42.3L179.2 32 89.4 0z" />
|
||||
<path
|
||||
fill="#ffe0b2"
|
||||
d="m102.9 146.3-63.3-30.5 36.3-22.4 63.7 30.6-36.7 22.3z"
|
||||
/>
|
||||
<path
|
||||
fill="#fff3e0"
|
||||
d="M102.9 122.8 39.6 92.2l36.3-22.3 63.7 30.6-36.7 22.3z"
|
||||
/>
|
||||
<path
|
||||
fill="#fff"
|
||||
d="M102.9 99.3 39.6 68.7l36.3-22.4 63.7 30.6-36.7 22.4z"
|
||||
/>
|
||||
</svg>
|
||||
<span>Angular Material</span>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" />
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a
|
||||
class="card"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://blog.angular.io/"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M13.5.67s.74 2.65.74 4.8c0 2.06-1.35 3.73-3.41 3.73-2.07 0-3.63-1.67-3.63-3.73l.03-.36C5.21 7.51 4 10.62 4 14c0 4.42 3.58 8 8 8s8-3.58 8-8C20 8.61 17.41 3.8 13.5.67zM11.71 19c-1.78 0-3.22-1.4-3.22-3.14 0-1.62 1.05-2.76 2.81-3.12 1.77-.36 3.6-1.21 4.62-2.58.39 1.29.59 2.65.59 4.04 0 2.65-2.15 4.8-4.8 4.8z"
|
||||
/>
|
||||
</svg>
|
||||
<span>Angular Blog</span>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" />
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a
|
||||
class="card"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://angular.io/devtools/"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
enable-background="new 0 0 24 24"
|
||||
height="24px"
|
||||
viewBox="0 0 24 24"
|
||||
width="24px"
|
||||
fill="#000000"
|
||||
>
|
||||
<g><rect fill="none" height="24" width="24" /></g>
|
||||
<g>
|
||||
<g>
|
||||
<path
|
||||
d="M14.73,13.31C15.52,12.24,16,10.93,16,9.5C16,5.91,13.09,3,9.5,3S3,5.91,3,9.5C3,13.09,5.91,16,9.5,16 c1.43,0,2.74-0.48,3.81-1.27L19.59,21L21,19.59L14.73,13.31z M9.5,14C7.01,14,5,11.99,5,9.5S7.01,5,9.5,5S14,7.01,14,9.5 S11.99,14,9.5,14z"
|
||||
/>
|
||||
<polygon
|
||||
points="10.29,8.44 9.5,6 8.71,8.44 6.25,8.44 8.26,10.03 7.49,12.5 9.5,10.97 11.51,12.5 10.74,10.03 12.75,8.44"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<span>Angular DevTools</span>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" />
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Next Steps -->
|
||||
<h2>Next Steps</h2>
|
||||
<p>What do you want to do next with your app?</p>
|
||||
|
||||
<input type="hidden" #selection />
|
||||
|
||||
<div class="card-container">
|
||||
<button
|
||||
class="card card-small"
|
||||
(click)="selection.value = 'component'"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||
</svg>
|
||||
<span>New Component</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="card card-small"
|
||||
(click)="selection.value = 'material'"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||
</svg>
|
||||
<span>Angular Material</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="card card-small"
|
||||
(click)="selection.value = 'pwa'"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||
</svg>
|
||||
<span>Add PWA Support</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="card card-small"
|
||||
(click)="selection.value = 'dependency'"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||
</svg>
|
||||
<span>Add Dependency</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="card card-small"
|
||||
(click)="selection.value = 'test'"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||
</svg>
|
||||
<span>Run and Watch Tests</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="card card-small"
|
||||
(click)="selection.value = 'build'"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
||||
</svg>
|
||||
<span>Build for Production</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Terminal -->
|
||||
<div class="terminal" [ngSwitch]="selection.value">
|
||||
<pre *ngSwitchDefault>ng generate component xyz</pre>
|
||||
<pre *ngSwitchCase="'material'">ng add @angular/material</pre>
|
||||
<pre *ngSwitchCase="'pwa'">ng add @angular/pwa</pre>
|
||||
<pre *ngSwitchCase="'dependency'">ng add _____</pre>
|
||||
<pre *ngSwitchCase="'test'">ng test</pre>
|
||||
<pre *ngSwitchCase="'build'">ng build</pre>
|
||||
</div>
|
||||
|
||||
<!-- Links -->
|
||||
<div class="card-container">
|
||||
<a
|
||||
class="circle-link"
|
||||
title="Find a Local Meetup"
|
||||
href="https://www.meetup.com/find/?keywords=angular"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24.607"
|
||||
height="23.447"
|
||||
viewBox="0 0 24.607 23.447"
|
||||
>
|
||||
<title>Meetup Logo</title>
|
||||
<path
|
||||
id="logo--mSwarm"
|
||||
d="M21.221,14.95A4.393,4.393,0,0,1,17.6,19.281a4.452,4.452,0,0,1-.8.069c-.09,0-.125.035-.154.117a2.939,2.939,0,0,1-2.506,2.091,2.868,2.868,0,0,1-2.248-.624.168.168,0,0,0-.245-.005,3.926,3.926,0,0,1-2.589.741,4.015,4.015,0,0,1-3.7-3.347,2.7,2.7,0,0,1-.043-.38c0-.106-.042-.146-.143-.166a3.524,3.524,0,0,1-1.516-.69A3.623,3.623,0,0,1,2.23,14.557a3.66,3.66,0,0,1,1.077-3.085.138.138,0,0,0,.026-.2,3.348,3.348,0,0,1-.451-1.821,3.46,3.46,0,0,1,2.749-3.28.44.44,0,0,0,.355-.281,5.072,5.072,0,0,1,3.863-3,5.028,5.028,0,0,1,3.555.666.31.31,0,0,0,.271.03A4.5,4.5,0,0,1,18.3,4.7a4.4,4.4,0,0,1,1.334,2.751,3.658,3.658,0,0,1,.022.706.131.131,0,0,0,.1.157,2.432,2.432,0,0,1,1.574,1.645,2.464,2.464,0,0,1-.7,2.616c-.065.064-.051.1-.014.166A4.321,4.321,0,0,1,21.221,14.95ZM13.4,14.607a2.09,2.09,0,0,0,1.409,1.982,4.7,4.7,0,0,0,1.275.221,1.807,1.807,0,0,0,.9-.151.542.542,0,0,0,.321-.545.558.558,0,0,0-.359-.534,1.2,1.2,0,0,0-.254-.078c-.262-.047-.526-.086-.787-.138a.674.674,0,0,1-.617-.75,3.394,3.394,0,0,1,.218-1.109c.217-.658.509-1.286.79-1.918a15.609,15.609,0,0,0,.745-1.86,1.95,1.95,0,0,0,.06-1.073,1.286,1.286,0,0,0-1.051-1.033,1.977,1.977,0,0,0-1.521.2.339.339,0,0,1-.446-.042c-.1-.092-.2-.189-.307-.284a1.214,1.214,0,0,0-1.643-.061,7.563,7.563,0,0,1-.614.512A.588.588,0,0,1,10.883,8c-.215-.115-.437-.215-.659-.316a2.153,2.153,0,0,0-.695-.248A2.091,2.091,0,0,0,7.541,8.562a9.915,9.915,0,0,0-.405.986c-.559,1.545-1.015,3.123-1.487,4.7a1.528,1.528,0,0,0,.634,1.777,1.755,1.755,0,0,0,1.5.211,1.35,1.35,0,0,0,.824-.858c.543-1.281,1.032-2.584,1.55-3.875.142-.355.28-.712.432-1.064a.548.548,0,0,1,.851-.24.622.622,0,0,1,.185.539,2.161,2.161,0,0,1-.181.621c-.337.852-.68,1.7-1.018,2.552a2.564,2.564,0,0,0-.173.528.624.624,0,0,0,.333.71,1.073,1.073,0,0,0,.814.034,1.22,1.22,0,0,0,.657-.655q.758-1.488,1.511-2.978.35-.687.709-1.37a1.073,1.073,0,0,1,.357-.434.43.43,0,0,1,.463-.016.373.373,0,0,1,.153.387.7.7,0,0,1-.057.236c-.065.157-.127.316-.2.469-.42.883-.846,1.763-1.262,2.648A2.463,2.463,0,0,0,13.4,14.607Zm5.888,6.508a1.09,1.09,0,0,0-2.179.006,1.09,1.09,0,0,0,2.179-.006ZM1.028,12.139a1.038,1.038,0,1,0,.01-2.075,1.038,1.038,0,0,0-.01,2.075ZM13.782.528a1.027,1.027,0,1,0-.011,2.055A1.027,1.027,0,0,0,13.782.528ZM22.21,6.95a.882.882,0,0,0-1.763.011A.882.882,0,0,0,22.21,6.95ZM4.153,4.439a.785.785,0,1,0,.787-.78A.766.766,0,0,0,4.153,4.439Zm8.221,18.22a.676.676,0,1,0-.677.666A.671.671,0,0,0,12.374,22.658ZM22.872,12.2a.674.674,0,0,0-.665.665.656.656,0,0,0,.655.643.634.634,0,0,0,.655-.644A.654.654,0,0,0,22.872,12.2ZM7.171-.123A.546.546,0,0,0,6.613.43a.553.553,0,1,0,1.106,0A.539.539,0,0,0,7.171-.123ZM24.119,9.234a.507.507,0,0,0-.493.488.494.494,0,0,0,.494.494.48.48,0,0,0,.487-.483A.491.491,0,0,0,24.119,9.234Zm-19.454,9.7a.5.5,0,0,0-.488-.488.491.491,0,0,0-.487.5.483.483,0,0,0,.491.479A.49.49,0,0,0,4.665,18.936Z"
|
||||
transform="translate(0 0.123)"
|
||||
fill="#f64060"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a
|
||||
class="circle-link"
|
||||
title="Join the Conversation on Discord"
|
||||
href="https://discord.gg/angular"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="26"
|
||||
height="26"
|
||||
viewBox="0 0 245 240"
|
||||
>
|
||||
<title>Discord Logo</title>
|
||||
<path
|
||||
d="M104.4 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1.1-6.1-4.5-11.1-10.2-11.1zM140.9 103.9c-5.7 0-10.2 5-10.2 11.1s4.6 11.1 10.2 11.1c5.7 0 10.2-5 10.2-11.1s-4.5-11.1-10.2-11.1z"
|
||||
/>
|
||||
<path
|
||||
d="M189.5 20h-134C44.2 20 35 29.2 35 40.6v135.2c0 11.4 9.2 20.6 20.5 20.6h113.4l-5.3-18.5 12.8 11.9 12.1 11.2 21.5 19V40.6c0-11.4-9.2-20.6-20.5-20.6zm-38.6 130.6s-3.6-4.3-6.6-8.1c13.1-3.7 18.1-11.9 18.1-11.9-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.5-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.7-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.3-1.8-1-2.8-1.7-2.8-1.7s4.8 8 17.5 11.8c-3 3.8-6.7 8.3-6.7 8.3-22.1-.7-30.5-15.2-30.5-15.2 0-32.2 14.4-58.3 14.4-58.3 14.4-10.8 28.1-10.5 28.1-10.5l1 1.2c-18 5.2-26.3 13.1-26.3 13.1s2.2-1.2 5.9-2.9c10.7-4.7 19.2-6 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.6 0 0-7.9-7.5-24.9-12.7l1.4-1.6s13.7-.3 28.1 10.5c0 0 14.4 26.1 14.4 58.3 0 0-8.5 14.5-30.6 15.2z"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer>
|
||||
Love Angular?
|
||||
<a href="https://github.com/angular/angular" target="_blank" rel="noopener">
|
||||
Give our repo a star.
|
||||
<div class="github-star-badge">
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path d="M0 0h24v24H0z" fill="none" />
|
||||
<path
|
||||
d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"
|
||||
/>
|
||||
</svg>
|
||||
Star
|
||||
</div>
|
||||
</a>
|
||||
<a href="https://github.com/angular/angular" target="_blank" rel="noopener">
|
||||
<svg
|
||||
class="material-icons"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"
|
||||
fill="#1976d2"
|
||||
/>
|
||||
<path d="M0 0h24v24H0z" fill="none" />
|
||||
</svg>
|
||||
</a>
|
||||
</footer>
|
||||
|
||||
<svg
|
||||
id="clouds"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="2611.084"
|
||||
height="485.677"
|
||||
viewBox="0 0 2611.084 485.677"
|
||||
>
|
||||
<title>Gray Clouds Background</title>
|
||||
<path
|
||||
id="Path_39"
|
||||
data-name="Path 39"
|
||||
d="M2379.709,863.793c10-93-77-171-168-149-52-114-225-105-264,15-75,3-140,59-152,133-30,2.83-66.725,9.829-93.5,26.25-26.771-16.421-63.5-23.42-93.5-26.25-12-74-77-130-152-133-39-120-212-129-264-15-54.084-13.075-106.753,9.173-138.488,48.9-31.734-39.726-84.4-61.974-138.487-48.9-52-114-225-105-264,15a162.027,162.027,0,0,0-103.147,43.044c-30.633-45.365-87.1-72.091-145.206-58.044-52-114-225-105-264,15-75,3-140,59-152,133-53,5-127,23-130,83-2,42,35,72,70,86,49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33,61.112,8.015,113.854-5.72,150.492-29.764a165.62,165.62,0,0,0,110.861-3.236c47,94,178,113,251,33,31.385,4.116,60.563,2.495,86.487-3.311,25.924,5.806,55.1,7.427,86.488,3.311,73,80,204,61,251-33a165.625,165.625,0,0,0,120,0c51,13,108,15,157-5a147.188,147.188,0,0,0,33.5-18.694,147.217,147.217,0,0,0,33.5,18.694c49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33C2446.709,1093.793,2554.709,922.793,2379.709,863.793Z"
|
||||
transform="translate(142.69 -634.312)"
|
||||
fill="#eee"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * The content above * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * End of Placeholder * * * * * * * * * * * -->
|
||||
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
|
||||
|
|
|
|||
31
examples/angular/src/app/app.component.spec.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { TestBed } from '@angular/core/testing'
|
||||
import { AppComponent } from './app.component'
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent)
|
||||
const app = fixture.componentInstance
|
||||
expect(app).toBeTruthy()
|
||||
})
|
||||
|
||||
it(`should have as title 'angular-modern-examples'`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent)
|
||||
const app = fixture.componentInstance
|
||||
expect(app.title).toEqual('angular-modern-examples')
|
||||
})
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent)
|
||||
fixture.detectChanges()
|
||||
const compiled = fixture.nativeElement as HTMLElement
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain(
|
||||
'Hello, angular-modern-examples',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
@ -1,58 +1,32 @@
|
|||
import { CommonModule } from '@angular/common'
|
||||
import { Component, type OnInit } from '@angular/core'
|
||||
import { DashboardComponent, DashboardModalComponent } from '@uppy/angular'
|
||||
import { Uppy } from '@uppy/core'
|
||||
import GoogleDrive from '@uppy/google-drive'
|
||||
import Tus from '@uppy/tus'
|
||||
import Webcam from '@uppy/webcam'
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
template: /* html */ `
|
||||
<h1>Uppy Angular Example!</h1>
|
||||
<h2>Inline dashboard</h2>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
(change)="showInline = $any($event.target)?.checked"
|
||||
[checked]="showInline"
|
||||
/>
|
||||
Show Dashboard
|
||||
</label>
|
||||
|
||||
<uppy-dashboard
|
||||
[uppy]="uppy"
|
||||
[props]="dashboardProps"
|
||||
*ngIf="showInline"
|
||||
></uppy-dashboard>
|
||||
|
||||
<h2>Modal Dashboard</h2>
|
||||
<div>
|
||||
<uppy-dashboard-modal
|
||||
[uppy]="uppy"
|
||||
[open]="showModal"
|
||||
[props]="dashboardModalProps"
|
||||
></uppy-dashboard-modal>
|
||||
<button (click)="showModal = !showModal">
|
||||
{{ showModal ? 'Close dashboard' : 'Open dashboard' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h2>Progress Bar</h2>
|
||||
<uppy-progress-bar
|
||||
[uppy]="uppy"
|
||||
[props]="{ hideAfterFinish: false }"
|
||||
></uppy-progress-bar>
|
||||
`,
|
||||
styleUrls: [],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css'],
|
||||
standalone: true,
|
||||
imports: [CommonModule, DashboardComponent, DashboardModalComponent],
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
title = 'angular-example'
|
||||
|
||||
showInline = false
|
||||
title = 'Uppy Dashboard Angular Example'
|
||||
|
||||
showModal = false
|
||||
|
||||
dashboardProps = {
|
||||
plugins: ['Webcam'],
|
||||
height: 470,
|
||||
showProgressDetails: true,
|
||||
note: 'Images and video only, 2-3 files, up to 1 MB',
|
||||
restrictions: {
|
||||
maxFileSize: 1000000,
|
||||
maxNumberOfFiles: 3,
|
||||
allowedFileTypes: ['image/*', 'video/*'],
|
||||
},
|
||||
}
|
||||
|
||||
dashboardModalProps = {
|
||||
|
|
@ -60,14 +34,30 @@ export class AppComponent implements OnInit {
|
|||
onRequestCloseModal: (): void => {
|
||||
this.showModal = false
|
||||
},
|
||||
closeModalOnClickOutside: true,
|
||||
animateOpenClose: true,
|
||||
}
|
||||
|
||||
uppy = new Uppy({ debug: true, autoProceed: true })
|
||||
uppy = new Uppy({
|
||||
debug: true,
|
||||
autoProceed: false,
|
||||
restrictions: {
|
||||
maxFileSize: 1000000,
|
||||
maxNumberOfFiles: 3,
|
||||
allowedFileTypes: ['image/*', 'video/*'],
|
||||
},
|
||||
})
|
||||
|
||||
ngOnInit(): void {
|
||||
this.uppy
|
||||
.use(Webcam)
|
||||
.use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/' })
|
||||
.use(GoogleDrive, { companionUrl: 'https://companion.uppy.io' })
|
||||
.on('complete', (result) => {
|
||||
console.log("Upload complete! We've uploaded these files:", result)
|
||||
})
|
||||
}
|
||||
|
||||
toggleModal(): void {
|
||||
this.showModal = !this.showModal
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
import { NgModule } from '@angular/core'
|
||||
import { BrowserModule } from '@angular/platform-browser'
|
||||
|
||||
import {
|
||||
UppyAngularDashboardModalModule,
|
||||
UppyAngularDashboardModule,
|
||||
UppyAngularStatusBarModule,
|
||||
} from '@uppy/angular'
|
||||
import { AppComponent } from './app.component'
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
UppyAngularDashboardModule,
|
||||
UppyAngularStatusBarModule,
|
||||
UppyAngularDashboardModalModule,
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
Before Width: | Height: | Size: 948 B |
|
|
@ -1,13 +1,13 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>AngularExample</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>AngularModernExamples</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
||||
import { bootstrapApplication } from '@angular/platform-browser'
|
||||
import { AppComponent } from './app/app.component'
|
||||
|
||||
import { AppModule } from './app/app.module'
|
||||
|
||||
platformBrowserDynamic()
|
||||
.bootstrapModule(AppModule)
|
||||
.catch((err) => console.error(err))
|
||||
bootstrapApplication(AppComponent).catch((err) => console.error(err))
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
/* You can add global styles to this file, and also import other style files */
|
||||
@import "@uppy/core/dist/style.css";
|
||||
@import "@uppy/dashboard/dist/style.css";
|
||||
/* Global styles for the Angular Uppy example */
|
||||
@import "@uppy/core/css/style.css";
|
||||
@import "@uppy/dashboard/css/style.css";
|
||||
@import "@uppy/webcam/css/style.css";
|
||||
@import "@uppy/drag-drop/css/style.css";
|
||||
@import "@uppy/status-bar/css/style.css";
|
||||
|
||||
/* Global reset and base styles */
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
||||
min-height: 100vh;
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
"types": ["jasmine"],
|
||||
"module": "es2022",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"files": ["src/main.ts"],
|
||||
"include": ["src/**/*.d.ts"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
|
|
@ -10,16 +10,21 @@
|
|||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"downlevelIteration": true,
|
||||
"skipLibCheck": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "bundler",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"useDefineForClassFields": false,
|
||||
"lib": ["ES2022", "dom"]
|
||||
"lib": ["ES2022", "dom"],
|
||||
"paths": {
|
||||
"@uppy/angular": [
|
||||
"../../packages/@uppy/angular/projects/uppy/angular/src/public-api.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
|
|
|
|||
10
examples/angular/tsconfig.spec.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
||||
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": ["jasmine"]
|
||||
},
|
||||
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
|
||||
}
|
||||
44
examples/nextjs/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/versions
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
# files
|
||||
files/
|
||||
36
examples/nextjs/README.md
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||
7
examples/nextjs/next.config.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import type { NextConfig } from 'next'
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
}
|
||||
|
||||
export default nextConfig
|
||||
31
examples/nextjs/package.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "example-nextjs",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack",
|
||||
"build": "next build --turbopack",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tus/file-store": "latest",
|
||||
"@tus/server": "latest",
|
||||
"@uppy/core": "workspace:*",
|
||||
"@uppy/dashboard": "workspace:*",
|
||||
"@uppy/react": "workspace:*",
|
||||
"@uppy/transloadit": "workspace:*",
|
||||
"@uppy/tus": "workspace:*",
|
||||
"@uppy/xhr-upload": "workspace:*",
|
||||
"next": "15.5.2",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"tailwindcss": "^4",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
5
examples/nextjs/postcss.config.mjs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const config = {
|
||||
plugins: ['@tailwindcss/postcss'],
|
||||
}
|
||||
|
||||
export default config
|
||||
1
examples/nextjs/public/file.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
||||
|
After Width: | Height: | Size: 391 B |
1
examples/nextjs/public/globe.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
||||
|
After Width: | Height: | Size: 1 KiB |
1
examples/nextjs/public/next.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
1
examples/nextjs/public/vercel.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 128 B |
1
examples/nextjs/public/window.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
||||
|
After Width: | Height: | Size: 385 B |
87
examples/nextjs/src/app/api/transloadit/route.ts
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
import crypto from 'node:crypto'
|
||||
import type { NextRequest } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
function utcDateString(ms: number): string {
|
||||
return new Date(ms)
|
||||
.toISOString()
|
||||
.replace(/-/g, '/')
|
||||
.replace(/T/, ' ')
|
||||
.replace(/\.\d+Z$/, '+00:00')
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const expires = utcDateString(Date.now() + 1 * 60 * 60 * 1000) // 1 hour expiry
|
||||
const authKey = process.env.TRANSLOADIT_KEY
|
||||
const authSecret = process.env.TRANSLOADIT_SECRET
|
||||
const templateId = process.env.TRANSLOADIT_TEMPLATE_ID
|
||||
|
||||
if (!authKey || !authSecret) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error:
|
||||
'Missing Transloadit credentials. Please set TRANSLOADIT_KEY and TRANSLOADIT_SECRET environment variables.',
|
||||
},
|
||||
{ status: 500 },
|
||||
)
|
||||
}
|
||||
|
||||
const body = await request.json().catch(() => ({}))
|
||||
|
||||
// Create a basic template if no template ID is provided
|
||||
const params = JSON.stringify({
|
||||
auth: {
|
||||
key: authKey,
|
||||
expires,
|
||||
},
|
||||
// Use template_id if provided, otherwise use inline steps
|
||||
...(templateId
|
||||
? { template_id: templateId }
|
||||
: {
|
||||
steps: {
|
||||
// Basic image resize step as an example
|
||||
resized: {
|
||||
use: ':original',
|
||||
robot: '/image/resize',
|
||||
width: 800,
|
||||
height: 600,
|
||||
resize_strategy: 'fit',
|
||||
imagemagick_stack: 'v3.0.0',
|
||||
},
|
||||
// Thumbnail generation
|
||||
thumbs: {
|
||||
use: ':original',
|
||||
robot: '/image/resize',
|
||||
width: 200,
|
||||
height: 200,
|
||||
resize_strategy: 'crop',
|
||||
imagemagick_stack: 'v3.0.0',
|
||||
},
|
||||
},
|
||||
}),
|
||||
fields: {
|
||||
// Dynamic fields you can use inside your Template
|
||||
customValue: body?.customValue ?? 'nextjs-example',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
})
|
||||
|
||||
const signatureBytes = crypto
|
||||
.createHmac('sha384', authSecret)
|
||||
.update(Buffer.from(params, 'utf-8'))
|
||||
const signature = `sha384:${signatureBytes.digest('hex')}`
|
||||
|
||||
return NextResponse.json({
|
||||
expires,
|
||||
signature,
|
||||
params: JSON.parse(params),
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error generating Transloadit signature:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to generate Transloadit signature' },
|
||||
{ status: 500 },
|
||||
)
|
||||
}
|
||||
}
|
||||
27
examples/nextjs/src/app/api/tus/[[...slug]]/route.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { mkdir } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { FileStore } from '@tus/file-store'
|
||||
import { Server } from '@tus/server'
|
||||
import type { NextRequest } from 'next/server'
|
||||
|
||||
// Ensure the upload directory exists
|
||||
const uploadDir = path.join(process.cwd(), 'files')
|
||||
await mkdir(uploadDir, { recursive: true }).catch(() => {
|
||||
// Directory might already exist, ignore the error
|
||||
})
|
||||
|
||||
const server = new Server({
|
||||
// `path` needs to match the route declared by the next file router
|
||||
// ie /api/tus
|
||||
path: '/api/tus',
|
||||
datastore: new FileStore({ directory: uploadDir }),
|
||||
respectForwardedHeaders: true,
|
||||
})
|
||||
|
||||
// For Next.js App Router, we use the handleWeb method which properly handles Web API Request/Response
|
||||
export const GET = async (req: NextRequest) => server.handleWeb(req)
|
||||
export const POST = async (req: NextRequest) => server.handleWeb(req)
|
||||
export const PATCH = async (req: NextRequest) => server.handleWeb(req)
|
||||
export const DELETE = async (req: NextRequest) => server.handleWeb(req)
|
||||
export const OPTIONS = async (req: NextRequest) => server.handleWeb(req)
|
||||
export const HEAD = async (req: NextRequest) => server.handleWeb(req)
|
||||
43
examples/nextjs/src/app/api/xhr/route.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { mkdir, writeFile } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import type { NextRequest } from 'next/server'
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const formData = await request.formData()
|
||||
const file = formData.get('file') as File | null
|
||||
|
||||
if (!file) {
|
||||
return NextResponse.json({ error: 'No file uploaded' }, { status: 400 })
|
||||
}
|
||||
|
||||
const buffer = Buffer.from(await file.arrayBuffer())
|
||||
const filename = file.name.replace(/\s/g, '-')
|
||||
|
||||
// Use the same upload directory as TUS server for consistency
|
||||
const uploadDir = path.join(process.cwd(), 'files')
|
||||
const filepath = path.join(uploadDir, filename)
|
||||
|
||||
try {
|
||||
// Ensure the upload directory exists
|
||||
await mkdir(uploadDir, { recursive: true }).catch(() => {
|
||||
// Directory might already exist, ignore the error
|
||||
})
|
||||
|
||||
await writeFile(filepath, buffer)
|
||||
return NextResponse.json({
|
||||
message: 'File uploaded successfully',
|
||||
filename,
|
||||
filepath: `/files/${filename}`,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error saving file:', error)
|
||||
return NextResponse.json({ error: 'Error saving file' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
BIN
examples/nextjs/src/app/favicon.ico
Normal file
|
After Width: | Height: | Size: 25 KiB |
26
examples/nextjs/src/app/globals.css
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
@import "tailwindcss";
|
||||
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #171717;
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--font-sans: var(--font-geist-sans);
|
||||
--font-mono: var(--font-geist-mono);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background: #0a0a0a;
|
||||
--foreground: #ededed;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--background);
|
||||
color: var(--foreground);
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
22
examples/nextjs/src/app/layout.tsx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import type { Metadata } from 'next'
|
||||
import { Inter } from 'next/font/google'
|
||||
import './globals.css'
|
||||
|
||||
const inter = Inter({ subsets: ['latin'] })
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Create Next App',
|
||||
description: 'Generated by create next app',
|
||||
}
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={inter.className}>{children}</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
10
examples/nextjs/src/app/page.tsx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import UppyDashboard from '@/components/UppyDashboard'
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<main>
|
||||
<h1>Uppy Dashboard with Next.js</h1>
|
||||
<UppyDashboard />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
125
examples/nextjs/src/components/UppyDashboard.tsx
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
'use client'
|
||||
|
||||
import Uppy from '@uppy/core'
|
||||
import { Dashboard } from '@uppy/react'
|
||||
import Transloadit from '@uppy/transloadit'
|
||||
import Tus from '@uppy/tus'
|
||||
import Xhr from '@uppy/xhr-upload'
|
||||
import { useState } from 'react'
|
||||
|
||||
import '@uppy/core/css/style.min.css'
|
||||
import '@uppy/dashboard/css/style.min.css'
|
||||
import '@uppy/webcam/css/style.min.css'
|
||||
|
||||
const UppyDashboard = () => {
|
||||
const [uppyTus] = useState(() =>
|
||||
new Uppy({
|
||||
debug: true,
|
||||
restrictions: {
|
||||
maxFileSize: 100 * 1024 * 1024, // 100MB
|
||||
maxNumberOfFiles: 10,
|
||||
allowedFileTypes: [
|
||||
'image/*',
|
||||
'video/*',
|
||||
'audio/*',
|
||||
'.pdf',
|
||||
'.txt',
|
||||
'.zip',
|
||||
'.rar',
|
||||
],
|
||||
},
|
||||
}).use(Tus, {
|
||||
endpoint: '/api/tus',
|
||||
retryDelays: [0, 1000, 3000, 5000],
|
||||
removeFingerprintOnSuccess: true,
|
||||
}),
|
||||
)
|
||||
const [uppyXhr] = useState(() =>
|
||||
new Uppy({
|
||||
debug: true,
|
||||
restrictions: {
|
||||
maxFileSize: 10 * 1024 * 1024, // 10MB for XHR
|
||||
maxNumberOfFiles: 5,
|
||||
},
|
||||
}).use(Xhr, { endpoint: '/api/xhr' }),
|
||||
)
|
||||
|
||||
const [uppyTransloadit] = useState(() => {
|
||||
const uppyInstance = new Uppy({
|
||||
debug: true,
|
||||
restrictions: {
|
||||
maxFileSize: 200 * 1024 * 1024, // 200MB for Transloadit
|
||||
maxNumberOfFiles: 10,
|
||||
allowedFileTypes: ['image/*', 'video/*', 'audio/*'],
|
||||
},
|
||||
})
|
||||
|
||||
return uppyInstance.use(Transloadit, {
|
||||
async assemblyOptions() {
|
||||
// Send optional metadata
|
||||
const { meta }: { meta: Record<string, unknown> } =
|
||||
uppyInstance.getState()
|
||||
const body: string = JSON.stringify({
|
||||
customValue: meta.customValue || 'nextjs-transloadit-example',
|
||||
})
|
||||
|
||||
const res: Response = await fetch('/api/transloadit', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body,
|
||||
})
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
`Failed to get Transloadit signature: ${res.statusText}`,
|
||||
)
|
||||
}
|
||||
|
||||
return res.json() // { params, signature, expires }
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="uppy-container">
|
||||
<h2>TUS Resumable Upload Example</h2>
|
||||
<p>
|
||||
Supports large files with resume capability. Upload will continue even
|
||||
if connection is lost.
|
||||
</p>
|
||||
<Dashboard
|
||||
uppy={uppyTus}
|
||||
height={400}
|
||||
hideProgressDetails={false}
|
||||
showLinkToFileUploadResult={true}
|
||||
showRemoveButtonAfterComplete={true}
|
||||
note="Upload up to 10 files, max 100MB each"
|
||||
/>
|
||||
|
||||
<h2>XHR Upload Example</h2>
|
||||
<p>Traditional HTTP upload for smaller files.</p>
|
||||
<Dashboard
|
||||
uppy={uppyXhr}
|
||||
height={300}
|
||||
hideProgressDetails={false}
|
||||
note="Upload up to 5 files, max 10MB each"
|
||||
/>
|
||||
|
||||
<h2>Transloadit Upload Example</h2>
|
||||
<p>
|
||||
Upload with automatic processing (resize, thumbnails, format
|
||||
conversion).
|
||||
</p>
|
||||
<Dashboard
|
||||
uppy={uppyTransloadit}
|
||||
height={400}
|
||||
hideProgressDetails={false}
|
||||
showLinkToFileUploadResult={true}
|
||||
showRemoveButtonAfterComplete={true}
|
||||
note="Upload media files for automatic processing (max 200MB each)"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default UppyDashboard
|
||||
27
examples/nextjs/tsconfig.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
7
examples/reactrouter/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
node_modules
|
||||
|
||||
/build
|
||||
.env
|
||||
|
||||
.react-router/
|
||||
uploads/
|
||||
49
examples/reactrouter/README.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# React Router v7 + Uppy Upload Examples
|
||||
|
||||
**Complete showcase** of Uppy Dashboard with TUS (resumable), XHR (standard), and Transloadit (with processing) uploads in React Router v7 framework mode.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Visit [http://localhost:3000](http://localhost:3000) to explore three upload methods:
|
||||
- **TUS uploads**: Resumable, perfect for large files
|
||||
- **XHR uploads**: Standard HTTP, ideal for regular files
|
||||
- **Transloadit uploads**: With powerful file processing capabilities
|
||||
|
||||
## What You'll Learn
|
||||
|
||||
This example demonstrates **three upload approaches** with Uppy in React Router v7:
|
||||
|
||||
1. **TUS server setup** with Express middleware for resumable uploads
|
||||
2. **XHR uploads** using React Router's native resource routes
|
||||
3. **Transloadit uploads** with signature generation and file processing
|
||||
|
||||
|
||||
|
||||
|
||||
## Transloadit Setup
|
||||
|
||||
To use Transloadit uploads, you need to:
|
||||
|
||||
1. **Sign up** at [transloadit.com](https://transloadit.com)
|
||||
2. **Get your credentials** from your account dashboard
|
||||
3. **Create a template** for your processing needs
|
||||
4. **Set environment variables**:
|
||||
|
||||
```bash
|
||||
export TRANSLOADIT_KEY="your_key_here"
|
||||
export TRANSLOADIT_SECRET="your_secret_here"
|
||||
export TRANSLOADIT_TEMPLATE_ID="your_template_id_here"
|
||||
```
|
||||
|
||||
Or create a `.env` file:
|
||||
```env
|
||||
TRANSLOADIT_KEY=your_key_here
|
||||
TRANSLOADIT_SECRET=your_secret_here
|
||||
TRANSLOADIT_TEMPLATE_ID=your_template_id_here
|
||||
```
|
||||
|
||||
12
examples/reactrouter/app/entry.client.tsx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { StrictMode, startTransition } from 'react'
|
||||
import { hydrateRoot } from 'react-dom/client'
|
||||
import { HydratedRouter } from 'react-router/dom'
|
||||
|
||||
startTransition(() => {
|
||||
hydrateRoot(
|
||||
document,
|
||||
<StrictMode>
|
||||
<HydratedRouter />
|
||||
</StrictMode>,
|
||||
)
|
||||
})
|
||||
66
examples/reactrouter/app/entry.server.tsx
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { PassThrough } from 'node:stream'
|
||||
import { createReadableStreamFromReadable } from '@react-router/node'
|
||||
import { renderToPipeableStream } from 'react-dom/server'
|
||||
import type { AppLoadContext, EntryContext } from 'react-router'
|
||||
import { ServerRouter } from 'react-router'
|
||||
|
||||
export default function handleRequest(
|
||||
request: Request,
|
||||
responseStatusCode: number,
|
||||
responseHeaders: Headers,
|
||||
reactRouterContext: EntryContext,
|
||||
loadContext: AppLoadContext,
|
||||
) {
|
||||
return handleBrowserRequest(
|
||||
request,
|
||||
responseStatusCode,
|
||||
responseHeaders,
|
||||
reactRouterContext,
|
||||
)
|
||||
}
|
||||
|
||||
function handleBrowserRequest(
|
||||
request: Request,
|
||||
responseStatusCode: number,
|
||||
responseHeaders: Headers,
|
||||
reactRouterContext: EntryContext,
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let shellRendered = false
|
||||
const { pipe, abort } = renderToPipeableStream(
|
||||
<ServerRouter context={reactRouterContext} url={request.url} />,
|
||||
{
|
||||
onShellReady() {
|
||||
shellRendered = true
|
||||
const body = new PassThrough()
|
||||
const stream = createReadableStreamFromReadable(body)
|
||||
|
||||
responseHeaders.set('Content-Type', 'text/html')
|
||||
|
||||
resolve(
|
||||
new Response(stream, {
|
||||
headers: responseHeaders,
|
||||
status: responseStatusCode,
|
||||
}),
|
||||
)
|
||||
|
||||
pipe(body)
|
||||
},
|
||||
onShellError(error: unknown) {
|
||||
reject(error)
|
||||
},
|
||||
onError(error: unknown) {
|
||||
responseStatusCode = 500
|
||||
// Log streaming rendering errors from inside the shell. Don't log
|
||||
// errors encountered during initial shell rendering since they'll
|
||||
// reject and get logged in handleDocumentRequest.
|
||||
if (shellRendered) {
|
||||
console.error(error)
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
setTimeout(abort, 5000)
|
||||
})
|
||||
}
|
||||
25
examples/reactrouter/app/root.tsx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'
|
||||
import '@uppy/core/css/style.min.css'
|
||||
import '@uppy/dashboard/css/style.min.css'
|
||||
|
||||
export function Layout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<Meta />
|
||||
<Links />
|
||||
</head>
|
||||
<body>
|
||||
{children}
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return <Outlet />
|
||||
}
|
||||
7
examples/reactrouter/app/routes.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { index, type RouteConfig, route } from '@react-router/dev/routes'
|
||||
|
||||
export default [
|
||||
index('routes/_index.tsx'),
|
||||
route('api/upload/xhr', 'routes/upload/route.ts'),
|
||||
route('api/transloadit-params', 'routes/transloadit-params/route.ts'),
|
||||
] satisfies RouteConfig
|
||||
142
examples/reactrouter/app/routes/_index.tsx
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
import Uppy from '@uppy/core'
|
||||
import { Dashboard } from '@uppy/react'
|
||||
import Transloadit from '@uppy/transloadit'
|
||||
import Tus from '@uppy/tus'
|
||||
import Xhr from '@uppy/xhr-upload'
|
||||
import { useState } from 'react'
|
||||
import type { MetaFunction } from 'react-router'
|
||||
|
||||
export const meta: MetaFunction = () => [
|
||||
{ title: 'React Router + Uppy Upload Examples' },
|
||||
{
|
||||
name: 'description',
|
||||
content: 'Minimal Uppy upload examples (TUS & XHR) with React Router',
|
||||
},
|
||||
]
|
||||
|
||||
function createTusUppy() {
|
||||
return new Uppy({
|
||||
restrictions: {
|
||||
maxFileSize: 50 * 1024 * 1024, // 50MB
|
||||
maxNumberOfFiles: 5,
|
||||
},
|
||||
}).use(Tus, { endpoint: '/api/upload/tus' })
|
||||
}
|
||||
|
||||
function createXhrUppy() {
|
||||
return new Uppy({
|
||||
restrictions: {
|
||||
maxFileSize: 10 * 1024 * 1024, // 10MB
|
||||
maxNumberOfFiles: 3,
|
||||
},
|
||||
}).use(Xhr, {
|
||||
endpoint: '/api/upload/xhr',
|
||||
method: 'POST',
|
||||
fieldName: 'files',
|
||||
allowedMetaFields: [],
|
||||
})
|
||||
}
|
||||
|
||||
function createTransloaditUppy() {
|
||||
const uppy = new Uppy({
|
||||
restrictions: {
|
||||
maxFileSize: 100 * 1024 * 1024, // 100MB
|
||||
maxNumberOfFiles: 10,
|
||||
},
|
||||
})
|
||||
|
||||
uppy.use(Transloadit, {
|
||||
async assemblyOptions() {
|
||||
// You can send meta data along for use in your template.
|
||||
// https://transloadit.com/docs/topics/assembly-instructions/#form-fields-in-instructions
|
||||
const { meta } = uppy.getState()
|
||||
const body = JSON.stringify({
|
||||
customValue: meta.customValue || 'react-router-uppy-example',
|
||||
})
|
||||
const res = await fetch('/api/transloadit-params', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body,
|
||||
})
|
||||
if (!res.ok) {
|
||||
const errorData = await res.json().catch(() => ({}))
|
||||
if (errorData.details) {
|
||||
throw new Error(errorData.details)
|
||||
}
|
||||
throw new Error(`Failed to get Transloadit params: ${res.statusText}`)
|
||||
}
|
||||
return res.json()
|
||||
},
|
||||
})
|
||||
|
||||
return uppy
|
||||
}
|
||||
|
||||
export default function Index() {
|
||||
const [tusUppy] = useState(createTusUppy)
|
||||
const [xhrUppy] = useState(createXhrUppy)
|
||||
const [transloaditUppy] = useState(createTransloaditUppy)
|
||||
|
||||
return (
|
||||
<main
|
||||
style={{
|
||||
fontFamily: 'system-ui, sans-serif',
|
||||
padding: '2rem',
|
||||
maxWidth: '900px',
|
||||
margin: '0 auto',
|
||||
}}
|
||||
>
|
||||
<h1>React Router + Uppy Upload Examples</h1>
|
||||
<p style={{ color: '#666', marginBottom: '3rem' }}>
|
||||
Three upload methods: TUS (resumable), XHR (standard), and Transloadit
|
||||
(with processing).
|
||||
</p>
|
||||
|
||||
<section style={{ marginBottom: '3rem' }}>
|
||||
<h2 style={{ color: '#333', fontSize: '1.5rem', marginBottom: '1rem' }}>
|
||||
🔄 TUS Resumable Upload
|
||||
</h2>
|
||||
<p style={{ color: '#666', marginBottom: '1rem', fontSize: '0.9rem' }}>
|
||||
Uses Express middleware with <code>@tus/server</code>. Supports
|
||||
resumable uploads for large files.
|
||||
</p>
|
||||
<Dashboard
|
||||
uppy={tusUppy}
|
||||
height={250}
|
||||
note="TUS: Upload up to 5 files, max 50MB each (resumable)"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 style={{ color: '#333', fontSize: '1.5rem', marginBottom: '1rem' }}>
|
||||
⚡ XHR Upload
|
||||
</h2>
|
||||
<p style={{ color: '#666', marginBottom: '1rem', fontSize: '0.9rem' }}>
|
||||
Uses React Router's native resource routes with{' '}
|
||||
<code>@mjackson/file-storage</code>. Standard HTTP uploads.
|
||||
</p>
|
||||
<Dashboard
|
||||
uppy={xhrUppy}
|
||||
height={250}
|
||||
note="XHR: Upload up to 3 files, max 10MB each"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 style={{ color: '#333', fontSize: '1.5rem', marginBottom: '1rem' }}>
|
||||
⚙️ Transloadit Upload & Processing
|
||||
</h2>
|
||||
<p style={{ color: '#666', marginBottom: '1rem', fontSize: '0.9rem' }}>
|
||||
Uses Transloadit for uploads with powerful processing capabilities.{' '}
|
||||
<strong>Requires environment variables</strong> - see README for
|
||||
setup.
|
||||
</p>
|
||||
<Dashboard
|
||||
uppy={transloaditUppy}
|
||||
height={250}
|
||||
note="Transloadit: Upload up to 10 files, max 100MB each (with processing)"
|
||||
/>
|
||||
</section>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
69
examples/reactrouter/app/routes/transloadit-params/route.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import crypto from 'node:crypto'
|
||||
import type { ActionFunctionArgs } from 'react-router'
|
||||
import { data } from 'react-router'
|
||||
|
||||
function utcDateString(ms: number): string {
|
||||
return new Date(ms)
|
||||
.toISOString()
|
||||
.replace(/-/g, '/')
|
||||
.replace(/T/, ' ')
|
||||
.replace(/\.\d+Z$/, '+00:00')
|
||||
}
|
||||
|
||||
export async function action({ request }: ActionFunctionArgs) {
|
||||
// expire 1 hour from now (this must be milliseconds)
|
||||
const expires = utcDateString(Date.now() + 1 * 60 * 60 * 1000)
|
||||
const authKey = process.env.TRANSLOADIT_KEY
|
||||
const authSecret = process.env.TRANSLOADIT_SECRET
|
||||
const templateId = process.env.TRANSLOADIT_TEMPLATE_ID
|
||||
|
||||
if (!authKey || !authSecret || !templateId) {
|
||||
console.error('Missing Transloadit credentials. Please set:')
|
||||
console.error('- TRANSLOADIT_KEY')
|
||||
console.error('- TRANSLOADIT_SECRET')
|
||||
console.error('- TRANSLOADIT_TEMPLATE_ID')
|
||||
console.error('See README.md for setup instructions.')
|
||||
|
||||
throw data(
|
||||
{
|
||||
error: 'Missing Transloadit credentials',
|
||||
details:
|
||||
'Please set TRANSLOADIT_KEY, TRANSLOADIT_SECRET, and TRANSLOADIT_TEMPLATE_ID environment variables. See README.md for setup instructions.',
|
||||
setupUrl: 'https://transloadit.com/accounts/',
|
||||
},
|
||||
{ status: 500 },
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
const body = await request.json()
|
||||
const params = JSON.stringify({
|
||||
auth: {
|
||||
key: authKey,
|
||||
expires,
|
||||
},
|
||||
template_id: templateId,
|
||||
fields: {
|
||||
// You can use this in your template.
|
||||
customValue: body.customValue || 'react-router-uppy-example',
|
||||
},
|
||||
// your other params like notify_url, etc.
|
||||
})
|
||||
|
||||
const signatureBytes = crypto
|
||||
.createHmac('sha384', authSecret)
|
||||
.update(Buffer.from(params, 'utf-8'))
|
||||
// The final signature needs the hash name in front, so
|
||||
// the hashing algorithm can be updated in a backwards-compatible
|
||||
// way when old algorithms become insecure.
|
||||
const signature = `sha384:${signatureBytes.digest('hex')}`
|
||||
|
||||
return data({ expires, signature, params })
|
||||
} catch (error) {
|
||||
console.error('Transloadit params error:', error)
|
||||
throw data(
|
||||
{ error: 'Failed to generate Transloadit parameters' },
|
||||
{ status: 500 },
|
||||
)
|
||||
}
|
||||
}
|
||||
44
examples/reactrouter/app/routes/upload/route.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { LocalFileStorage } from '@mjackson/file-storage/local'
|
||||
import { type FileUpload, parseFormData } from '@mjackson/form-data-parser'
|
||||
import type { ActionFunctionArgs } from 'react-router'
|
||||
|
||||
const fileStorage = new LocalFileStorage('./uploads')
|
||||
|
||||
export async function action({ request }: ActionFunctionArgs) {
|
||||
const uploadedFiles: { filename: string; size: number; type: string }[] = []
|
||||
|
||||
const uploadHandler = async (fileUpload: FileUpload) => {
|
||||
// Generate a unique filename with timestamp
|
||||
const timestamp = Date.now()
|
||||
const filename = `${timestamp}-${fileUpload.name}`
|
||||
|
||||
await fileStorage.set(filename, fileUpload)
|
||||
const storedFile = await fileStorage.get(filename)
|
||||
|
||||
// Store file info for response
|
||||
uploadedFiles.push({
|
||||
filename,
|
||||
size: storedFile?.size || 0,
|
||||
type: fileUpload.type,
|
||||
})
|
||||
|
||||
// Return the filename for FormData
|
||||
return filename
|
||||
}
|
||||
|
||||
try {
|
||||
await parseFormData(request, uploadHandler)
|
||||
|
||||
return Response.json({
|
||||
success: true,
|
||||
files: uploadedFiles,
|
||||
message: `Successfully uploaded ${uploadedFiles.length} file(s)`,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Upload error:', error)
|
||||
return Response.json(
|
||||
{ success: false, error: 'Upload failed' },
|
||||
{ status: 500 },
|
||||
)
|
||||
}
|
||||
}
|
||||
4323
examples/reactrouter/package-lock.json
generated
Normal file
40
examples/reactrouter/package.json
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "example-reactrouter",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "React Router + Uppy upload example with TUS and XHR support",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx ./server.ts",
|
||||
"typecheck": "react-router typegen && tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mjackson/file-storage": "^0.7.0",
|
||||
"@mjackson/form-data-parser": "^0.9.1",
|
||||
"@react-router/express": "latest",
|
||||
"@tus/file-store": "latest",
|
||||
"@tus/server": "latest",
|
||||
"@uppy/core": "workspace:*",
|
||||
"@uppy/dashboard": "workspace:*",
|
||||
"@uppy/react": "workspace:*",
|
||||
"@uppy/transloadit": "workspace:*",
|
||||
"@uppy/tus": "workspace:*",
|
||||
"@uppy/xhr-upload": "workspace:*",
|
||||
"express": "^4.19.2",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-router/dev": "latest",
|
||||
"@types/express": "^4.17.20",
|
||||
"@types/react": "^18.2.20",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"tsx": "^4.0.0",
|
||||
"typescript": "^5.1.6",
|
||||
"vite": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
}
|
||||
BIN
examples/reactrouter/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
111
examples/reactrouter/server.ts
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import { mkdir } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { createRequestHandler } from '@react-router/express'
|
||||
import { FileStore } from '@tus/file-store'
|
||||
import { Server as TusServer } from '@tus/server'
|
||||
import express from 'express'
|
||||
import type { ViteDevServer } from 'vite'
|
||||
|
||||
async function startServer() {
|
||||
try {
|
||||
// Setup upload directory
|
||||
const uploadDir = path.join(process.cwd(), 'uploads')
|
||||
await mkdir(uploadDir, { recursive: true }).catch(() => {})
|
||||
|
||||
// Create TUS server for resumable uploads
|
||||
const tusServer = new TusServer({
|
||||
path: '/api/upload/tus',
|
||||
datastore: new FileStore({ directory: uploadDir }),
|
||||
})
|
||||
|
||||
// Setup Vite dev server
|
||||
const viteDevServer: ViteDevServer = await import('vite').then((vite) =>
|
||||
vite.createServer({
|
||||
server: { middlewareMode: true },
|
||||
logLevel: 'info',
|
||||
}),
|
||||
)
|
||||
|
||||
// React Router request handler
|
||||
const reactRouterHandler = createRequestHandler({
|
||||
build: () =>
|
||||
viteDevServer.ssrLoadModule(
|
||||
'virtual:react-router/server-build',
|
||||
) as Promise<any>,
|
||||
})
|
||||
|
||||
const app = express()
|
||||
|
||||
// Use Vite dev middleware
|
||||
app.use(viteDevServer.middlewares)
|
||||
|
||||
// TUS upload endpoints (before React Router)
|
||||
app.all('/api/upload/tus', (req, res) => tusServer.handle(req, res))
|
||||
app.all('/api/upload/tus/*', (req, res) => tusServer.handle(req, res))
|
||||
|
||||
// Handle Chrome DevTools requests silently
|
||||
app.get('/.well-known/appspecific/com.chrome.devtools.json', (req, res) => {
|
||||
res.status(404).end()
|
||||
})
|
||||
|
||||
// React Router handles all other routes
|
||||
app.all('*', reactRouterHandler)
|
||||
|
||||
const port = process.env.PORT || 3000
|
||||
const server = app.listen(port, () => {
|
||||
console.log(`🚀 Server running at http://localhost:${port}`)
|
||||
console.log(`📁 TUS uploads: /api/upload/tus`)
|
||||
console.log(`📁 XHR uploads: /api/upload/xhr`)
|
||||
console.log(`Press Ctrl+C to stop the server`)
|
||||
})
|
||||
|
||||
// Graceful shutdown handling
|
||||
const shutdown = async (signal: string) => {
|
||||
console.log(`\n${signal} received. Shutting down gracefully...`)
|
||||
|
||||
server.close(async (err) => {
|
||||
if (err) {
|
||||
console.error('Error during server close:', err)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
try {
|
||||
await viteDevServer.close()
|
||||
console.log('✅ Server closed successfully')
|
||||
process.exit(0)
|
||||
} catch (closeErr) {
|
||||
console.error('Error closing Vite dev server:', closeErr)
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
// Force exit after 10 seconds if graceful shutdown fails
|
||||
setTimeout(() => {
|
||||
console.error('❌ Forceful shutdown after timeout')
|
||||
process.exit(1)
|
||||
}, 10000)
|
||||
}
|
||||
|
||||
// Handle various shutdown signals
|
||||
process.on('SIGINT', () => shutdown('SIGINT'))
|
||||
process.on('SIGTERM', () => shutdown('SIGTERM'))
|
||||
process.on('SIGHUP', () => shutdown('SIGHUP'))
|
||||
|
||||
// Handle uncaught exceptions
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error('Uncaught exception:', err)
|
||||
shutdown('UNCAUGHT_EXCEPTION')
|
||||
})
|
||||
|
||||
process.on('unhandledRejection', (reason, promise) => {
|
||||
console.error('Unhandled rejection at:', promise, 'reason:', reason)
|
||||
shutdown('UNHANDLED_REJECTION')
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Failed to start server:', error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Start the server
|
||||
startServer()
|
||||
27
examples/reactrouter/tsconfig.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
"**/.server/**/*.ts",
|
||||
"**/.server/**/*.tsx",
|
||||
"**/.client/**/*.ts",
|
||||
"**/.client/**/*.tsx",
|
||||
"./.react-router/types/**/*"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
||||
"types": ["@react-router/node", "vite/client"],
|
||||
"verbatimModuleSyntax": true,
|
||||
"esModuleInterop": true,
|
||||
"jsx": "react-jsx",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"target": "ES2022",
|
||||
"strict": true,
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true,
|
||||
"rootDirs": [".", "./.react-router/types"]
|
||||
}
|
||||
}
|
||||
6
examples/reactrouter/vite.config.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { reactRouter } from '@react-router/dev/vite'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [reactRouter()],
|
||||
})
|
||||