Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrew-templeton/1e4335fec9923675b0bb95ccc235bc71 to your computer and use it in GitHub Desktop.
Save andrew-templeton/1e4335fec9923675b0bb95ccc235bc71 to your computer and use it in GitHub Desktop.
Text breaking-bad-ification

Breaking Bad JS

Write a JS module for the browser that turns a string of text into a Breaking Bad styled DOM element. The below image is an example of properly done string of text.

http://cdn.playbuzz.com/cdn/51fc2ed1-0d68-4f15-99e8-b09ef37f8a4a/d2207e9f-0087-44d1-baf4-2a1d4b0ba88a.jpg

This is a JSON document that contains information about the periodic table

Level 1: Segmenting and Detection

Requirements:
Make a JS function that return an unambiguous description of how to render the text. This does not need to actually make HTML or CSS. You should produce an object in JS that correctly describes which letters of which words are to be turned into the squares.

  1. Only words 3 letters or longer should have any element effects applied.
  2. Only prefixes to words should be used.
  3. If there is no match (like Xylophone), do not apply any effect.
  4. If there is more than one match, like Hello, which matches H for Hydrogen and He for Helium, use the 2 letter element over the one letter one.
  5. Capitalization doesn't matter.
Level 2: Build Elements

Requirements:
Produce semantically-acceptable HTML that makes nodes looking like the test logo above.

  1. Use a green-ish background like the image.
  2. Use any Sans-Serif family font for the element-ified text.
  3. Use a font with serifs for the unaffected text.
  4. Make the text white.
  5. Make the square around the element-ified text white.
  6. The element-ified text should be both vertically and horizontally centered inside the white bounding box.
  7. You do not need to put anything inside the element squares but the text for the element symbol.
Level 3: Add Flair

Requirements:
You get points for adding in any or all of the following in roughly the same position as in the sample logo:

  1. Molar mass ("molar" in the JSON)
  2. Atomic number
  3. Electrons
Level 4:

Make colors, fonts, dimensions, and inclusion/exclusion of flair configurable using a JS object as a second parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment