diff --git a/components/tabs/style.scss b/components/tabs/style.scss new file mode 100644 index 00000000..dafa3643 --- /dev/null +++ b/components/tabs/style.scss @@ -0,0 +1,72 @@ +@import "../variables"; + +$tab-text: $color-black !default; +$tab-text-color: unquote("rgb(#{$tab-text})") !default; +$tab-text-inactive-color: unquote("rgba(#{$tab-text}, 0.70)") !default; +$tab-pointer-height: .2 * $unit; +$tab-pointer-color: unquote("rgb(#{$color-primary})") !default; +$tab-navigation-border-color: $color-divider; +$tab-text-height: 1.4 * $unit; +$tab-label-height: 4.8 * $unit; +$tab-label-h-padding: 1.2 * $unit; +$tab-label-v-padding: ($tab-label-height - $tab-text-height) / 2; +$tab-label-disabled-opacity: .2; + +.root { + position: relative; +} + +.navigation { + box-shadow: inset 0 -1px $tab-navigation-border-color; +} + +.label { + padding: $tab-label-v-padding $tab-label-h-padding; + font-size: $tab-text-height; + font-weight: $font-weight-semi-bold; + line-height: 1; + color: $tab-text-inactive-color; + text-transform: uppercase; + transition-timing-function: $animation-curve-default; + transition-duration: $animation-duration; + transition-property: box-shadow, color; + + &.active { + color: $tab-text-color; + } + + &.disabled { + opacity: $tab-label-disabled-opacity; + } + + &:not(.disabled) { + cursor: pointer; + } + + &.hidden { + display: none; + } +} + +.pointer { + position: absolute; + width: 0; + height: $tab-pointer-height; + margin-top: - $tab-pointer-height; + background-color: $tab-pointer-color; + transition-timing-function: $animation-curve-default; + transition-duration: $animation-duration; + transition-property: left, width; +} + +.tab { + padding: $tab-label-v-padding $tab-label-h-padding; + + &:not(.active) { + display: none; + } + + &.active { + display: block; + } +} diff --git a/components/tabs/style.styl b/components/tabs/style.styl deleted file mode 100644 index e7f88c0c..00000000 --- a/components/tabs/style.styl +++ /dev/null @@ -1,43 +0,0 @@ -@import '../constants' - -:local(.root) - position : relative - > nav - box-shadow : inset 0 -1px DIVIDER - > label - padding : (OFFSET / 2) OFFSET - font-size : FONT_SIZE_TINY - font-weight : FONT_WEIGHT_BOLD - text-transform : Uppercase - color : TEXT_SECONDARY - transition-property : box-shadow, color - transition-duration : ANIMATION_DURATION - transition-timing-function : ANIMATION_EASE - &.active - color : TEXT - // box-shadow : inset 0 (-(OFFSET / 10)) PRIMARY - &.disabled - opacity : 0.2 - &:not(.disabled) - cursor : pointer - &.hidden - display : none - -:local(.pointer) - HEIGHT = (OFFSET / 10) - position : absolute - margin-left : -(OFFSET) - margin-top : -(HEIGHT) - height : HEIGHT - width : 128px - background-color : PRIMARY - transition-property : left, width - transition-duration : ANIMATION_DURATION - transition-timing-function : ANIMATION_EASE - -:local(.tab) - padding : (OFFSET / 2) OFFSET - &:not(.active) - display : none - &.active - display : block diff --git a/components/tabs/tab.jsx b/components/tabs/tab.jsx index a2db87a4..f14234c1 100644 --- a/components/tabs/tab.jsx +++ b/components/tabs/tab.jsx @@ -1,5 +1,4 @@ import React from 'react'; - import style from './style'; export default React.createClass({ @@ -32,9 +31,9 @@ export default React.createClass({ render () { let className = `${style.tab} ${this.props.className}`; - if (this.props.active) className += ' active'; - if (this.props.disabled) className += ' disabled'; - if (this.props.hidden) className += ' hidden'; + if (this.props.active) className += ` ${style.active}`; + if (this.props.disabled) className += ` ${style.disabled}`; + if (this.props.hidden) className += ` ${style.hidden}`; return (
{ + return ; + }); + }, + render () { let labels = []; + const tabs = this.props.children.map((tab, index) => { let active = this.state.index === index; + let className = `${style.label} ${tab.props.className}`; - let className = tab.props.className; - if (active) className += ' active'; - if (tab.props.disabled) className += ' disabled'; - if (tab.props.hidden) className += ' hidden'; + if (active) className += ` ${style.active}`; + if (tab.props.disabled) className += ` ${style.disabled}`; + if (tab.props.hidden) className += ` ${style.hidden}`; labels.push({ className: className, @@ -79,16 +87,15 @@ export default React.createClass({ return React.cloneElement(tab, {active: active, key: index, tabIndex: index }); }); + let className = style.root; + if (this.props.className) className += ` ${this.props.className}`; + return ( -
-