From 901b0bcc4c39267ddb43833a6b20dc4ca2cecfed Mon Sep 17 00:00:00 2001 From: PierreDillard <7gaspard77@gmail.com> Date: Fri, 15 Nov 2024 10:03:47 +0100 Subject: [PATCH 1/3] refactor(theme): move hashed file references from base.html to main.js - Moved problematic hashed file references from base.html: - assets/javascripts/bundle.83f73b43.min.js - assets/javascripts/workers/search.6ce7567c.min.js --- overrides/main.html | 79 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/overrides/main.html b/overrides/main.html index d2c31128..a9b872ce 100644 --- a/overrides/main.html +++ b/overrides/main.html @@ -1,10 +1,69 @@ -{#- - This file was automatically generated - do not edit - -#} - {% extends "base.html" %} - - {% block content %} -
- {{ page.content }} -
-{% endblock %} \ No newline at end of file +{#- + This file is an override of the original base.html + It includes only custom blocks. Do not edit the original base.html directly. +-#} + +{% extends "base.html" %} + +{# Block Scripts: Ajout de vos scripts personnalisés #} +{% block scripts %} + + + {% for script in config.extra_javascript %} + {{ script | script_tag }} + {% endfor %} +{% endblock %} + +{# Block Styles: Ajout de vos feuilles de style personnalisées #} +{% block styles %} + + {% if config.theme.palette %} + {% set palette = config.theme.palette %} + + {% endif %} + {% include "partials/icons.html" %} +{% endblock %} + +{# Block Config: Ajout ou modification de configuration JSON #} +{% block config %} + {%- set app = { + "base": base_url, + "features": features, + "translations": {}, + "search": "assets/javascripts/workers/search.6ce7567c.min.js" | url + } -%} + {%- if config.extra.version -%} + {%- set mike = config.plugins.get("mike") -%} + {%- if not mike or mike.config.version_selector -%} + {%- set _ = app.update({ "version": config.extra.version }) -%} + {%- endif -%} + {%- endif -%} + {%- if config.extra.tags -%} + {%- set _ = app.update({ "tags": config.extra.tags }) -%} + {%- endif -%} + {%- set translations = app.translations -%} + {%- for key in [ + "clipboard.copy", + "clipboard.copied", + "search.result.placeholder", + "search.result.none", + "search.result.one", + "search.result.other", + "search.result.more.one", + "search.result.more.other", + "search.result.term.missing", + "select.version" + ] -%} + {%- set _ = translations.update({ key: lang.t(key) }) -%} + {%- endfor -%} + +{% endblock %} + +{# Block Content: Personnalisation de la zone de contenu principal si nécessaire #} +{% block content %} +
+ {{ page.content }} +
+{% endblock %} From ac7204e8678aadd09b6e64f43ab370ca512e36fe Mon Sep 17 00:00:00 2001 From: PierreDillard <7gaspard77@gmail.com> Date: Fri, 15 Nov 2024 14:24:12 +0100 Subject: [PATCH 2/3] fix(feedback): fix feedback widget interference with sidebar navigation - Modified feedback behavior to properly hide after submission --- docs/javascripts/main.js | 95 +++++++++++++++++------------------ docs/stylesheets/feedback.css | 44 ++++++++++++++++ overrides/main.html | 9 ---- 3 files changed, 89 insertions(+), 59 deletions(-) diff --git a/docs/javascripts/main.js b/docs/javascripts/main.js index a1ed4f08..727a7505 100644 --- a/docs/javascripts/main.js +++ b/docs/javascripts/main.js @@ -103,71 +103,66 @@ function handlePopState() { } // Feedback -function initializeFeedback(selector) { - try { - const feedback = document.querySelector(selector); - if (!feedback) return; - const buttons = feedback.querySelectorAll('.md-feedback__icon:not(.md-feedback__contribute)'); - const note = getFeedbackNote(feedback); +// Feedback State Management +const FeedbackState = { + INITIAL: 'initial', + SUBMITTED: 'submitted' +}; - buttons.forEach(button => { - button.addEventListener('click', () => handleFeedbackClick(button, buttons, note)); +function initializeFeedback(selector) { + const feedback = document.querySelector(selector); + if (!feedback) return; + + const buttons = feedback.querySelectorAll('.md-feedback__icon:not(.md-feedback__contribute)'); + const feedbackContainer = feedback.querySelector('.md-feedback__inner'); + const feedbackNote = feedback.querySelector('.md-feedback__note'); + let currentState = FeedbackState.INITIAL; + + buttons.forEach(button => { + button.addEventListener('click', () => { + handleFeedbackClick(button, buttons, feedbackContainer, feedbackNote); + initializeContributeIcon(feedback); }); + }); - initializeContributeIcon(feedback); - } catch (error) { - console.error("Error in initializeFeedback:", error); - } -} - -function getFeedbackNote(feedback) { - try { - let note = feedback.querySelector('.md-feedback__note'); - if (!note) { - note = document.createElement('div'); - note.className = 'md-feedback__note'; - note.hidden = true; - feedback.querySelector('.md-feedback__inner').appendChild(note); - } - return note; - } catch (error) { - console.error("Error in getFeedbackNote:", error); - return null; - } -} - -function handleFeedbackClick(button, allButtons, note) { - try { + function handleFeedbackClick(button, allButtons, container, note) { const data = button.getAttribute('data-md-value'); - const url = `/${window.location.pathname}`; - const title = document.querySelector('.md-content__inner h1')?.textContent || ''; - - console.log(`Feedback: ${data} for page ${url} (${title})`); - - note.textContent = `Thank you for your feedback!`; - note.hidden = false; + + + // Disable all buttons allButtons.forEach(btn => btn.disabled = true); - } catch (error) { - console.error("Error in handleFeedbackClick:", error); + + // Show thank you message using existing note element + if (note) { + note.textContent = 'Thank you for your feedback!'; + note.hidden = false; + } + + // Fade out and hide feedback after delay + setTimeout(() => { + feedback.classList.add('md-feedback--fade-out'); + setTimeout(() => { + feedback.style.display = 'none'; + }, 100); + }, 1000); } } function initializeContributeIcon(feedback) { - try { - const contributeIcon = feedback.querySelector('.md-feedback__contribute'); - const contributeNote = feedback.querySelector('.md-feedback__contribute-note'); + const contributeIcon = feedback.querySelector('.md-feedback__contribute'); + const contributeNote = feedback.querySelector('.md-feedback__contribute-note'); - if (contributeIcon && contributeNote) { - contributeIcon.addEventListener('mouseenter', () => contributeNote.hidden = false); - contributeIcon.addEventListener('mouseleave', () => contributeNote.hidden = true); - } - } catch (error) { - console.error("Error in initializeContributeIcon:", error); + if (contributeIcon && contributeNote) { + contributeIcon.addEventListener('mouseenter', () => contributeNote.hidden = false); + contributeIcon.addEventListener('mouseleave', () => contributeNote.hidden = true); } } + + + // Collapse function handleSearchPageCollapse() { try { diff --git a/docs/stylesheets/feedback.css b/docs/stylesheets/feedback.css index f39e7b90..74d4d912 100644 --- a/docs/stylesheets/feedback.css +++ b/docs/stylesheets/feedback.css @@ -22,6 +22,50 @@ flex-direction: column; align-items: flex-start; } +.md-feedback__inner--fade-out { + opacity: 0; + transform: translateY(10px); + transition: opacity 0.2s ease, transform 0.2s ease; +} + +.md-feedback__indicator { + display: flex; + align-items: center; + justify-content: center; + padding: 8px; + border-radius: 4px; + background-color: #fff; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); + margin-top: 8px; +} + +.md-feedback__indicator.hidden { + display: none; +} + +.md-feedback__indicator i { + margin-right: 8px; + font-size: 16px; +} + +.feedback-success { + color: #45a049; +} + +.feedback-neutral { + color: #666; +} + +.md-feedback--fade-out { + opacity: 0; + transform: translateY(-10px); + transition: opacity 0.3s ease, transform 0.3s ease; +} + +.feedback-text { + font-size: 12px; + color: #666; +} .md-feedback__list, .md-nav__feedback .md-feedback__list { diff --git a/overrides/main.html b/overrides/main.html index a9b872ce..e6a90786 100644 --- a/overrides/main.html +++ b/overrides/main.html @@ -1,11 +1,5 @@ -{#- - This file is an override of the original base.html - It includes only custom blocks. Do not edit the original base.html directly. --#} - {% extends "base.html" %} -{# Block Scripts: Ajout de vos scripts personnalisés #} {% block scripts %} @@ -14,7 +8,6 @@ {% endfor %} {% endblock %} -{# Block Styles: Ajout de vos feuilles de style personnalisées #} {% block styles %} {% if config.theme.palette %} @@ -24,7 +17,6 @@ {% include "partials/icons.html" %} {% endblock %} -{# Block Config: Ajout ou modification de configuration JSON #} {% block config %} {%- set app = { "base": base_url, @@ -61,7 +53,6 @@ {% endblock %} -{# Block Content: Personnalisation de la zone de contenu principal si nécessaire #} {% block content %}
{{ page.content }} From 7de5eca687c0c931fbd220f2b38b64463a8760e8 Mon Sep 17 00:00:00 2001 From: PierreDillard <7gaspard77@gmail.com> Date: Mon, 18 Nov 2024 11:55:54 +0100 Subject: [PATCH 3/3] Optimize feedback component layout and behavior - Minimize feedback component vertical space with horizontal layout - Restore message after feedback submission - Update feedback partial to avoid modify base.html --- docs/stylesheets/extra.css | 2 +- docs/stylesheets/feedback.css | 33 ++------ overrides/base.html | 118 +++++++++++++++++++------- overrides/partials/feedback.html | 140 ++++++++++++++++++++----------- 4 files changed, 188 insertions(+), 105 deletions(-) diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 31cc8969..8e50ad43 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -115,7 +115,7 @@ .md-nav--secondary { flex: 1; - margin-bottom: 5rem; + margin-bottom: 5.5rem; } .keywords-cloud-container { diff --git a/docs/stylesheets/feedback.css b/docs/stylesheets/feedback.css index 74d4d912..b9ce717a 100644 --- a/docs/stylesheets/feedback.css +++ b/docs/stylesheets/feedback.css @@ -3,16 +3,15 @@ } .md-feedback, .md-nav__feedback { - padding: 1rem; - margin-top: 1rem; - border-top: 1px solid var(--md-default-fg-color--lightest); + padding: 0.1rem; + } .md-feedback p, .md-nav__feedback p { - margin: 0 0 0.5rem; + margin: 0 0 0.1rem; font-weight: 700; - font-size: 0.8rem; + font-size: 0.7rem; color: var(--md-default-fg-color--light); } @@ -20,7 +19,7 @@ .md-nav__feedback .md-feedback__inner { display: flex; flex-direction: column; - align-items: flex-start; + align-items: center; } .md-feedback__inner--fade-out { opacity: 0; @@ -28,25 +27,8 @@ transition: opacity 0.2s ease, transform 0.2s ease; } -.md-feedback__indicator { - display: flex; - align-items: center; - justify-content: center; - padding: 8px; - border-radius: 4px; - background-color: #fff; - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); - margin-top: 8px; -} -.md-feedback__indicator.hidden { - display: none; -} -.md-feedback__indicator i { - margin-right: 8px; - font-size: 16px; -} .feedback-success { color: #45a049; @@ -77,7 +59,6 @@ .md-feedback__icon, .md-nav__feedback .md-feedback__icon { margin-right: 0.5rem; - padding: 0.25rem; background: none; border: none; cursor: pointer; @@ -113,9 +94,9 @@ display: block; position: fixed; bottom: 4%; + background-color: var(--md-default-bg-color); - box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), - 0 4px 6px -2px rgba(0, 0, 0, 0.05); + border-radius: 0.2rem; } diff --git a/overrides/base.html b/overrides/base.html index f76e8f0c..d0407e7b 100644 --- a/overrides/base.html +++ b/overrides/base.html @@ -206,40 +206,96 @@ {% if config.extra.analytics %} {% set feedback = config.extra.analytics.feedback %} {% if feedback %} -
- -
-
- {% for rating in feedback.ratings %} - - {% endfor %} - - {% include ".icons/material/plus-circle.svg" %} - + -
-
-

{{ feedback.title }}

-
-
- {% for rating in feedback.ratings %} - - {% endfor %} - - {% include ".icons/material/plus-circle.svg" %} - + + +
+ + {# Mobile feedback section - same structure #} +
+
-
- {% endif %} + + +
{% endif %} + {% endif %}
{% endif %} {% endblock %} diff --git a/overrides/partials/feedback.html b/overrides/partials/feedback.html index d48551f3..db03cc95 100644 --- a/overrides/partials/feedback.html +++ b/overrides/partials/feedback.html @@ -1,50 +1,96 @@ - - - \ No newline at end of file + {% endif %} \ No newline at end of file