Skip to content

Commit

Permalink
add smooth animation transitions to tab content
Browse files Browse the repository at this point in the history
Auditors: @luixxiul
close brave#10883
  • Loading branch information
cezaraugusto committed Sep 21, 2017
1 parent c3def82 commit 33c5d10
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 7 deletions.
14 changes: 13 additions & 1 deletion app/renderer/components/styles/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@ const opacityIncreaseKeyframes = {
}
}

// TODO: this could be a function with param included
// to which property should be changed
const widthIncreaseKeyframes = (start, end) => ({
'from': {
width: start
},
'to': {
width: end
}
})

module.exports = {
spinKeyframes,
opacityIncreaseKeyframes
opacityIncreaseKeyframes,
widthIncreaseKeyframes
}
2 changes: 1 addition & 1 deletion app/renderer/components/styles/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// mimics chrome hover effect
transition: `
background-color 200ms cubic-bezier(0.26, 0.63, 0.39, 0.65),
color 200ms linear
color 200ms cubic-bezier(0.26, 0.63, 0.39, 0.65)
`,
background: '#ddd',
borderColor: '#bbb',
Expand Down
9 changes: 9 additions & 0 deletions app/renderer/components/tabs/content/audioTabIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const tabState = require('../../../../common/state/tabState')
const windowActions = require('../../../../../js/actions/windowActions')

// Styles
const {widthIncreaseKeyframes} = require('../../styles/animations')
const globalStyles = require('../../styles/global')
const {theme} = require('../../styles/theme')

Expand Down Expand Up @@ -71,6 +72,14 @@ class AudioTabIcon extends React.Component {

const styles = StyleSheet.create({
audioTab__icon: {
width: 0,
animationName: widthIncreaseKeyframes(0, globalStyles.spacing.iconSize),
animationDelay: '50ms',
animationTimingFunction: 'linear',
animationDuration: '100ms',
animationFillMode: 'forwards',

overflow: 'hidden',
margin: '0 -2px 0 2px',
zIndex: globalStyles.zindex.zindexTabsAudioTopBorder,
color: theme.tab.content.icon.audio.color,
Expand Down
6 changes: 4 additions & 2 deletions app/renderer/components/tabs/content/closeTabIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const appActions = require('../../../../../js/actions/appActions')

// Styles
const {theme} = require('../../styles/theme')
const {spacing} = require('../../styles/global')
const {spacing, zindex} = require('../../styles/global')
const {opacityIncreaseKeyframes} = require('../../styles/animations')
const closeTabSvg = require('../../../../extensions/brave/img/tabs/close_btn.svg')

Expand Down Expand Up @@ -91,10 +91,12 @@ const styles = StyleSheet.create({
willChange: 'opacity',
animationName: opacityIncreaseKeyframes,
animationTimingFunction: 'linear',
animationDuration: '100ms',
animationDuration: '200ms',
animationDelay: '25ms',
animationFillMode: 'forwards',

boxSizing: 'border-box',
zIndex: zindex.zindexTabsThumbnail,
backgroundImage: `url(${closeTabSvg})`,
backgroundSize: spacing.closeIconSize,
// mask icon to gray to avoid calling another icon on hover
Expand Down
10 changes: 9 additions & 1 deletion app/renderer/components/tabs/content/favIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const tabState = require('../../../../common/state/tabState')
const defaultIconSvg = require('../../../../extensions/brave/img/tabs/default.svg')
const loadingIconSvg = require('../../../../extensions/brave/img/tabs/loading.svg')
const {filter, color, spacing} = require('../../styles/global')
const {spinKeyframes} = require('../../styles/animations')
const {spinKeyframes, opacityIncreaseKeyframes} = require('../../styles/animations')

class Favicon extends React.Component {
mergeProps (state, ownProps) {
Expand Down Expand Up @@ -99,6 +99,14 @@ module.exports = ReduxComponent.connect(Favicon)

const styles = StyleSheet.create({
icon: {
opacity: 0,
willChange: 'opacity',
animationName: opacityIncreaseKeyframes,
animationDelay: '50ms',
animationTimingFunction: 'linear',
animationDuration: '200ms',
animationFillMode: 'forwards',

position: 'relative',
boxSizing: 'border-box',
width: spacing.iconSize,
Expand Down
9 changes: 9 additions & 0 deletions app/renderer/components/tabs/content/newSessionIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const frameStateUtil = require('../../../../../js/state/frameStateUtil')

// Styles
const globalStyles = require('../../styles/global')
const {opacityIncreaseKeyframes} = require('../../styles/animations')
const newSessionSvg = require('../../../../extensions/brave/img/tabs/new_session.svg')

class NewSessionIcon extends React.Component {
Expand Down Expand Up @@ -67,6 +68,14 @@ module.exports = ReduxComponent.connect(NewSessionIcon)

const styles = StyleSheet.create({
newSession__icon: {
opacity: 0,
willChange: 'opacity',
animationName: opacityIncreaseKeyframes,
animationDelay: '100ms',
animationTimingFunction: 'linear',
animationDuration: '200ms',
animationFillMode: 'forwards',

zIndex: globalStyles.zindex.zindexWindow,
boxSizing: 'border-box',
display: 'flex',
Expand Down
11 changes: 10 additions & 1 deletion app/renderer/components/tabs/content/privateIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const tabState = require('../../../../common/state/tabState')
// Styles
const {theme} = require('../../styles/theme')
const globalStyles = require('../../styles/global')
const {opacityIncreaseKeyframes} = require('../../styles/animations')
const privateSvg = require('../../../../extensions/brave/img/tabs/private.svg')

class PrivateIcon extends React.Component {
Expand Down Expand Up @@ -58,7 +59,15 @@ module.exports = ReduxComponent.connect(PrivateIcon)

const styles = StyleSheet.create({
private__icon: {
zIndex: 99,
opacity: 0,
willChange: 'opacity',
animationName: opacityIncreaseKeyframes,
animationDelay: '100ms',
animationTimingFunction: 'linear',
animationDuration: '200ms',
animationFillMode: 'forwards',

zIndex: globalStyles.zindex.zindexWindow,
boxSizing: 'border-box',
WebkitMaskRepeat: 'no-repeat',
WebkitMaskPosition: 'center',
Expand Down
1 change: 1 addition & 0 deletions app/renderer/components/tabs/content/tabTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TabTitle extends React.Component {
module.exports = ReduxComponent.connect(TabTitle)

const styles = StyleSheet.create({

tab__title: {
boxSizing: 'border-box',
display: 'flex',
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/components/tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ const styles = StyleSheet.create({
},

// this enable us to have gradient text
'::after': {
'::before': {
zIndex: globalStyles.zindex.zindexTabs,
content: '""',
position: 'absolute',
Expand Down

0 comments on commit 33c5d10

Please sign in to comment.