Coding an Advent Calendar: Day 13

This year, I decided to create an Advent Calendar website in HTML5, CSS3, and JavaScript. My hopes for the site are to showcase some of my frontend development abilities as well as make something fun, functional, and reusable.

Day 13

Add JS handlers for “Today”
“Today” I didn’t have tons of time to put in to work on this project. So, I chose some of the “low hanging fruit” to work on – to make meaningful progress with small(er) modifications.

One of these “low hanging fruit” was adding JavaScript handlers for properly displaying the proper packages based on the current date. Here’s the procedure:

  1. Use .getDate() from the JavaScript Date object to get the numeric date for today
  2. Use jQuery selectors to grab the page elements that need manipulated accordingly
  3. Use conditionals to determine which classes or CSS to apply to each (particularly the Font Awesome gifts in the footer – as each can have 3 “states”)
    1. "active" = green/red package
    2. "today" = highlighted (darker) and scaled (larger)
    3. "disabled" = grayed out
  4. Also, use jQuery .unbind('click') on any "disabled" footer packages to prevent clicking (and peeking at presents before the time has come)
Better styling of REST Posts
Another of the “low hanging fruits” I decided to tackle today was the styling of the WordPress Posts called in with the REST API. This is particularly important for the responsiveness of this design as leaving the Posts underneath the large Gift box on smaller screens would crowd the screen.

I decided to make the WordPress Posts pop up on an “overlay” or “lightbox” style screen (as the Featured Image above shows) when the Gift is clicked on. Here are the steps I took to do this as well as thoughts for its further development:

  1. Make the React Component #posts container act as the overlay (with dark blue background)
  2. Add an extra <div className="inner"> in React to surround each Post’s content
  3. Query the WP REST API for 25 Posts (with per_page=25)
  4. Make the #posts container pushed off the page 100% to the bottom so that when the Gift is clicked, I apply a CSS animation to ease-in the top-margin back to 0 (which makes the #posts container slide in from the bottom
  5. Make the entire dark blue background of the #posts container clickable – to rehide the container at the bottom of the page (slide down)

Notes for future development:

Although I’d originally considered just having React dynamically “react” to clicks on various boxes to display ONLY the Post from that date, I’m now considering styling #posts in the same way as the Gift boxes #carousel:

  1. allow each Gift to take up the full width and height of the visible page area
  2. allow each Post to take up the full width and height of the invisible page area to the bottom of the screen

This would easily line up both the Gift box and the Post for its date one on top of the other, so that when the Gift box is clicked and the #posts container animates upward, ONLY the Post for that date would be visible. This would also give me a little more freedom about how to style each Post individually.

One more consideration I’d made is how I might use React to ONLY (dynamically) load 3 Posts at once:

  1. The currently selected Post (defaults to "today")
  2. The previous Post and dated Gift
  3. The next Post and dated Gift

This would allow both the Gift #carousel and the #posts containers to reduce their maximum necessary width to only 3 screen-lengths (instead of 25 screen-lengths) and therefore also probably reduce the “bugginess” that’s currently affecting my Carousel (about 5px extra left margin on EVERY subsequent date for some reason – which adds up to a HUGE space by the time Christmas comes).

But, I haven’t yet worked out how to do that with my limited knowledge of React.js and Components – and that’s what led me to the third step for today ↓

Begin Ray Villalobos React Course
I decided to head back over to Lynda.com to try to learn some more about React. There aren’t actually that many React courses on Lynda.com YET, but the one that looked most helpful for the kinds of ways I’m considering using React in this project was Ray Villalobos’ React Course:

Building a Web Interface with React.js

I’m looking forward to learning much more through this Course that I can put into practice in my Advent Calendar. PLUS, as I am able to use create-react-app on my Windows PC but not getstorybook, it will allow me to continue (branched) development both at work (Windows) and at home (Mac).


Work Completed (to date)

  • December 13, 2016
    • Add JS handlers for “Today”
    • Better styling of REST Posts
    • Begin Building a Web Interface with React.js (Lynda.com)
  • December 12, 2016
    • Storybook on Windows (FAIL)
    • Continue styling <Tag> Components
    • Begin responsive styles
  • December 11, 2016
    • Begin separating out CSS per Component
    • Attempt to load in static files & Sass
    • Begin coding a Tag for the Gifts
  • December 10, 2016
    • Finish Lynda.com videos
    • Get all React Components working in Storybook
    • Begin creating a Christmas Scene
  • December 9, 2016
    • Learn and use Create-React-App
    • Learn and use Storybook for developing React Components in isolation
    • Update npm and node and figure out my git process between Windows and Mac
  • December 8, 2016
    • Use React and Babel via CDN to get it working “locally”
    • Install React developer Tools for Chrome
    • Create very basic React.js pages to learn it
  • December 7, 2016
    • Pull post data with the WP REST API in WordPress core!!
    • Write structural code for the React Component to be rendered
    • Install and setup BabelJS to compile the React code
  • December 6, 2016
    • Add README.md
    • Add a GitHub Issue to hold usable images
    • Add LICENSE
  • December 5, 2016
    • Create a GitHub repository and full site files for easier management
    • Setup Grunt.js to compile my Sass into CSS
    • Begin blogging about the process
  • December 4, 2016
    • Countdown clock (JS Date class & jQuery Easing) with SVGs
    • Dynamic text output for Year based on the current date
    • CSS only slider (off by 5px each slide)
  • December 3, 2016
    • CSS bow & ribbon
    • Footer with FontAwesome presents
    • Hover, active, and “Christmas Day” styles for footer presents
  • December 2, 2016
    • React.js + Axios.js initial code structure
    • Color palette
    • CSS → Sass
  • December 1, 2016
    • Let it snow
    • Typography choices
    • CSS presents (first design)
    • Design notes menu

Coding an Advent Calendar: Day 12

This year, I decided to create an Advent Calendar website in HTML5, CSS3, and JavaScript. My hopes for the site are to showcase some of my frontend development abilities as well as make something fun, functional, and reusable.

Day 12

Storybook on Windows (FAIL)
So, after some good work on React Components in Storybook on my Mac over the weekend, it was back to the office on Monday – and my Windows computer.

Last week, I’d had trouble setting up Storybook on the Windows computer – it kept giving me a sh: start-storybook: command not found error. I found two GitHub issues that were similar to my problem:

  1. ERR! on npm run storybook
  2. sh: start-storybook: command not found

and quickly read through the discussions there to see if I could fix my installation. It didn’t work.

Then, I tried a completely fresh installation of both create-react-app (successful) and getstorybook (less so) to see if that wouldn’t solve the problem and get me up and running on Windows. It didn’t. I got the same errors as before, so that seems to indicate that there may be some compatibility issues with Windows – or maybe I just screwed up something in my system setup from the start.

Well, rather than give this issue any more time (I’d already spent 1-2 hours on it), I decided to move back over to my Codepen version of the site and continue working on some CSS styling.

Continue styling <Tag> Components
As the Featured Image for this Post shows, I decided to continue working on the Tag (and other) CSS since Windows was being picky about my React Storybook configuration.

As far as the Tags go, currently they are CSS shapes, although I feel like there may be some limitations in how I want to handle interactivity with them as CSS shapes. For example: the Tags are currently styled like so:

  1. A <div> box that contains the main text
  2. A div:before that creates the triangular portion of the tag
  3. A div:after that creates the rear Pac-man portion of the tag

So, technically, the Tag is 3 individual pieces as a CSS shape, so doing something like “flipping” it over to read the back (as I’ve done with a sample Lynda.com flip cards menu here) doesn’t seem like it will be very easy. So, I’ve considered two other options:

  1. Create an SVG shape for the Tag (a single item)
  2. Change how I show interactivity – like having some sort of “Christmas-y magic sparkle animation” flow over the To: text before displaying the From: text (and vice versa)

In addition to styling the Tags with CSS, I also added a "disabled" class to all the “gift boxes” in the footer whose dates have not yet come. Ideally, these will be linked up to the big (tagged) gifts and will be controlled by JavaScript (jQuery or React – whichever I work out) to change the date as the countdown clock changes. (i.e. when the clock reads 00:00:01 second remaining for a day, then flips over to the next day, ideally, the "active" Gift would also change.)

Also, the "disabled" tag should prevent users from being able to click on any of those Gifts to view their days “in advance” (and scrolling to dates later than the present date should also be disallowed).

Begin Responsive Styles
Finally, I decided to work on Responsive styling a little bit since the computer I did most of this coding work on in the afternoon had a screen resolution of 1024x768px (and at that size the whole Codepen looked pretty ugly). The following are some of the considerations I need to make when making this site responsive:

  1. Gifts in the footer
    1. Reduce the font size (DONE)
    2. or make the footer scrollable,
    3. or only display only the a few gifts (like some WordPress paging menus with [Prev] ... [12] [13] [14] ... [Next] buttons)
  2. Big gifts
    1. Reduce the size on smaller screens
    2. or scale them smaller
    3. and/or remove/reposition the Tag
  3. Countdown clock
    1. Reduce the size
    2. or stack it vertically to the left or right of the gift
    3. or divide it in two and stack half vertically to the left, half to the right
    4. or remove much of the styling (including the background circles) and turn it into a kind of smaller “digital clock” (as opposed to analog)
  4. Header and top menu
    1. Reduce font size and height (DONE)
    2. Also use a “hamburger” style menu button at very small sizes
  5. React-loading Blog Posts
    1. Still need to figure out how I want these styled initially anyway (title only, title and excerpt, or what) – after that we can figure out responsive styling

Work Completed (to date)

  • December 12, 2016
    • Storybook on Windows (FAIL)
    • Continue styling <Tag> Components
    • Begin responsive styles
  • December 11, 2016
    • Begin separating out CSS per Component
    • Attempt to load in static files & Sass
    • Begin coding a Tag for the Gifts
  • December 10, 2016
    • Finish Lynda.com videos
    • Get all React Components working in Storybook
    • Begin creating a Christmas Scene
  • December 9, 2016
    • Learn and use Create-React-App
    • Learn and use Storybook for developing React Components in isolation
    • Update npm and node and figure out my git process between Windows and Mac
  • December 8, 2016
    • Use React and Babel via CDN to get it working “locally”
    • Install React developer Tools for Chrome
    • Create very basic React.js pages to learn it
  • December 7, 2016
    • Pull post data with the WP REST API in WordPress core!!
    • Write structural code for the React Component to be rendered
    • Install and setup BabelJS to compile the React code
  • December 6, 2016
    • Add README.md
    • Add a GitHub Issue to hold usable images
    • Add LICENSE
  • December 5, 2016
    • Create a GitHub repository and full site files for easier management
    • Setup Grunt.js to compile my Sass into CSS
    • Begin blogging about the process
  • December 4, 2016
    • Countdown clock (JS Date class & jQuery Easing) with SVGs
    • Dynamic text output for Year based on the current date
    • CSS only slider (off by 5px each slide)
  • December 3, 2016
    • CSS bow & ribbon
    • Footer with FontAwesome presents
    • Hover, active, and “Christmas Day” styles for footer presents
  • December 2, 2016
    • React.js + Axios.js initial code structure
    • Color palette
    • CSS → Sass
  • December 1, 2016
    • Let it snow
    • Typography choices
    • CSS presents (first design)
    • Design notes menu

Coding an Advent Calendar: Day 2

This year, I decided to create an Advent Calendar website in HTML5, CSS3, and JavaScript. My hopes for the site are to showcase some of my frontend development abilities as well as make something fun, functional, and reusable.

Day 2

WP REST API with React.js (structure)
There’s been a lot of excitement recently about the WP REST API’s inclusion of content endpoints in WordPress 4.7 lately, so I’ve been wanting to learn about that and create something useful that utilizes it. I have built both a simple WordPress REST plugin and a WordPress REST theme in October this year, by following these Lynda.com courses:

  1. WordPress REST API (WP-API): First Look by Morten Rand-Hendriksen
  2. AngularJS and WordPress: Building a Single-Page Application by Roy Sivan

After building these projects, I wanted to do some more with the WP-API. Then, after Brian Krogsgard created a Codepen which utilizes React.js and the WP REST API (and one with Vue.js), I thought it would be a good thing to fork and learn from.

Color Palette
Initially, I set the colors for the CSS present to green and maroon but was quite unsatisfied with that combination. Eventually, after checking some other color palettes on ColourLovers.com and Dribbble.com, I settled on the following (similar to this Codepen):

  • Dark Red: #9D1313
  • Light Red: #F17259
  • Dark Green: #0B8972
  • Light Green: #65C0A5
  • Dark Blue: #2A6FB0
  • Light Blue: #CAE4F2

Along with various other alpha shades, tones, and tints of these colors as well as  Black  and White.

Sass CSS
Since the color palette I chose would need to be used and reused in the various elements I created on the page, I decided the best way to keep track of those (and easily call them up later) would be to switch my CSS stylesheet to Sass. I stored the color (and other) variables at the top of the stylesheet and was able to easily use them at will throughout the page.

I may yet do something else with Sass mixins or functions (like a @for loop), and I intend to rewrite the stylesheet using Sass nested selectors later.


Work Completed (to date)

  • December 2, 2016
    • React.js + Axios.js initial code structure
    • Color palette
    • CSS → Sass
  • December 1, 2016
    • Let it snow
    • Typography choices
    • CSS presents (first design)
    • Design notes menu

Coding an Advent Calendar: Day 1

This year, I decided to create an Advent Calendar website in HTML5, CSS3, and JavaScript. My hopes for the site are to showcase some of my frontend development abilities as well as make something fun, functional, and reusable (for the next year, and the next year, and the next year, etc).

Day One

The goal here is to add a little bit (1-2 hours of coding) to this each day of December leading up to Christmas (at which point it should be a completed project). I may then add some bells and whistles in the week after Christmas as well to make it more fun for New Year’s too.

The following are some initial notes (and inspirational links) I made to help guide my design decisions as I started creating this site.


Design Decisions

JavaScript plugins
I searched through a number of Codepens and sites that were using a (surprisingly wide) variety of jQuery plugins to “Let it snow” on websites. I settled on a plugin from MadeByMagnitude.com that showed snowflakes at different sizes and fell lightly over my page. Here are others:

  1. jQuery Snowfall 1.5: Small, pixel-sized snowflakes that collect on top of objects
  2. Snowstorm: Round snowflakes that “blow in the wind” as your mouse moves
  3. Round snowflakes that disburse when moused over
  4. 3D snowing effect with Three.js
Typography
The first font I selected was for the headings of the site. I wanted something that would have good thick, stylized numerals that I could use for the dates I marked on the packages. Then, I wanted looked for a body font to complement it. I thought something with rounded edges would look nice, but I found a very nice old and rounded serif font that fit the Christmas theme very nicely as well.

advent-calendar

  1. Headings: Sonsie One
  2. Body – 1st try: Varela Round
  3. Body – 2nd try: Averia Serif Libre
  4. Body – 3rd try: Quicksand
  5. Body – 4th try: Nunito

And, actually, it’s because of my time spent choosing typefaces that I decided to use this Advent Calendar design to highlight some of my favorite all-time typefaces. In a separate blog series, I’ll post One typeface per day that I’ve really enjoyed using in other designs.

CSS Shapes
I’ve recently been working with SVGs and SVG animation, but I haven’t done a whole lot with CSS shapes (i.e. using a bunch of <div> elements and strange border-radius settings to draw something interesting). Therefore, I decided to create the Christmas presents (and ribbons) in pure CSS and HTML.
day1-present

Work Completed (to date)

  • December 1, 2016
    • Let it snow (jQuery plugin)
    • Typography choices
    • CSS presents (first design)
    • Design notes menu