├── .gitignore ├── README-template.md ├── README.md ├── app.js ├── design ├── bonus │ ├── desktop-rules-modal-bonus.jpg │ ├── desktop-step-1-bonus.jpg │ ├── desktop-step-2-bonus.jpg │ ├── desktop-step-3-bonus.jpg │ ├── desktop-step-4-bonus.jpg │ ├── mobile-rules-modal-bonus.jpg │ ├── mobile-step-1-bonus.jpg │ ├── mobile-step-2-bonus.jpg │ ├── mobile-step-3-bonus.jpg │ └── mobile-step-4-bonus.jpg ├── desktop-preview.jpg └── original │ ├── desktop-rules-modal.jpg │ ├── desktop-step-1.jpg │ ├── desktop-step-2.jpg │ ├── desktop-step-3.jpg │ ├── desktop-step-4-lose.jpg │ ├── desktop-step-4-win.jpg │ ├── mobile-rules-modal.jpg │ ├── mobile-step-1.jpg │ ├── mobile-step-2.jpg │ ├── mobile-step-3.jpg │ ├── mobile-step-4-lose.jpg │ └── mobile-step-4-win.jpg ├── images ├── bg-pentagon.svg ├── bg-triangle.svg ├── favicon-32x32.png ├── icon-close.svg ├── icon-lizard.svg ├── icon-paper.svg ├── icon-rock.svg ├── icon-scissors.svg ├── icon-spock.svg ├── image-rules-bonus.svg ├── image-rules.svg ├── logo-bonus.svg └── logo.svg ├── index.html ├── style-guide.md └── styles.css /.gitignore: -------------------------------------------------------------------------------- 1 | # Avoid accidental Sketch file upload 2 | ############################################### 3 | ## Please do not remove line 5 - thanks! 🙂 ## 4 | ############################################### 5 | *.sketch 6 | 7 | # Avoid accidental XD or Figma upload if you convert the design file 8 | ####################################################### 9 | ## Please do not remove lines 11 and 12 - thanks! 🙂 ## 10 | ####################################################### 11 | *.xd 12 | *.fig 13 | 14 | # Avoid your project being littered with annoying .DS_Store files! 15 | .DS_Store 16 | -------------------------------------------------------------------------------- /README-template.md: -------------------------------------------------------------------------------- 1 | # Frontend Mentor - Rock, Paper, Scissors solution 2 | 3 | This is a solution to the [Rock, Paper, Scissors challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/rock-paper-scissors-game-pTgwgvgH). Frontend Mentor challenges help you improve your coding skills by building realistic projects. 4 | 5 | ## Table of contents 6 | 7 | - [Overview](#overview) 8 | - [The challenge](#the-challenge) 9 | - [Screenshot](#screenshot) 10 | - [Links](#links) 11 | - [My process](#my-process) 12 | - [Built with](#built-with) 13 | - [What I learned](#what-i-learned) 14 | - [Continued development](#continued-development) 15 | - [Useful resources](#useful-resources) 16 | - [Author](#author) 17 | - [Acknowledgments](#acknowledgments) 18 | 19 | **Note: Delete this note and update the table of contents based on what sections you keep.** 20 | 21 | ## Overview 22 | 23 | ### The challenge 24 | 25 | Users should be able to: 26 | 27 | - View the optimal layout for the game depending on their device's screen size 28 | - Play Rock, Paper, Scissors against the computer 29 | - Maintain the state of the score after refreshing the browser _(optional)_ 30 | - **Bonus**: Play Rock, Paper, Scissors, Lizard, Spock against the computer _(optional)_ 31 | 32 | ### Screenshot 33 | 34 | ![](./screenshot.jpg) 35 | 36 | Add a screenshot of your solution. The easiest way to do this is to use Firefox to view your project, right-click the page and select "Take a Screenshot". You can choose either a full-height screenshot or a cropped one based on how long the page is. If it's very long, it might be best to crop it. 37 | 38 | Alternatively, you can use a tool like [FireShot](https://getfireshot.com/) to take the screenshot. FireShot has a free option, so you don't need to purchase it. 39 | 40 | Then crop/optimize/edit your image however you like, add it to your project, and update the file path in the image above. 41 | 42 | **Note: Delete this note and the paragraphs above when you add your screenshot. If you prefer not to add a screenshot, feel free to remove this entire section.** 43 | 44 | ### Links 45 | 46 | - Solution URL: [Add solution URL here](https://your-solution-url.com) 47 | - Live Site URL: [Add live site URL here](https://your-live-site-url.com) 48 | 49 | ## My process 50 | 51 | ### Built with 52 | 53 | - Semantic HTML5 markup 54 | - CSS custom properties 55 | - Flexbox 56 | - CSS Grid 57 | - Mobile-first workflow 58 | - [React](https://reactjs.org/) - JS library 59 | - [Next.js](https://nextjs.org/) - React framework 60 | - [Styled Components](https://styled-components.com/) - For styles 61 | 62 | **Note: These are just examples. Delete this note and replace the list above with your own choices** 63 | 64 | ### What I learned 65 | 66 | Use this section to recap over some of your major learnings while working through this project. Writing these out and providing code samples of areas you want to highlight is a great way to reinforce your own knowledge. 67 | 68 | To see how you can add code snippets, see below: 69 | 70 | ```html 71 |

Some HTML code I'm proud of

72 | ``` 73 | ```css 74 | .proud-of-this-css { 75 | color: papayawhip; 76 | } 77 | ``` 78 | ```js 79 | const proudOfThisFunc = () => { 80 | console.log('🎉') 81 | } 82 | ``` 83 | 84 | If you want more help with writing markdown, we'd recommend checking out [The Markdown Guide](https://www.markdownguide.org/) to learn more. 85 | 86 | **Note: Delete this note and the content within this section and replace with your own learnings.** 87 | 88 | ### Continued development 89 | 90 | Use this section to outline areas that you want to continue focusing on in future projects. These could be concepts you're still not completely comfortable with or techniques you found useful that you want to refine and perfect. 91 | 92 | **Note: Delete this note and the content within this section and replace with your own plans for continued development.** 93 | 94 | ### Useful resources 95 | 96 | - [Example resource 1](https://www.example.com) - This helped me for XYZ reason. I really liked this pattern and will use it going forward. 97 | - [Example resource 2](https://www.example.com) - This is an amazing article which helped me finally understand XYZ. I'd recommend it to anyone still learning this concept. 98 | 99 | **Note: Delete this note and replace the list above with resources that helped you during the challenge. These could come in handy for anyone viewing your solution or for yourself when you look back on this project in the future.** 100 | 101 | ## Author 102 | 103 | - Website - [Add your name here](https://www.your-site.com) 104 | - Frontend Mentor - [@yourusername](https://www.frontendmentor.io/profile/yourusername) 105 | - Twitter - [@yourusername](https://www.twitter.com/yourusername) 106 | 107 | **Note: Delete this note and add/remove/edit lines above based on what links you'd like to share.** 108 | 109 | ## Acknowledgments 110 | 111 | This is where you can give a hat tip to anyone who helped you out on this project. Perhaps you worked in a team or got some inspiration from someone else's solution. This is the perfect place to give them some credit. 112 | 113 | **Note: Delete this note and edit this section's content as necessary. If you completed this challenge by yourself, feel free to delete this section entirely.** 114 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Frontend Mentor - Rock, Paper, Scissors 2 | 3 | ![Design preview for the Rock, Paper, Scissors coding challenge](./design/desktop-preview.jpg) 4 | 5 | ## Welcome! 👋 6 | 7 | Thanks for checking out this front-end coding challenge. 8 | 9 | [Frontend Mentor](https://www.frontendmentor.io) challenges help you improve your coding skills by building realistic projects. 10 | 11 | **To do this challenge, you need a basic understanding of HTML, CSS and JavaScript.** 12 | 13 | ## The challenge 14 | 15 | Your challenge is to build out this Rock, Paper, Scissors game and get it looking as close to the design as possible. 16 | 17 | You can use any tools you like to help you complete the challenge. So if you've got something you'd like to practice, feel free to give it a go. 18 | 19 | Your users should be able to: 20 | 21 | - View the optimal layout for the game depending on their device's screen size 22 | - Play Rock, Paper, Scissors against the computer 23 | - Maintain the state of the score after refreshing the browser _(optional)_ 24 | - **Bonus**: Play Rock, Paper, Scissors, Lizard, Spock against the computer _(optional)_ 25 | 26 | ### Rules 27 | 28 | If the player wins, they gain 1 point. If the computer wins, the player loses one point. 29 | 30 | #### Original 31 | 32 | - Paper beats Rock 33 | - Rock beats Scissors 34 | - Scissors beats Paper 35 | 36 | #### Bonus 37 | 38 | - Scissors beats Paper 39 | - Paper beats Rock 40 | - Rock beats Lizard 41 | - Lizard beats Spock 42 | - Spock beats Scissors 43 | - Scissors beats Lizard 44 | - Paper beats Spock 45 | - Rock beats Scissors 46 | - Lizard beats Paper 47 | - Spock beats Rock 48 | 49 | Not sure what Rock, Paper, Scissors, Lizard, Spock is? [Check out this clip from The Big Bang Theory](https://www.youtube.com/watch?v=iSHPVCBsnLw). 50 | 51 | Want some support on the challenge? [Join our Slack community](https://www.frontendmentor.io/slack) and ask questions in the **#help** channel. 52 | 53 | ## Where to find everything 54 | 55 | Your task is to build out the project to the designs inside the `/design` folder. You can either choose the `original` designs for the simpler version or the `bonus` designs for the harder version. You will find both mobile and desktop versions of the design to work to. Each file is also named depending on which step in the game the design is for. 56 | 57 | The designs are in JPG static format. Using JPGs will mean that you'll need to use your best judgment for styles such as `font-size`, `padding` and `margin`. 58 | 59 | If you would like the design files (we provide Sketch & Figma versions) to inspect the design in more detail, you can [subscribe as a PRO member](https://www.frontendmentor.io/pro). 60 | 61 | You will find all the required assets in the `/images` folder. The assets are already optimized. 62 | 63 | There is also a `style-guide.md` file containing the information you'll need, such as color palette and fonts. 64 | 65 | ## Building your project 66 | 67 | Feel free to use any workflow that you feel comfortable with. Below is a suggested process, but do not feel like you need to follow these steps: 68 | 69 | 1. Initialize your project as a public repository on [GitHub](https://github.com/). Creating a repo will make it easier to share your code with the community if you need help. If you're not sure how to do this, [have a read-through of this Try Git resource](https://try.github.io/). 70 | 2. Configure your repository to publish your code to a web address. This will also be useful if you need some help during a challenge as you can share the URL for your project with your repo URL. There are a number of ways to do this, and we provide some recommendations below. 71 | 3. Look through the designs to start planning out how you'll tackle the project. This step is crucial to help you think ahead for CSS classes to create reusable styles. 72 | 4. Before adding any styles, structure your content with HTML. Writing your HTML first can help focus your attention on creating well-structured content. 73 | 5. Write out the base styles for your project, including general content styles, such as `font-family` and `font-size`. 74 | 6. Start adding styles to the top of the page and work down. Only move on to the next section once you're happy you've completed the area you're working on. 75 | 76 | ## Deploying your project 77 | 78 | As mentioned above, there are many ways to host your project for free. Our recommend hosts are: 79 | 80 | - [GitHub Pages](https://pages.github.com/) 81 | - [Vercel](https://vercel.com/) 82 | - [Netlify](https://www.netlify.com/) 83 | 84 | You can host your site using one of these solutions or any of our other trusted providers. [Read more about our recommended and trusted hosts](https://medium.com/frontend-mentor/frontend-mentor-trusted-hosting-providers-bf000dfebe). 85 | 86 | ## Create a custom `README.md` 87 | 88 | We strongly recommend overwriting this `README.md` with a custom one. We've provided a template inside the [`README-template.md`](./README-template.md) file in this starter code. 89 | 90 | The template provides a guide for what to add. A custom `README` will help you explain your project and reflect on your learnings. Please feel free to edit our template as much as you like. 91 | 92 | Once you've added your information to the template, delete this file and rename the `README-template.md` file to `README.md`. That will make it show up as your repository's README file. 93 | 94 | ## Submitting your solution 95 | 96 | Submit your solution on the platform for the rest of the community to see. Follow our ["Complete guide to submitting solutions"](https://medium.com/frontend-mentor/a-complete-guide-to-submitting-solutions-on-frontend-mentor-ac6384162248) for tips on how to do this. 97 | 98 | Remember, if you're looking for feedback on your solution, be sure to ask questions when submitting it. The more specific and detailed you are with your questions, the higher the chance you'll get valuable feedback from the community. 99 | 100 | ## Sharing your solution 101 | 102 | There are multiple places you can share your solution: 103 | 104 | 1. Share your solution page in the **#finished-projects** channel of the [Slack community](https://www.frontendmentor.io/slack). 105 | 2. Tweet [@frontendmentor](https://twitter.com/frontendmentor) and mention **@frontendmentor**, including the repo and live URLs in the tweet. We'd love to take a look at what you've built and help share it around. 106 | 3. Share your solution on other social channels like LinkedIn. 107 | 4. Blog about your experience building your project. Writing about your workflow, technical choices, and talking through your code is a brilliant way to reinforce what you've learned. Great platforms to write on are [dev.to](https://dev.to/), [Hashnode](https://hashnode.com/), and [CodeNewbie](https://community.codenewbie.org/). 108 | 109 | We provide templates to help you share your solution once you've submitted it on the platform. Please do edit them and include specific questions when you're looking for feedback. 110 | 111 | The more specific you are with your questions the more likely it is that another member of the community will give you feedback. 112 | 113 | ## Got feedback for us? 114 | 115 | We love receiving feedback! We're always looking to improve our challenges and our platform. So if you have anything you'd like to mention, please email hi[at]frontendmentor[dot]io. 116 | 117 | This challenge is completely free. Please share it with anyone who will find it useful for practice. 118 | 119 | **Have fun building!** 🚀 120 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | // Prevent animation on load 2 | setTimeout(() => { 3 | document.body.classList.remove("preload"); 4 | }, 500); 5 | 6 | // DOM 7 | const btnRules = document.querySelector(".rules-btn"); 8 | const btnClose = document.querySelector(".close-btn"); 9 | const modalRules = document.querySelector(".modal"); 10 | 11 | const CHOICES = [ 12 | { 13 | name: "paper", 14 | beats: "rock", 15 | }, 16 | { 17 | name: "scissors", 18 | beats: "paper", 19 | }, 20 | { 21 | name: "rock", 22 | beats: "scissors", 23 | }, 24 | ]; 25 | const choiceButtons = document.querySelectorAll(".choice-btn"); 26 | const gameDiv = document.querySelector(".game"); 27 | const resultsDiv = document.querySelector(".results"); 28 | const resultDivs = document.querySelectorAll(".results__result"); 29 | 30 | const resultWinner = document.querySelector(".results__winner"); 31 | const resultText = document.querySelector(".results__text"); 32 | 33 | const playAgainBtn = document.querySelector(".play-again"); 34 | 35 | const scoreNumber = document.querySelector(".score__number"); 36 | let score = 0; 37 | 38 | // Game Logic 39 | choiceButtons.forEach((button) => { 40 | button.addEventListener("click", () => { 41 | const choiceName = button.dataset.choice; 42 | const choice = CHOICES.find((choice) => choice.name === choiceName); 43 | choose(choice); 44 | }); 45 | }); 46 | 47 | function choose(choice) { 48 | const aichoice = aiChoose(); 49 | displayResults([choice, aichoice]); 50 | displayWinner([choice, aichoice]); 51 | } 52 | 53 | function aiChoose() { 54 | const rand = Math.floor(Math.random() * CHOICES.length); 55 | return CHOICES[rand]; 56 | } 57 | 58 | function displayResults(results) { 59 | resultDivs.forEach((resultDiv, idx) => { 60 | setTimeout(() => { 61 | resultDiv.innerHTML = ` 62 |
63 | ${results[idx].name} 64 |
65 | `; 66 | }, idx * 1000); 67 | }); 68 | 69 | gameDiv.classList.toggle("hidden"); 70 | resultsDiv.classList.toggle("hidden"); 71 | } 72 | 73 | function displayWinner(results) { 74 | setTimeout(() => { 75 | const userWins = isWinner(results); 76 | const aiWins = isWinner(results.reverse()); 77 | 78 | if (userWins) { 79 | resultText.innerText = "you win"; 80 | resultDivs[0].classList.toggle("winner"); 81 | keepScore(1); 82 | } else if (aiWins) { 83 | resultText.innerText = "you lose"; 84 | resultDivs[1].classList.toggle("winner"); 85 | keepScore(-1); 86 | } else { 87 | resultText.innerText = "draw"; 88 | } 89 | resultWinner.classList.toggle("hidden"); 90 | resultsDiv.classList.toggle("show-winner"); 91 | }, 1000); 92 | } 93 | 94 | function isWinner(results) { 95 | return results[0].beats === results[1].name; 96 | } 97 | 98 | function keepScore(point) { 99 | score += point; 100 | scoreNumber.innerText = score; 101 | } 102 | 103 | // Play Again 104 | playAgainBtn.addEventListener("click", () => { 105 | gameDiv.classList.toggle("hidden"); 106 | resultsDiv.classList.toggle("hidden"); 107 | 108 | resultDivs.forEach((resultDiv) => { 109 | resultDiv.innerHTML = ""; 110 | resultDiv.classList.remove("winner"); 111 | }); 112 | 113 | resultText.innerText = ""; 114 | resultWinner.classList.toggle("hidden"); 115 | resultsDiv.classList.toggle("show-winner"); 116 | }); 117 | 118 | // Show/Hide Rules 119 | btnRules.addEventListener("click", () => { 120 | modalRules.classList.toggle("show-modal"); 121 | }); 122 | btnClose.addEventListener("click", () => { 123 | modalRules.classList.toggle("show-modal"); 124 | }); 125 | -------------------------------------------------------------------------------- /design/bonus/desktop-rules-modal-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/desktop-rules-modal-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/desktop-step-1-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/desktop-step-1-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/desktop-step-2-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/desktop-step-2-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/desktop-step-3-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/desktop-step-3-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/desktop-step-4-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/desktop-step-4-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/mobile-rules-modal-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/mobile-rules-modal-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/mobile-step-1-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/mobile-step-1-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/mobile-step-2-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/mobile-step-2-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/mobile-step-3-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/mobile-step-3-bonus.jpg -------------------------------------------------------------------------------- /design/bonus/mobile-step-4-bonus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/bonus/mobile-step-4-bonus.jpg -------------------------------------------------------------------------------- /design/desktop-preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/desktop-preview.jpg -------------------------------------------------------------------------------- /design/original/desktop-rules-modal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/desktop-rules-modal.jpg -------------------------------------------------------------------------------- /design/original/desktop-step-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/desktop-step-1.jpg -------------------------------------------------------------------------------- /design/original/desktop-step-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/desktop-step-2.jpg -------------------------------------------------------------------------------- /design/original/desktop-step-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/desktop-step-3.jpg -------------------------------------------------------------------------------- /design/original/desktop-step-4-lose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/desktop-step-4-lose.jpg -------------------------------------------------------------------------------- /design/original/desktop-step-4-win.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/desktop-step-4-win.jpg -------------------------------------------------------------------------------- /design/original/mobile-rules-modal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/mobile-rules-modal.jpg -------------------------------------------------------------------------------- /design/original/mobile-step-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/mobile-step-1.jpg -------------------------------------------------------------------------------- /design/original/mobile-step-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/mobile-step-2.jpg -------------------------------------------------------------------------------- /design/original/mobile-step-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/mobile-step-3.jpg -------------------------------------------------------------------------------- /design/original/mobile-step-4-lose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/mobile-step-4-lose.jpg -------------------------------------------------------------------------------- /design/original/mobile-step-4-win.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/design/original/mobile-step-4-win.jpg -------------------------------------------------------------------------------- /images/bg-pentagon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/bg-triangle.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codeSTACKr/rock-paper-scissors-video/87d59ddb4a104b111ab68be1a0989f718da23a5e/images/favicon-32x32.png -------------------------------------------------------------------------------- /images/icon-close.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icon-lizard.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icon-paper.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icon-rock.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icon-scissors.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icon-spock.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/image-rules-bonus.svg: -------------------------------------------------------------------------------- 1 | BEATSBEATSBEATSBEATSBEATSBEATSBEATSBEATSBEATSBEATS -------------------------------------------------------------------------------- /images/image-rules.svg: -------------------------------------------------------------------------------- 1 | BEATSBEATSBEATS -------------------------------------------------------------------------------- /images/logo-bonus.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | Frontend Mentor | Rock, Paper, Scissors 17 | 18 | 19 |
20 |
21 | 22 |
23 |
score
24 |
0
25 |
26 |
27 |
28 | 33 | 38 | 43 |
44 |
45 | 46 | 56 | 57 | 58 | 73 | 74 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /style-guide.md: -------------------------------------------------------------------------------- 1 | # Front-end Style Guide 2 | 3 | ## Layout 4 | 5 | The designs were created to the following widths: 6 | 7 | - Mobile: 375px 8 | - Desktop: 1366px 9 | 10 | ## Colors 11 | 12 | ### Primary 13 | 14 | - Scissors Gradient: hsl(39, 89%, 49%) to hsl(40, 84%, 53%) 15 | - Paper Gradient: hsl(230, 89%, 62%) to hsl(230, 89%, 65%) 16 | - Rock Gradient: hsl(349, 71%, 52%) to hsl(349, 70%, 56%) 17 | - Lizard Gradient: hsl(261, 73%, 60%) to hsl(261, 72%, 63%) 18 | - Cyan: hsl(189, 59%, 53%) to hsl(189, 58%, 57%) 19 | 20 | ### Neutral 21 | 22 | - Dark Text: hsl(229, 25%, 31%) 23 | - Score Text: hsl(229, 64%, 46%) 24 | - Header Outline: hsl(217, 16%, 45%) 25 | 26 | ### Background 27 | 28 | - Radial Gradient: hsl(214, 47%, 23%) to hsl(237, 49%, 15%) 29 | 30 | ## Fonts 31 | 32 | - Family: [Barlow Semi Condensed](https://fonts.google.com/specimen/Barlow+Semi+Condensed) 33 | - Weights: 600, 700 34 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /* Font */ 2 | @import url("https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@600;700&display=swap"); 3 | 4 | /* Variables */ 5 | :root { 6 | --light-text: #ffffff; 7 | --dark-text: hsl(229, 25%, 31%); 8 | --score-text: hsl(229, 64%, 46%); 9 | --outline: hsl(217, 16%, 45%); 10 | --bg-grad-1: hsl(214, 47%, 23%); 11 | --bg-grad-2: hsl(237, 49%, 15%); 12 | --scissors-1: hsl(39, 89%, 49%); 13 | --scissors-2: hsl(40, 84%, 53%); 14 | --paper-1: hsl(230, 89%, 62%); 15 | --paper-2: hsl(230, 89%, 65%); 16 | --rock-1: hsl(349, 71%, 52%); 17 | --rock-2: hsl(349, 70%, 56%); 18 | --shadow-light: #00000026; 19 | --shadow-med: #0000004d; 20 | } 21 | 22 | * { 23 | margin: 0; 24 | padding: 0; 25 | box-sizing: border-box; 26 | } 27 | 28 | body { 29 | font-family: "Barlow Semi Condensed", sans-serif; 30 | background: radial-gradient(at top, var(--bg-grad-1), var(--bg-grad-2)); 31 | min-height: 100vh; 32 | text-transform: uppercase; 33 | color: var(--light-text); 34 | } 35 | 36 | /* Main Content */ 37 | .container { 38 | position: relative; 39 | max-width: 700px; 40 | margin: 0 auto; 41 | padding-top: 2rem; 42 | } 43 | 44 | .header { 45 | display: flex; 46 | justify-content: space-between; 47 | align-items: center; 48 | height: 150px; 49 | border: 3px solid var(--outline); 50 | border-radius: 20px; 51 | padding: 1rem 1.4rem 1rem 2rem; 52 | } 53 | 54 | .logo img { 55 | height: 100%; 56 | } 57 | 58 | .score { 59 | display: flex; 60 | flex-direction: column; 61 | align-items: center; 62 | justify-content: center; 63 | background: #fff; 64 | border-radius: 10px; 65 | width: 150px; 66 | height: 100%; 67 | line-height: 1; 68 | } 69 | 70 | .score__title { 71 | font-size: 1.1rem; 72 | letter-spacing: 0.1em; 73 | color: var(--score-text); 74 | } 75 | 76 | .score__number { 77 | font-size: 4rem; 78 | font-weight: 700; 79 | color: var(--dark-text); 80 | } 81 | 82 | /* Game */ 83 | .game { 84 | position: relative; 85 | display: grid; 86 | grid-template-columns: (repeat(2, 1fr)); 87 | grid-template-areas: 88 | "paper scissors" 89 | "rock rock"; 90 | place-items: center; 91 | height: 30rem; 92 | padding-top: 4rem; 93 | } 94 | .game::before { 95 | content: ""; 96 | position: absolute; 97 | width: 100%; 98 | height: 100%; 99 | left: 28%; 100 | top: 35%; 101 | background: url("./images/bg-triangle.svg") no-repeat; 102 | z-index: -1; 103 | } 104 | 105 | .choice-btn { 106 | border: none; 107 | outline: none; 108 | background: none; 109 | cursor: pointer; 110 | } 111 | .choice { 112 | position: relative; 113 | width: 10rem; 114 | height: 10rem; 115 | background: #fff; 116 | border-radius: 50%; 117 | display: grid; 118 | place-items: center; 119 | box-shadow: inset 0 0.5rem var(--shadow-light); 120 | } 121 | .choice::before, 122 | .choice::after { 123 | content: ""; 124 | position: absolute; 125 | left: -15%; 126 | top: -15%; 127 | width: 130%; 128 | height: 130%; 129 | border-radius: 50%; 130 | z-index: -1; 131 | } 132 | 133 | .choice::after { 134 | opacity: 0; 135 | transition: opacity 0.4s ease; 136 | } 137 | .choice-btn:focus .choice::after { 138 | opacity: 1; 139 | box-shadow: 0 0 0 2rem #223351; 140 | z-index: -2; 141 | } 142 | 143 | .choice img { 144 | transform: scale(1.5); 145 | } 146 | 147 | .choice.paper::before { 148 | background: linear-gradient(to bottom, var(--paper-1), var(--paper-2)); 149 | box-shadow: 0 0.5rem var(--shadow-med), 0 0.5rem var(--paper-2); 150 | } 151 | .choice.scissors::before { 152 | background: linear-gradient(to bottom, var(--scissors-1), var(--scissors-2)); 153 | box-shadow: 0 0.5rem var(--shadow-med), 0 0.5rem var(--scissors-2); 154 | } 155 | .choice.rock::before { 156 | background: linear-gradient(to bottom, var(--rock-1), var(--rock-2)); 157 | box-shadow: 0 0.5rem var(--shadow-med), 0 0.5rem var(--rock-2); 158 | } 159 | 160 | .choice-btn[data-choice="paper"] { 161 | grid-area: paper; 162 | } 163 | .choice-btn[data-choice="scissors"] { 164 | grid-area: scissors; 165 | } 166 | .choice-btn[data-choice="rock"] { 167 | grid-area: rock; 168 | } 169 | 170 | /* Results */ 171 | .results { 172 | display: grid; 173 | grid-template-columns: repeat(2, 1fr); 174 | place-items: center; 175 | grid-template-areas: 176 | "you-title ai-title" 177 | "you-picked ai-picked"; 178 | max-width: 1000px; 179 | margin: 0 auto; 180 | } 181 | 182 | .results__heading { 183 | font-size: 1.5rem; 184 | letter-spacing: 0.1em; 185 | padding: 4rem 0 8rem; 186 | } 187 | .results__result { 188 | min-width: 10rem; 189 | min-height: 10rem; 190 | background: #16213d; 191 | border-radius: 50%; 192 | transform: scale(1.4); 193 | z-index: -1; 194 | } 195 | 196 | .results__heading:first-of-type { 197 | grid-area: you-title; 198 | } 199 | .results__heading:last-of-type { 200 | grid-area: ai-title; 201 | } 202 | .results__result:first-of-type { 203 | grid-area: you-picked; 204 | } 205 | .results__result:last-of-type { 206 | grid-area: ai-picked; 207 | } 208 | 209 | .results.show-winner { 210 | grid-template-columns: repeat(3, 1fr); 211 | grid-template-areas: 212 | "you-title . ai-title" 213 | "you-picked result-winner ai-picked"; 214 | } 215 | 216 | .winner .choice::after { 217 | box-shadow: 0 0 0 40px #293251, 0 0 0 80px #232c4b, 0 0 0 130px #1e2949; 218 | animation: winner 1s ease forwards; 219 | } 220 | 221 | @keyframes winner { 222 | from { 223 | opacity: 0; 224 | } 225 | to { 226 | opacity: 1; 227 | } 228 | } 229 | 230 | .results__winner { 231 | grid-area: result-winner; 232 | display: grid; 233 | place-items: center; 234 | } 235 | .results__text { 236 | font-size: 3.5rem; 237 | padding-bottom: 1.5rem; 238 | } 239 | .play-again { 240 | background: #fff; 241 | outline: none; 242 | border: 2px solid transparent; 243 | border-radius: 0.6rem; 244 | color: var(--dark-text); 245 | padding: 0.6rem 3.5rem; 246 | font-family: inherit; 247 | text-transform: inherit; 248 | font-size: 1.3rem; 249 | letter-spacing: 0.1em; 250 | cursor: pointer; 251 | } 252 | .play-again:focus { 253 | border: 2px solid var(--outline); 254 | } 255 | 256 | /* Rules Button */ 257 | .rules-btn { 258 | position: absolute; 259 | bottom: 2rem; 260 | right: 2rem; 261 | background: none; 262 | outline: none; 263 | border: 2px solid var(--outline); 264 | border-radius: 0.6rem; 265 | color: var(--light-text); 266 | padding: 0.6rem 2.5rem; 267 | font-family: inherit; 268 | text-transform: inherit; 269 | font-size: 1.3rem; 270 | letter-spacing: 0.1em; 271 | cursor: pointer; 272 | } 273 | .rules-btn:focus { 274 | border: 2px solid #fff; 275 | } 276 | 277 | /* Rules Modal */ 278 | .modal { 279 | position: absolute; 280 | height: 100%; 281 | width: 100%; 282 | top: 0; 283 | left: 0; 284 | display: grid; 285 | place-items: center; 286 | background: var(--shadow-med); 287 | opacity: 0; 288 | transition: opacity 0.3s ease-in-out; 289 | pointer-events: none; 290 | } 291 | .modal__container { 292 | background: #fff; 293 | border-radius: 0.5rem; 294 | } 295 | .modal__header { 296 | display: flex; 297 | width: 100%; 298 | justify-content: space-between; 299 | padding: 2rem 2rem 1rem; 300 | } 301 | .modal__heading { 302 | font-size: 1.5rem; 303 | color: var(--dark-text); 304 | } 305 | .close-btn { 306 | border: none; 307 | outline: none; 308 | background: none; 309 | cursor: pointer; 310 | } 311 | .rules-img { 312 | padding: 2rem 4rem; 313 | } 314 | .show-modal { 315 | opacity: 1; 316 | pointer-events: initial; 317 | } 318 | 319 | /* Footer */ 320 | .footer { 321 | position: absolute; 322 | bottom: 2rem; 323 | width: 100%; 324 | padding: 0 2rem; 325 | text-align: center; 326 | } 327 | 328 | .attribution { 329 | font-size: 12px; 330 | text-align: center; 331 | } 332 | .attribution a { 333 | color: #ff652f; 334 | } 335 | 336 | /* Utilities */ 337 | .preload * { 338 | transition: none; 339 | } 340 | 341 | .hidden { 342 | display: none; 343 | } 344 | --------------------------------------------------------------------------------