Skip to content

Commit

Permalink
Ui updates main page
Browse files Browse the repository at this point in the history
  • Loading branch information
1447bits committed Oct 15, 2023
1 parent d10021c commit 7fb642f
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
8 changes: 4 additions & 4 deletions talebuddy/allStories.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"total_number_of_stories":2,
"total_number_of_stories":3,
"story_paths":[
"talebuddy/stories/HARRY_POTTER.json"
"talebuddy/stories/The_Gulliver's_Travels.json"

"/stories/HARRY_POTTER.json",
"/stories/The_Gulliver's_Travels.json",
"/stories/A_KING.json"
]
}
18 changes: 18 additions & 0 deletions talebuddy/components/card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../index.css">
</head>
<body>
<div class="card">
<h3>
{{Cardtitle}}
</h3>
<p>
{{CardDescription}}
</p>
</div>
</body>
</html>
38 changes: 38 additions & 0 deletions talebuddy/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,44 @@ nav .githubIcon {
}


#Allcards {
display: flex;
flex-wrap: wrap;
align-items: start;
justify-content: start;
gap: 1em;
margin-top: max(50px, 3%);
width: min(95vw, 1600px);
margin-inline: auto;
}

.card:hover {
box-shadow: 6px 0.55px 18px -3px rgba(101, 101, 101, 0.608);
}

.card {
display: flex;
flex-direction: column;
width: min(80vw, 45%);
max-width: fit-content;
min-width: min(85%, 350px);
margin-inline: auto;
padding: 2em;
border-radius: 12px;
border: 1px solid rgba(34, 34, 34, 0.25);
background: #FFF;
gap: 1em;
transition: 0.5s;
cursor: pointer;
}

.card p {
width: 95%;
margin: auto;
opacity: 0.6;
}


@media only screen and (max-width : 520px) {

nav .search-container {
Expand Down
1 change: 1 addition & 0 deletions talebuddy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<div id="main">
<div id="navbar"></div>
<div id="Allcards"></div>
</div>

</body>
Expand Down
48 changes: 48 additions & 0 deletions talebuddy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,52 @@ document.addEventListener("DOMContentLoaded", function () {
.then(navbarHtml => {
document.getElementById("navbar").innerHTML = navbarHtml;
});


// fetchAllCards
async function fetchAllcards() {
await fetch("./allStories.json")
.then(responce => responce.json())
.then(data => {
// console.log(data.chapter_data_paths)
for (let i = 0; i < data.story_paths.length; i++) {
console.log("card path : ", data.story_paths[i])
rendercard(`.${data.story_paths[i]}`)
}
// let allchapter = JSON.parse(data)
})
}

//render Cards
async function rendercard(path) {

console.log(path)
let carddata;
await fetch(path)
.then(response => response.json())
.then(cardData => {
console.log("cardData : ", cardData)
carddata = cardData

});

await fetch("./components/card.html")
.then(responce => responce.text())
.then((componentHTML) => {
const cardsContainer = document.getElementById("Allcards")

// const type = typeof componentHTML
// console.log(type) // string

const FinalCardComponent = componentHTML
.replace(/{{Cardtitle}}/g, carddata.title)
.replace(/{{CardDescription}}/g, carddata.about_story);

cardsContainer.innerHTML += FinalCardComponent

})
}

fetchAllcards()

});
1 change: 1 addition & 0 deletions talebuddy/stories/A_KING.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"title": "A king",
"about_story" : "A lion who is king, really !!",
"number_of_pages": 1,
"pages": [
{
Expand Down
1 change: 1 addition & 0 deletions talebuddy/stories/HARRY_POTTER.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"title": "Harry Potter Introduction",
"about_story" : "harry was potter who used to make posts with his stick and had a slang Jo koi nahi bol sakta",
"number_of_pages": 1,
"pages": [
{
Expand Down
1 change: 1 addition & 0 deletions talebuddy/stories/SAMPLE_STRUCTURE.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"title": "story title",
"about_story": "about the story",
"number_of_pages": "<number>",
"pages": [
{
Expand Down
1 change: 1 addition & 0 deletions talebuddy/stories/The_Gulliver's_Travels.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"title": "Gulliver's Travels",
"about_story" : "Gulliver's Travels is a satirical novel written by Jonathan Swift, first published in 1726. The book is a classic of English literature and is known",
"number_of_pages": "383",
"pages": [
{
Expand Down

0 comments on commit 7fb642f

Please sign in to comment.