@@ -5,6 +5,7 @@ import { themes, animations, layouts, fonts, colorValues, quoteTypes } from '../
55import TextField from '@material-ui/core/TextField' ;
66import Autocomplete from '@material-ui/lab/Autocomplete' ;
77import ContributorsCard from '../../ContributorsCard/ContributorCard'
8+ import useQuoteAuthors from '../../../util/authors' ;
89import { makeStyles } from '@material-ui/core/styles' ;
910
1011const useStyles = makeStyles ( {
@@ -24,6 +25,9 @@ const Home = () => {
2425 const [ bgColor , setBgColor ] = useState ( null ) ;
2526 const [ borderColor , setBorderColor ] = useState ( null ) ;
2627 const [ quoteType , setQuoteType ] = useState ( "random" ) ;
28+ const [ quoteAuthor , setQuoteAuthor ] = useState ( null ) ;
29+
30+ const { quoteAuthors, loadingQuoteAuthors } = useQuoteAuthors ( ) ;
2731
2832 const classes = useStyles ( ) ;
2933
@@ -158,11 +162,25 @@ const Home = () => {
158162 />
159163 </ Grid >
160164
165+ < Grid item xs = { 12 } sm = { 6 } lg = { 3 } >
166+ < Autocomplete
167+ id = "author"
168+ options = { quoteAuthors }
169+ value = { quoteAuthor }
170+ style = { { width : 300 } }
171+ loading = { loadingQuoteAuthors }
172+ onChange = { ( _event , newValue ) => {
173+ setQuoteAuthor ( newValue )
174+ } }
175+ renderInput = { ( params ) => < TextField { ...params } label = "Author" placeholder = "Select an author" variant = "outlined" /> }
176+ />
177+ </ Grid >
178+
161179 </ Grid >
162180
163181 < Grid container spacing = { 4 } >
164182 < Grid item xs = { 12 } style = { { marginTop : '20px' } } >
165- < TemplateCard theme = { theme } animation = { animation } layout = { layout } font = { font } fontColor = { fontColor } bgColor = { bgColor } borderColor = { borderColor } quoteType = { quoteType } />
183+ < TemplateCard theme = { theme } animation = { animation } layout = { layout } font = { font } fontColor = { fontColor } bgColor = { bgColor } borderColor = { borderColor } quoteType = { quoteType } quoteAuthor = { quoteAuthor } />
166184 </ Grid >
167185 < Grid item xs = { 12 } >
168186 < Typography align = "center" > Other layouts</ Typography >
@@ -171,7 +189,7 @@ const Home = () => {
171189 layouts . filter ( ( item ) => item !== layout ) . map ( ( restLayout ) => {
172190 return (
173191 < Grid key = { restLayout } item xs = { 12 } sm = { 12 } md = { 6 } >
174- < TemplateCard theme = { theme } animation = { animation } layout = { restLayout } font = { font } fontColor = { fontColor } bgColor = { bgColor } borderColor = { borderColor } quoteType = { quoteType } />
192+ < TemplateCard theme = { theme } animation = { animation } layout = { restLayout } font = { font } fontColor = { fontColor } bgColor = { bgColor } borderColor = { borderColor } quoteType = { quoteType } quoteAuthor = { quoteAuthor } />
175193 </ Grid >
176194 )
177195 } )
0 commit comments