diff --git a/playground/react/package.json b/playground/react/package.json index ea159bfe..9305de10 100644 --- a/playground/react/package.json +++ b/playground/react/package.json @@ -12,7 +12,8 @@ "@cloudinary/react": "1.11.2", "@cloudinary/url-gen": "^1.10.0", "react": "^16.0.0", - "react-dom": "^16.0.0" + "react-dom": "^16.0.0", + "react-router-dom": "^6.11.2" }, "devDependencies": { "@types/react": "^16.0.0", diff --git a/playground/react/src/App.css b/playground/react/src/App.css index 2c5e2ef5..b6d4fe52 100644 --- a/playground/react/src/App.css +++ b/playground/react/src/App.css @@ -1,41 +1,23 @@ #root { + width: 100%; max-width: 1280px; margin: 0 auto; padding: 2rem; - text-align: center; } -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } +nav { + display: flex; + justify-content: center; + gap: 1em; } -.card { - padding: 2em; +article { + display: flex; + flex-direction: column; + align-items: center; + gap: 1em; } -.read-the-docs { - color: #888; +.responsive-image { + width: 100%; } diff --git a/playground/react/src/App.tsx b/playground/react/src/App.tsx index e3a26337..4d757cad 100644 --- a/playground/react/src/App.tsx +++ b/playground/react/src/App.tsx @@ -1,34 +1,30 @@ -import React from 'react' -import './App.css' -import { - AdvancedImage, - AdvancedVideo, - accessibility, - responsive, - lazyload, - placeholder -} from '@cloudinary/react' -import { CloudinaryImage } from '@cloudinary/url-gen/assets/CloudinaryImage' -import { CloudinaryVideo } from '@cloudinary/url-gen/assets/CloudinaryVideo' +import React from "react"; +import "./App.css"; +import { Routes, Route, useNavigate } from "react-router-dom"; + +import AdvancedImage from "./components/AdvancedImage"; +import AdvancedVideo from "./components/AdvancedVideo"; // This is our playground and can be used to test library -function App() { - const img = new CloudinaryImage('sample', { cloudName: 'demo' }) - const cldVid = new CloudinaryVideo( - 'docs/walking_talking', - { cloudName: 'demo' }, - { analytics: false } - ) +function App() { + const navigate = useNavigate(); + const onClick = (path: string) => () => navigate(path); return ( -
-

AdvancedImage

- -

AdvancedVideo

- -
- ) +
+

Cloudinary React Playground

+ + + + } /> + } /> + +
+ ); } -export default App +export default App; diff --git a/playground/react/src/components/AdvancedImage.tsx b/playground/react/src/components/AdvancedImage.tsx new file mode 100644 index 00000000..90dbf1aa --- /dev/null +++ b/playground/react/src/components/AdvancedImage.tsx @@ -0,0 +1,34 @@ +import React from "react"; +import "../App.css"; +import { + AdvancedImage, + accessibility, + responsive, + lazyload, + placeholder, +} from "@cloudinary/react"; +import { CloudinaryImage } from "@cloudinary/url-gen/assets/CloudinaryImage"; + +// This is our playground and can be used to test library +function App() { + const img = new CloudinaryImage("sample", { cloudName: "demo" }); + + return ( +
+

Advanced Image Demo

+ + +
+ ); +} + +export default App; diff --git a/playground/react/src/components/AdvancedVideo.tsx b/playground/react/src/components/AdvancedVideo.tsx new file mode 100644 index 00000000..ab902096 --- /dev/null +++ b/playground/react/src/components/AdvancedVideo.tsx @@ -0,0 +1,34 @@ +import React from "react"; +import "../App.css"; +import { + AdvancedVideo, + lazyload, +} from "@cloudinary/react"; +import { CloudinaryVideo } from "@cloudinary/url-gen/assets/CloudinaryVideo"; +import { fill } from "@cloudinary/url-gen/actions/resize"; + +// This is our playground and can be used to test library +function App() { + const cldVid = new CloudinaryVideo( + "docs/walking_talking", + { cloudName: "demo" }, + { analytics: false } + ); + + cldVid.resize(fill().width(600).height(600)); + + return ( +
+

Advanced Video Demo

+ + +
+ ); +} + +export default App; diff --git a/playground/react/src/index.css b/playground/react/src/index.css index 917888c1..f54e1872 100644 --- a/playground/react/src/index.css +++ b/playground/react/src/index.css @@ -28,13 +28,13 @@ body { margin: 0; display: flex; place-items: center; - min-width: 320px; - min-height: 100vh; + width: 100%; } h1 { font-size: 3.2em; line-height: 1.1; + text-align: center; } button { diff --git a/playground/react/src/main.tsx b/playground/react/src/main.tsx index f107c23e..e7e51de2 100644 --- a/playground/react/src/main.tsx +++ b/playground/react/src/main.tsx @@ -1,11 +1,12 @@ import React from 'react' import ReactDOM from 'react-dom' +import { BrowserRouter } from 'react-router-dom'; import App from './App' import './index.css' ReactDOM.render( - + - , + , document.getElementById('root') as HTMLElement )