Skip to content

feat: refinement of knowledge panel rendering template. - #9890

Open
deveshidwivedi wants to merge 17 commits into
openfoodfacts:mainfrom
deveshidwivedi:simpler-template
Open

feat: refinement of knowledge panel rendering template.#9890
deveshidwivedi wants to merge 17 commits into
openfoodfacts:mainfrom
deveshidwivedi:simpler-template

Conversation

@deveshidwivedi

@deveshidwivedi deveshidwivedi commented Mar 9, 2024

Copy link
Copy Markdown
Contributor

What

Replaced inline styles with CSS classes for easier modification and better adaptability.

Related issue(s) and discussion

@deveshidwivedi
deveshidwivedi requested a review from a team as a code owner March 9, 2024 07:19
@github-actions github-actions Bot added 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels CSS Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. labels Mar 9, 2024
@codecov-commenter

codecov-commenter commented Mar 9, 2024

Copy link
Copy Markdown

❌ 17 Tests Failed:

Tests completed Failed Passed Skipped
9405 17 9388 0
View the top 3 failed test(s) by shortest run time
tests_integration_product_write_t::0020 - post-product-add-nutrition
Stack Traces | 0.0018s run time
not ok 0020 - post-product-add-nutrition
tests_integration_product_write_t::0008 - post-product-no-nutrition-data-on
Stack Traces | 0.00264s run time
not ok 0008 - post-product-no-nutrition-data-on
tests_integration_product_write_t::0014 - post-product-no-nutrition-data-off
Stack Traces | 0.00264s run time
not ok 0014 - post-product-no-nutrition-data-off
tests_integration_protected_product_t::0033 - edit-protected-product-web-form-moderator
Stack Traces | 0.00279s run time
not ok 0033 - edit-protected-product-web-form-moderator
tests_integration_protected_product_t::0021 - edit-protected-product-web-form
Stack Traces | 0.00372s run time
not ok 0021 - edit-protected-product-web-form
tests_integration_protected_product_t::0015 - edit-unprotected-product-web-form
Stack Traces | 0.00416s run time
not ok 0015 - edit-unprotected-product-web-form
tests_integration_page_crawler_t::0005 - crawler-access-product-page
Stack Traces | 0.00427s run time
not ok 0005 - crawler-access-product-page
tests_integration_web_html_t::0098 - world-product-content-only
Stack Traces | 0.00657s run time
not ok 0098 - world-product-content-only
tests_integration_web_html_t::0017 - world-product
Stack Traces | 0.00667s run time
not ok 0017 - world-product
tests_integration_page_crawler_t::0002 - normal-user-access-product-page
Stack Traces | 0.0071s run time
not ok 0002 - normal-user-access-product-page
tests_integration_web_html_t::0020 - fr-product
Stack Traces | 0.00732s run time
not ok 0020 - fr-product
tests_integration_web_html_t::0101 - world-product-smoothie
Stack Traces | 0.0102s run time
not ok 0101 - world-product-smoothie
tests_integration_web_html_t::0107 - world-search-scatter-plot-nutrition-sugars-fat
Stack Traces | 0.0117s run time
not ok 0107 - world-search-scatter-plot-nutrition-sugars-fat
tests_integration_web_html_t::0026 - fr-product-raw-panel
Stack Traces | 0.0121s run time
not ok 0026 - fr-product-raw-panel
tests_integration_product_read_t::0002 - get-existing-product
Stack Traces | 0.0127s run time
not ok 0002 - get-existing-product
tests_integration_web_html_t::0023 - fr-product-2
Stack Traces | 0.022s run time
not ok 0023 - fr-product-2
tests_integration_web_html_t::Test Plan Failure
Stack Traces | 61.3s run time
Errors were encountered (Count: 1)
    No plan was declared

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Comment thread scss/_product-page.scss Outdated
@stephanegigandet

Copy link
Copy Markdown
Contributor

Thank you @deveshidwivedi !

Could you separate the 2 changes (1: moving the CSS from the template to classes, and 2: how to see where the panel end)? It will be easier to merge the first 1 first.

For the left border, the idea was to show where the body of the panel ends (when the accordion is opened), so that's it's clearer what happens when the user closes the panel.

So the border should be on the panel title + content:

image

But we will have to try different ways, maybe it will look very busy with the border, and other solutions might be better.

@deveshidwivedi

Copy link
Copy Markdown
Contributor Author

I have removed the border from this PR as requested, thank you.

For the left border, the idea was to show where the body of the panel ends (when the accordion is opened), so that's it's clearer what happens when the user closes the panel.
So the border should be on the panel title + content

I am sorry to misunderstand, I now got how it was supposed to be, we could try out different styles before finally making a PR to address this.

But we will have to try different ways, maybe it will look very busy with the border, and other solutions might be better.

Sure!

@stephanegigandet

Copy link
Copy Markdown
Contributor

Hi @deveshidwivedi , have you been able to run your changes locally? I tried it but there's an issue with the icon image of all panels:

image

@deveshidwivedi

Copy link
Copy Markdown
Contributor Author

Hi @stephanegigandet! I have tried to correct the image icons, I had tried to run the changes locally but mistakenly made unrequired changes to the branch. Please have a look. Thank you.

Comment thread templates/web/panels/panel.tt.html Outdated
Comment thread templates/web/panels/panel.tt.html Outdated
Comment thread templates/web/panels/panel.tt.html Outdated
Comment thread templates/web/panels/panel.tt.html Outdated
@stephanegigandet

Copy link
Copy Markdown
Contributor

Hi @stephanegigandet! I have tried to correct the image icons, I had tried to run the changes locally but mistakenly made unrequired changes to the branch. Please have a look. Thank you.

Hi @deveshidwivedi , there are still some typos that prevent some CSS rules to work.

In order to make sure everything works, it would be good to test the product pages side by side: one side with your changes, and one side with the "main" branch, to check if you get visually similar results.

@github-actions github-actions Bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Mar 18, 2024
@deveshidwivedi

Copy link
Copy Markdown
Contributor Author

Hi! @stephanegigandet I did run make front_build and make restart successfully, I see similar knowledge panels on both the localhost and the website. Could you please confirm? Thank you!

@stephanegigandet

Copy link
Copy Markdown
Contributor

@deveshidwivedi Thank you, it looks good! There is a conflicting change:

<<<<<<< simpler-template
                <div id="tag_map" class="large-9 columns hidden">
                    <div id="container" class="custom-container"></div>
=======
                <div id="tag_map" class="large-9 columns" style="display: none;  z-index: 1;">
                    <div id="container" style="height: 300px; z-index: 1;"></div>
>>>>>>> main

Can you move the "z-index: 1;" to the customer-container scss, and resolve the merge conflict?

@deveshidwivedi

Copy link
Copy Markdown
Contributor Author

@stephanegigandet does this look fine?

@github-actions github-actions Bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Mar 21, 2024
@stephanegigandet

Copy link
Copy Markdown
Contributor

Updating the branch to solve the failing tests (en:Cheese)

@stephanegigandet stephanegigandet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@github-actions github-actions Bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Mar 26, 2024
@alexgarel

Copy link
Copy Markdown
Member

@deveshidwivedi can you resolve the conflict ?

@github-actions github-actions Bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Mar 26, 2024
@deveshidwivedi

Copy link
Copy Markdown
Contributor Author

Resolved! @alexgarel

Comment thread scss/_product-page.scss
@github-actions github-actions Bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Apr 4, 2024
@sonarqubecloud

sonarqubecloud Bot commented Apr 5, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@deveshidwivedi

Copy link
Copy Markdown
Contributor Author

Hi @stephanegigandet, please take a look at this. The merge conflicts are now resolved. Thank you.

@github-actions github-actions Bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Apr 5, 2024
@github-actions github-actions Bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Jul 12, 2024
@teolemon teolemon moved this from To triage to Needs review in 📖 Knowledge panels Jul 7, 2025
@teolemon

teolemon commented Aug 6, 2025

Copy link
Copy Markdown
Member

damn, merge conflict again @deveshidwivedi 😅
could you fix it, and then we merge. cc @alexgarel

…nd main features

Merge origin/main into simpler-template. Two conflicted paths;
everything else merged cleanly and is staged as-is.

Context of each side:

- This PR (simpler-template) de-inlines presentation from the knowledge
  panel template: templates/web/panels/panel.tt.html no longer carries
  style="..." attributes; the corresponding rules were moved into
  scss/_product-page.scss as reusable classes (.panel_small,
  .panel_margin_small/.panel_margin_large, .panel_title_small,
  .panel_icon very_small/small/large, .small-panel, .small-subtitle,
  .text-icon, .text-container, .valign-middle, .custom-class,
  .custom-container, .image_source, .hidden).

- main kept the inline styles but functionally extended the same areas
  of panel.tt.html: panels without elements now render an inactive
  accordion item (new has_elements variable, accordion-navigation-inactive
  class, <a> switched to <div> via IF has_elements); new title fallbacks
  (title -> name) plus new value_string / value (with percent type)
  subtitle branches; image imgid lookup and nutripatrol_url parameter;
  actions wrapped in <div>; table_id renamed to element.id; map block
  rewritten as an ES module import.

scss/_product-page.scss:

- Conflict was two independent additions at the end of the file.
  Resolution keeps both blocks verbatim: first the knowledge panel
  classes from this PR (required by the refactored template - dropping
  them would leave every panel size/icon/text rule undefined), then
  main's SVG barcode responsive rules (#barcode_div_code/#barcode_div_svg
  inline-block, hidden under 600px). No selector or declaration was
  modified; only the three conflict marker lines were removed.

templates/web/panels/panel.tt.html:

- wrapper_for_other_types header: applied main's functional changes on
  top of the PR's class-based markup. The <ul> keeps the
  panel_margin_[small|large] class instead of main's inline margins;
  the <li> gains main's accordion-navigation-inactive when
  has_elements is false; the title tag uses main's <a>/<div> switch
  while keeping the PR's panel_title_small class instead of main's
  inline padding style.

- subtitle block: kept the PR's class-based span for the existing
  subtitle branch, and grafted main's new value_string / value /
  percent branches onto it. Their inline style="font-size:0.9rem;"
  were expressed through the PR's equivalent small-subtitle class so
  that new content introduced by main follows this PR's stated goal
  (no inline styles in templates). Trailing whitespace from main's
  line was dropped.

- Everything outside the conflict regions is the auto-merge result:
  main's has_elements logic, name/title fallback, value_string/value
  branches, image handling, action wrappers, table id and module-based
  map are all retained unchanged.

Verification: no conflict markers remain; Template::Toolkit directive
counts of the resolved file (opens 65 / ends 67) match main's side
exactly, with the same pre-existing +2 comment-banner offset already
present in both parents, so no block was broken by the resolution.

Merge conflict resolved by Ox Alpha Free (Unlimited), running via
OpenCode Zen.

Co-authored-by: hangy <hangy@hangy.de>
@github-actions github-actions Bot added 💥 Merge Conflicts 💥 Merge Conflicts and removed 💥 Merge Conflicts 💥 Merge Conflicts labels Aug 22, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@github-actions github-actions Bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes.

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

Simplify the templates that render knowledge panels on the web

5 participants