From 2b8fa43f7244b21664dd43022c8c3ddbed3bbe1e Mon Sep 17 00:00:00 2001 From: Stephen Sprinkle Date: Thu, 27 Apr 2017 11:31:23 -0600 Subject: [PATCH] initial transition of notification component + established custom properties for animation speeds to be more easily accessible via JS + updated documentation --- docs/conventions.md | 1 + src/modules/app/components/nav.jsx | 36 ++++++++++++--- src/modules/app/less/animations.less | 9 ++++ .../less/notifications-view.less | 44 ++++++++++++++++--- 4 files changed, 78 insertions(+), 12 deletions(-) diff --git a/docs/conventions.md b/docs/conventions.md index e7be6319fe..d800cf3afe 100644 --- a/docs/conventions.md +++ b/docs/conventions.md @@ -58,6 +58,7 @@ To help ensure this, the following conventions have been employed: * The full breadth of Less's functionality is permissible. * All external borders (parent level components within a view) should be the normal border color * All internal borders should be either muted or light (depending on the application) +* When utilizing `CSSTransitionGroup`, styling of this wrapper should be housed within the rendered child's stylesheet ### Other Conventions Above are the main points, but additional structural and styling conventions of the stylesheets themselves are enforced through linting. diff --git a/src/modules/app/components/nav.jsx b/src/modules/app/components/nav.jsx index 46c137ff65..bf0e203a01 100644 --- a/src/modules/app/components/nav.jsx +++ b/src/modules/app/components/nav.jsx @@ -1,5 +1,5 @@ import React, { Component, PropTypes } from 'react'; - +import CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup'; import classnames from 'classnames'; import Link from 'modules/link/components/link'; @@ -22,10 +22,21 @@ export default class Nav extends Component { super(props); this.state = { - isNotificationsVisible: false + isNotificationsVisible: false, + notificationIconXOffset: null, + notificationIconYOffset: null }; this.collapseFooter = this.collapseFooter.bind(this); + this.setNotificationIconOffeset = this.setNotificationIconOffeset.bind(this); + } + + componentDidMount() { + this.setNotificationIconOffeset(); + } + + setNotificationIconOffeset() { + console.log('### setNotificationIconOffeset -- ', this.notificationBell); } collapseFooter() { @@ -38,6 +49,9 @@ export default class Nav extends Component { const p = this.props; const s = this.state; + const animationInSpeed = parseInt(window.getComputedStyle(document.body).getPropertyValue('--animation-speed-fast'), 10); + const animationOutSpeed = parseInt(window.getComputedStyle(document.body).getPropertyValue('--animation-speed-very'), 10); + return ( ); } diff --git a/src/modules/app/less/animations.less b/src/modules/app/less/animations.less index 4897f92e22..bb2dbdceb5 100644 --- a/src/modules/app/less/animations.less +++ b/src/modules/app/less/animations.less @@ -11,6 +11,15 @@ @animation-speed-fast: 300ms; @animation-speed-very-fast: 200ms; +// For accessibility w/in JS +body { + --animation-speed-very-fast: @animation-speed-very-fast; + --animation-speed-slow: @animation-speed-slow; + --animation-speed-normal: @animation-speed-normal; + --animation-speed-fast: @animation-speed-fast; + --animation-speed-very-fast: @animation-speed-very-fast; +} + @animation-direction-up: 'up'; @animation-direction-right: 'right'; @animation-direction-down: 'down'; diff --git a/src/modules/notifications/less/notifications-view.less b/src/modules/notifications/less/notifications-view.less index e17b6463f1..d8a538bac1 100644 --- a/src/modules/notifications/less/notifications-view.less +++ b/src/modules/notifications/less/notifications-view.less @@ -1,10 +1,42 @@ -#notifications_view { - .border(true); - - background-color: @color-white; +#transition_notifications_view { bottom: 0; - margin: 0; position: absolute; transform: translateY(100%); - width: 300px; + + #notifications_view { + .border(true); + + background-color: @color-white; + margin: 0; + width: 300px; + + &.notifications-enter { + opacity: 0; + + &.notifications-enter-active { + opacity: 1; + transition-duration: @animation-speed-fast; + transition-property: opacity; + transition-timing-function: @animation-default-type; + } + } + + &.notifications-leave { + opacity: 1; + + &.notifications-leave-active { + opacity: 0; + transition-duration: @animation-speed-very-fast; + transition-property: opacity; + transition-timing-function: @animation-default-type; + } + } + + h3 { + .border(true, @border-bottom); + .font-color-dark(); + + padding-left: 1em; + } + } }