Skip to content

Instantly share code, notes, and snippets.

View straker's full-sized avatar

Steven Lambert straker

View GitHub Profile
@straker
straker / nativeDomAPI.js
Last active October 20, 2022 11:22
HTML DOM api standards proposal - examples of how the native HTML DOM api is cumbersome to use and how different libraries handle it
View nativeDomAPI.js
/**
* Create element with attributes
*
* <input type="number" min="0" max="99" name="number" id="number" class="number-input" disabled/>
*/
// native
var input = document.createElement('input');
input.type = "number";
input.min = 0;
@straker
straker / wrapper.js
Last active October 20, 2022 11:31
Simple wrapper around DOM functions to make DOM interactions a bit easier to work with
View wrapper.js
(function(Node, Element, HTMLCollection, Array) {
/**
* Wrap addEventListener to handle multiple event types and be chainable.
* @param {string} types - Space-separated event types.
* @param {function} listener
* @param {boolean} useCapture
* @returns {Node}
*
* @example
* document.querySelector('a')
@straker
straker / .babelrc
Created March 7, 2022 17:34
Example of running axe-core using Jest and @testing-library/react
View .babelrc
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
],
@straker
straker / .babelrc
Last active October 20, 2022 12:00
Example of running axe-core using Jest and Enzyme
View .babelrc
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
],
@straker
straker / README.md
Last active July 14, 2023 02:53
Basic Block Dude HTML and JavaScript Game
View README.md

Basic Block Dude HTML and JavaScript Game

This is a basic implementation of Block Dude, an old TI-83/4 Calculator game. It's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration

  • More levels
  • Add more levels and have the next level start once the last one is finished
@straker
straker / README.md
Last active July 14, 2023 02:53
Basic Doodle Jump HTML and JavaScript Game
View README.md

Basic Doodle Jump HTML and JavaScript Game

This is a basic implementation of the game Doodle Jump, but it's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration

  • Platforms Types
  • There are 4 different types of platforms: Normal, Broken, Moving, and Disappearing
@straker
straker / README.md
Last active July 14, 2023 02:53
Basic Sokoban HTML and JavaScript Game
View README.md

Basic Sokoban HTML and JavaScript Game

This is a basic implementation of the game Sokoban, but it's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration

  • More levels
  • Add more levels and have the next level start once the last one is finished
@straker
straker / README.md
Last active August 21, 2023 16:28
Basic Snake HTML and JavaScript Game
View README.md

Basic Snake HTML and JavaScript Game

Snake is a fun game to make as it doesn't require a lot of code (less than 100 lines with all comments removed). This is a basic implementation of the snake game, but it's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration

  • Score
  • When the snake eats an apple, the score should increase by one. Use context.fillText() to display the score to the screen
@straker
straker / two-way-binding.js
Last active August 30, 2023 11:28
Simple and small two-way data binding between DOM and data
View two-way-binding.js
/**
* @param {object} scope - Object that all bound data will be attached to.
*/
function twoWayBind(scope) {
// a list of all bindings used in the DOM
// @example
// { 'person.name': [<input type="text" data-bind="person.name"/>] }
var bindings = {};
// each bindings old value to be compared for changes
@straker
straker / README.md
Last active September 3, 2023 21:28
Basic Frogger HTML and JavaScript Game
View README.md

Basic Frogger HTML and JavaScript Game

This is a basic implementation of the Konami Frogger game, but it's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration

  • Lives
  • Frogger starts with 6 lives and should lose a life whenever it is hit by a vehicle or lands in the water