Updating NuGet Gallery’s frontend
Styling
We use Bootstrap 3 as our base CSS framework. This provides a grid layout, CSS normalization, and some common styles. Changes to our styles should be made to LESS files and not to a CSS file directly. LESS is a syntax that itself is not usable by a browser but is compiled to CSS. It provides niceties that CSS does not offer such as rule nesting, mixins, variables, and arithmetic (calculated values). Each page may have its own set of specific styles. These page-specific styles are in apage-*.less file
in the src\Bootstrap\less\theme\ directory.
Prerequisites
To compile LESS files:- Install node: https://nodejs.org/en/download/
- Install Grunt:
npm install -g grunt - Navigate to
.\src\Bootstrap - Install NPM dependencies:
npm install
Updating styling
- Update one or more
.lessfiles in thesrc\Bootstrap\lessdirectory - Navigate to
.\src\Bootstrap - Run
grunt
bootstrap.min.css file is loaded correctly. A hard refresh will reload the page and bypass the cache, ensuring the latest version of the page and its resources (like images and scripts) are loaded from the server. In Edge, Chrome, and Firefox the command for hard refresh is Ctrl + Shift + R.
Alternatively, you can disable the cache entirely in the Developer Tools Network tab.
Adding a new page
- Create a new
page-X.lessfile in thesrc\Bootstrap\less\theme\directory - Add the new page in
src\Bootstrap\less\theme\all.less
JavaScript
We use jQuery and Knockout.js. Common JavaScript should be added tosrc\NuGetGallery\Scripts\gallery\common.js.
Each page may have its own custom logic. These page-specific scripts are in a page-*.js file
in the src\NuGetGallery\Scripts\gallery\ directory.