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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paper background support to side navigation #4881

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vanilla-framework",
"version": "4.3.0",
"version": "4.4.0",
"author": {
"email": "webteam@canonical.com",
"name": "Canonical Webteam"
Expand Down
6 changes: 6 additions & 0 deletions releases.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
- version: 4.4.0
features:
- component: Side navigation / Paper
url: /docs/patterns/navigation#paper
status: New
notes: We've added a support for paper background for the side navigation (via <code>is-paper</code> class on body element).
- version: 4.3.0
features:
- component: Logo section
Expand Down
27 changes: 26 additions & 1 deletion scss/_patterns_side-navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
.p-side-navigation--raw-html {
@include vf-side-navigation-raw-html-theme-light;

&.is-light {
&.is-dark {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drive-by: fixed a broken class name when switching from light theme to dark theme in raw HTML variant.

@include vf-side-navigation-raw-html-theme-dark;
}
}
Expand Down Expand Up @@ -723,6 +723,20 @@
$color-sidenav-list-border: $colors--light-theme--border-low-contrast,
$color-sidenav-toggle-icon: $colors--light-theme--text-inactive
);

.is-paper & {
@include vf-side-navigation-theme(
$color-sidenav-text-default: $colors--light-theme--text-inactive,
$color-sidenav-background-default: $color-paper,
$color-sidenav-background-overlay: $colors--light-theme--background-overlay,
$color-sidenav-text-active: $colors--light-theme--text-default,
$color-sidenav-item-background-active: $colors--paper-theme--background-active,
$color-sidenav-item-background-hover: $colors--paper-theme--background-hover,
$color-sidenav-item-border-highlight: $colors--light-theme--text-default,
$color-sidenav-list-border: $colors--light-theme--border-low-contrast,
$color-sidenav-toggle-icon: $colors--light-theme--text-inactive
);
}
}

@mixin vf-side-navigation-theme-dark {
Expand Down Expand Up @@ -804,6 +818,17 @@
$color-sidenav-item-border-highlight: $colors--light-theme--text-default,
$color-sidenav-list-border: $colors--light-theme--border-low-contrast
);

.is-paper {
@include vf-side-navigation-raw-html-theme(
$color-sidenav-text-default: $colors--light-theme--text-inactive,
$color-sidenav-text-active: $colors--light-theme--text-default,
$color-sidenav-item-background-active: $colors--paper-theme--background-active,
$color-sidenav-item-background-hover: $colors--paper-theme--background-hover,
$color-sidenav-item-border-highlight: $colors--light-theme--text-default,
$color-sidenav-list-border: $colors--light-theme--border-low-contrast
);
}
}

@mixin vf-side-navigation-raw-html-theme-dark {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- dark background color should be changed via color theme variables, inline style is used here for example purposes -->
{% endif %}
<nav class="p-side-navigation__drawer" aria-label="Example side navigation with icons"
style="background: {% if is_dark %}#003b4e{% else %}#f7f7f7{% endif %}">
style="background: {% if is_dark %}#003b4e{% elif is_paper %}transparent{% else %}#f7f7f7{% endif %}">
<div class="p-side-navigation__drawer-header" style="background: {% if is_dark %}#003b4e{% else %}#f7f7f7{% endif %}">
<a href="#" class="p-side-navigation__toggle--in-drawer js-drawer-toggle" aria-controls="drawer-icons">
Toggle side navigation
Expand Down
26 changes: 26 additions & 0 deletions templates/docs/examples/patterns/side-navigation/paper.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends "_layouts/examples.html" %}
{% block title %}Side navigation / Paper{% endblock %}

{% block standalone_css %}patterns_side-navigation{% endblock %}

{% set is_paper = True %}
{% block content %}
<div class="row">
<div class="col-4">
{% include "docs/examples/patterns/side-navigation/_default.html" %}
</div>
<div class="col-4">
{% include "docs/examples/patterns/side-navigation/_icons.html" %}
</div>
<div class="col-4">
{% with is_sticky = True %}
{% include "docs/examples/patterns/side-navigation/_default.html" %}
{% endwith %}
</div>
</div>

<script>
{% include "docs/examples/patterns/side-navigation/_example_script.js" %}
{% include "docs/examples/patterns/side-navigation/_toggle_script.js" %}
</script>
{% endblock %}
6 changes: 3 additions & 3 deletions tests/parker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function generateMetrics(file, metricsArray) {
{
name: 'Stylesheet size',
benchmark: 150000,
threshold: 380000,
threshold: 430000,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding more themes to side navigation increases the size of CSS noticeably.
It's OK, because in the end this additional CSS is quite repetitive and will GZIP nicely, so doesn't affect performance too much.

But we need to increase our allowed thresholds so that the tests pass.

result: results['total-stylesheet-size'],
},
{
Expand All @@ -37,13 +37,13 @@ function generateMetrics(file, metricsArray) {
{
name: 'Identifiers per selectors',
benchmark: 1.75,
threshold: 2.8,
threshold: 3.0,
result: results['identifiers-per-selector'],
},
{
name: 'Specificity per selector',
benchmark: 15,
threshold: 23,
threshold: 25,
result: results['specificity-per-selector'],
},
{
Expand Down