Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kristofferandreasen/react-announcement
📣 Push out beautiful website announcements in React 📣 An NPM package to quickly convey your message to visitors.
https://github.com/kristofferandreasen/react-announcement
create-react-library hacktoberfest javascript react reactjs typescript
Last synced: about 5 hours ago
JSON representation
📣 Push out beautiful website announcements in React 📣 An NPM package to quickly convey your message to visitors.
- Host: GitHub
- URL: https://github.com/kristofferandreasen/react-announcement
- Owner: kristofferandreasen
- License: mit
- Created: 2020-01-07T13:39:57.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:22:32.000Z (almost 2 years ago)
- Last Synced: 2024-11-14T09:52:36.724Z (28 days ago)
- Topics: create-react-library, hacktoberfest, javascript, react, reactjs, typescript
- Language: TypeScript
- Homepage: https://kristofferandreasen.github.io/react-announcement/
- Size: 7.03 MB
- Stars: 159
- Watchers: 4
- Forks: 16
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
📣 Push out beautiful website announcements in React 📣
This simple and modern component makes it easier for you to engage with your visitors in a non-intrusive way.
The component is fully responsive and will render perfectly on desktop, tablets and mobile.
## Install
```bash
npm install --save react-announcement
```## Usage
```tsx
import * as React from 'react'
import Logo from './logo.svg'
import Announcement from 'react-announcement'class Example extends React.Component {
render () {
return (
)
}
}
```### Usage with optional properties
This example includes the optional properties in the component.
The `daysToLive` property changes to the cookie created by the component.
This way you can control how many days you want to wait before you show the announcement to the same user.The `secondsBeforeBannerShows` property changes the number of seconds a user waits before the announcement is presented.
The `closeIconSize` is to allow you to change to size of the icon in the top right corner.
The `animateInDuration` changes the duration of the fade-in animation.
The `animateOutDuration` changes the duration of the fade-out animation - this is fired on the click of the close icon.
```tsx
import * as React from 'react'
import Logo from './logo.svg'
import Announcement from 'react-announcement'class Example extends React.Component {
render () {
return (
)
}
}
```## Properties
Property | Type | Required | Default value | Description
:--- | :--- | :--- | :--- | :---
`title`|string|yes|| The title of the announcement
`subtitle`|string|yes|| The general card text on the announcement
`imageSource`|string|yes|| The image source string used on the left side of the image. Use a square image for the best results. Dimensions are 68x68 pixels.
`link`|string|yes|| The link used when the announcement is clicked.
`daysToLive`|number|no|7| An optional property specifying the number of days the cookie will live before the announcement is shown again to a user.
`secondsBeforeBannerShows`|number|no|5| The number of seconds a user has to keep the page open before the announcement is shown.
`animateInDuration`|number|no|1000| Changes the duration of the fade-in animation.
`animateOutDuration`|number|no|30| Change the duration of the fade-out animation.
-----## Responsive
The announcement is shown on the left side of the screen on desktop and centered at the bottom on mobile.
## Developing
The project is bootstrapped with [create-react-library](https://github.com/transitive-bullshit/create-react-library) and TypeScript has been added to the project. You can read more about the development workflow in the [project docs](https://github.com/transitive-bullshit/create-react-library).
To start developing, you need to open two terminals.
In the first tab, run from the main directory:
```
npm start
```
This will activate rollup to watch for any changes to your src directory and build the dist everytime.In another terminal, navigate to the example folder:
```
cd example
```
Then run:
```
npm install
```
and finally:
```
npm start
```This will start up the development server allowing you to see the results.
Be aware that the solution is setting a cookie and this cookie will be stored in your browser.
In order to see the banner again, you will need to open the localhost link in incognito or clear your browser cookies.## Contributing
Your contributions are always welcome!
Please have a look at the [contribution guidelines](https://github.com/kristofferandreasen/react-announcement/blob/master/CONTRIBUTING.md) first 🎉## License
MIT © [kristofferandreasen](https://github.com/kristofferandreasen)