Skip to content

Add Resources and make Donate a button #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ With your environment setup properly, the following explains how to build from s
1. Clone this repository

```sh
git clone https://github.com/MonoGame/monogame.github.io.git
git clone https://github.com/MonoGame/docs.monogame.github.io.git
```

2. Install DotNet dependencies
Expand Down
1 change: 1 addition & 0 deletions templates/monogame/layout/_master.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
{{/_enableSearch}}

{{>partials/footer}}
<script type="text/javascript" src="/public/injectDonateButton.js" /
</body>
{{/redirect_url}}
</html>
18 changes: 9 additions & 9 deletions templates/monogame/partials/topnav.tmpl.partial
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
{{_appName}}
</a>
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
<i class="bi bi-three-dots"></i>
<i class="bi bi-three-dots"></i>
</button>
<div class="collapse navbar-collapse" id="navpanel">
<div id="navbar">
{{#_enableSearch}}
<form class="search" role="search" id="search">
<i class="bi bi-search"></i>
<input class="form-control" id="search-query" type="search" disabled placeholder="{{__global.search}}" autocomplete="off" aria-label="Search">
</form>
{{/_enableSearch}}
</div>
<div id="navbar">
{{#_enableSearch}}
<form class="search" role="search" id="search">
<i class="bi bi-search"></i>
<input class="form-control" id="search-query" type="search" disabled placeholder="{{__global.search}}" autocomplete="off" aria-label="Search">
</form>
{{/_enableSearch}}
</div>
</div>
</div>
</nav>
Expand Down
25 changes: 25 additions & 0 deletions templates/monogame/public/injectDonateButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Donate button Injector
*
* This script dynamically adds a "Donate" button to the navigation.
* Since the navbar is dynamically generated **after page load**, it uses a MutationObserver to watch
* for the form.icons element to be added to the DOM, injects the donate button as its first child
* the disconnects the observer.
*/

document.addEventListener('DOMContentLoaded', function() {
const observer = new MutationObserver(function(mutations) {
const iconsForm = document.querySelector('form.icons');
if (iconsForm) {
observer.disconnect();
const donateDiv = document.createElement('div');
donateDiv.innerHTML = '<a class="btn mg-donate-button ms-3" type="button" href="https://monogame.net/donate"><i class="bi bi-heart"></i> Donate</a>';
iconsForm.insertAdjacentElement('afterbegin', donateDiv);
}
});

observer.observe(document.body, {
childList: true,
subtree: true
});
});
17 changes: 17 additions & 0 deletions templates/monogame/public/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ body[data-disable-toc="true" i] .toc-offcanvas {
color: var(--mg-orange-primary)
}

/*******************************************************************************
*** Section: Navbar Fixes
*** The main monogame website uses bootstrap 5.3.2 while docfx is sitll on
*** bootstrap 3.4.1. The following are fixes for the top navbar specifically
*** so that it looks the same as the main website
*******************************************************************************/
nav#autocollapse > div.container-xxl {
max-width: 1320px;
}


/*******************************************************************************
*** Section: MonoGame Utility Classes
*** Utility classes used throughout the site that provide some MonoGame specific
Expand Down Expand Up @@ -182,6 +193,12 @@ box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
color: var(--bs-body-color);
}

.mg-donate-button {
--bs-btn-bg: #F1465A;
--bs-btn-hover-bg: #F25265;
--bs-btn-color: #fff;
--bs-btn-hover-color: #fff;
}

/*******************************************************************************
*** Some adjustments to give the content some space.
Expand Down
6 changes: 3 additions & 3 deletions toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
href: https://monogame.net/blog/
- name: Bounties
href: https://monogame.net/bounties/
- name: Resources
href: https://monogame.net/resources/
- name: About
href: https://monogame.net/about/
- name: Donate
href: https://monogame.net/donate/
href: https://monogame.net/about/