Skip to content

Commit 09563e7

Browse files
committed
style(ui): update styles and add search results message
1 parent dae85f1 commit 09563e7

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en" data-bs-theme="light">
33
<head>
44
<meta charset="utf-8" />
55
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
@@ -35,7 +35,7 @@
3535
</script>
3636
<!-- End Single Page Apps for GitHub Pages -->
3737
</head>
38-
<body>
38+
<body class="bg-light">
3939
<noscript>You need to enable JavaScript to run this app.</noscript>
4040
<div id="root"></div>
4141
</body>

src/components/App.jsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Searchbar from './Searchbar';
33
import { ImageGallery } from './ImageGallery';
44
import ImagePortalWelcome from './ImagePortalWelcome';
55

6+
import { Container, Row, Col, Alert } from 'react-bootstrap';
7+
68
import axios from 'axios';
79

810
import 'bootstrap/dist/css/bootstrap.min.css';
@@ -17,6 +19,7 @@ class App extends Component {
1719

1820
this.state = {
1921
images: [],
22+
searchQuery: '',
2023
};
2124
}
2225

@@ -25,7 +28,7 @@ class App extends Component {
2528
const response = await axios.get(
2629
`/?q=${searchQuery}&page=1&key=${API_KEY}&image_type=photo&orientation=horizontal&per_page=12`
2730
);
28-
this.setState({ images: response.data.hits });
31+
this.setState({ images: response.data.hits, searchQuery });
2932
} catch (error) {
3033
console.error('Error searching for images:', error);
3134
} finally {
@@ -40,18 +43,29 @@ class App extends Component {
4043
}
4144

4245
render() {
43-
const { images } = this.state;
46+
const { images, searchQuery } = this.state;
4447

4548
return (
4649
<>
4750
<Searchbar onSearch={this.getImages} />
48-
<div>
51+
<Container>
4952
{images.length > 0 ? (
50-
<ImageGallery images={images} />
53+
<Row className="d-flex justify-content-center mb-5 mx-auto">
54+
<Alert
55+
variant="primary"
56+
as={Col}
57+
style={{ width: 'fit-content' }}
58+
>
59+
Showing results for
60+
<span className="fw-bold"> {searchQuery}</span>
61+
</Alert>
62+
63+
<ImageGallery images={images} />
64+
</Row>
5165
) : (
5266
<ImagePortalWelcome />
5367
)}
54-
</div>
68+
</Container>
5569
</>
5670
);
5771
}

src/components/ImageGallery.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Container, Col, Row, Image } from 'react-bootstrap';
22

33
export const ImageGallery = ({ images }) => (
4-
<Container className="justify-content-center pt-4 mt-5 mb-5">
4+
<Container className="justify-content-center">
55
<Row xs={1} sm={2} md={3} lg={4} className="g-4">
66
<ImageGalleryItem images={images} />
77
</Row>

src/components/ImagePortalWelcome.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Container, Row, Col, Alert } from 'react-bootstrap';
33
function ImagePortalWelcome() {
44
return (
55
<Container>
6-
<Row className="d-flex align-items-center justify-content-center vh-100">
7-
<Col xs={12} md={6}>
6+
<Row className="d-flex align-items-center justify-content-center vh-100 position-absolute top-0 start-0">
7+
<Col xs={8} md={6}>
88
<Alert variant="success">
99
<Alert.Heading>Hey, nice to see you!</Alert.Heading>
1010
<p>

src/components/Searchbar.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Searchbar extends Component {
2929
this.setState({ theme: selectedTheme });
3030

3131
document.documentElement.setAttribute('data-bs-theme', selectedTheme);
32+
document.body.className = `bg-${selectedTheme}`;
3233
};
3334

3435
handleInputChange = e => {

src/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ body {
77
sans-serif;
88
-webkit-font-smoothing: antialiased;
99
-moz-osx-font-smoothing: grayscale;
10+
margin-top: 116px;
11+
}
12+
13+
@media screen and (min-width: 768px) {
14+
body {
15+
margin-top: 64px;
16+
}
1017
}
1118

1219
code {

0 commit comments

Comments
 (0)