Overview
TheBootstrap directory is a local vendor copy of Bootstrap 3.4.1 (the final stable Bootstrap 3 release) that has been extended in-place to serve as the front-end design system for nuget.org. Rather than pulling Bootstrap from a CDN or NuGet package at runtime, the Gallery keeps the full source tree under version control so that NuGet-specific styles, theming tokens, and JavaScript overrides can be built into the final distribution files as part of a reproducible Grunt build.
The project outputs two artifacts that are copied directly into the main NuGetGallery web project:
dist/css/bootstrap.min.css→../NuGetGallery/Content/gallery/css/dist/js/bootstrap.js→../NuGetGallery/Scripts/gallery/
Bootstrap v3 is in maintenance-only mode upstream. No new features are accepted by the upstream project; the Gallery’s additions are maintained entirely within this vendored copy.
Role in System
CSS Build
LESS source compiled via
grunt-contrib-less, then autoprefixed and minified with clean-css. IE 8 compatibility is preserved via ieCompat: true and cssmin compatibility flags.JS Build
Twelve Bootstrap plugin files concatenated in dependency order, jQuery version-checked at runtime, then minified with UglifyJS with IE 8 mangling support enabled.
Theme System
Light and dark modes are driven entirely by CSS custom properties defined in
themes.less. The data-theme attribute on <html> switches the active palette at runtime with no JavaScript required.Gallery Copy Task
grunt copy:gallerycss and grunt copy:galleryjs push the compiled artefacts into the main Gallery project. Developers must run Grunt after any LESS changes.Key Files
| File | Purpose |
|---|---|
less/bootstrap.less | Imports all upstream Bootstrap 3 partials. carousel.less is commented out (not used). |
less/variables.less | Defines all Bootstrap LESS variables; NuGet overrides @brand-danger to #c50f1f (Cranberry) and adds @verified-color. |
less/theme/all.less | Aggregates every NuGet-specific partial in correct import order. |
less/theme/base.less | Global layout — defines .nuget-logo-image, .footer, .package-list, .tag, .banner. |
less/theme/themes.less | Full Fluent Design + .NET brand CSS custom-property palette for light and dark themes. Brand blues map to dotnet color ramp (dotnetBluePrimary #0b6cff). |
less/theme/common-high-contrast.less | @media (-ms-high-contrast:active) overrides for SVG text fill and popover arrows. |
less/theme/page-display-package.less | .page-package-details scoped styles: package icon, version badge, TFM framework badges, deprecation banners. |
less/theme/page-home.less | Jumbotron overrides, what-is-nuget section, gradient home background. |
dist/js/bootstrap.js | Concatenated JS with jQuery version guard (requires jQuery 1.9.1–3.x). |
Gruntfile.js | Defines dist, dist-css, dist-js, and default tasks; copy tasks target ../NuGetGallery. |
Dependencies
Build-time (npm / Grunt)
| Package | Purpose |
|---|---|
grunt | Task runner |
grunt-contrib-less | LESS to CSS compilation (ieCompat, strictMath, source maps) |
grunt-postcss + autoprefixer | Vendor-prefix injection post-compilation |
grunt-contrib-cssmin | CSS minification (IE 8 compat mode) |
grunt-contrib-concat | JS plugin concatenation |
grunt-contrib-uglify | JS minification (IE 8 mangling) |
grunt-contrib-copy | Copies artefacts into NuGetGallery project |
Runtime
| Dependency | Version | Purpose |
|---|---|---|
| jQuery | 1.9.1 – 3.x | Required by all Bootstrap JS plugins; version-checked at boot |
There are no
.csproj or NuGet package references in this folder. This is a pure front-end npm/Grunt project with no .NET build integration. It must be built separately before the ASP.NET application picks up updated styles.Notable Patterns and Implementation Details
Fluent Design token naming:
themes.less uses a verbose but systematic naming convention (--neutralBackground2Rest, --brandForegroundLinkHover, etc.) derived from Microsoft Fluent UI. Every interactive state (Rest, Hover, Pressed, Selected) and every semantic role has an explicit token, making it straightforward to audit colour-contrast compliance per WCAG.carousel.lessis intentionally disabled inbootstrap.less(commented out). The Gallery does not use Bootstrap carousels.- Glyphicons are also disabled — the Gallery uses Microsoft Fluent UI icons (
.ms-Icon) instead of the Bootstrap glyph font. - xs container width bug workaround:
base.lesssetswidth: calc(100vw - 20px)on.containeratmax-width: @screen-smbecause Bootstrap 3 does not constrain overflow at the extra-small breakpoint. @verified-color: #068918is a custom LESS variable added on top of Bootstrap’s standard palette to style the package verified/prefix-reserved indicator badge.- IE 8 support is explicit throughout:
cssmincompatibility flag, UglifyJSie8: true, andieCompat: truein the LESS compiler are all set. - Per-page LESS files (~35
page-*.lessfiles) scope all page-specific rules under a top-level class (e.g..page-package-details,.page-home) to prevent cross-page style bleed.