react-slideshow: cleaner looking front page.

This commit is contained in:
Bill Thiede 2020-06-17 18:11:58 -07:00
parent 7e2cf1b956
commit 4fc0bc9d01
5 changed files with 156 additions and 1403 deletions

View File

@ -13,7 +13,9 @@
"@types/react-dom": "^16.9.5", "@types/react-dom": "^16.9.5",
"@types/react-router": "^5.1.4", "@types/react-router": "^5.1.4",
"@types/react-router-dom": "^5.1.3", "@types/react-router-dom": "^5.1.3",
"bootstrap": "^4.5.0",
"react": "^16.12.0", "react": "^16.12.0",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.12.0", "react-dom": "^16.12.0",
"react-router-dom": "^5.1.2", "react-router-dom": "^5.1.2",
"react-scripts": "3.4.0", "react-scripts": "3.4.0",

View File

@ -2,6 +2,10 @@ body, html, #root {
height: 100%; height: 100%;
} }
.container {
margin-top: 2em;
}
#ui { #ui {
top: 0; top: 0;
line-height: 3em; line-height: 3em;

View File

@ -5,6 +5,10 @@ import {
Route, Route,
useParams useParams
} from "react-router-dom"; } from "react-router-dom";
import {
Button,
Card
} from 'react-bootstrap';
import Random from './rand'; import Random from './rand';
import './App.css'; import './App.css';
@ -296,8 +300,10 @@ class AlbumIndex extends React.Component<AlbumIndexProps, AlbumIndexState> {
return <h2>Error: {JSON.stringify(error)}</h2>; return <h2>Error: {JSON.stringify(error)}</h2>;
} else if (albums !== null) { } else if (albums !== null) {
return albums.map((a) => { return albums.map((a) => {
let img_url = "https://via.placeholder.com/256x128";
let img = <img src="https://via.placeholder.com/256x128" className="mr-3" alt="unset"/>; let img = <img src="https://via.placeholder.com/256x128" className="mr-3" alt="unset"/>;
if (a.coverPhotoMediaItemId !== undefined) { if (a.coverPhotoMediaItemId !== undefined) {
img_url = `/api/image/${a.coverPhotoMediaItemId}?w=512&h=512`
img = <img src={ `/api/image/${a.coverPhotoMediaItemId}?w=256&h=256` } className="mr-3" alt={ a.title }/> img = <img src={ `/api/image/${a.coverPhotoMediaItemId}?w=256&h=256` } className="mr-3" alt={ a.title }/>
} }
@ -305,9 +311,16 @@ class AlbumIndex extends React.Component<AlbumIndexProps, AlbumIndexState> {
{img} {img}
<figcaption className="figure-caption">{ a.title || "No title" } - { a.mediaItemsCount || 0 } photos </figcaption> <figcaption className="figure-caption">{ a.title || "No title" } - { a.mediaItemsCount || 0 } photos </figcaption>
</figure>; </figure>;
return <a key={ a.id } href={ '#' + a.id }> return <Card key={a.id} style={{width: '50%'}}>
{ figure } <Card.Img variant="top" src={img_url} />
</a> <Card.Body>
<Card.Title>{a.title}</Card.Title>
<Card.Text>
{a.mediaItemsCount || 0} photos
</Card.Text>
<Button href={'#' + a.id} variant="primary" block>Slideshow</Button>
</Card.Body>
</Card>
}); });
} else { } else {
return <h2>Loading...</h2>; return <h2>Loading...</h2>;
@ -333,6 +346,9 @@ const App = () => {
<AlbumIndex /> <AlbumIndex />
</div> </div>
</Route> </Route>
<Route exact path="/lookup/:albumId">
<AlbumRoute showUI={showUI} sleepTimeSeconds={sleepTimeSeconds} />
</Route>
<Route exact path="/:albumId"> <Route exact path="/:albumId">
<AlbumRoute showUI={showUI} sleepTimeSeconds={sleepTimeSeconds} /> <AlbumRoute showUI={showUI} sleepTimeSeconds={sleepTimeSeconds} />
</Route> </Route>

View File

@ -3,6 +3,8 @@ import ReactDOM from 'react-dom';
import './index.css'; import './index.css';
import App from './App'; import App from './App';
import * as serviceWorker from './serviceWorker'; import * as serviceWorker from './serviceWorker';
// Importing the Bootstrap CSS
import 'bootstrap/dist/css/bootstrap.min.css';
ReactDOM.render(<App />, document.getElementById('root')); ReactDOM.render(<App />, document.getElementById('root'));

File diff suppressed because it is too large Load Diff