Skip to content

Commit 09cb4c0

Browse files
committed
s-c and glamor examples
1 parent c007d16 commit 09cb4c0

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const moveLeft = format(
3636
- [Introduction](#introduction)
3737
- [Examples](#examples)
3838
- [styled-components](#styled-components)
39+
- [glamor](#glamor)
3940
- [API](#api)
4041
- [spring(start, target, options)](#springstart-target-options)
4142
- [format(keyframes, formatter)](#formatkeyframes-formatter)
@@ -46,11 +47,47 @@ Some introductory text
4647

4748
## Examples
4849

49-
Some example text
50+
This section lists some examples of popular css-in-js libraries such as `styled-components` and `glamor`. If you have additional examples, feel free to add them!
5051

5152
### styled-components
5253

53-
styled-components example
54+
When used with the [styled-components](https://github.com/styled-components/styled-components) `keyframes` helper, generated keyframe animations can be applied to a styled component like this:
55+
56+
```javascript
57+
import spring, { format } from 'css-spring'
58+
import styled, { keyframes } from 'styled-components'
59+
60+
const springLeft = format(spring(
61+
{ left: 50 }, { left: 250 }, { preset: 'gentle' }
62+
))
63+
64+
const StyledDiv = styled.div`
65+
position: absolute;
66+
width: 100px;
67+
height: 50px;
68+
top: 50px;
69+
animation: ${keyframes`${springLeft}`} 1s linear infinite;
70+
`
71+
```
72+
73+
### glamor
74+
75+
When used with the `keyframes` method of [glamor](https://github.com/threepointone/glamor), no special formatting is needed for pixel values:
76+
77+
```jsx
78+
import { css } from 'glamor';
79+
import spring from 'css-spring';
80+
81+
const springLeft = css.keyframes('springLeft', spring(
82+
{ left: 50 }, { left: 250 }, { preset: 'gentle' }
83+
));
84+
85+
const MyComponent = () => (
86+
<div {...css({ animation: `${springLeft} 1s linear infinite` })}>
87+
gentle
88+
</div>
89+
)
90+
```
5491

5592
## API
5693
### `spring(start, target, options)`

0 commit comments

Comments
 (0)