Ciellumiere Posted September 25 Share Posted September 25 Site URL: https://thethingfromthefuture.netlify.app/ Hey a client of mine would like to build a page on their existing website featuring random prompts that could also be shuffled to show a new prompt upon button click. Here is an example website of what we want: https://thethingfromthefuture.netlify.app/ Is there an app or any other way that this could be build in Squarespace. I am also open to any other ideas of how we could showcase random prompts, not necessarily in the exact same way as on the example page. I was thinking of possibly making cards/boxes that show the prompt upon hover but we have more than 100 prompts so it's not very realistic. Thank you for your input! Link to comment
Solution tuanphan Posted September 27 Solution Share Posted September 27 Edit Page where you want to do this > Add a Code Block > Paste this code <div class="contentCenter"> <section> <div class="promptBar"> <div class="promptTitle">Future Prompt</div> <div class="promptShuffle">Shuffle ↺</div> </div> <div class="promptBox"> <p class="prompttext"></p> </div> </section> </div> <style> .contentCenter, .contentRight { display: flex; flex-direction: row; } .promptBar { width: 700px; display: flex; flex-direction: row; justify-content: space-between; border: 2px solid #000; border-bottom: 0; } .promptBox { width: 700px; border: 2px solid #000; padding: 16px; } .promptShuffle, .promptTitle { font-size: 24px; line-height: 32px; padding: 8px 16px; } .promptShuffle { border-left: 2px solid #000; color: #000; cursor: pointer; } .promptBox { width: 700px; border: 2px solid #000; padding: 16px; } .prompttext { font-size: 40px; line-height: 48px; color: #000; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function() { // Array of random texts var prompts = [ "What will the world look like in 50 years?", "How will technology shape the future?", "What is your vision for a sustainable future?", "How will we solve the climate crisis?", "What will education look like in the future?" ]; // Event listener for the Shuffle button $(".promptShuffle").on('click', function() { // Pick a random prompt from the array var randomPrompt = prompts[Math.floor(Math.random() * prompts.length)]; // Update the paragraph with the new random prompt $(".prompttext").text(randomPrompt); }); }); </script> Demo: https://tuanphan-demo01.squarespace.com/click-button-show-random-text-1?noredirect Pass: abc Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Ciellumiere Posted Tuesday at 12:58 PM Author Share Posted Tuesday at 12:58 PM (edited) @tuanphan You are an absolute rockstar!!! it works like a charm. Brilliant! How could I optimize it for mobile though? Extra question: How should i go about adding a button below the prompt that links to a PDF file like in an example: Edited Tuesday at 01:25 PM by Ciellumiere Link to comment
tuanphan Posted Tuesday at 11:35 PM Share Posted Tuesday at 11:35 PM 10 hours ago, Ciellumiere said: @tuanphan You are an absolute rockstar!!! it works like a charm. Brilliant! How could I optimize it for mobile though? Extra question: How should i go about adding a button below the prompt that links to a PDF file like in an example: Each text will have a different "View the document" link or same link? Can you share link to page where you added the code? I can check & adjust mobile view easier Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Ciellumiere Posted Wednesday at 01:09 PM Author Share Posted Wednesday at 01:09 PM 13 hours ago, tuanphan said: Each text will have a different "View the document" link or same link? Can you share link to page where you added the code? I can check & adjust mobile view easier Same link. For now, I added it to the test page: flounder-bamboo-r38z.squarespace.com Password: demo Once again, a huge thank you for your help 🙂 Link to comment
tuanphan Posted Wednesday at 03:09 PM Share Posted Wednesday at 03:09 PM You can try this new code <div class="contentCenter"> <section> <div class="promptBar"> <div class="promptTitle">Future Prompt</div> <div class="promptShuffle">Shuffle ↺</div> </div> <div class="promptBox"> <p class="prompttext"></p> <a href="https://google.com">View Document</a> </div> </section> </div> <style> .contentCenter, .contentRight { display: flex; flex-direction: row; } .promptBar { width: 732px; display: flex; flex-direction: row; justify-content: space-between; border: 2px solid #000; border-bottom: 0; } .promptBox { width: 700px; border: 2px solid #000; padding: 16px; } .promptShuffle, .promptTitle { font-size: 24px; line-height: 32px; padding: 8px 16px; } .promptShuffle { border-left: 2px solid #000; color: #000; cursor: pointer; background-color:#FD97FA } .promptBox { width: 700px; border: 2px solid #000; padding: 16px; } .prompttext { font-size: 40px; line-height: 48px; color: #000; } /* For link */ .promptBox a { background-color: #65ac82; position: absolute; bottom: 0; left: 0; right: 0; text-align: center; padding-top: 5px; padding-bottom: 5px; } .promptBox { position: relative; } p.prompttext { padding-bottom: 20px; } @media screen and (max-width:767px) { .promptBox { width: 100%; max-width: 300px; } .promptBar { width: 100%; max-width: 350px; } } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function() { // Array of random texts var prompts = [ "In a Biblically guided future, Project 2025 aims to promote Christian-centric policies, potentially marginalizing other faiths and challenging church-state separation. (p. 4, 560, 581, 589)", "In a Gilead-esque future, Project 2025 advocates for 'fetal personhood' from conception, potentially jeopardizing procedures like IVF. (p. 450)", "In a barely democratic future, Project 2025 seeks to expand executive power over agencies and ease civil servant dismissals, potentially concentrating power in the executive branch. (p. 43, 825)", "In a surveillance-heavy future, Project 2025 plans to reduce privacy protections for non-citizens and green card holders, potentially exposing them to discrimination and harm. (p. 139, 165)", "In a womb-regulated future, Project 2025 aims to reverse guidelines allowing Medicare-funded hospitals to perform emergency abortions, even when necessary to save a woman's life. (p. 473)", "In a sanctioned-by-the-church future, Project 2025 proposes allowing religious organizations to discriminate based on their beliefs, potentially violating individual rights. (p. 586)", ]; // Event listener for the Shuffle button $(".promptShuffle").on('click', function() { // Pick a random prompt from the array var randomPrompt = prompts[Math.floor(Math.random() * prompts.length)]; // Update the paragraph with the new random prompt $(".prompttext").text(randomPrompt); }); }); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
tuanphan Posted Wednesday at 03:10 PM Share Posted Wednesday at 03:10 PM I added the code, but you can wait some hours or some days 😅 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment