Showing posts with label SASS. Show all posts
Showing posts with label SASS. Show all posts

Sunday, 4 October 2015

Mid-semester break: style updates and more angular

I used the break to work on CSS/SASS and spend time with trove and the Wayback Time-machine.

Styles

  • fixed some style inconsistencies with p and h styles
  • fixed the logotype: h1 size ration (logotype in now larger)
  • looked at the design of the page and changed from the 'indigo' colour palette to 'blackboard green' to match the infographic
  • crop the category image using CSS


CSS Crop


Page design



Trove/Wayback machine

My next task for the break was sourcing material for our site.  We had already decided on the four categories (sport, arts, education, government) and my task was to find approx 3 websites per category and source appropriate illustrative images from Trove, and web historical content from the Wayback Time-machine.  I search a combination of Pandora and Wayback Time-machine to find good examples of sites for each categories.  I concentrated on local sites (Brisbane, Queensland, Australia).

Once I had selected the sites and made a list of the Wayback Machine addresses, I then went to Trove to find good search queries for each site.  Some were definitely easier than others.  I had AFL listed as one of the sport categories but was unable to find any images that were copyright free/retrievable with the Trove API.  I then proceeded to make the API calls, found the work IDs I needed, checked the calls work, and added the image URLs to an array to access for home.html.  

Problems and solutions

I used Plnkr to test adding real images to angular using a hard-coded array.  I then applied that to our real code but changed the hard coded array to the dynamic one constructed using API calls to Trove.

The complicated part of using this array is the combination of Angular and Trove loading times.  The angular repeat happens much quicker than the Trove API calls.  Given that a lot of the information about the website (the link, website name, alt text, etc) the order of the images in the image array is important. The first step was then to direct each API call to a specific place in the array that corresponded to the data in the angular file.  

e.g. imageArraySport[1]=olympicsImg;

Where imageArraySport is the array to store the images for the sports tab and olympicsImg is the variable storing the image for the Sydney Olympics website.

The next problem I had adding the images to the html generated by Angular.  I wrote a jQuery function that worked in plnkr that targeted a class and added the image source link from the links in the array.  This worked fine but wouldn't work when I used the real API calls instead of the hardcoded array.  I realised this was because the API calls came back at different times and when the function iterated over the array, it was not always full and returned a src link of nothing.

To counteract this, I ran the function in each AJAX API calland added an if statement to check if the array had the number of images.

e.g. if(imageArraySport.length == 3)

Where the sport category has 3 websites and the if statement checks this first before running the rest of the function.

Thursday, 17 September 2015

Week 8: SASS how-to

Initial set-up

  1. Download the source files from Bootstrap 
  2. Unzip them into the folder where you will be using them (in our case, I have set-up a 'SASS' folder in our git repo)
  3. Follow the instructions on tooling set-up on Bootstrap (repeated below)
    1. Download and install Node.js
    2. Using the command line (Terminal, iTerm, Powershell, what-have-you), install Grunt with npm install -g grunt-cli
    3. After a quick refresher in command line, navigate to the Bootstrap folder that you unzipped (for us: 'SASS' as above).  OK, so now you're using the command line and you're in the Bootstrap folder.  If you type ls it should look similar to this:

    4. Install the local dependencies listed in package.json by running npm install
    5. Next up is Ruby.  If you are on a mac, you should have it already installed but can check by typing ruby -v into the command line.  If you need to download or update there is info here and here.  But, if you need to install on Windows, we ran into a few problems and used this tutorial from Forward HQ to sort it out.
    6. Almost there! Two-parter for Bundler: 1) install in the command line by running gem install bundler and then 2) run bundle (for all the Ruby dependencies you will need).
  4. Last step, install SCSS Lint by running gem install scss_lint
Phew, you still with me?  You may (or hopefully not) have any errors.  You may need to prefix the command line with sudo (I know, I know, lots of people say you shouldn't), or might get other random errors (google is your friend), but hopefully you have the things installed.  Now for the fun part :)

Using SASS

In your Bootstrap folder (for our team 'SASS') is a folder called 'scss' which is filled with many, many .scss files.  Being Bootstrap, it is all fairly logically named so it shouldn't be too hard to find any CSS you need to change.  '_variables.scss' has all the colours and typography (amongst other things), etc, etc. Have a look at the SASS documentation for how to use variables, nesting, other syntaxy-things.

Once you've changed the things you need to, how do you get it to be a CSS (and JS) file to use on the website?  Back to the command line!

To compile the CSS/JS files:
  1. Using command line, navigate to the bootstrap folder we were working in before.  You may still be there :)  (I'm a broken record but "For our team it is the 'SASS' folder")
  2. run grunt dist and fingers crossed, 0 errors!
For our purposes, that's about it but there is more info on grunt commands in the Bootstrap documentation.

Notes for team

  • No need to copy/paste files or folders, the CSS and JS import links are now up to date!
  • Remember: sync git, make changes, sync git
  • The Bootstrap 4 documentation has lots of great info, start with Layout, Content, Components
  • Bootstrap also has a slack channel - a great place to go for help!


Week 8: Prep for Part B

Our team met this week to discuss the division of tasks ahead of Part B being due next week.  Part of my task list was having a look at the header again and styling.  We decided as a group not to pursue web components at this time.  There are some cross-browser issues and ultimately it came down to time available vs core functionality we need to do first.  Web components hasn't been ruled out, just put in the 'nice to have' basket.

Part of the feedback we got from the paper prototype we tested last week was to make all our header/nav the same across all pages.  While updating the header (and taking it out of its own HTML import), I had a look at the bootstrap framework we were using  the material design theme.  I decided to ditch the theme in an effort to make the design more our own and instead build on vanilla Bootstrap.

I had a look into the newly released Bootstrap 4 and thought this would be a good option, but it is only available as source files (not pre-compiled code), which means setting up SASS for our project.

Today in our workshop I went through how to set-up SASS with my team and how to edit and compile.  In my next post I will document the how-tos for our team to refer back to if necessary.

I also wrote a set of success criteria for our Part B report based on the interactions we want our users to have with our web app.  We will discuss these as a group next week.