Skip to content

Commit c414326

Browse files
docs: add vite template (#4620)
Co-authored-by: Lukas Harbarth <[email protected]>
1 parent 9db7041 commit c414326

21 files changed

+5679
-0
lines changed

examples/vite-ts/.eslintrc.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
5+
parser: '@typescript-eslint/parser',
6+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
7+
plugins: ['react-refresh'],
8+
rules: {
9+
'react-refresh/only-export-components': 'warn'
10+
}
11+
};

examples/vite-ts/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

examples/vite-ts/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# UI5 Web Components for React - Vite + TypeScript Template
2+
3+
## How to use this template
4+
5+
```bash
6+
npx degit SAP/ui5-webcomponents-react/examples/vite-ts#main my-project
7+
cd my-project
8+
```
9+
10+
## Getting Started
11+
12+
First, install the `node_modules`:
13+
14+
```bash
15+
npm install
16+
```
17+
18+
Then, run the development server:
19+
20+
```bash
21+
npm run dev
22+
```
23+
24+
## Run Tests
25+
26+
Run all component tests headlessly in Chrome:
27+
28+
```bash
29+
npm run test
30+
```
31+
32+
Open component tests in Chrome:
33+
34+
```bash
35+
npm run test:open
36+
```
37+
38+
## Learn More
39+
40+
To learn more about Vite and UI5 Web Components for React, please visit the following resources:
41+
42+
- [Vite Documentation](https://vitejs.dev/)
43+
- [UI5 Web Components Documentation](https://sap.github.io/ui5-webcomponents/)
44+
- [UI5 Web Components for React Documentation](https://sap.github.io/ui5-webcomponents-react/)

examples/vite-ts/cypress.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
component: {
5+
devServer: {
6+
framework: 'react',
7+
bundler: 'vite'
8+
}
9+
}
10+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************
3+
// This example commands.ts shows you how to
4+
// create various custom commands and overwrite
5+
// existing commands.
6+
//
7+
// For more comprehensive examples of custom
8+
// commands please read more here:
9+
// https://on.cypress.io/custom-commands
10+
// ***********************************************
11+
//
12+
//
13+
// -- This is a parent command --
14+
// Cypress.Commands.add('login', (email, password) => { ... })
15+
//
16+
//
17+
// -- This is a child command --
18+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19+
//
20+
//
21+
// -- This is a dual command --
22+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23+
//
24+
//
25+
// -- This will overwrite an existing command --
26+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27+
//
28+
// declare global {
29+
// namespace Cypress {
30+
// interface Chainable {
31+
// login(email: string, password: string): Chainable<void>
32+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35+
// }
36+
// }
37+
// }
38+
// Cypress commands and queries that help interacting with ui5-webcomponents
39+
import '@ui5/webcomponents-cypress-commands';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
7+
<title>Components App</title>
8+
<script data-ui5-config type="application/json">
9+
{
10+
"theme": "sap_horizon"
11+
}
12+
</script>
13+
</head>
14+
<body>
15+
<div data-cy-root></div>
16+
</body>
17+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// ***********************************************************
2+
// This example support/component.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
import '@ui5/webcomponents-react/dist/Assets.js';
16+
import { ThemeProvider } from '@ui5/webcomponents-react';
17+
18+
// Alternatively you can use CommonJS syntax:
19+
// require('./commands')
20+
import { mount } from 'cypress/react18';
21+
// Import commands.js using ES2015 syntax:
22+
import './commands';
23+
24+
// Augment the Cypress namespace to include type definitions for
25+
// your custom command.
26+
// Alternatively, can be defined in cypress/support/component.d.ts
27+
// with a <reference path="./component" /> at the top of your spec.
28+
declare global {
29+
namespace Cypress {
30+
interface Chainable {
31+
mount: typeof mount;
32+
}
33+
}
34+
}
35+
36+
Cypress.Commands.add('mount', (component, options) => {
37+
return mount(<ThemeProvider>{component}</ThemeProvider>, options);
38+
});
39+
40+
// Example use:
41+
// cy.mount(<MyComponent />)

examples/vite-ts/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>UI5 Web Components React - Vite + TS</title>
8+
<script data-ui5-config type="application/json">
9+
{
10+
"theme": "sap_horizon"
11+
}
12+
</script>
13+
</head>
14+
<body>
15+
<div id="root"></div>
16+
<script type="module" src="/src/main.tsx"></script>
17+
</body>
18+
</html>

0 commit comments

Comments
 (0)