Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Added animation, content wrapper and small fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHirt committed May 11, 2020
1 parent 2a7d025 commit 2aea840
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 125 deletions.
2 changes: 1 addition & 1 deletion changelog/unreleased/deprecated-application-menu-component
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Change: Deprecated application menu component

We've deprecated application menu component in favor of the sidebar component.
We've deprecated the application menu component in favor of the sidebar component.

https://github.com/owncloud/owncloud-design-system/pull/735
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Created animation section in docs

We've added an animation section in the documentation to show available animations and how to use them.

https://github.com/owncloud/owncloud-design-system/pull/735
7 changes: 7 additions & 0 deletions config/docs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ module.exports = {
usageMode: "hide",
sectionDepth: 1,
},
{
name: "Animations",
content: "../docs/animations.md",
exampleMode: "hide",
usageMode: "hide",
sectionDepth: 1,
},
{
name: "Use of ARIA",
content: "../docs/use-of-aria.md",
Expand Down
8 changes: 8 additions & 0 deletions docs/animations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## How to use animations
To see how to use animations, please follow [transitions section of Vue.js documentation](https://vuejs.org/v2/guide/transitions.html). As a name of the transition, it is possible to use any of the following animations.

## Available animations
| Name | Description |
| -------------- | ----------- |
| fade | The element fades in |
| push-right | The element slides from the left side and pushes the element to the right. It might be necessary to include a content wrapper with fixed width inside of the element to prevent deformation of the element. |
4 changes: 2 additions & 2 deletions src/elements/OcSidebar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const defaultProps = {
}

describe("OcSidebar", () => {
it('displays a logo image if its source is specified', () => {
it('displays a logo image if its source is specified', () => {
const logoSrc = 'https://owncloud.org/wp-content/themes/owncloud/img/owncloud-org-logo.svg'
const wrapper = shallowMount(Sidebar, {
propsData: {
Expand Down Expand Up @@ -78,6 +78,6 @@ describe("OcSidebar", () => {

wrapper.find('.oc-sidebar-button-close').trigger('click')
await wrapper.vm.$nextTick()
expect(wrapper.emitted().closed).toBeTruthy()
expect(wrapper.emitted().close).toBeTruthy()
})
})
88 changes: 45 additions & 43 deletions src/elements/OcSidebar.vue
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
<template>
<div :class="$_ocSidebar_classes">
<oc-button
v-if="fixed"
class="oc-sidebar-button-close"
variation="raw"
@click.native="$_ocSidebar_buttonClose_click"
:aria-label="closeButtonLabel"
>
<oc-icon name="close" aria-hidden="true" />
</oc-button>
<router-link to="/" class="oc-sidebar-logo">
<oc-img
v-if="logoImg"
key="logo-image"
:src="logoImg"
:alt="productName"
class="oc-sidebar-logo-img"
/>
<span v-else key="product-name" class="oc-sidebar-logo-text" v-text="productName" />
</router-link>
<div v-if="$slots.upperContent" class="oc-sidebar-upper-content">
<!-- @slot Content above the navigation block -->
<slot name="upperContent" />
</div>
<nav :class="[{ 'uk-margin-bottom' : $slots.footer }, 'oc-sidebar-nav']">
<ul>
<oc-sidebar-nav-item
v-for="item in navItems"
:key="item.route.path"
:icon="item.icon || item.iconMaterial"
:active="item.active"
:target="item.route.path"
class="oc-sidebar-nav-item"
>
{{ item.name }}
</oc-sidebar-nav-item>
</ul>
</nav>
<div v-if="$slots.footer" class="oc-sidebar-footer">
<!-- @slot Footer of the sidebar -->
<slot name="footer" />
<div class="oc-sidebar-content-wrapper">
<oc-button
v-if="fixed"
class="oc-sidebar-button-close"
variation="raw"
@click.native="$_ocSidebar_buttonClose_click"
:aria-label="closeButtonLabel"
>
<oc-icon name="close" aria-hidden="true" />
</oc-button>
<router-link to="/" class="oc-sidebar-logo">
<oc-img
v-if="logoImg"
key="logo-image"
:src="logoImg"
:alt="productName"
class="oc-sidebar-logo-img"
/>
<span v-else key="product-name" class="oc-sidebar-logo-text" v-text="productName" />
</router-link>
<div v-if="$slots.upperContent" class="oc-sidebar-upper-content">
<!-- @slot Content above the navigation block -->
<slot name="upperContent" />
</div>
<nav :class="[{ 'uk-margin-bottom' : $slots.footer }, 'oc-sidebar-nav']">
<ul>
<oc-sidebar-nav-item
v-for="item in navItems"
:key="item.route.path"
:icon="item.icon || item.iconMaterial"
:active="item.active"
:target="item.route.path"
class="oc-sidebar-nav-item"
>
{{ item.name }}
</oc-sidebar-nav-item>
</ul>
</nav>
<div v-if="$slots.footer" class="oc-sidebar-footer">
<!-- @slot Footer of the sidebar -->
<slot name="footer" />
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -90,7 +92,7 @@ export default {
fixed: {
type: Boolean,
required: false,
defult: false
default: false
},
/**
* Accessibility label of the close button
Expand Down Expand Up @@ -119,7 +121,7 @@ export default {
/**
* The user clicked on the close button
*/
this.$emit("closed")
this.$emit("close")
}
}
}
Expand Down Expand Up @@ -195,7 +197,7 @@ The navigation block will automatically receive bottom margin in case the `foote
<strong class="oc-light">Files app</strong>
</template>
<template v-slot:footer>
<small slot="footer" class="oc-light">
<small class="oc-light">
Made by ownClouders
</small>
</template>
Expand Down
154 changes: 81 additions & 73 deletions src/elements/__snapshots__/OcSidebar.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,100 @@

exports[`OcSidebar Sets fixed position 1`] = `
<div class="oc-sidebar oc-sidebar-fixed">
<oc-button-stub type="button" arialabel="Close sidebar" variation="raw" class="oc-sidebar-button-close">
<oc-icon-stub name="close" arialabel="icon" type="span" size="small" variation="system" aria-hidden="true"></oc-icon-stub>
</oc-button-stub>
<router-link-stub tag="a" to="/" class="oc-sidebar-logo"><span class="oc-sidebar-logo-text">ownCloud</span></router-link-stub>
<!---->
<nav class="oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<!---->
<div class="oc-sidebar-content-wrapper">
<oc-button-stub type="button" arialabel="Close sidebar" variation="raw" class="oc-sidebar-button-close">
<oc-icon-stub name="close" arialabel="icon" type="span" size="small" variation="system" aria-hidden="true"></oc-icon-stub>
</oc-button-stub>
<router-link-stub tag="a" to="/" class="oc-sidebar-logo"><span class="oc-sidebar-logo-text">ownCloud</span></router-link-stub>
<!---->
<nav class="oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<!---->
</div>
</div>
`;

exports[`OcSidebar displays a logo image if its source is specified 1`] = `
exports[`OcSidebar displays a logo image if its source is specified 1`] = `
<div class="oc-sidebar">
<!---->
<router-link-stub tag="a" to="/" class="oc-sidebar-logo">
<oc-img-stub src="https://owncloud.org/wp-content/themes/owncloud/img/owncloud-org-logo.svg" alt="ownCloud" class="oc-sidebar-logo-img"></oc-img-stub>
</router-link-stub>
<!---->
<nav class="oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<!---->
<div class="oc-sidebar-content-wrapper">
<!---->
<router-link-stub tag="a" to="/" class="oc-sidebar-logo">
<oc-img-stub src="https://owncloud.org/wp-content/themes/owncloud/img/owncloud-org-logo.svg" alt="ownCloud" class="oc-sidebar-logo-img"></oc-img-stub>
</router-link-stub>
<!---->
<nav class="oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<!---->
</div>
</div>
`;

exports[`OcSidebar displays nav items 1`] = `
<div class="oc-sidebar">
<!---->
<router-link-stub tag="a" to="/" class="oc-sidebar-logo"><span class="oc-sidebar-logo-text">ownCloud</span></router-link-stub>
<!---->
<nav class="oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<!---->
<div class="oc-sidebar-content-wrapper">
<!---->
<router-link-stub tag="a" to="/" class="oc-sidebar-logo"><span class="oc-sidebar-logo-text">ownCloud</span></router-link-stub>
<!---->
<nav class="oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<!---->
</div>
</div>
`;

exports[`OcSidebar displays upperContent and footer slots 1`] = `
<div class="oc-sidebar">
<!---->
<router-link-stub tag="a" to="/" class="oc-sidebar-logo"><span class="oc-sidebar-logo-text">ownCloud</span></router-link-stub>
<div class="oc-sidebar-upper-content"><strong class="upper-slot">Files app</strong></div>
<nav class="uk-margin-bottom oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<div class="oc-sidebar-footer"><small slot="footer" class="footer-slot">Made by ownClouders</small></div>
<div class="oc-sidebar-content-wrapper">
<!---->
<router-link-stub tag="a" to="/" class="oc-sidebar-logo"><span class="oc-sidebar-logo-text">ownCloud</span></router-link-stub>
<div class="oc-sidebar-upper-content"><strong class="upper-slot">Files app</strong></div>
<nav class="uk-margin-bottom oc-sidebar-nav">
<ul>
<oc-sidebar-nav-item-stub target="/" icon="home" class="oc-sidebar-nav-item">
Home
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub target="/files" icon="folder" class="oc-sidebar-nav-item">
All files
</oc-sidebar-nav-item-stub>
<oc-sidebar-nav-item-stub active="true" target="/shared" icon="share" class="oc-sidebar-nav-item">
Shared files
</oc-sidebar-nav-item-stub>
</ul>
</nav>
<div class="oc-sidebar-footer"><small slot="footer" class="footer-slot">Made by ownClouders</small></div>
</div>
</div>
`;
2 changes: 2 additions & 0 deletions src/styles/_owncloud.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
@import "theme/login";
@import "theme/menu-secondary";

@import "theme/animations.scss";

@import "theme/oc-alert";
@import "theme/oc-app-container";
@import "theme/oc-app-menu";
Expand Down
2 changes: 2 additions & 0 deletions src/styles/theme/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ $global-danger-background: $danger-background;
$global-border: #ccd4e0;

$navbar-nav-item-height: 60px;

$transitions-length: 500ms;
25 changes: 25 additions & 0 deletions src/styles/theme/animations.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Fade
*/
.fade-enter-active,
.fade-leave-active {
transition: opacity $transitions-length ease-in-out;
}

.fade-enter,
.fade-leave-to {
opacity: 0;
}

/**
* Push right
*/
.push-right-enter-active,
.push-right-leave-active {
transition: width $transitions-length ease-in-out;
}

.push-right-enter,
.push-right-leave-to {
width: 0 !important;
}
Loading

0 comments on commit 2aea840

Please sign in to comment.