Skip to content

Commit

Permalink
new component <Dialog/>
Browse files Browse the repository at this point in the history
  • Loading branch information
soyjavi committed Jun 15, 2015
1 parent fa7d199 commit 022c282
Show file tree
Hide file tree
Showing 13 changed files with 1,868 additions and 51 deletions.
44 changes: 44 additions & 0 deletions components/dialog.cjsx
@@ -0,0 +1,44 @@
###
@todo
###

Style = require './style/dialog'
Button = require './button'
Navigation = require './Navigation'

module.exports = React.createClass

# -- States & Properties
propTypes:
type : React.PropTypes.string
className : React.PropTypes.string
title : React.PropTypes.string
active : React.PropTypes.bool
actions : React.PropTypes.array

getDefaultProps: ->
className : "normal"
active : false
actions : []

getInitialState: ->
active : @props.active

# -- Render
render: ->
className = @props.className
className += " active" if @state.active
<div ref="sss" data-component-dialog={@props.type} data-flex="vertical center" className={className}>
<div>
{<h1>{@props.title}</h1>}
{@props.children}
{<Navigation actions={@props.actions}/> if @props.actions.length > 0}
</div>
</div>

# -- Extends
show: ->
@setState active: true

hide: ->
@setState active: false
2 changes: 1 addition & 1 deletion components/font_icon.cjsx
Expand Up @@ -7,7 +7,7 @@ module.exports = React.createClass

# -- States & Properties
propTypes:
value : React.PropTypes.array.required
value : React.PropTypes.string

# -- Render
render: ->
Expand Down
16 changes: 9 additions & 7 deletions components/form.cjsx
Expand Up @@ -19,6 +19,7 @@ module.exports = React.createClass
onChange : React.PropTypes.func

getDefaultProps: ->
attributes : []
storage : false

getInitialState: ->
Expand Down Expand Up @@ -50,13 +51,14 @@ module.exports = React.createClass
<form data-component-form
onSubmit={@onSubmit}
onChange={@onChange}>
{
for attribute, index in @props.attributes
if attribute.type is "submit"
<Button {...attribute} type="square" ref="submit" onClick={@onSubmit}/>
else
<Input {...attribute} />
}
{
for attribute, index in @props.attributes
if attribute.type is "submit"
<Button {...attribute} type="square" ref="submit" onClick={@onSubmit}/>
else
<Input {...attribute} />
}
{ @props.children }
</form>

# -- Extends
Expand Down
2 changes: 1 addition & 1 deletion components/ripple.cjsx
Expand Up @@ -2,7 +2,7 @@
@todo
###

require "./style/ripple"
Style = require './style/ripple'

module.exports = React.createClass

Expand Down
29 changes: 29 additions & 0 deletions components/router.coffee
@@ -0,0 +1,29 @@
###
@todo
###

require "./style/ripple"

module.exports = React.createClass

# -- States & Properties
propTypes:
origin : React.PropTypes.object

getInitialState: ->
className : undefined

# -- Lifecycle
componentWillReceiveProps: (next_props) ->
@setState className: "active" if next_props.origin?

componentDidMount: ->
el = @getDOMNode()
for key in ["animationend", "webkitAnimationEnd", "oAnimationEnd", "MSAnimationEnd"]
el.addEventListener key, (=> @setState className: undefined), false

# -- Render
render: ->
<div data-component-ripple
className={@state.className}
style={left: @props.origin?.left, top: @props.origin?.top} />
56 changes: 38 additions & 18 deletions components/style/button.styl
@@ -1,4 +1,4 @@
@import '__constants.styl'
@import "__constants.styl"

[data-component-button]
z-index : 1
Expand All @@ -17,32 +17,52 @@
// -- Style
&:not([disabled])
cursor : pointer
box-shadow ZDEPTH_SHADOW_1
&:hover /*, &:active, &:focus */
&:hover, &:active, &:focus
outline : 0
box-shadow ZDEPTH_SHADOW_2, inset 0 0 0 UNIT alpha(WHITE, 10%)
&:not(.primary):not(.secondary)
color : COLOR
background-color : WHITE
&.primary, &.secondary
color : WHITE
&.primary
background-color : PRIMARY
&.secondary
background-color : SECONDARY
&:not(.transparent)
box-shadow ZDEPTH_SHADOW_1
&:not(.primary):not(.secondary)
color : COLOR
background-color : WHITE
&:hover
box-shadow ZDEPTH_SHADOW_2, inset 0 0 0 UNIT alpha(WHITE, 10%)
&.primary, &.secondary
color : WHITE
&.primary
background-color : PRIMARY
&.secondary
background-color : SECONDARY

&.transparent
background-color : transparent
&:not(.primary):not(.secondary)
&:hover
background-color : alpha(COLOR, 12.5%)
&.primary
color : PRIMARY
&:hover
background-color : alpha(PRIMARY, 12.5%)
&.secondary
color : SECONDARY
&:hover
background-color : alpha(SECONDARY, 12.5%)

&[disabled]
background-color : darken(BACKGROUND, 7.5%)
color : darken(BACKGROUND, 35%)
&:not(.transparent)
color : darken(BACKGROUND, 35%)
background-color : darken(BACKGROUND, 7.5%)
&.transparent
color : darken(BACKGROUND, 25%)
background-color : transparent


// -- Layout
& ~ &:not(:last-child)
&:not(.transparent) ~ &:not(:last-child)
margin-left : SPACE
> *
pointer-events : none
pointer-events : none

[data-component-button="square"]
margin-bottom : SPACE
padding : (SPACE / 2) (SPACE / 1.25)
font-size : FONT_SIZE_SMALL
text-transform : uppercase
Expand Down
51 changes: 51 additions & 0 deletions components/style/dialog.styl
@@ -0,0 +1,51 @@
@import "__constants.styl"

[data-component-dialog]
z-index : 3
position : absolute
left : 0
top : 0
width : 100vw
height : 100vh
background-color : rgba(0,0,0,0.5)
transition-property opacity
transition-duration (ANIMATION_DURATION / 2)
transition-timing-function ANIMATION_EASE
// -- Children
> div
margin : SPACE
padding : SPACE (SPACE * 1.5)
background-color : WHITE
border-radius : (SPACE / 5)
box-shadow ZDEPTH_SHADOW_5
transition-property opacity, transform
transition-duration ANIMATION_DURATION
transition-timing-function ANIMATION_EASE
transition-delay ANIMATION_DELAY
> h1
margin-bottom : SPACE
> nav
margin-top : SPACE
text-align : right
> *:not(.transparent)
margin-left : SPACE

// -- Styles
&.small > div
width : 30vw
&.normal > div
width : 50vw
&.large > div
width : 96vw
&:not(.active)
pointer-events : none
opacity : 0
transition-delay (ANIMATION_DELAY * 2)
> div
opacity : 0
transform translateY(-(UNIT))
&.active
opacity : 1
> div
opacity : 1
transform translateY(0%)

0 comments on commit 022c282

Please sign in to comment.