Skip to content

Commit 02bd3fb

Browse files
committed
docs: poll documentation and type fixes
1 parent 209bc15 commit 02bd3fb

22 files changed

+235
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A method that will be used as a callback whenever the default `CreatePoll` component back button is pressed in the header. Unless used, it will have no effect if the default `CreatePollContent` is overriden.
2+
3+
| Type |
4+
| ------------------------------------ |
5+
| `() => void` |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A method that will be used as a callback whenever send button is clicked on the `CreatePoll` modal. If a custom UI is used for `CreatePollContent`, it can be used as an out-of-the-box method to create and send a poll to the `MessageList`.
2+
3+
| Type |
4+
| ------------------------------------ |
5+
| `(thread, channel) => Promise<void>` |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A custom UI component used to render the entire poll creation form. It has access to the [`CreatePollContext`](../../../contexts/create-poll-context.mdx) values by default through the `useCreatePollContext` hook.
2+
3+
| Type | Default |
4+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
5+
| ComponentType | [`CreatePollContent`](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/Poll/CreatePollContent.tsx) |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A property used to define the height of the poll options in the `CreatePollContent` draggable list. The items can have a constant and equal height only and this should only be used if custom theming implies that the static height of the items changes. Has no effect if a custom UI for `CreatePollContent` is provided.
2+
3+
| Type |
4+
| ------------------------------------ |
5+
| number |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Function called whenever the close button is pressed on the poll creation modal. Has no effect if [`PollCreateContent`](../../../core-components/channel.mdx#createpollcontent) is custom.
2+
3+
| Type |
4+
| -------- |
5+
| function |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A boolean signifying whether the poll creation dialog is shown or not. Will always be `false` if [`PollCreateContent`](../../../core-components/channel.mdx#createpollcontent) is custom.
2+
3+
| Type |
4+
| -------- |
5+
| boolean |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A boolean value that is responsible for controlling whether the poll creation button is visible or not.
2+
3+
| Type |
4+
| -------- |
5+
| boolean |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Function called immediately when the poll creation button is clicked in the attachment picker. Can be used to override the default behaviour of the poll creation UI appearing as a Modal.
2+
3+
If overridden, a `payload` is passed containing the `sendMessage` callback from [`MessageInputContext`](../../../../contexts/message-input-context.mdx) is passed, so that [`CreatePoll`](../../../../ui-components/create-poll.mdx)
4+
5+
| Type |
6+
| -------- |
7+
| function |
8+
9+
| Parameter | Description |
10+
| --------- | ----------------------------- |
11+
| payload | `{ sendMessage }` |
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
id: create-poll-context
3+
title: CreatePollContext
4+
---
5+
6+
import ClosePollCreationDialog from '../common-content/contexts/create-poll-context/close-poll-creation-dialog.mdx';
7+
import CreateAndSendPoll from '../common-content/contexts/create-poll-context/create-and-send-poll.mdx';
8+
import CreatePollContent from '../common-content/contexts/create-poll-context/create-poll-content.mdx';
9+
import CreatePollOptionHeight from '../common-content/contexts/create-poll-context/create-poll-option-height.mdx';
10+
import SendMessage from '../common-content/contexts/message-input-context/send_message.mdx'
11+
12+
The `CreatePollContext` is provided by the [`CreatePoll`](../../ui-components/create-poll) component. If you are not familiar with React Context API, please read about it on [React docs](https://reactjs.org/docs/context.html).
13+
14+
The `CreatePollContext` needs to be used within the [`Channel` component](../../core-components/channel) as it depends on the [`MessageInputContext`](./message-input-context.mdx) which is added by it.
15+
16+
## Basic Usage
17+
18+
The `CreatePollContext` can be consumed by any of the child components of `Channel` as following:
19+
20+
```tsx
21+
import { useContext } from 'react';
22+
import { CreatePollContext } from 'stream-chat-react-native';
23+
24+
const value = useContext(CreatePollContext);
25+
```
26+
27+
Alternatively, you can also use `useCreatePollContext` hook provided by library to consume `CreatePollContext`.
28+
29+
```tsx
30+
import { useCreatePollContext } from 'stream-chat-react-native';
31+
32+
const value = useCreatePollContext();
33+
```
34+
35+
## Value
36+
37+
### <div class="label description">_forwarded from [MessageInputContext](../../contexts/message-input-context#sendmessage)_ props</div> sendMessage {#sendmessage}
38+
39+
<SendMessage />
40+
41+
### `closePollCreationDialog`
42+
43+
<ClosePollCreationDialog />
44+
45+
### `createAndSendPoll`
46+
47+
<CreateAndSendPoll />
48+
49+
### `onThreadSelect`
50+
51+
<CreatePollOptionHeight />

docusaurus/docs/reactnative/contexts/message-input-context.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ import UploadImage from '../common-content/contexts/message-input-context/upload
9494
import UpdateMessage from '../common-content/contexts/message-input-context/update_message.mdx';
9595
import UploadNewFile from '../common-content/contexts/message-input-context/upload_new_file.mdx';
9696
import UploadNewImage from '../common-content/contexts/message-input-context/upload_new_image.mdx';
97+
import ClosePollCreationDialog from '../common-content/contexts/message-input-context/close-poll-creation-dialog.mdx'
98+
import ShowPollCreationDialog from '../common-content/contexts/message-input-context/show-poll-creation-dialog.mdx'
9799

98100
`MessageInputContext` is provided by [`Channel`](../../core-components/channel) component. If you are not familiar with React Context API, please read about it on [React docs](https://reactjs.org/docs/context.html).
99101

@@ -490,3 +492,11 @@ const { sendMessage, toggleAttachmentPicker } = useMessageInputContext();
490492
### <div class="label description">_forwarded from [Channel](../../core-components/channel#uploadprogressindicator)_ props</div> UploadProgressIndicator {#uploadprogressindicator}
491493

492494
<UploadProgressIndicator />
495+
496+
### `closePollCreationDialog`
497+
498+
<ClosePollCreationDialog />
499+
500+
### `showPollCreationDialog`
501+
502+
<ShowPollCreationDialog />

0 commit comments

Comments
 (0)