├── .eslintrc.json ├── .gitignore ├── README.md ├── babel.config.js ├── codegrade_mvp.test.js ├── design-files └── desktop-example.png ├── jest.config.js ├── mocks ├── api.js ├── handlers.js ├── img │ ├── accent.png │ ├── cta.png │ └── logo.png ├── jest.globals.js └── server.js ├── package-lock.json ├── package.json ├── src ├── index.html ├── index.js ├── original.html └── styles.css └── webpack.config.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "commonjs": true, 5 | "es2021": true, 6 | "jest": true 7 | }, 8 | "extends": "eslint:recommended", 9 | "parserOptions": { 10 | "ecmaVersion": "latest" 11 | }, 12 | "rules": { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Microbundle cache 58 | .rpt2_cache/ 59 | .rts2_cache_cjs/ 60 | .rts2_cache_es/ 61 | .rts2_cache_umd/ 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # dotenv environment variables file 73 | .env 74 | .env.test 75 | .env.production 76 | 77 | # parcel-bundler cache (https://parceljs.org/) 78 | .cache 79 | .parcel-cache 80 | 81 | # Next.js build output 82 | .next 83 | out 84 | 85 | # Nuxt.js build / generate output 86 | .nuxt 87 | dist 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and not Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # Serverless directories 99 | .serverless/ 100 | 101 | # FuseBox cache 102 | .fusebox/ 103 | 104 | # DynamoDB Local files 105 | .dynamodb/ 106 | 107 | # TernJS port file 108 | .tern-port 109 | 110 | # Stores VSCode versions used for testing VSCode extensions 111 | .vscode-test 112 | 113 | # yarn v2 114 | .yarn/cache 115 | .yarn/unplugged 116 | .yarn/build-state.yml 117 | .yarn/install-state.gz 118 | .pnp.* 119 | 120 | # Mac cruft 121 | .DS_Store 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DOM I 2 | 3 | ## Project Description 4 | 5 | You are going to be emulating a content management system by controlling the content in the JavaScript file instead of the HTML file. This project is an exercise pointed at selecting elements and then updating them without touching the HTML file using the DOM. 6 | 7 | Compare `src/index.html` against `src/original.html` and notice how `index.html` is lacking text content and other things. The goal is to make the page look the same as `original.html` using JavaScript. You can find a screenshot of the goal in `design-files/desktop-example.png`. 8 | 9 | Inside `src/index.js` there is declared an object literal containing all the data needed to make the page look like the screenshot. Do not change this object! Below the declaration you should perform your DOM manipulations. Typically you would select an element and then use the data inside the object to add text content to it, or to change its attributes. Access the data using dot or square-bracket notation. 10 | 11 | **THE MOST IMPORTANT RULE: You cannot update the HTML file directly. You must use JavaScript alone.** 12 | 13 | ## Git Setup 14 | 15 | * [ ] Create a forked copy of this project. 16 | * [ ] Clone your OWN version of the repository. 17 | * [ ] Push commits: `git push origin main`. 18 | 19 | ## Running the project 20 | 21 | * [ ] Run `npm install` to download the project's dependencies. 22 | * [ ] Run `npm start` to launch the page on `http://localhost:3000`. 23 | * [ ] Run `npm test` to execute auto tests against your work (you'll need a new terminal window). 24 | 25 | ## MVP 26 | 27 | ### Create selectors to access the relevant elements 28 | 29 | * [ ] Declare variables pointing to the relevant DOM elements, using any of the selectors you have learned. 30 | 31 | ### Add text contents 32 | 33 | * [ ] Using your selectors, update the text contents of the relevant elements, matching the design file. 34 | * [ ] Find the correct texts for the elements inside the data object in `src/index.js`. 35 | 36 | ### Add class names 37 | 38 | * [ ] Give the anchor tags _inside the nav_ an italic style by adding the classname `italic` to them alone. 39 | * [ ] Give the anchor tag _inside the footer_ a bolder appearence by adding the classname `bold` to it alone. 40 | 41 | ### Add image sources 42 | 43 | * [ ] Make the img tags on the page display the correct images by editing their `src` attribute. 44 | * [ ] Find the correct URLs for the images inside the data object in `src/index.js`. 45 | 46 | ## Submission Format 47 | 48 | * [ ] Submit a link to your github repo in canvas. 49 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | testing: { // matches the `NODE_ENV=testing` in "test" script in package.json 4 | plugins: [ 5 | '@babel/plugin-transform-runtime', 6 | ], 7 | presets: [ 8 | [ 9 | '@babel/preset-env', 10 | { 11 | modules: 'commonjs', 12 | debug: false 13 | } 14 | ] 15 | ] 16 | } 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /codegrade_mvp.test.js: -------------------------------------------------------------------------------- 1 | const { server } = require('./mocks/server') 2 | const { screen } = require('@testing-library/dom') 3 | require('@testing-library/jest-dom/extend-expect') 4 | 5 | beforeAll(() => { 6 | server.listen() 7 | document.body.innerHTML = ` 8 |
Features content elementum magna eros, ac posuere elvit tempus et. Suspendisse vel tempus odio, 38 | in interdutm nisi. Suspendisse eu ornare nisl. Nullam convallis augue justo, at imperdiet metus 39 | scelerisque quis.
40 |About content elementum magna eros, ac posuere elvit tempus et. Suspendisse vel tempus odio, in 44 | interdutm nisi. Suspendisse eu ornare nisl. Nullam convallis augue justo, at imperdiet metus 45 | scelerisque quis.
46 |Services content elementum magna eros, ac posuere elvit tempus et. Suspendisse vel tempus odio, 54 | in interdutm nisi. Suspendisse eu ornare nisl. Nullam convallis augue justo, at imperdiet metus 55 | scelerisque quis.
56 |Product content elementum magna eros, ac posuere elvit tempus et. Suspendisse vel tempus odio, in 60 | interdutm nisi. Suspendisse eu ornare nisl. Nullam convallis augue justo, at imperdiet metus 61 | scelerisque quis.
62 |Vision content elementum magna eros, ac posuere elvit tempus et. Suspendisse vel tempus odio, in 66 | interdutm nisi. Suspendisse eu ornare nisl. Nullam convallis augue justo, at imperdiet metus 67 | scelerisque quis.
68 |123 Way 456 Street Somewhere, USA
74 |1 (888) 888-8888
75 |sales@greatidea.io
76 |