-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from SougataXdev/SougataXdev
Added new API Bored API
- Loading branch information
Showing
5 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Bored API Example</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="wrapper"> | ||
<div class="banner-image"></div> | ||
<div class="content"> | ||
<h1>Bored Activity Generator</h1> | ||
<p>Explore random activities to beat boredom!</p> | ||
<div class="button-wrapper"> | ||
<button class="btn outline">Get Random Activity</button> | ||
</div> | ||
<div class="activity"><ul class="ul"> | ||
|
||
</ul></div> <!-- Added this line --> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const searchButton = document.querySelector('.btn'); | ||
const activityContainer = document.querySelector('.activity'); | ||
searchButton.addEventListener('click', getRandomActivity); | ||
|
||
function getRandomActivity() { | ||
const apiUrl = 'https://www.boredapi.com/api/activity'; | ||
|
||
// Make API request | ||
fetch(apiUrl) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
displayActivity(data.activity); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching activity:', error); | ||
}); | ||
} | ||
|
||
function displayActivity(activity) { | ||
let ul = document.querySelector(".ul") | ||
ul.innerHTML = ""; // Clear the ul | ||
let li = document.createElement("li"); | ||
li.innerText = activity; | ||
ul.appendChild(li); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
body { | ||
font-family: 'Lato', sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.container { | ||
background: linear-gradient(45deg, rgba(0,212,255,1) 0%, rgba(11,3,45,1) 100%); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
|
||
.wrapper { | ||
width: 80%; | ||
max-width: 600px; | ||
margin: auto; | ||
} | ||
|
||
|
||
|
||
.content { | ||
background-color: rgba(17, 25, 40, 0.25); | ||
padding: 20px; | ||
border-radius: 12px; | ||
text-align: center; | ||
color: #fff; | ||
} | ||
|
||
h1 { | ||
font-family: 'Righteous', sans-serif; | ||
text-transform: uppercase; | ||
font-size: 2.4rem; | ||
margin-bottom: 10px; | ||
} | ||
|
||
p { | ||
font-size: 1rem; | ||
line-height: 1.5; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.button-wrapper { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.btn { | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 24px; | ||
font-size: 0.8rem; | ||
letter-spacing: 1px; | ||
cursor: pointer; | ||
margin: 0 10px; | ||
} | ||
|
||
.outline { | ||
background: transparent; | ||
color: rgba(0, 212, 255, 0.9); | ||
border: 1px solid rgba(0, 212, 255, 0.6); | ||
transition: all .3s ease; | ||
} | ||
|
||
.outline:hover { | ||
transform: scale(1.05); | ||
} | ||
|
||
.fill { | ||
background: rgba(0, 212, 255, 0.9); | ||
color: rgba(255,255,255,0.95); | ||
font-weight: bold; | ||
transition: all .3s ease; | ||
} | ||
|
||
.fill:hover { | ||
transform: scale(1.05); | ||
} | ||
|
||
.activity { | ||
background-color: transparent; | ||
border-radius: 8px; | ||
margin-top: 20px; | ||
font-family: 'Lato', sans-serif; | ||
font-size: 1.2rem; | ||
line-height: 1.5; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
.ul li { | ||
margin-bottom: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Bored Activity Generator | ||
|
||
Explore random activities to beat boredom! This simple web app uses the Bored API to fetch random activities for users to try out. | ||
|
||
## Table of Contents | ||
|
||
- [Introduction](#introduction) | ||
- [Demo](#demo) | ||
- [Features](#features) | ||
- [Getting Started](#getting-started) | ||
- [Built With](#built-with) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
## Introduction | ||
|
||
This web application provides users with a quick and easy way to discover new activities to do when they're feeling bored. By clicking the "Get Random Activity" button, users can fetch a random activity suggestion from the Bored API and get inspired to try something new. | ||
|
||
## Demo | ||
|
||
Insert a GIF or a link to a live demo of the project here. | ||
|
||
## Features | ||
|
||
- Fetches random activities from the Bored API. | ||
- Simple and intuitive user interface. | ||
- Responsive design for seamless use on various devices. | ||
|
||
## Getting Started | ||
|
||
To get a local copy up and running follow these simple steps: | ||
|
||
## Getting Started | ||
|
||
- Clone the repository: | ||
```sh | ||
git clone https://github.com/SougataXdev/APIVerse.git | ||
``` | ||
- Open the project folder in your code editor. | ||
- Open the `index.html` file in your web browser to view the application locally. | ||
|
||
## Built With | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
- [Bored API](https://www.boredapi.com/) - For fetching random activity suggestions. | ||
|
||
## Contributing | ||
|
||
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. | ||
## Steps: | ||
1. Fork the Project | ||
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) | ||
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) | ||
4. Push to the Branch (`git push origin feature/AmazingFeature`) | ||
5. Open a Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters