Skip to content

Commit 91ee458

Browse files
committed
New method and property "loading"
1 parent ae1cab3 commit 91ee458

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

components/card/card.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ var Card = require('react-toolbox/components/card');
2323
| **image** | String | | Sets a background image url.|
2424
| **text** | String | | Sets a complementary text.|
2525
| **legend** | String | | Sets a legend text.|
26+
| **loading** | Boolean | | If true, component will be disabled and show a loading animation.|
2627
| **onClick** | Function | | Callback function that is fired when the components's is clicked.|
2728
| **title** | String | "text" | Sets the title of the component.|
2829
| **type** | String | "text" | Type of the component, overwrite this property if you need set a different stylesheet.|
30+
31+
## Methods
32+
33+
#### loading
34+
If true, component will be disabled and show a loading animation.
35+
36+
```
37+
card_instance.loading(true);
38+
```

components/card/index.cjsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = React.createClass
1111
image : React.PropTypes.string
1212
text : React.PropTypes.string
1313
legend : React.PropTypes.string
14+
loading : React.PropTypes.bool
1415
onClick : React.PropTypes.func
1516
title : React.PropTypes.string
1617
type : React.PropTypes.string
@@ -43,6 +44,7 @@ module.exports = React.createClass
4344
className += " touch" if @props.onClick?
4445
className += " image" if @props.image?
4546
className += " color" if @props.color?
47+
className += " loading" if @state.loading?
4648
style = {}
4749
style.backgroundImage = "url(#{@props.image})" if @props.image?
4850
style.backgroundColor = @props.color if @props.color
@@ -60,3 +62,7 @@ module.exports = React.createClass
6062
{ <Navigation actions={@props.actions} /> if @props.actions }
6163
{ <Ripple origin={@state.ripple} loading={@state.loading} /> }
6264
</div>
65+
66+
# -- Extends
67+
loading: (value) ->
68+
@setState loading: value

components/card/style.styl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ OFFSET = (SPACE / 1.25)
5151
&.image, &.color
5252
> figure
5353
color : WHITE
54+
&.loading
55+
cursor : none
56+
-webkit-filter : grayscale(100%)
57+
&, &:hover
58+
box-shadow : 0 0 0 1px DIVIDER
59+
> [data-component-ripple]
60+
width : SIZE = (SIZE * 2)
61+
height : SIZE
5462

5563
// -- Extends
5664
[data-component-card="small"]

spec/components/card.cjsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ module.exports = React.createClass
2929

3030
<h3>Basic properties</h3>
3131
<Card title="Default Card" />
32+
<Card title="Default Card loading" loading />
3233
<Card title="Default Card with text" text={text} />
3334
<Card title="Default Card with legend" legend={legend} />
3435
<Card title="Default Card with actions" actions={actions} />
3536
<Card title="Defaulr Card with text & image" text={text}
3637
image="http://cdn.tapquo.com/photos/soyjavi.jpg" />
3738
<Card title="Default Card with text, color & onClick event" text={text}
3839
color="#e91e63" onClick={@onClick} />
40+
<Card title="Default Card loading with text, color & onClick event"
41+
text={text} color="#e91e63" onClick={@onClick} loading />
42+
3943

4044
<h3>Sizes using type property</h3>
4145
<Card type="small" title="Small Card with text & onClick event"

0 commit comments

Comments
 (0)