File size: 7,584 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# Banner
This component renders a customizable banner.
(Need to add an upsell? Use `UpsellNudge` instead.)
## Usage
```jsx
import { PLAN_BUSINESS, FEATURE_ADVANCED_SEO } from '@automattic/calypso-products';
import Banner from 'calypso/components/banner';
function render() {
return (
<Banner
callToAction="Upgrade now!"
description="Obtain more features."
disableHref
dismissPreferenceName="example-banner"
dismissTemporary
event="track_event"
feature={ FEATURE_ADVANCED_SEO }
href="https://wordpress.com/"
icon="star"
list={ [ 'A feature', 'Another feature' ] }
onClick={ someFunction }
plan={ PLAN_BUSINESS }
prices={ [ 10.99, 9.99 ] }
showIcon={ false }
title="Upgrade to a better plan!"
tracksImpressionName="calypso_banner_upgrade_view"
tracksClickName="calypso_banner_upgrade_click"
tracksDismissName="calypso_banner_upgrade_dismiss"
tracksImpressionProperties={ { cta_name: 'calyspo_banner_upgrade' } }
tracksClickProperties={ { cta_name: 'calyspo_banner_upgrade' } }
tracksDismissProperties={ { cta_name: 'calyspo_banner_upgrade' } }
/>
);
}
```
### Props
| Name | Type | Default | Description |
| ---------------------------- | ---------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `callToAction` | `string` | null | Shows a CTA text. |
| `className` | `string` | null | Any additional CSS classes. |
| `compact` | `bool` | false | Display a compact version of the banner. |
| `description` | `string` | null | The banner description. |
| `disableHref` | `bool` | false | When true, prevent the Banner to be linked either via the `href` props or as a side effect of the `siteSlug` connected prop. |
| `dismissPreferenceName` | `string` | null | The user preference name that we store a boolean against, prefixed with `dismissible-card-` to avoid namespace collisions. |
| `dismissTemporary` | `bool` | false | When true, clicking on the cross will dismiss the card for the current page load. |
| `event` | `string` | null | Event to distinguish the nudge in tracks. Used as <code>cta_name</code> event property. |
| `feature` | `string` | null | Slug of the feature to highlight in the plans compare card. |
| `horizontal` | `bool` | false | When true, the banner content will be laid out in a single row (similar to `compact` but normal size). |
| `href` | `string` | null | The component target URL. |
| `jetpack` | `bool` | false | When true, a Jetpack logo will be rendered and the border color will be set to Jetpack green. |
| `icon` | `string` | null | The component icon. |
| `list` | `string[] \| object[]` | null | A list of the upgrade features. Use a `object[]` if you want to pass arbitrary arguments to `renderListItem`. |
| `renderListItem` | `func` | | A [render prop](https://reactjs.org/docs/render-props.html) for rendering custom list UI. The elements of the `list` prop are passed as an argument. |
| `onClick` | `string` | null | A function associated to the click on the whole banner or just the CTA or dismiss button. |
| `plan` | `string` | null | PlanSlug of the plan that upgrade leads to. |
| `price` | `string` | null | One or two (original/discounted) upgrade prices. |
| `showIcon` | `bool` | `true` | Show the icon specified in `icon` |
| `title` | `string` | null | (required) The banner title. |
| `tracksImpressionName` | `string` | | Unique event name to track when the nudge is viewed |
| `tracksClickName` | `string` | | Unique event name to track when the nudge is clicked |
| `tracksDismissName` | `string` | | Unique event name to track when the nudge is dismissed |
| `tracksImpressionProperties` | `object` | | Additional props to track when the nudge is viewed |
| `tracksClickProperties` | `object` | | Additional props to track when the nudge is clicked |
| `tracksDismissProperties` | `object` | | Additional props to track when the nudge is dismissed |
### General guidelines
- If `href` is not provided, `feature` can auto-generate it.
- If `callToAction` is provided, `href` and `onClick` are not applied to the whole banner, but to the `callToAction` button only.
- If `dismissPreferenceName` is provided, `href` is only applied if `callToAction` is provided.
|