Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Displaying json contents in a tile grid format with tailwind and jquery.
- MagicCrayon9342
- Scratcher
1000+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
So, at https://github.com/get-catalyst/Flavors/ I have json files. In every flavor folder there is a json file named fork.json. I need to display every item in flavorName/fork.json with the icon as the icon, the description as the description, and the name as the name (description section on website needs to be the value in the json). In tiles with jquery and tailwind. Similar to https://www.electronjs.org/apps, how should I do this?
- uwv
- Scratcher
1000+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
flex.
i use arch linux (btw) with the linux zen kernel and enjoy writing silly things in silly languages using silly frameworks
- MagicCrayon9342
- Scratcher
1000+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
- skymover1239
- Scratcher
500+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
I think (I'm not an expert on this) but you should just be able to use the fetch API and display the contents from that.The issue isn't the cards, its the json => visible data on a web page flex.
For God so loved the world that he gave his one and only Son that whoever believes in him shall not perish but have eternal life
First time a moderator got ninjaed??
500 Posts
Current Mainline projects
AquaCSS - A CSS framework.
Ink - An editor that does, lots of things.
500 Posts
Current Mainline projects
AquaCSS - A CSS framework.
Ink - An editor that does, lots of things.
- Jeffalo
- Scratcher
1000+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
is it any different to rendering any other data? first fetch the json, then iterate over the json and add corresponding html elements to the page using document.createElement or something. might be even easier with jQuery.The issue isn't the cards, its the json => visible data on a web page flex.
I discovered Scratch in 2015 and created games and animations. From 2020 to 2023, I worked on Scratch browser extensions, found security vulnerabilities, and maintained a forum search engine called ocular. In the summer of 2024, I was an engineering intern with the Scratch Team. Now, I'm ready to finish my last year of high school. Scratch on!
- ZZC12345
- Scratcher
500+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
Oh, no! Not jQuery! XDis it any different to rendering any other data? first fetch the json, then iterate over the json and add corresponding html elements to the page using document.createElement or something. might be even easier with jQuery.The issue isn't the cards, its the json => visible data on a web page flex.
Assuming a card structure like this:
<template id="card-template"> <a class="card"> <img class="card__icon" /> <h1 class="card__header"></h1> <p class="card__description"></p> </a> </template>
// const container: HTMLElement; // const data: CatalystForkJson[]; const template = document.getElementById("card-template"); for (const fork of data) { const newElement = template.content.cloneNode(true); newElement.href = `https://github.com/${fork.repo}`; newElement.querySelector(".card__icon").src = fork.icon; newElement.querySelector(".card__header").textContent = fork.name; newElement.querySelector(".card__description").textContent = fork.desc; container.appendChild(newElement); }
With jQuery: https://stackoverflow.com/a/65969709
Without jQuery: https://stackoverflow.com/a/12265800
This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- MagicCrayon9342
- Scratcher
1000+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
May I ask why #1, there's framework code in this.Oh, no! Not jQuery! XDis it any different to rendering any other data? first fetch the json, then iterate over the json and add corresponding html elements to the page using document.createElement or something. might be even easier with jQuery.The issue isn't the cards, its the json => visible data on a web page flex.
Assuming a card structure like this:You can use:<template id="card-template"> <a class="card"> <img class="card__icon" /> <h1 class="card__header"></h1> <p class="card__description"></p> </a> </template>Please do not use this in Catalyst. It's just an example and is really bad; if you can make a browser, you can surely make a list of cards. Also, when in doubt: Google => StackOverflow. “display list of cards with json data” turns up a well-written question and answer on StackOverflow to copy and paste from, especially if you're using jQuery.// const container: HTMLElement; // const data: CatalystForkJson[]; const template = document.getElementById("card-template"); for (const fork of data) { const newElement = template.content.cloneNode(true); newElement.href = `https://github.com/${fork.repo}`; newElement.querySelector(".card__icon").src = fork.icon; newElement.querySelector(".card__header").textContent = fork.name; newElement.querySelector(".card__description").textContent = fork.desc; container.appendChild(newElement); }
With jQuery: https://stackoverflow.com/a/65969709
Without jQuery: https://stackoverflow.com/a/12265800
can't {fork.repo} only be used in React?
- Mrcomputer1
- Scratcher
500+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
#1: That isn't React, that's a template literal (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals). Also, React is just “{fork.repo}”, a template literal is “${fork.repo}”.May I ask why #1, there's framework code in this.snipOh, no! Not jQuery! XD
Assuming a card structure like this:You can use:<template id="card-template"> <a class="card"> <img class="card__icon" /> <h1 class="card__header"></h1> <p class="card__description"></p> </a> </template>Please do not use this in Catalyst. It's just an example and is really bad; if you can make a browser, you can surely make a list of cards. Also, when in doubt: Google => StackOverflow. “display list of cards with json data” turns up a well-written question and answer on StackOverflow to copy and paste from, especially if you're using jQuery.// const container: HTMLElement; // const data: CatalystForkJson[]; const template = document.getElementById("card-template"); for (const fork of data) { const newElement = template.content.cloneNode(true); newElement.href = `https://github.com/${fork.repo}`; newElement.querySelector(".card__icon").src = fork.icon; newElement.querySelector(".card__header").textContent = fork.name; newElement.querySelector(".card__description").textContent = fork.desc; container.appendChild(newElement); }
With jQuery: https://stackoverflow.com/a/65969709
Without jQuery: https://stackoverflow.com/a/12265800and #2 why the excessive underscores in classescan't {fork.repo} only be used in React?
My Profile / My User Page / My Talk Page / My 3.0 and 2.0 Modding Tutorials
——————–
Progress bar to 1000+ Posts - Image might not be up to date
——————–
My browser / operating system: Windows NT 10.0 (Windows 11 - 23H2), Firefox 131.0b9
——————–
My ScratchX Extensions——–If you like this post, give me an internet!——–Sharp Scratch Mod
- ZZC12345
- Scratcher
500+ posts
Displaying json contents in a tile grid format with tailwind and jquery.
#1, that's ES still, it's template literals and note the $:May I ask why #1, there's framework code in this.Oh, no! Not jQuery! XDis it any different to rendering any other data? first fetch the json, then iterate over the json and add corresponding html elements to the page using document.createElement or something. might be even easier with jQuery.The issue isn't the cards, its the json => visible data on a web page flex.
Assuming a card structure like this:You can use:<template id="card-template"> <a class="card"> <img class="card__icon" /> <h1 class="card__header"></h1> <p class="card__description"></p> </a> </template>Please do not use this in Catalyst. It's just an example and is really bad; if you can make a browser, you can surely make a list of cards. Also, when in doubt: Google => StackOverflow. “display list of cards with json data” turns up a well-written question and answer on StackOverflow to copy and paste from, especially if you're using jQuery.// const container: HTMLElement; // const data: CatalystForkJson[]; const template = document.getElementById("card-template"); for (const fork of data) { const newElement = template.content.cloneNode(true); newElement.href = `https://github.com/${fork.repo}`; newElement.querySelector(".card__icon").src = fork.icon; newElement.querySelector(".card__header").textContent = fork.name; newElement.querySelector(".card__description").textContent = fork.desc; container.appendChild(newElement); }
With jQuery: https://stackoverflow.com/a/65969709
Without jQuery: https://stackoverflow.com/a/12265800and #2 why the excessive underscores in classescan't {fork.repo} only be used in React?
const thing = "world"; `hello ${thing}`;
This is my signature. Go check out my GitHub if you want to!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make sure to check out these cool projects, written in real code! (outdated, sorry)
Aviate - Itinerary - Scratch Auth - Orange OS Linux Distro - ocular - Leopard - PyHelp - My GitHub
- Discussion Forums
- » Advanced Topics
- » Displaying json contents in a tile grid format with tailwind and jquery.