Skip to content
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

Add component menu #4414

Merged
merged 10 commits into from
Apr 20, 2022

Conversation

albertkol
Copy link
Contributor

@albertkol albertkol commented Apr 14, 2022

Done

Add component_tabs.yaml file that stores the /docs tab menu. It will be the source of truth for when the menu shows up on each docs page and which tab items get displayed (design/accessibility).

Structure of the component_tabs.yaml:

patterns/accordion:
  accessibility: True
  design_guidelines: False 

This PR add the menu only for the accordion docs page, future pages will be added in a separate PR.

QA

Screenshots

image

@webteam-app
Copy link

Demo starting at https://vanilla-framework-4414.demos.haus

@albertkol albertkol changed the base branch from main to new-vanilla-website April 14, 2022 12:46
@albertkol albertkol changed the title WIP Add component menu Add component menu Apr 19, 2022
Copy link
Contributor

@bethcollins92 bethcollins92 left a comment

Choose a reason for hiding this comment

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

Woooo nice job Albert! I'm not the most qualified to review the python but it LGTM!

templates/_layouts/_component_tabs.html Show resolved Hide resolved
templates/_layouts/_component_tabs.html Show resolved Hide resolved
@bethcollins92
Copy link
Contributor

@bartaz do you want to have a look too?

@@ -28,7 +28,7 @@

{% macro side_nav_item(url, title, label, type) -%}
<li class="p-side-navigation__item">
<a class="p-side-navigation__link" href="{{ url }}" {% if path == url %}aria-current="page"{% endif %}>
<a class="p-side-navigation__link" href="{{ url }}" {% if (slug and slug in url) or (url == path) %}aria-current="page"{% endif %}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Are both parts of this conditional needed? Would only (slug and slug in url) work or does it need the url == path for some other cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially I had only slug in url then highlight side menu item. It was broken for the home page, where slug is "" making the condition true for all menu items, so everything was highlighted.

It's not the prettiest condition.. I agree.

@bartaz
Copy link
Contributor

bartaz commented Apr 19, 2022

All the pages have duplicated titles:

image

I'm not sure if that's something to be addressed later? Is it just a matter or removing title from markdown and keeping it in meta data only?

@@ -155,7 +155,13 @@
</aside>

<main class="col-9" id="main-content">
{% block content %}{{ content | safe }}{% endblock content %}
{% block content %}
<h1>{{ title.split('|')[0] | safe }}</h1>
Copy link
Contributor

@bartaz bartaz Apr 19, 2022

Choose a reason for hiding this comment

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

I think we can drop | safe here, we don't want any HTML code passed from title to the page (there shouldn't be any HTML there anyway), so this should be enough:

Suggested change
<h1>{{ title.split('|')[0] | safe }}</h1>
<h1>{{ title.split('|')[0] }}</h1>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a fix for the double titles problem and removed safe.

@@ -146,7 +147,24 @@ def global_template_context():
version_parts = VANILLA_VERSION.split(".")
version_minor = f"{version_parts[0]}.{version_parts[1]}"

return {"version": VANILLA_VERSION, "versionMinor": version_minor, "path": flask.request.path}
docs_slug = flask.request.path.replace("/docs/", "")
docs_slug = docs_slug.replace("/design/", "")
Copy link
Contributor

@andesol andesol Apr 19, 2022

Choose a reason for hiding this comment

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

I'm sure there's a good reason not to... but why not chaining the replace method instead of reassigning the variable several times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The max 80 char per line rule.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think something like this would do the trick: (It's not particularly pretty, though... Feel free to leave as it is)

docs_slug = (
    flask.request.path.replace("/docs/", "")
    .replace("/design/", "")
    .replace("/accessibility", "")
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion! I will try it.

@albertkol albertkol deleted the add-component-menu branch April 20, 2022 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants