Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gugadev/storify
Instagram/Whatsapp stories clone built on Web Components and Web Animations API. 🔥
https://github.com/gugadev/storify
custom-elements javascript postcss typescript web-animations web-animations-api web-components webpack
Last synced: 3 months ago
JSON representation
Instagram/Whatsapp stories clone built on Web Components and Web Animations API. 🔥
- Host: GitHub
- URL: https://github.com/gugadev/storify
- Owner: gugadev
- License: mit
- Created: 2019-02-11T14:19:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T00:31:44.000Z (about 2 years ago)
- Last Synced: 2024-10-29T07:39:33.321Z (3 months ago)
- Topics: custom-elements, javascript, postcss, typescript, web-animations, web-animations-api, web-components, webpack
- Language: TypeScript
- Homepage: https://gugadev.github.io/storify
- Size: 2.55 MB
- Stars: 94
- Watchers: 5
- Forks: 19
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
wc 🌐 stories
Instagram/Whatsapp stories like built on Web Components and Web Animations API.
## Demos
| []()
Vanilla JS | []()
Angular | []()
React | []()
Vue |
|------------|---------|-------|-----|
| Link | Link | Link | Link |## Browser support
| [](http://godban.github.io/browsers-support-badges/)IE / Edge | [](http://godban.github.io/browsers-support-badges/)Firefox | [](http://godban.github.io/browsers-support-badges/)Chrome | [](http://godban.github.io/browsers-support-badges/)Safari | [](http://godban.github.io/browsers-support-badges/)Opera |
| --------- | --------- | --------- | --------- | --------- |
| IE11, Edge| last 10 versions| last 10 versions| last 10 versions| last 10 versions---
## 📦 Install
```bash
npm i @gugadev/wc-stories
```## 💡 What's the prupose of it?
Just fun 🙂. I love learn and code, so, this every time I have free time, pick some crazy idea or got inspiration from another projects and make it. 😋
## 🦄 Inspiration
When I saw the project of Mohit, [react-insta-stories](https://github.com/mohitk05/react-insta-stories), immediately wanted to know how complicated it would be to do the same thing using **Web Components**. So, I built this. Thanks, Mohit! 😃
## ⚙️ How it works?
There are three components working together:
- ``: this component shows a image. The maximun size of an image is the containers viewport.
- `: this component shows the progress bar at top the the container. It uses **Web Animations API** to run it. If we change of image (clicking on left/right), the previous animation is cancelled.
- ``: this is the main component. This one harbor the two components above. Here is the logic for control which image should be revealed, what happen if the user
clicks on left or right side, etc.## 🚀 How to run?
After install depenencies, you just need to run `yarn start`. Once the server was started, go to [localhost:4444](http://127.0.0.1:4444) and see it in action.
## 🛠️ How to build?
Execute the `yarn build` command to compile the source code and get the ES5 equivalent. Compiled code will be available on `dist/` folder.
## 🙋 How to use it in my web/app?
First, we need to add the needed polyfills:
- `@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js`
- `@webcomponents/webcomponentsjs/webcomponents-loader.js`.
- `web-animations-js/web-animations.min.js`### Web Components/Vanilla JavaScript
If you're using Web Components or vanilla JavaScript, just put the `wc-stories` tag inside your HTML and pass it the array of images:```html
```
### React
If you're using React, use the component as is. Instead of passing raw values you can use `state` to
store the component configuration:```javascript
export class MyComponent extends React.Component {
this.state = {
width: 320,
height: 480,
withShadow: true,
stories: [
'/path/to/image',
'/path/to/image',
'/path/to/image',
...
]
}
render() {
return (
{
this.state.stories.map(story => (
))
}
)
}
}
```### Angular
If you're using Angular, put the component inside your template. Like React, you can put the configuration inside the controller instead passing raw values:
```html
...
```
```typescript
@Component({
...
})
class MyComponent implements OnInit {ngOnInit() {
stories = [
'/path/to/image',
'/path/to/image',
'/path/to/image',
...
]
}
}
```### Vue
If you're using Vue, put the component inside your template. Like React, you can put the configuration inside the controller instead passing raw values:
```html
```
```javascript
export default {
data: () => ({
width: 320,
height: 480,
withShadow: tre,
stories: [
'/path/to/image',
'/path/to/image',
'/path/to/image',
...
]
})
}
```## 🆕 Lazy Loading
There are several ways to lazy loading images like _Low quality image placeholders_ and _progressive images_. This feature relies on the first one, so, in order to enable it, you need to pass, along with the images, the placeholders too.
**Tip:** you can generate lightweight svg LQIP from high resolution images using [sqip](https://github.com/technopagan/sqip).
```html
```
## 🚧 Roadmap
- [x] Implement Typescript
- [x] Implement PostCSS.
- [x] Make builds with Webpack.
- [x] Compile down to ES5.
- [x] Control animation's flow.
- [x] Orientation device support.
- [ ] Add mobile swipe support.
- [ ] Add more transition effects.
- [x] Add lazy loading support.
- [ ] Improve suite case.
- [x] Add demo page.
- [x] Publish the package to npm.## 🙌 Contribute
If you found this project interesting, I'm glade to
receive updates, new features or fixes 🙂. Just
fork the project, create your branch, make your changes
and send your Pull Request! 😃## 📖 API
### ``
- `radius :`: border radius. Default: 0.
- `startAt `: initial image index to show. Default: 0.
- `duration `: visibility time of images and animation.
- `height `: self-explanatory.
- `width `: self-explanatory.
- `withShadow `: enable or disable drop shadow.### ``
- `src`: image relative or absolute URL
- `placeholder`: an image URL or a base64 string.