Make basic version work using bootstrap.
This commit is contained in:
@@ -1,30 +1,22 @@
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import StarRatings from 'react-star-ratings';
|
import StarRatings from 'react-star-ratings';
|
||||||
|
import { Card, Row, Col } from 'react-bootstrap';
|
||||||
|
|
||||||
const BookCard = ({ book }) => (
|
const BookCard = ({ book }) => (
|
||||||
<div className="mx-auto flex-grow-0 w-11/12 md:w-56 rounded-lg overflow-hidden shadow-lg m-3 flex flex-column flex-wrap items-stretch">
|
<Card style={{ width: '44rem', height: '12rem' }}>
|
||||||
<img className="self-start" src="https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1457284880l/27220736.jpg" alt="Sunset in the mountains" />
|
<Row>
|
||||||
<div className="px-6 py-4 w-full content-start">
|
<Col>
|
||||||
<div className="font-bold text-xl mb-0">{ book.title }</div>
|
<Card.Img variant="side" src="https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1457284880l/27220736.jpg" />
|
||||||
<div className="text-gray-700 font-bold text-base mb-1">
|
</Col>
|
||||||
<span className="mr-2 align-middle">{ book.year }</span>
|
<Col>
|
||||||
<StarRatings
|
<Card.Body>
|
||||||
rating={ parseFloat(book.rating) }
|
<Card.Title>{book.title}</Card.Title>
|
||||||
numberOfStars={5}
|
<Card.Subtitle className="mb-2 text-muted">{book.author}</Card.Subtitle>
|
||||||
starDimension="18px"
|
</Card.Body>
|
||||||
starSpacing="1px"
|
</Col>
|
||||||
starRatedColor="#fa604a"
|
</Row>
|
||||||
/>
|
</Card>
|
||||||
</div>
|
|
||||||
<p className="text-gray-700 text-base">
|
|
||||||
{ book.author }
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div className="w-full self-end">
|
|
||||||
<span className="inline-block bg-blue-600 px-3 py-1 text-lg font-semibold text-gray-100 mr-2 w-full text-center">{book.category}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
BookCard.propTypes = {
|
BookCard.propTypes = {
|
||||||
@@ -32,7 +24,7 @@ BookCard.propTypes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BookCard.defaultProps = {
|
BookCard.defaultProps = {
|
||||||
book:{},
|
book: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BookCard
|
export default BookCard
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { useStaticQuery, graphql } from "gatsby"
|
|||||||
|
|
||||||
import Header from "./header"
|
import Header from "./header"
|
||||||
import "./layout.css"
|
import "./layout.css"
|
||||||
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
|
|
||||||
const Layout = ({ children }) => {
|
const Layout = ({ children }) => {
|
||||||
const data = useStaticQuery(graphql`
|
const data = useStaticQuery(graphql`
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { graphql } from 'gatsby'
|
|||||||
import Layout from "../components/layout"
|
import Layout from "../components/layout"
|
||||||
import SEO from "../components/seo"
|
import SEO from "../components/seo"
|
||||||
import BookCard from "../components/bookcard"
|
import BookCard from "../components/bookcard"
|
||||||
|
import SideBar from "../components/sidebar";
|
||||||
|
import {Container, Row, Col} from 'react-bootstrap';
|
||||||
|
|
||||||
function myFunction(setEnd, end) {
|
function myFunction(setEnd, end) {
|
||||||
if (document.documentElement.clientHeight+document.documentElement.scrollTop>=document.documentElement.scrollHeight) {
|
if (document.documentElement.clientHeight+document.documentElement.scrollTop>=document.documentElement.scrollHeight) {
|
||||||
@@ -19,17 +21,24 @@ export default ({data}) => {
|
|||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<SEO title="Home" />
|
<SEO title="Home" />
|
||||||
<div className="flex flex-row flex-wrap">
|
<Container fluid>
|
||||||
{data.allBooksJson.edges.map(function(x, index) {
|
<Row>
|
||||||
if(index<end){
|
<Col xs={2}>
|
||||||
return (
|
<SideBar />
|
||||||
<BookCard book={x.node} key={x.node.id} />
|
</Col>
|
||||||
)
|
<Col>
|
||||||
}else{
|
{data.allBooksJson.edges.map(function(x, index) {
|
||||||
return null;
|
if(index<end){
|
||||||
}
|
return (
|
||||||
})}
|
<BookCard book={x.node} key={x.node.id} />
|
||||||
</div>
|
)
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Container>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
@tailwind base;
|
|
||||||
|
|
||||||
@tailwind components;
|
|
||||||
|
|
||||||
@tailwind utilities;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user