Posted in Site Development
3109
12:05 am, December 23, 2020
 

Kruxor Moving from Bootstrap to CSS Grid

This is my notes on upgrading this site from bootstrap to css grid. 

Mission: Make this look good! and fast :)

Mmm… not so good at the moment, removed bootstrap and dark theme. But there is still some custom css being added here i think to add the purple in the header and things. 

Mission one was to move the main site into a dev site so i can totally break it and then rebuild the elements. 

Usually I just do this stuff and then give up in the middle, but i thought if i document this i might be more likely to come back to it again. 

Before Removal

Yeah its nothing to be too excited about just functional.

Stage 1 : Bootstrap Removed

Here I moved the site to dev and removed bootstrap and added custom css grid.

Yep thats pretty ugly now! But its an opportunity to make it nice! :)

Bootstrap CSS and JS

Lets have a look at the css that is added in bootstrap and see what kind bloat its adding. 

CSS:

157kb to beat with my new grid.css file, oh and the javascript. Which im not actually sure if i use many of the features.

Javascript: 

Another 77k of js. So total of about… 234kb. Does not seem like much, but probably a lot of it is unused anyway as i only really use the basic elements.

Update: So far the new grid.css CSS is currently.. 22kb which includes light mode and dark mode css. Where the old site used to reload the whole of bootstrap again to switch modes. Now i add a class to the header to switch modes, much quicker. Currently saving 212kb.

When you change from dark to light mode up here:

You can see that it switches pretty much instantly, where as the old version used to have to download the whole bootstrap darkly css file, which was another 160 ish kb. 

Top Bar

Not too hard to recreate this in the new structure. Had to remove the nav elements, as they do not conform to the new grid layout. 

The Menu + Navigation + Toggles

Ok how to sort out this mess!

What is going on here, well this menu is set out to use the bootstrap navigation layout, so its a bit of a mess now that the style and js is removed, not sure if the menu’s use js on bootstrap but they probably do. Lets see what needs to be changed to fix them, and still get the same kinda layout.

Bootstrap uses toggles for dropdowns and the menu’s so when i replicate this it will also work for the side nav toggles. 

Here is what they look like with bootstrap enabled.

Pretty neat, plus the mobile version is similar and easy to navigate.

See what we can do up the top here, using similar elements. 

Sidebar toggles:



I spent some time extracting some of the elements and re-doing them in both dark and light mode, here is what they look like so far. 

Light Mode:

Dark Mode:

I changed the padding to pixels rather than rem’s as i’m more used to the pixels. I find them a bit more accurate.

The responsive version im still working on the toggle function and appearance. 

Elements to Document

I think i will extract the code for these and add to a new code articles so it can be more easily re-used. 

View Statistics
This Week
56
This Month
242
This Year
346

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Articles
Search Articles by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote

"Olivia, my eldest daughter, caught measles when she was seven years old. As the illness took its usual course I can remember reading to her often in bed and not feeling particularly alarmed about it. Then one morning, when she was well on the road to recovery, I was sitting on her bed showing her how to fashion little animals out of coloured pipe-cleaners, and when it came to her turn to make one herself, I noticed that her fingers and her mind were not working together and she couldn’t do anything. 'Are you feeling all right?' I asked her. 'I feel all sleepy,' she said. In an hour, she was unconscious. In twelve hours she was dead. The measles had turned into a terrible thing called measles encephalitis and there was nothing the doctors could do to save her. That was...in 1962, but even now, if a child with measles happens to develop the same deadly reaction from measles as Olivia did, there would still be nothing the doctors could do to help her. On the other hand, there is today something that parents can do to make sure that this sort of tragedy does not happen to a child of theirs. They can insist that their child is immunised against measles. ...I dedicated two of my books to Olivia, the first was ‘James and the Giant Peach’. That was when she was still alive. The second was ‘The BFG’, dedicated to her memory after she had died from measles. You will see her name at the beginning of each of these books. And I know how happy she would be if only she could know that her death had helped to save a good deal of illness and death among other children."

I just checked google books for BFG, and the dedication is there. 

https://www.google.com.au/books/edition/_/quybcXrFhCIC?hl=en&gbpv=1 


Roald Dahl, 1986
Random CSS Property

element()

Experimental: This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.
element() css reference