From 032c4ed3f3e72b58e9c6d2763a06a0e7cdbb760a Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 21 Feb 2025 23:06:13 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20fonctionnalit=C3=A9=20de=20cita?= =?UTF-8?q?tion=20al=C3=A9atoire=20dans=20le=20composant=20QuoteCard=20ave?= =?UTF-8?q?c=20r=C3=A9cup=C3=A9ration=20des=20donn=C3=A9es=20depuis=20un?= =?UTF-8?q?=20fichier=20JSON.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/app/page.tsx | 1 - front/components/quote-card.tsx | 56 ++++++--- front/public/quotes.json | 202 ++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+), 15 deletions(-) create mode 100644 front/public/quotes.json diff --git a/front/app/page.tsx b/front/app/page.tsx index 7e396f2..7c7a96b 100644 --- a/front/app/page.tsx +++ b/front/app/page.tsx @@ -1,4 +1,3 @@ -import { SpaceNav } from "@/components/space-nav"; import { QuoteCard } from "@/components/quote-card"; import { Messages } from "@/components/messages"; import { Podcast } from "@/components/podcast"; diff --git a/front/components/quote-card.tsx b/front/components/quote-card.tsx index ade2898..c3e244b 100644 --- a/front/components/quote-card.tsx +++ b/front/components/quote-card.tsx @@ -1,22 +1,50 @@ -import { RefreshCw } from 'lucide-react' -import { Card, CardContent } from "@/components/ui/card" +"use client"; + +import { RefreshCw } from "lucide-react"; +import { Card, CardContent } from "@/components/ui/card"; +import { useEffect, useState } from "react"; + +interface Quote { + quote: string; + author: string; +} export function QuoteCard() { + const fetchQuote = async (): Promise => { + // Récupere la liste des citations depuis le fichier dans /public/quotes.json + const response = await fetch("/quotes.json"); + const data = await response.json(); + + // Retourne une citation aléatoire + return data[Math.floor(Math.random() * data.length)]; + }; + + const [quote, setQuote] = useState(null); + + useEffect(() => { + fetchQuote().then(setQuote); + }, []); + + const handleRefresh = () => { + fetchQuote().then(setQuote); + }; + return ( - - -
-

- "To be a good artist / letterer / designer / guitar player, it takes practice. A lot of it. More than you can even - fathom when you're starting out." -

-
Jessica Hische
+ + +
+

{quote ? quote.quote : "Loading..."}

+
+ {quote ? quote.author : "Loading..."} +
-
- ) + ); } - diff --git a/front/public/quotes.json b/front/public/quotes.json new file mode 100644 index 0000000..f41d4f9 --- /dev/null +++ b/front/public/quotes.json @@ -0,0 +1,202 @@ +[ + { + "quote": "Imagination is more important than knowledge.", + "author": "Albert Einstein" + }, + { + "quote": "The important thing is not to stop questioning.", + "author": "Albert Einstein" + }, + { + "quote": "If you can't explain it simply, you don't understand it well enough.", + "author": "Albert Einstein" + }, + { + "quote": "If I have seen further it is by standing on the shoulders of giants.", + "author": "Isaac Newton" + }, + { + "quote": "The present is theirs; the future, for which I really worked, is mine.", + "author": "Nikola Tesla" + }, + { + "quote": "Our virtues and our failures are inseparable, like force and matter. When they separate, man is no more.", + "author": "Nikola Tesla" + }, + { + "quote": "Nothing in life is to be feared, it is only to be understood.", + "author": "Marie Curie" + }, + { + "quote": "One never notices what has been done; one can only see what remains to be done.", + "author": "Marie Curie" + }, + { + "quote": "Intelligence is the ability to adapt to change.", + "author": "Stephen Hawking" + }, + { + "quote": "However difficult life may seem, there is always something you can do and succeed at.", + "author": "Stephen Hawking" + }, + { + "quote": "I learned very early the difference between knowing the name of something and knowing something.", + "author": "Richard Feynman" + }, + { + "quote": "The first principle is that you must not fool yourself, and you are the easiest person to fool.", + "author": "Richard Feynman" + }, + { + "quote": "Somewhere, something incredible is waiting to be known.", + "author": "Carl Sagan" + }, + { + "quote": "Science is more than a body of knowledge; it's a way of thinking.", + "author": "Carl Sagan" + }, + { + "quote": "All truths are easy to understand once they are discovered; the point is to discover them.", + "author": "Galileo Galilei" + }, + { + "quote": "You cannot teach a man anything; you can only help him find it within himself.", + "author": "Galileo Galilei" + }, + { + "quote": "Learning never exhausts the mind.", + "author": "Leonardo da Vinci" + }, + { + "quote": "Simplicity is the ultimate sophistication.", + "author": "Leonardo da Vinci" + }, + { + "quote": "I have not failed. I've just found 10,000 ways that won't work.", + "author": "Thomas Edison" + }, + { + "quote": "Genius is one percent inspiration and ninety-nine percent perspiration.", + "author": "Thomas Edison" + }, + { + "quote": "Thoroughly conscious ignorance is the prelude to every real advance in science.", + "author": "James Clerk Maxwell" + }, + { + "quote": "Prediction is very difficult, especially if it's about the future.", + "author": "Niels Bohr" + }, + { + "quote": "Give me a place to stand, and I shall move the earth.", + "author": "Archimedes" + }, + { + "quote": "An investment in knowledge always pays the best interest.", + "author": "Benjamin Franklin" + }, + { + "quote": "Tell me and I forget, teach me and I may remember, involve me and I learn.", + "author": "Benjamin Franklin" + }, + { + "quote": "In mathematics you don't understand things. You just get used to them.", + "author": "John von Neumann" + }, + { + "quote": "The most dangerous phrase in the language is, 'We've always done it this way.'", + "author": "Grace Hopper" + }, + { + "quote": "The Analytical Engine weaves algebraic patterns just as the Jacquard loom weaves flowers and leaves.", + "author": "Ada Lovelace" + }, + { + "quote": "Science, the product of human curiosity, is our best tool for understanding the universe.", + "author": "Richard Dawkins" + }, + { + "quote": "We are all atheists about most of the gods that humanity has ever believed in.", + "author": "Richard Dawkins" + }, + { + "quote": "We can only see a short distance ahead, but we can see plenty there that needs to be done.", + "author": "Alan Turing" + }, + { + "quote": "Machines take me by surprise with great frequency.", + "author": "Alan Turing" + }, + { + "quote": "Mathematics is the queen of the sciences.", + "author": "Carl Friedrich Gauss" + }, + { + "quote": "I have had my results for a long time; but I do not yet know how I am to arrive at them.", + "author": "Carl Friedrich Gauss" + }, + { + "quote": "Science and everyday life cannot and should not be separated.", + "author": "Rosalind Franklin" + }, + { + "quote": "There is nothing in the world of science that does not have its wondrous and awe-inspiring element.", + "author": "Dmitri Mendeleev" + }, + { + "quote": "When one door closes, another opens; but we often look so long and so regretfully upon the closed door that we do not see the one which has opened for us.", + "author": "Alexander Graham Bell" + }, + { + "quote": "Before anything else, preparation is the key to success.", + "author": "Alexander Graham Bell" + }, + { + "quote": "Heat is a mode of motion.", + "author": "James Prescott Joule" + }, + { + "quote": "All science is either physics or stamp collecting.", + "author": "Ernest Rutherford" + }, + { + "quote": "Equipped with his five senses, man explores the universe around him and calls the adventure science.", + "author": "Edwin Hubble" + }, + { + "quote": "Science advances one funeral at a time.", + "author": "Max Planck" + }, + { + "quote": "What we observe is not nature itself, but nature exposed to our method of questioning.", + "author": "Werner Heisenberg" + }, + { + "quote": "There are no secrets about the world of nature. There are secrets about the thoughts and intentions of men.", + "author": "J. Robert Oppenheimer" + }, + { + "quote": "There are two possible outcomes: if the result confirms the hypothesis, then you have made a measurement. If it doesn't, then you have made a discovery.", + "author": "Enrico Fermi" + }, + { + "quote": "I am not thinking of all the misery but of the beauty that still remains.", + "author": "Lise Meitner" + }, + { + "quote": "Look for the unexpected in the nature of things. There is wonder everywhere.", + "author": "Barbara McClintock" + }, + { + "quote": "Nature uses only the longest threads to weave her patterns, so that each small piece of her fabric reveals the organization of the entire tapestry.", + "author": "Richard Feynman" + }, + { + "quote": "Of all things, I liked books best.", + "author": "Nikola Tesla" + }, + { + "quote": "Life would be tragic if it weren't funny.", + "author": "Stephen Hawking" + } +]