Skip to content

Instantly share code, notes, and snippets.

View m-yahya's full-sized avatar
🛠️
Building Stuff

Muhammad Yahya m-yahya

🛠️
Building Stuff
View GitHub Profile
@m-yahya
m-yahya / App.css
Created June 2, 2022 09:22
CSS Styles for React Todo App
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
padding: 50px;
color: #f7f7f7;
min-height: 100vh;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@m-yahya
m-yahya / ui-tree_14.js
Created April 28, 2021 15:23
Tutorial: Nested UI from JSON data and Tree view
// get details
const getDetails = (details) => {
// iterate over the detail items of object
for (const detail in details) {
// fetch the value of each item
if (detail == "img") {
markupArray.push(
`<img src="./img/${details[detail]}" alt="${details[detail]}">`
);
} else if (detail == "children") {
@m-yahya
m-yahya / ui-tree_13.js
Created April 28, 2021 15:22
Tutorial: Nested UI from JSON data and Tree view
const data = {
Parent: {
img: "father.png",
name: "Jan Doe",
age: "50",
children: [
{
child: {
img: "child_1.png",
name: "child 1",
@m-yahya
m-yahya / ui-tree_12.js
Created April 28, 2021 15:21
Tutorial: Nested UI from JSON data and Tree view
// get details
const getDetails = (details) => {
// iterate over the detail items of object
for (const detail in details) {
// fetch the value of each item
if (detail == "img") {
markupArray.push(
`<img src="./img/${details[detail]}" alt="${details[detail]}">`
);
} else {
@m-yahya
m-yahya / ui-tree_11.js
Created April 28, 2021 15:21
Tutorial: Nested UI from JSON data and Tree view
// get items in the object
const getItems = (items) => {
for (const item in items) {
markupArray.push(`<li> ${item}`);
// fetch the parent object
let details = items[item];
getDetails(details);
// push the closing tag for parent
markupArray.push("</li>");
}
@m-yahya
m-yahya / ui-tree_10.js
Created April 28, 2021 15:20
Tutorial: Nested UI from JSON data and Tree view
// get details
const getDetails = (details) => {
// iterate over the detail items of object
for (const detail in details) {
// fetch the value of each item
markupArray.push(`<span> ${details[detail]} </span>`);
}
};
@m-yahya
m-yahya / ui-tree_9.js
Created April 28, 2021 15:18
Tutorial: Nested UI from JSON data and Tree view
// get items in the object
const getItems = (items) => {
for (const item in items) {
markupArray.push(`<li> ${item}`);
markupArray.push("</li>");
}
};
@m-yahya
m-yahya / ui-tree_8.js
Created April 28, 2021 15:17
Tutorial: Nested UI from JSON data and Tree view
// evaluate expressions
const createList = (items) => {
switch ($.type(items)) {
case "object":
getItems(items);
break;
}
};
@m-yahya
m-yahya / ui-tree_7.js
Created April 28, 2021 15:16
Tutorial: Nested UI from JSON data and Tree view
// add a parent with some details
const data = {
Parent: {
name: "Jan Doe",
age: "50",
img: "father.png",
},
};