Skip to content

Commit

Permalink
docs(README): Adding methods example
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaperret committed Dec 11, 2017
1 parent 22189e0 commit dabebf9
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,19 @@ import * as Gaspard from 'gaspard'
const Gaspard = require('gaspard')
```

:fire: Use gaspard's [Collection](https://github.com/lucaperret/gaspard/blob/master/docs/API.md#srccollectionjs) to queries elements and perform actions on each :fire:
```javascript
import { Collection } from 'gaspard'
const collection = new Collection('div.highlight')
collection
.css('background-color', 'green')
.find('p:first-child') // returns a new gaspard collection
.addClass('introduction')
.fadeIn(400)
.elements // Array of matched elements
.forEach(element => {
console.log('div.highlight first paragraph', element)
})
```
And import methods (listed in the [API Documentation](#API))
```javascript
import { documentReady } from 'gaspard'
import { documentReady, find, css, addClass, fadeIn } from 'gaspard'

documentReady(() => {
addClass(document.documentElement, 'dom-loaded')

const app = find('#app')
css(app, 'background-color', 'green')

const paragraph = find('p:first-child', app)[0]
addClass(paragraph, 'introduction')
fadeIn(paragraph)
})
```

Expand Down

0 comments on commit dabebf9

Please sign in to comment.