Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/coffee-warehouse-nextjs/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This project has been released under the [Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html), the text of which is included below. This license applies ONLY to the source of this repository and does not extend to any other Kendo UI distribution or variant, or any other 3rd party libraries used in a repository. For licensing information about KendoReact, see the [License Agreements page](https://www.telerik.com/purchase/license-agreement/progress-kendoreact) at [KendoReact.com](http://www.kendoreact.com).

> Copyright © 2023 Progress Software Corporation and/or its subsidiaries or affiliates.
> Copyright © 2024 Progress Software Corporation and/or its subsidiaries or affiliates.

> Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions examples/kendo-react-ssr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
21 changes: 21 additions & 0 deletions examples/kendo-react-ssr/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright © 2024 Progress Software Corporation and/or its subsidiaries or affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions examples/kendo-react-ssr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Setup

To start the project and use the Server-side rendering execute the following commands:

1. yarn install
1. yarn build
1. yarn ssr

The applciation should be loaded on locahost:8000.

Inspect the received `index.html` file to observed how the KendoReact Grid is received pre-rendered on the server.
66 changes: 66 additions & 0 deletions examples/kendo-react-ssr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "kendo-react-ssr",
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/preset-env": "^7.23.5",
"@babel/preset-react": "^7.23.3",
"@babel/register": "^7.22.15",
"@progress/kendo-data-query": "^1.7.0",
"@progress/kendo-date-math": "^1.5.12",
"@progress/kendo-drawing": "^1.19.0",
"@progress/kendo-inputs-common": "^3.1.0",
"@progress/kendo-intl": "^3.1.1",
"@progress/kendo-licensing": "^1.3.3",
"@progress/kendo-popup-common": "^1.9.2",
"@progress/kendo-react-animation": "^7.0.2",
"@progress/kendo-react-buttons": "^7.0.2",
"@progress/kendo-react-common": "^7.0.2",
"@progress/kendo-react-data-tools": "^7.0.2",
"@progress/kendo-react-dateinputs": "^7.0.2",
"@progress/kendo-react-dialogs": "^7.0.2",
"@progress/kendo-react-dropdowns": "^7.0.2",
"@progress/kendo-react-grid": "^7.0.2",
"@progress/kendo-react-inputs": "^7.0.2",
"@progress/kendo-react-intl": "^7.0.2",
"@progress/kendo-react-labels": "^7.0.2",
"@progress/kendo-react-layout": "^7.0.2",
"@progress/kendo-react-popup": "^7.0.2",
"@progress/kendo-react-progressbars": "^7.0.2",
"@progress/kendo-react-tooltip": "^7.0.2",
"@progress/kendo-react-treeview": "^7.0.2",
"@progress/kendo-theme-default": "^7.0.2",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.1",
"express": "^4.18.2",
"ignore-styles": "^5.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-transition-group": "^4.4.5",
"rewire": "^7.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"ssr": "node server/index.js"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added examples/kendo-react-ssr/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/kendo-react-ssr/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added examples/kendo-react-ssr/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/kendo-react-ssr/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/kendo-react-ssr/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions examples/kendo-react-ssr/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
7 changes: 7 additions & 0 deletions examples/kendo-react-ssr/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require('ignore-styles');
require('@babel/register')({
ignore: [/(node_modules)/],
presets: ['@babel/preset-env', '@babel/preset-react']
})

require('./server');
28 changes: 28 additions & 0 deletions examples/kendo-react-ssr/server/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import express, { response } from 'express';
import fs from 'fs';
import path from 'path';

import React from 'react';
import ReactDOMServer from 'react-dom/server';

import App from '../src/App';

const PORT = 8000;

const app = express();

app.use('^/$', (request, response, next) =>{
fs.readFile(path.resolve('./build/index.html'), 'utf-8', (err,data)=> {
if(err){
console.log(err);
return response.status(500).send('There is error');
}
return response.send(data.replace('<div id="root"></div>', `<div id="root">${ReactDOMServer.renderToString(<App/>)}</div>`));
})
})

app.use(express.static(path.resolve(__dirname, '..', 'build')));

app.listen(PORT, () => {
console.log(`App works on ${PORT}`);
});
42 changes: 42 additions & 0 deletions examples/kendo-react-ssr/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}
.item-name {
color: rgb(101, 101, 101);;
font-weight: 500;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
58 changes: 58 additions & 0 deletions examples/kendo-react-ssr/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import './App.css';

import { Grid, GridColumn } from '@progress/kendo-react-grid';
import { Tooltip } from '@progress/kendo-react-tooltip';
import { process } from '@progress/kendo-data-query';

import '@progress/kendo-theme-default/dist/all.css';


import products from './products.json';

const MyCustomCell = (props) => {
const value = props.dataItem[props.field];
return (
<td>
<span title={props.dataItem.ProductID}>
{value}
</span>
</td>
)
}

const MyTooltipTemplate = (props) => {
let findItem = products.filter(item => item.ProductID === parseInt(props.title))[0]
return (
<div>
<h4>{findItem.ProductName}</h4>
<hr className='k-hr'/>
<p><span className="item-name">Category:</span> {findItem.Category.CategoryName}</p>
<p><span className="item-name">Price:</span> {findItem.UnitPrice}</p>
<p><span className="item-name">Discontinued:</span> {findItem.Discontinued.toString()}</p>
</div>
)
}

function App() {
const [dataState, setDataState] = React.useState({ skip: 0, take: 10 })
return (
<div>
<Tooltip content={MyTooltipTemplate} anchorElement="target" position="right">
<Grid
pageable
sortable
data={process(products, dataState)}
{...dataState}
onDataStateChange={(e) => setDataState(e.dataState)}
>
<GridColumn field="ProductID" title="Product Id" filter="numeric" />
<GridColumn field="ProductName" title="Product Name" cell={MyCustomCell} />
<GridColumn field="UnitsInStock" title="Units In Stock" filter="numeric" />
</Grid>
</Tooltip>
</div>
);
}

export default App;
9 changes: 9 additions & 0 deletions examples/kendo-react-ssr/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
13 changes: 13 additions & 0 deletions examples/kendo-react-ssr/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
12 changes: 12 additions & 0 deletions examples/kendo-react-ssr/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.hydrate(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
7 changes: 7 additions & 0 deletions examples/kendo-react-ssr/src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading