Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit 426b812

Browse files
committed
fix(docs): add ShareBlockAside to docs
1 parent 2bea541 commit 426b812

File tree

14 files changed

+294
-13
lines changed

14 files changed

+294
-13
lines changed

docs/content/pages/3--share-block-standard/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It renders one or more share buttons inside a `flex` container with optional hea
1616

1717
## Usage
1818

19-
Let's create a share block with three items, for Facebook, Twitter and GooglePlus.
19+
Let's create a share block with five items, for Facebook, Twitter, GooglePlus, Email and Linkedin.
2020

2121
**Step 1.** Import the icons. As usual, we are going to use icons provided by [react-icons](https://github.com/react-icons/react-icons).
2222

@@ -59,7 +59,7 @@ const shareBlockProps = {
5959
};
6060
```
6161

62-
**Step 4.** Add `ShareBlock` to your app. Remember to pass all prepared props to the component.
62+
**Step 4.** Add `ShareBlockStandard` to your app. Remember to pass all prepared props to the component.
6363

6464
```javascript
6565
<ShareBlockStandard {...shareBlockProps} />
38.5 KB
Loading
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: <ShareBlockAside />
3+
description: ShareBlockAside is a dynamic container with additional buttons floating aside the content.
4+
cover: cover.png
5+
---
6+
7+
## Demo
8+
9+
[Live demo](../live-share-block-aside)
10+
11+
## Description
12+
13+
`ShareBlockAside` is a built-in, ready-to-use 'share' block component.
14+
15+
It renders two block of share buttons, one is static placed inside/under the content, the second one is floating aside.
16+
17+
The floating buttons appear only when there is a free space aside.
18+
19+
The components script automatically hide the floating block whenever the static block is visible in the viewport. Set the `pageHeaderSelector` prop to turn on similar behavior for the title of the web page.
20+
21+
## Usage
22+
23+
Let's create a share block using `ShareBlockAside` with buttons for five networks.
24+
25+
**Step 1.** Import the icons. As usual, we are going to use icons provided by [react-icons](https://github.com/react-icons/react-icons).
26+
27+
```javascript
28+
import FaTwitter from "react-icons/lib/fa/twitter";
29+
import FaFacebook from "react-icons/lib/fa/facebook";
30+
import FaGooglePlus from "react-icons/lib/fa/google-plus";
31+
import FaEnvelope from "react-icons/lib/fa/envelope";
32+
import FaPinterest from "react-icons/lib/fa/pinterest";
33+
import FaLinkedin from "react-icons/lib/fa/linkedin";
34+
```
35+
36+
**Step 2.** Import the `react-custom-share` components: a button and a block. Notice that we will use `ShareButtonRectangle` as a button component to render the items of the block.
37+
38+
```javascript
39+
import { ShareButtonRectangle, ShareBlockAside } from "react-custom-share";
40+
```
41+
42+
**Step 3.** Prepare an object with props for the `ShareBlockAside` component. The `url`, `button` and `buttons` are required props.
43+
44+
```javascript
45+
const shareBlockProps = {
46+
url: "https://github.com/greglobinski/react-custom-share",
47+
button: ShareButtonRectangle,
48+
buttons: [
49+
{ network: "Twitter", icon: FaTwitter },
50+
{ network: "Facebook", icon: FaFacebook },
51+
{ network: "GooglePlus", icon: FaGooglePlus },
52+
{ network: "Email", icon: FaEnvelope },
53+
{
54+
network: "Pinterest",
55+
icon: FaPinterest,
56+
media:
57+
"https://raw.githubusercontent.com/greglobinski/react-custom-share/master/static/react-custom-share.gif"
58+
}
59+
],
60+
text: "Give it a try - react-custom-share component",
61+
longtext:
62+
"Social sharing buttons for React. Use one of the build-in themes or create a custom one from the scratch.",
63+
header: "Share it",
64+
pageHeaderSelector: ".header"
65+
};
66+
```
67+
68+
Take a look at the new prop `pageHeaderSelector`. It's a distinctive prop of `ShareBlockAside`. If set the floating buttons will be hidden when the page header is visible in the viewport.
69+
70+
**Step 4.** Add `ShareBlockAside` to your app. Remember to pass all prepared props to the component.
71+
72+
```javascript
73+
<ShareBlockAside {...shareBlockProps} />
74+
```
75+
76+
**Full code**
77+
78+
```javascript
79+
import React from "react";
80+
import ReactDOM from "react-dom";
81+
import FaTwitter from "react-icons/lib/fa/twitter";
82+
import FaFacebook from "react-icons/lib/fa/facebook";
83+
import FaGooglePlus from "react-icons/lib/fa/google-plus";
84+
import FaEnvelope from "react-icons/lib/fa/envelope";
85+
import FaPinterest from "react-icons/lib/fa/pinterest";
86+
import FaLinkedin from "react-icons/lib/fa/linkedin";
87+
88+
import { ShareButton, ShareBlockAside } from "react-custom-share";
89+
90+
const App = props => {
91+
const shareBlockProps = {
92+
url: "https://github.com/greglobinski/react-custom-share",
93+
button: ShareButtonRectangle,
94+
buttons: [
95+
{ network: "Twitter", icon: FaTwitter },
96+
{ network: "Facebook", icon: FaFacebook },
97+
{ network: "GooglePlus", icon: FaGooglePlus },
98+
{ network: "Email", icon: FaEnvelope },
99+
{
100+
network: "Pinterest",
101+
icon: FaPinterest,
102+
media:
103+
"https://raw.githubusercontent.com/greglobinski/react-custom-share/master/static/react-custom-share.gif"
104+
},
105+
{ network: "Linkedin", icon: FaLinkedin }
106+
],
107+
text: "Give it a try - react-custom-share component",
108+
longtext:
109+
"Social sharing buttons for React. Use one of the build-in themes or create a custom one from the scratch.",
110+
header: "Share it",
111+
pageHeaderSelector: ".header"
112+
};
113+
114+
return <ShareBlockAside {...shareBlockProps} />;
115+
};
116+
117+
ReactDOM.render(<App />, document.getElementById("root"));
118+
```
119+
120+
## ShareBlockStandard's props
121+
122+
* **header** - the inline share block's title | _string_ | optional
123+
* **debounce**: wait option for the `debounce` method applied to `window.resize` event | number _(milliseconds)_ | optional | default: 250
124+
* **pageHeaderSelector**: selector for `document.querySelector()` pointing the header of the web page | _string_ | optional
125+
* other props the same as `ShareBlock`
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
"normalize.css": "^8.0.0",
2626
"prismjs": "^1.14.0",
2727
"react-addons-perf": "^15.4.2",
28-
"react-custom-share": "^0.3.0",
28+
"react-custom-share": "^0.4.4",
2929
"react-helmet": "^5.2.0",
3030
"react-icons": "^2.2.7",
31+
"react-lorem-component": "^0.13.0",
3132
"styled-jsx": "^2.2.6",
3233
"styled-jsx-plugin-postcss": "^0.1.3",
3334
"styled-jsx-plugin-stylelint": "^0.1.0",

0 commit comments

Comments
 (0)