Skip to content

Commit 57c817f

Browse files
committed
Added Grid property in app.js and updated the style sheet
1 parent 566fa64 commit 57c817f

2 files changed

Lines changed: 27 additions & 39 deletions

File tree

Week1/homework/app.js

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ function createBookList(bookId) {
3232
}
3333
}
3434

35-
// createBookList(bookTitles);
36-
3735
document.body.appendChild(ul);
3836

39-
// 1.5
37+
// 1.4 create a object of book elements with title,language and author information.
4038

4139
// eslint-disable-next-line vars-on-top
4240
const books = {
@@ -82,8 +80,7 @@ const books = {
8280
author: 'Charles Dickens',
8381
},
8482
};
85-
86-
// const ul = document.createElement('ul');
83+
// 1.5 create Html element for Book title,Language and Author.Create id for each li element
8784

8885
function createBookListUsingObject(bookObj) {
8986
// eslint-disable-next-line guard-for-in
@@ -96,7 +93,7 @@ function createBookListUsingObject(bookObj) {
9693
// console.log(objectKeys[j]);
9794
li.setAttribute('id', objectKeys[j]);
9895

99-
const head = document.createElement('h1');
96+
const head = document.createElement('h2');
10097
const headContent = document.createTextNode(bookObj[i].title);
10198

10299
const headLanguage = document.createElement('h2');
@@ -112,7 +109,6 @@ function createBookListUsingObject(bookObj) {
112109
li.appendChild(head);
113110
li.appendChild(headLanguageContent);
114111
li.appendChild(headAuthor);
115-
li.style.cssFloat = 'left';
116112

117113
ul.appendChild(li);
118114

@@ -123,7 +119,21 @@ function createBookListUsingObject(bookObj) {
123119

124120
createBookListUsingObject(books);
125121

126-
// Create a object with Bookid and image
122+
// 1.6 set up display property of ul element
123+
124+
document.getElementById('booktitle').style.display = 'grid';
125+
document.getElementById('booktitle').style.gridTemplateColumns = 'auto auto';
126+
document.getElementById('booktitle').style.gridAutoColumns = 'minmax(auto, auto)';
127+
document.getElementById('booktitle').style.gridAutoRows = 'minmax(auto, auto)';
128+
document.getElementById('booktitle').style.gridGap = '2em';
129+
130+
// 1.6 Set up the style of ul element
131+
132+
ul.style.listStyle = 'none';
133+
ul.style.border = '2px red solid';
134+
ul.style.padding = '2em';
135+
136+
// 1.7 Create a object with Bookid and image.
127137

128138
const bookimage = {
129139
my_experiment_with_truth: 'gandhi.jpg',
@@ -135,12 +145,13 @@ const bookimage = {
135145
the_tale_of_two_cities: 'thetaleoftwocities.jpg',
136146
};
137147

148+
// 1.8 Match the book image with book title using unique list id of the book
149+
138150
function imageDisplay(imageObject) {
139151
// eslint-disable-next-line guard-for-in
140152
let j = 0;
141153
// eslint-disable-next-line guard-for-in
142154
for (const i in imageObject) {
143-
// console.log(Object.keys(imageObject)[j]);
144155
const container = document.getElementById(Object.keys(imageObject)[j]);
145156
const imageElement = document.createElement('img');
146157
imageElement.src = imageObject[i];
@@ -150,30 +161,3 @@ function imageDisplay(imageObject) {
150161
}
151162

152163
imageDisplay(bookimage);
153-
154-
// eslint-disable-next-line no-undef
155-
ul.style.display = 'grid';
156-
ul.style.gridTemplateColumns = 'auto auto';
157-
ul.style.gridAutoColumns = 'minmax(auto,auto)';
158-
ul.style.gridAutoRows = 'minmax(auto,auto)';
159-
160-
// eslint-disable-next-line no-unused-vars
161-
function createGrid(x) {
162-
for (let rows = 0; rows < x; rows++) {
163-
for (let col = 0; col < x; col++) {
164-
// eslint-disable-next-line no-undef
165-
// $('#booktitle').append("<div> class='grid'></div>");
166-
const grid = document.getElementById("booktitle");
167-
grid.appendChild(li)
168-
}
169-
}
170-
171-
// eslint-disable-next-line no-undef
172-
$('.grid').height(960 / x);
173-
// eslint-disable-next-line no-undef
174-
$('.grid').width(960 / x);
175-
}
176-
177-
// eslint-disable-next-line no-undef
178-
createGrid(2);
179-
*/

Week1/homework/style.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
margin: 0;
44
}
55
body {
6-
background-color: aqua;
6+
background-color: seashell;
77
}
88
#mybooks {
99
text-align: center;
1010
}
11-
ol li {
12-
text-align: justify;
11+
12+
ul li {
13+
background: orange;
14+
padding: 1em;
15+
border: #333 1px solid;
16+
height: auto;
1317
}

0 commit comments

Comments
 (0)