aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/static
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/static')
-rw-r--r--pydis_site/static/css/collapsibles.css12
-rw-r--r--pydis_site/static/css/content/page.css13
-rw-r--r--pydis_site/static/css/resources/resources.css214
-rw-r--r--pydis_site/static/css/resources/resources_list.css55
-rw-r--r--pydis_site/static/images/resources/duck_pond_404.pngbin0 -> 2371374 bytes
-rw-r--r--pydis_site/static/js/collapsibles.js (renamed from pydis_site/static/js/content/page.js)0
-rw-r--r--pydis_site/static/js/resources/resources.js247
7 files changed, 456 insertions, 85 deletions
diff --git a/pydis_site/static/css/collapsibles.css b/pydis_site/static/css/collapsibles.css
new file mode 100644
index 00000000..7b76d8d5
--- /dev/null
+++ b/pydis_site/static/css/collapsibles.css
@@ -0,0 +1,12 @@
+.collapsible {
+ cursor: pointer;
+ width: 100%;
+ border: none;
+ outline: none;
+}
+
+.collapsible-content {
+ overflow: hidden;
+ max-height: 0;
+ transition: max-height 0.2s ease-out;
+} \ No newline at end of file
diff --git a/pydis_site/static/css/content/page.css b/pydis_site/static/css/content/page.css
index 2d4bd325..d831f86d 100644
--- a/pydis_site/static/css/content/page.css
+++ b/pydis_site/static/css/content/page.css
@@ -77,16 +77,3 @@ ul.menu-list.toc {
li img {
margin-top: 0.5em;
}
-
-.collapsible {
- cursor: pointer;
- width: 100%;
- border: none;
- outline: none;
-}
-
-.collapsible-content {
- overflow: hidden;
- max-height: 0;
- transition: max-height 0.2s ease-out;
-}
diff --git a/pydis_site/static/css/resources/resources.css b/pydis_site/static/css/resources/resources.css
index cf4cb472..b24fcb5b 100644
--- a/pydis_site/static/css/resources/resources.css
+++ b/pydis_site/static/css/resources/resources.css
@@ -1,29 +1,209 @@
-.box, .tile.is-parent {
- transition: 0.1s ease-out;
+/* Colors for icons */
+i.resource-icon.is-orangered {
+ color: #FE640A;
}
-.box {
- min-height: 15vh;
+i.resource-icon.is-blurple {
+ color: #7289DA;
}
-.tile.is-parent:hover .box {
- box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
+i.resource-icon.is-teal {
+ color: #95DBE5;
}
-.tile.is-parent:hover {
- padding: 0.65rem 0.85rem 0.85rem 0.65rem;
- filter: saturate(1.1) brightness(1.1);
+i.resource-icon.is-youtube-red {
+ color: #BB0000;
+}
+i.resource-icon.is-black {
+ color: #2c3334;
+}
+
+/* Colors when icons are hovered */
+i.resource-icon.is-hoverable:hover {
+ filter: brightness(125%);
+}
+i.resource-icon.is-hoverable.is-black:hover {
+ filter: brightness(170%);
+}
+i.resource-icon.is-hoverable.is-teal:hover {
+ filter: brightness(80%);
+}
+
+/* Icon padding */
+.breadcrumb-section {
+ padding: 1rem;
+}
+i.has-icon-padding {
+ padding: 0 10px 25px 0;
+}
+#tab-content p {
+ display: none;
+}
+#tab-content p.is-active {
+display: block;
+}
+
+/* Disable highlighting for all text in the filters. */
+.filter-checkbox,
+.filter-panel label,
+.card-header span {
+ user-select: none
+}
+
+/* Remove pointless margin in panel header */
+#filter-panel-header {
+ margin-bottom: 0;
+}
+
+/* Full width filter cards */
+#resource-filtering-panel .card .collapsible-content .card-content {
+ padding:0
+}
+
+/* Don't round the corners of the collapsibles */
+.filter-category-header {
+ border-radius: 0;
+}
+
+/* Center the 404 div */
+.no-resources-found {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+
+/* Hide the no resources h2 by default */
+.no-resources-found {
+ display: none;
+ margin-top: 1em;
+}
+
+/* Disable clicking on the checkbox itself. */
+/* Instead, we want to let the anchor tag handle clicks. */
+.filter-checkbox {
+ pointer-events: none;
+}
+
+/* Blurple category icons */
+i.is-primary {
+ color: #7289da;
}
-#readingBlock {
- background-image: linear-gradient(141deg, #911eb4 0%, #b631de 71%, #cf4bf7 100%);
+/* A little space around the filter card, please! */
+.filter-tags {
+ padding-bottom: .5em;
+ padding-right: .5em;
}
-#interactiveBlock {
- background-image: linear-gradient(141deg, #d05600 0%, #da722a 71%, #e68846 100%);
+/* Set default display to inline-flex, for centering. */
+span.filter-box-tag {
+ display: none;
+ align-items: center;
+ cursor: pointer;
+ user-select: none;
}
-#communitiesBlock {
- background-image: linear-gradient(141deg, #3b756f 0%, #3a847c 71%, #41948b 100%);
+/* Make sure jQuery will use inline-flex when setting `show()` again. */
+span.filter-box-tag[style*='display: block'] {
+ display: inline-flex !important;
}
-#podcastsBlock {
- background-image: linear-gradient(141deg, #232382 0%, #30309c 71%, #4343ad 100%);
+/* Make resource tags clickable */
+.resource-tag {
+ cursor: pointer;
+ user-select: none;
}
+
+/* When hovering tags, brighten them a bit. */
+.resource-tag:hover,
+.filter-box-tag:hover {
+ filter: brightness(95%);
+}
+
+/* Move the x down 1 pixel to align center */
+button.delete {
+ margin-top: 1px;
+}
+
+/* Colors for delete button x's */
+button.delete.is-primary::before,
+button.delete.is-primary::after {
+ background-color: #2a45a2;
+}
+button.delete.is-success::before,
+button.delete.is-success::after {
+ background-color: #2c9659;
+}
+button.delete.is-danger::before,
+button.delete.is-danger::after {
+ background-color: #c32841;
+}
+button.delete.is-info::before,
+button.delete.is-info::after {
+ background-color: #237fbd;
+}
+
+/* Give outlines to active tags */
+span.filter-box-tag,
+span.resource-tag.active {
+ outline-width: 1px;
+ outline-style: solid;
+}
+
+/* Make filter tags sparkle when selected! */
+@keyframes glow_success {
+ from { box-shadow: 0 0 2px 2px #aef4af; }
+ 33% { box-shadow: 0 0 2px 2px #87af7a; }
+ 66% { box-shadow: 0 0 2px 2px #9ceaac; }
+ to { box-shadow: 0 0 2px 2px #7cbf64; }
+}
+
+@keyframes glow_primary {
+ from { box-shadow: 0 0 2px 2px #aeb8f3; }
+ 33% { box-shadow: 0 0 2px 2px #909ed9; }
+ 66% { box-shadow: 0 0 2px 2px #6d7ed4; }
+ to { box-shadow: 0 0 2px 2px #6383b3; }
+}
+
+@keyframes glow_danger {
+ from { box-shadow: 0 0 2px 2px #c9495f; }
+ 33% { box-shadow: 0 0 2px 2px #92486f; }
+ 66% { box-shadow: 0 0 2px 2px #d455ba; }
+ to { box-shadow: 0 0 2px 2px #ff8192; }
+}
+@keyframes glow_info {
+ from { box-shadow: 0 0 2px 2px #4592c9; }
+ 33% { box-shadow: 0 0 2px 2px #6196bb; }
+ 66% { box-shadow: 0 0 2px 2px #5adade; }
+ to { box-shadow: 0 0 2px 2px #6bcfdc; }
+}
+
+span.resource-tag.active.is-primary {
+ animation: glow_primary 4s infinite alternate;
+}
+span.resource-tag.active.has-background-danger-light {
+ animation: glow_danger 4s infinite alternate;
+}
+span.resource-tag.active.has-background-success-light {
+ animation: glow_success 4s infinite alternate;
+}
+span.resource-tag.active.has-background-info-light {
+ animation: glow_info 4s infinite alternate;
+}
+
+/* Smaller filter category headers when on mobile */
+@media screen and (max-width: 480px) {
+ .filter-category-header .card-header .card-header-title {
+ font-size: 14px;
+ padding: 0;
+ }
+ .filter-panel {
+ padding-top: 4px;
+ padding-bottom: 4px;
+ }
+}
+
+/* Disable transitions */
+.no-transition {
+ -webkit-transition: none !important;
+ -moz-transition: none !important;
+ -o-transition: none !important;
+ transition: none !important;
+} \ No newline at end of file
diff --git a/pydis_site/static/css/resources/resources_list.css b/pydis_site/static/css/resources/resources_list.css
deleted file mode 100644
index 33129c87..00000000
--- a/pydis_site/static/css/resources/resources_list.css
+++ /dev/null
@@ -1,55 +0,0 @@
-.breadcrumb-section {
- padding: 1rem;
-}
-
-i.resource-icon.is-orangered {
- color: #FE640A;
-}
-
-i.resource-icon.is-orangered:hover {
- color: #fe9840;
-}
-
-i.resource-icon.is-blurple {
- color: #7289DA;
-}
-
-i.resource-icon.is-blurple:hover {
- color: #93a8da;
-}
-
-i.resource-icon.is-teal {
- color: #95DBE5;
-}
-
-i.resource-icon.is-teal:hover {
- color: #a9f5ff;
-}
-
-i.resource-icon.is-youtube-red {
- color: #BB0000;
-}
-
-i.resource-icon.is-youtube-red:hover {
- color: #f80000;
-}
-
-i.resource-icon.is-amazon-orange {
- color: #FF9900;
-}
-
-i.resource-icon.is-amazon-orange:hover {
- color: #ffb71a;
-}
-
-i.resource-icon.is-black {
- color: #000000;
-}
-
-i.resource-icon.is-black {
- color: #191919;
-}
-
-i.has-icon-padding {
- padding: 0 10px 25px 0;
-}
diff --git a/pydis_site/static/images/resources/duck_pond_404.png b/pydis_site/static/images/resources/duck_pond_404.png
new file mode 100644
index 00000000..3aed4d62
--- /dev/null
+++ b/pydis_site/static/images/resources/duck_pond_404.png
Binary files differ
diff --git a/pydis_site/static/js/content/page.js b/pydis_site/static/js/collapsibles.js
index 366a033c..366a033c 100644
--- a/pydis_site/static/js/content/page.js
+++ b/pydis_site/static/js/collapsibles.js
diff --git a/pydis_site/static/js/resources/resources.js b/pydis_site/static/js/resources/resources.js
new file mode 100644
index 00000000..44d4db5c
--- /dev/null
+++ b/pydis_site/static/js/resources/resources.js
@@ -0,0 +1,247 @@
+"use strict";
+
+// Filters that are currently selected
+var activeFilters = {
+ topics: [],
+ type: [],
+ "payment-tiers": [],
+ difficulty: []
+};
+
+function addFilter(filterName, filterItem) {
+ // Push the filter into the stack
+ var filterIndex = activeFilters[filterName].indexOf(filterItem);
+ if (filterIndex === -1) {
+ activeFilters[filterName].push(filterItem);
+ }
+ updateUI();
+
+ // Show a corresponding filter box tag
+ $(`.filter-box-tag[data-filter-name=${filterName}][data-filter-item=${filterItem}]`).show();
+
+ // Make corresponding resource tags active
+ $(`.resource-tag[data-filter-name=${filterName}][data-filter-item=${filterItem}]`).addClass("active");
+
+ // Hide the "No filters selected" tag.
+ $(".no-tags-selected.tag").hide();
+}
+
+function removeFilter(filterName, filterItem) {
+ // Remove the filter from the stack
+ var filterIndex = activeFilters[filterName].indexOf(filterItem);
+ if (filterIndex !== -1) {
+ activeFilters[filterName].splice(filterIndex, 1);
+ }
+ updateUI();
+
+ // Hide the corresponding filter box tag
+ $(`.filter-box-tag[data-filter-name=${filterName}][data-filter-item=${filterItem}]`).hide();
+
+ // Make corresponding resource tags inactive
+ $(`.resource-tag[data-filter-name=${filterName}][data-filter-item=${filterItem}]`).removeClass("active");
+
+ // Show "No filters selected" tag, if there are no filters active
+ if (noFilters()) {
+ $(".no-tags-selected.tag").show();
+ }
+}
+
+/* Check if there are no filters */
+function noFilters() {
+ return (
+ activeFilters.topics.length === 0 &&
+ activeFilters.type.length === 0 &&
+ activeFilters["payment-tiers"].length === 0 &&
+ activeFilters.difficulty.length === 0
+ );
+}
+
+/* Get the params out of the URL and use them. This is run when the page loads. */
+function deserializeURLParams() {
+ let searchParams = new window.URLSearchParams(window.location.search);
+
+ // Work through the parameters and add them to the filter object
+ $.each(Object.keys(activeFilters), function(_, filterType) {
+ let paramFilterContent = searchParams.get(filterType);
+
+ if (paramFilterContent !== null) {
+ // We use split here because we always want an array, not a string.
+ let paramFilterArray = paramFilterContent.split(",");
+ activeFilters[filterType] = paramFilterArray;
+
+ // Update the corresponding filter UI, so it reflects the internal state.
+ $(paramFilterArray).each(function(_, filter) {
+ let checkbox = $(`.filter-checkbox[data-filter-name='${filterType}'][data-filter-item='${filter}']`);
+ let filterTag = $(`.filter-box-tag[data-filter-name='${filterType}'][data-filter-item='${filter}']`);
+ let resourceTags = $(`.resource-tag[data-filter-name='${filterType}'][data-filter-item='${filter}']`);
+ checkbox.prop("checked", true);
+ filterTag.show();
+ resourceTags.addClass("active");
+ });
+ }
+ });
+}
+
+/* Update the URL with new parameters */
+function updateURL() {
+ // If there's nothing in the filters, we don't want anything in the URL.
+ if (noFilters()) {
+ window.history.replaceState(null, document.title, './');
+ return;
+ }
+
+ // Iterate through and get rid of empty ones
+ let searchParams = new URLSearchParams(activeFilters);
+ $.each(activeFilters, function(filterType, filters) {
+ if (filters.length === 0) {
+ searchParams.delete(filterType);
+ }
+ });
+
+ // Now update the URL
+ window.history.replaceState(null, document.title, `?${searchParams.toString()}`);
+}
+
+/* Update the resources to match 'active_filters' */
+function updateUI() {
+ let resources = $('.resource-box');
+ let filterTags = $('.filter-box-tag');
+
+ // Update the URL to match the new filters.
+ updateURL();
+
+ // If there's nothing in the filters, show everything and return.
+ if (noFilters()) {
+ resources.show();
+ filterTags.hide();
+ return;
+ }
+
+ // Otherwise, hide everything and then filter the resources to decide what to show.
+ let hasMatches = false;
+ resources.hide();
+ resources.filter(function() {
+ let validation = {
+ topics: false,
+ type: false,
+ 'payment-tiers': false,
+ difficulty: false
+ };
+ let resourceBox = $(this);
+
+ // Validate the filters
+ $.each(activeFilters, function(filterType, filters) {
+ // If the filter list is empty, this passes validation.
+ if (filters.length === 0) {
+ validation[filterType] = true;
+ return;
+ }
+
+ // Otherwise, we need to check if one of the classes exist.
+ $.each(filters, function(index, filter) {
+ if (resourceBox.hasClass(`${filterType}-${filter}`)) {
+ validation[filterType] = true;
+ }
+ });
+ });
+
+ // If validation passes, show the resource.
+ if (Object.values(validation).every(Boolean)) {
+ hasMatches = true;
+ return true;
+ } else {
+ return false;
+ }
+ }).show();
+
+ // If there are no matches, show the no matches message
+ if (!hasMatches) {
+ $(".no-resources-found").show();
+ } else {
+ $(".no-resources-found").hide();
+ }
+}
+
+// Executed when the page has finished loading.
+document.addEventListener("DOMContentLoaded", function () {
+ /* Check if the user has navigated to one of the old resource pages,
+ like pydis.com/resources/communities. In this case, we'll rewrite
+ the URL before we do anything else. */
+ let resourceTypeInput = $("#resource-type-input").val();
+ if (resourceTypeInput !== "None") {
+ window.history.replaceState(null, document.title, `../?type=${resourceTypeInput}`);
+ }
+
+ // Update the filters on page load to reflect URL parameters.
+ $('.filter-box-tag').hide();
+ deserializeURLParams();
+ updateUI();
+
+ // If you collapse or uncollapse a filter group, swap the icon.
+ $('button.collapsible').on("click", function() {
+ let icon = $(this).find(".card-header-icon i");
+
+ if ($(icon).hasClass("fa-window-minimize")) {
+ $(icon).removeClass(["far", "fa-window-minimize"]);
+ $(icon).addClass(["fas", "fa-angle-down"]);
+ } else {
+ $(icon).removeClass(["fas", "fa-angle-down"]);
+ $(icon).addClass(["far", "fa-window-minimize"]);
+ }
+ });
+
+ // If this is a mobile device, collapse the categories to win back some screen real estate.
+ if (screen.width < 480) {
+ let categoryHeaders = $(".filter-category-header .collapsible-content");
+ let icons = $('.filter-category-header button .card-header-icon i');
+ categoryHeaders.addClass("no-transition");
+ categoryHeaders.css("max-height", 0);
+ icons.removeClass(["far", "fa-window-minimize"]);
+ icons.addClass(["fas", "fa-angle-down"]);
+ categoryHeaders.removeClass("no-transition");
+ }
+
+ // If you click on the div surrounding the filter checkbox, it clicks the corresponding checkbox.
+ $('.filter-panel').click(function() {
+ let checkbox = $(this).find(".filter-checkbox");
+ checkbox.prop("checked", !checkbox.prop("checked"));
+ checkbox.change();
+ });
+
+ // If you click on one of the tags in the filter box, it unchecks the corresponding checkbox.
+ $('.filter-box-tag').click(function() {
+ let filterItem = this.dataset.filterItem;
+ let filterName = this.dataset.filterName;
+ let checkbox = $(`.filter-checkbox[data-filter-name='${filterName}'][data-filter-item='${filterItem}']`);
+
+ removeFilter(filterName, filterItem);
+ checkbox.prop("checked", false);
+ });
+
+ // If you click on one of the tags in the resource cards, it clicks the corresponding checkbox.
+ $('.resource-tag').click(function() {
+ let filterItem = this.dataset.filterItem;
+ let filterName = this.dataset.filterName;
+ let checkbox = $(`.filter-checkbox[data-filter-name='${filterName}'][data-filter-item='${filterItem}']`);
+
+ if (!$(this).hasClass("active")) {
+ addFilter(filterName, filterItem);
+ checkbox.prop("checked", true);
+ } else {
+ removeFilter(filterName, filterItem);
+ checkbox.prop("checked", false);
+ }
+ });
+
+ // When checkboxes are toggled, trigger a filter update.
+ $('.filter-checkbox').change(function () {
+ let filterItem = this.dataset.filterItem;
+ let filterName = this.dataset.filterName;
+
+ if (this.checked) {
+ addFilter(filterName, filterItem);
+ } else {
+ removeFilter(filterName, filterItem);
+ }
+ });
+});