Code Monkey home page Code Monkey logo

langsdale's Introduction

Proof of concept refactorings for UB Langsdale Find Materials web page

https://brianzelip.github.io/langsdale

There are four solutions provided in index.html:

  1. row-based float solution
  2. column-based float solution
  3. row-based flexbox solution
  4. column-based flexbox solution

As a point of reference for what row- and column-based mean here, I consider the live Find Materials page tiles to be column-based. That is, when the viewport is narrow enough, the second column collapses under the first column to create one column.

The row-based solutions provide a better visual output in my opinion, because each horizontal pair (on larger devices) are the same height. The column-based approaches can't achieve this.

About index.html

Each solution is contained in a <section> element in index.html

The CSS for each solution is included in a <style> block directly above the solution's markup, for streamlining the reference look up of how the CSS and HTML interact.

About the CSS inside index.html

Use a modern browser to view!

I prototyped these solutions as quick and dirty as possible, which means that I didn't stop to add Autoprefixer to the development workflow.

Use a modern Firefox or Chrome browser to see these solutions, as the uses of flexbox may require vendor-prefixes for older browsers.

CSS conventions

There are two types of CSS conventions on display here - BEM and atomic CSS.

While I prefer to wield atomic CSS, the BEM method is closer to the "normal way of writing CSS" that the Find Materials page uses. BEM is used here to promote the idea of user interface components with semantic class names.

I kept one solution written in atomic CSS, the fourth "Column-based flexbox method", for demonstration. Basscss is the library used herein for most of the atomic css instances. The rest are original and are contained in the <head>'s style block.

About the float solutions

I included float solutions to demonstrate how to fix the wrapping bugs in the live page.

There are comments in the CSS that point to the essential parts of each solution.

The code currently in production is written in such a way that it becomes difficult to change course for the better. Some major code smells in this regard are the many uses of large amounts of padding and margin, and very particular positioning length values, for general layout. I see this happening all over the place, not just the Find Materials tiles.

Ultimately, what's missing from the live page is a rock solid method for reusable layout patterns. This is what Flexbox and CSS Grid provide. If not using these newer CSS tools, then you want to implement some kind of float-based grid system.

The float-based grid system is conceptually comprised of rows and columns.

Working with floats means you have to know how to work around the undesirable wrapping situations that happen. The general wisdom here is to incoporate a clearfix and know when to use overflow: hidden.

Use <wbr> for long strings with no spaces ('KnowledgeWorks@UB')

These solutions use <wbr> to break up long strings with no spaces in them, like "KnowledgeWorks@UB". This solves:

  1. the bug of truncating such long strings on smaller devices that also have an overflow: hidden assigned to it (like in the case of "KnowledgeWorks@UB")
  2. the forced horizontal scroll on smaller devices due to such long strings that do not have overflow: hidden assigned to it.

About index.pug

Continuing our discussion of the developer user experience, automation, and front end tooling, Pug is a HTML templating engine for Node.js.

I used Pug here to minimize the amount of code needed to demonstrate the solutions. I use the pug-cli locally to render index.html from index.pug, before publishing index.html.

Another argument for incorporating git into your dev workflow

One of the many benefits of git is that you can see the evolution of the project via the log of "commit messages". See the log of commits for this project.

This feature is especially useful for understanding what's going on in your code long after it was written!

Also note that the log lists who is responsible for what changes to the code, and at exactly what point in time. Very handy for teams.

Further resources

Here are some resources that I used when writing these solutions:

langsdale's People

Contributors

brianzelip avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.