Skip to content
Nubgrammer
Menu
  • Home
  • Contact Me
Menu
Building Blocks

100DaysOfCode Day 2 – The Building Blocks

Posted on August 18, 2020August 18, 2020 by Tyler Sells

I’m still a little bit ahead of schedule but I’m back on track today. Today’s update was focused on building out my knockoutjs component shells and a little bit of CSS styling.

Knockoutjs Components

Component files
Component files

All these files currently have similar code in them.

dashboard-albums.js

define(['ko'], function (ko) {
    var koModel = function (params) {
        var self = this;
        self.title = "Dashboard Albums";

    };
    return koModel;
});

dashboard-albums.html

<div>
    <h2 data-bind="text:title"></h2>
</div>

app.js

require(['ko'], function (ko) {
    ko.components.register('dashboard', {
        viewModel: { require: "dashboard/scripts/dashboard" },
        template: { require: "text!dashboard/templates/dashboard.html" }
    });
    ko.components.register('dashboard-albums', {
        viewModel: { require: "dashboard/scripts/dashboard-albums" },
        template: { require: "text!dashboard/templates/dashboard-albums.html" }
    });
    ko.components.register('dashboard-photos', {
        viewModel: { require: "dashboard/scripts/dashboard-photos" },
        template: { require: "text!dashboard/templates/dashboard-photos.html" }
    });
    ko.components.register('dashboard-posts', {
        viewModel: { require: "dashboard/scripts/dashboard-posts" },
        template: { require: "text!dashboard/templates/dashboard-posts.html" }
    });
    ko.components.register('dashboard-sidebar', {
        viewModel: { require: "dashboard/scripts/dashboard-sidebar" },
        template: { require: "text!dashboard/templates/dashboard-sidebar.html" }
    });
    ko.components.register('dashboard-to-do', {
        viewModel: { require: "dashboard/scripts/dashboard-to-do" },
        template: { require: "text!dashboard/templates/dashboard-to-do.html" }
    });
    ko.components.register('dashboard-to-dos', {
        viewModel: { require: "dashboard/scripts/dashboard-to-dos" },
        template: { require: "text!dashboard/templates/dashboard-to-dos.html" }
    });
    ko.applyBindings();
});

It’s not much yet, but I have big plans.

All of the component shells rendering on-screen
All of the component shells rendering on-screen

LESS, or is it CSS?

I’ve also added a little bit of layout styling using a grid system. I prefer not to nest more than 2 or 3 levels deep, but this seems to work pretty well. I may refactor it at some point though. The main take-away here though is that a typical layout with a sidebar and content panel is achieved by giving a block element the following class string:

ngts-panel ngts-sidebar ngts-content

I can also split panels vertically as much as I want by adding a block element with these classes:

ngts-panel ngts-content ngts-content-split

I plan to add ngts-content-divide as an option for splitting horizontally.

layouts.less

.ngts-panel {
    &.ngts-sidebar {
        &.ngts-content {
            display: grid;
            grid-template-columns: minmax(200px, 300px) 1fr;
            grid-template-rows: 100vh;

            &.ngts-content-split {
                grid-template-columns: minmax(200px, 300px) 1fr 1fr;
            }
        }
    }

    &.ngts-content {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: 100vh;

        &.ngts-content-split {
            grid-template-columns: 1fr 1fr;
        }
    }
}

@media screen and (max-width : @var-bp-small) {
    .ngts-panel {
        &.ngts-sidebar {
            &.ngts-content {
                display: grid;
                grid-template-columns: 100vw;
                grid-template-rows: 60px 1fr;

                &.ngts-content-split {
                    grid-template-columns: 100vw;
                    grid-template-rows: 60px 1fr 1fr;
                }
            }
        }

        &.ngts-content {
            display: grid;
            grid-template-columns: 100vw;
            grid-template-rows: 1fr;

            &.ngts-content-split {
                grid-template-columns: 100vw;
                grid-template-rows: 1fr 1fr;
            }
        }
    }
}

That’s pretty much it for this update. I’m going to have to figure out a hosting solution sooner rather than later when I’m ready to demo the actual app-building side of things. That’s a problem for another day though.

Author: Tyler Sells

Github

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • More
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to email a link to a friend (Opens in new window) Email
  • Click to share on Reddit (Opens in new window) Reddit

Like this:

Like Loading...

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow me on Twitter

My Tweets

Github Repos

vtsells (Tyler Sells)

Tyler Sells

vtsells
http://www.nubgrammer.com
Joined on Jun 21, 2017
9 Public Repositories
100DaysOfCode
embers
MultiSelect
MVC-Project-Start
nubgrammer.com
PermIT
Spray
vtsells.github.io
Wizard
0 Public Gists

Categories

  • #100DaysOfCode (4)
  • ASP.NET (7)
  • ASP.NET Core (1)
  • ASP.NET MVC (3)
  • CSS (4)
  • General (13)
  • JS (3)
  • LESS (2)
  • Snippets (4)
  • Tools (4)
  • Tutorials (9)

Recent Posts

  • Creating a Knockout.js project on Codepen
  • 100DaysOfCode Day 3 – A State of Mind
  • 100DaysOfCode Day 2 – The Building Blocks
  • 100DaysOfCode Day 1 (Sort of cheated already)
  • Committing to #100DaysOfCode
© 2025 Nubgrammer | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
%d

    Privacy Policy