From de5d1f664a48866401e8c7f3131aff2dfad4fb90 Mon Sep 17 00:00:00 2001 From: Christopher-Martinez-422 <107010274+Christopher-Martinez-422@users.noreply.github.com> Date: Thu, 30 Mar 2023 12:28:54 -0700 Subject: [PATCH] first commit --- README.md | 18 +++++++++--------- src/index.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c6a3fafd8..5e0c984cb 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ Fun Bus wants you to make their site more interactive. They are relying on you t ## Git Setup -* [ ] Create a forked copy of this project. -* [ ] Clone your OWN version of the repository. -* [ ] Implement the project on the main branch, committing changes regularly. -* [ ] Push commits: `git push origin main`. +* [X] Create a forked copy of this project. +* [X] Clone your OWN version of the repository. +* [X] Implement the project on the main branch, committing changes regularly. +* [X] Push commits: `git push origin main`. ## Running the project @@ -17,8 +17,8 @@ This project uses [Webpack and Babel](https://bloomtech-1.wistia.com/medias/bhi9 Do not **move or rename any files** in this project. The website's source files live inside the `src` folder. Do not make changes to any files outside of the `src` folder, unless it's new dependecies declared in the `package.json` due to installing NPM libraries (E.G. `npm i lodash`). -* [ ] Run `npm install` to download the project's dependencies. -* [ ] Run `npm start` to launch the website on `http://localhost:3000`. +* [X] Run `npm install` to download the project's dependencies. +* [X] Run `npm start` to launch the website on `http://localhost:3000`. ## MVP @@ -28,14 +28,14 @@ Do not **move or rename any files** in this project. The website's source files * [ ] Here are some event types you could try to use: * [ ] `mouseover` - * [ ] `keydown` + * [X] `keydown` * [ ] `wheel` - * [ ] `load` + * [X] `load` * [ ] `focus` * [ ] `resize` * [ ] `scroll` * [ ] `select` - * [ ] `dblclick` + * [X] `dblclick` * [ ] `drag / drop` Note: Drag and drop is a bit more advanced than the others. It's not actually a single type of event but several types that need to work together. diff --git a/src/index.js b/src/index.js index 13e4739cd..beab4e891 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,53 @@ import './less/index.less' // Your code goes here! + +// 1 - Load +window.onload = function (evt) { + const heading = document.querySelector('h1') + heading.textContent = 'Ready to go!' + +// 2 - Copy +window.addEventListener('copy', () => { + navigator.clipboard.readText() + .then(text => { + heading.textContent += text + }) +}) + +// 3 - Click +document.body.addEventListener('click', evt => { + evt.target.classList.toggle('mirror') +}) + +// 4 - Double Click +document.body.addEventListener('dblclick', evt => { + evt.target.outerHTML = '' +}) + +// 5 - Keydown +window.addEventListener('keydown', evt => { + if (evt.key == 6) { + document.body.innerHTML = 'YOU RAN ORDER 66' + } +}) + +// 6 - Mouse Move +document.body.addEventListener('mousemove', evt => { + const { clientX, clientY} = evt + console.log(`mouse is at ${clientX}, ${clientY}`) +}) + +// 7 - Mouse Enter +// 8 - Mouse Leave +const destinations = document.querySelectorAll('.destination') +for (let destination of destinations) { + destination.addEventListener('mouseenter', evt => { + destination.style.fontWeight = 'bold' + }) + destination.addEventListener('mouseleave', () => { + destination.style.fontWeight = 'initial' + }) +} + +} \ No newline at end of file