@@ -5,6 +5,8 @@ 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' ;
9+
810const Home = ( ) => {
911
1012 const [ theme , setTheme ] = useState ( themes [ 0 ] ) ;
@@ -14,6 +16,9 @@ const Home = () => {
1416 const [ fontColor , setFontColor ] = useState ( null ) ;
1517 const [ bgColor , setBgColor ] = useState ( null ) ;
1618 const [ quoteType , setQuoteType ] = useState ( "random" ) ;
19+ const [ quoteAuthor , setQuoteAuthor ] = useState ( null ) ;
20+
21+ const { quoteAuthors, loadingQuoteAuthors } = useQuoteAuthors ( ) ;
1722
1823 return (
1924 < React . Fragment >
@@ -126,11 +131,25 @@ const Home = () => {
126131 />
127132 </ Grid >
128133
134+ < Grid item xs = { 12 } sm = { 6 } lg = { 3 } >
135+ < Autocomplete
136+ id = "author"
137+ options = { quoteAuthors }
138+ value = { quoteAuthor }
139+ style = { { width : 300 } }
140+ loading = { loadingQuoteAuthors }
141+ onChange = { ( _event , newValue ) => {
142+ setQuoteAuthor ( newValue )
143+ } }
144+ renderInput = { ( params ) => < TextField { ...params } label = "Author" placeholder = "Select an author" variant = "outlined" /> }
145+ />
146+ </ Grid >
147+
129148 </ Grid >
130149
131150 < Grid container spacing = { 4 } >
132151 < Grid item xs = { 12 } style = { { margin : '20px' } } >
133- < TemplateCard theme = { theme } animation = { animation } layout = { layout } font = { font } fontColor = { fontColor } bgColor = { bgColor } quoteType = { quoteType } />
152+ < TemplateCard theme = { theme } animation = { animation } layout = { layout } font = { font } fontColor = { fontColor } bgColor = { bgColor } quoteType = { quoteType } quoteAuthor = { quoteAuthor } />
134153 </ Grid >
135154 < Grid item xs = { 12 } >
136155 < Typography align = "center" > Other layouts</ Typography >
@@ -139,7 +158,7 @@ const Home = () => {
139158 layouts . filter ( ( item ) => item !== layout ) . map ( ( restLayout ) => {
140159 return (
141160 < Grid key = { restLayout } item xs = { 12 } sm = { 12 } md = { 6 } >
142- < TemplateCard theme = { theme } animation = { animation } layout = { restLayout } font = { font } fontColor = { fontColor } bgColor = { bgColor } quoteType = { quoteType } />
161+ < TemplateCard theme = { theme } animation = { animation } layout = { restLayout } font = { font } fontColor = { fontColor } bgColor = { bgColor } quoteType = { quoteType } quoteAuthor = { quoteAuthor } />
143162 </ Grid >
144163 )
145164 } )
0 commit comments