Skip to content

Commit

Permalink
docs: usage example for Tab Items (react-native-elements#3576)
Browse files Browse the repository at this point in the history
Co-authored-by: Arpit Bhalla <[email protected]>
  • Loading branch information
srj101 and arpitBhalla authored Jul 19, 2022
1 parent 70db3d3 commit 4dc1c0f
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 23 deletions.
8 changes: 6 additions & 2 deletions packages/base/src/Skeleton/Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ export interface SkeletonProps extends ViewProps {
* ### Variants
* The component supports 2 shape variants, i.e. `circle`, `rectangle`.
* ```tsx live
* <Skeleton width={120} height={40} />
* <Skeleton circle width={40} height={40} />
* <Stack row align="center" spacing={4}>
* <Skeleton width={120} height={40} />
* <Skeleton circle width={40} height={40} />
* </Stack>
* ```
* ### Animations
* By default, the skeleton pulsates, but you can change the animation to a wave or disable it entirely.
* ```tsx live
* <Stack row align="center" spacing={4}>
* <Skeleton animation="pulse"width={80} height={40} />
* <Skeleton LinearGradientComponent={LinearGradient} animation="wave"width={80} height={40} />
* <Skeleton animation="none"width={80} height={40} />
* </Stack>
* ```
*
*/
Expand Down
14 changes: 13 additions & 1 deletion packages/base/src/Tab/Tab.Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ export interface TabItemProps
/**
* They are individual item of the parent Tab.
* They are clickable and allows users to click and change Tab.
* Receives all [Button](https://reactnativeelements.com/docs/button#props) props.
* @usage
*
* ### Active Tab Items
* ```tsx
* <Tab.Item
* containerStyle={(active) => ({
* backgroundColor: active ? 'red' : undefined,
* })}
* >
* Tab
* </Tab.Item>
* ```
*
* */
export const TabItem: RneFunctionComponent<TabItemProps> = ({
active,
Expand Down
26 changes: 24 additions & 2 deletions packages/base/src/Tab/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,35 @@ export interface TabProps extends ViewProps {
* This component is not for (complex) navigation. Use [React Navigation](https://reactnavigation.org) for that.
* :::
* @usage
* ### Basic Tabs
* ```tsx live
* <Tab value={0} variant='primary'>
* <Tab.Item>Tab 1</Tab.Item>
* <Tab.Item>Tab 2</Tab.Item>
* <Tab.Item>Tab</Tab.Item>
* <Tab.Item>Tab</Tab.Item>
* </Tab>
* ```
*
* ### Active Tab Items
* ```tsx live
* <Tab value={0} variant="primary" scrollable>
* <Tab.Item
* containerStyle={(active) => ({
* backgroundColor: active ? 'red' : undefined,
* })}
* >
* Tab
* </Tab.Item>
* <Tab.Item
* buttonStyle={(active) => ({
* backgroundColor: active ? 'red' : undefined,
* })}
* >
* Tab
* </Tab.Item>
* </Tab>
* ```
*
* */
export const TabBase: RneFunctionComponent<TabProps> = ({
theme = defaultTheme,
Expand Down
19 changes: 14 additions & 5 deletions website/docs/components/Skeleton.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ import { Skeleton } from "@rneui/themed";
The component supports 2 shape variants, i.e. `circle`, `rectangle`.

```tsx live
<Skeleton width={120} height={40} />
<Skeleton circle width={40} height={40} />
<Stack row align="center" spacing={4}>
<Skeleton width={120} height={40} />
<Skeleton circle width={40} height={40} />
</Stack>
```

### Animations

By default, the skeleton pulsates, but you can change the animation to a wave or disable it entirely.

```tsx live
<Skeleton animation="pulse" width={80} height={40} />
<Skeleton LinearGradientComponent={LinearGradient} animation="wave" width={80} height={40} />
<Skeleton animation="none" width={80} height={40} />
<Stack row align="center" spacing={4}>
<Skeleton animation="pulse" width={80} height={40} />
<Skeleton
LinearGradientComponent={LinearGradient}
animation="wave"
width={80}
height={40}
/>
<Skeleton animation="none" width={80} height={40} />
</Stack>
```

## Props
Expand Down
15 changes: 14 additions & 1 deletion website/docs/components/Tab.Item.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@ import TabItem from "@theme/TabItem";

They are individual item of the parent Tab.
They are clickable and allows users to click and change Tab.
Receives all [Button](https://reactnativeelements.com/docs/button#props) props.

## Import

```tsx
import { Tab } from "@rneui/themed";
```

## Usage

### Active Tab Items

```tsx
<Tab.Item
containerStyle={(active) => ({
backgroundColor: active ? "red" : undefined,
})}
>
Tab
</Tab.Item>
```

## Props

:::note
Expand Down
27 changes: 25 additions & 2 deletions website/docs/components/Tab.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,33 @@ import { Tab } from "@rneui/themed";

## Usage

### Basic Tabs

```tsx live
<Tab value={0} variant="primary">
<Tab.Item>Tab 1</Tab.Item>
<Tab.Item>Tab 2</Tab.Item>
<Tab.Item>Tab</Tab.Item>
<Tab.Item>Tab</Tab.Item>
</Tab>
```

### Active Tab Items

```tsx live
<Tab value={0} variant="primary" scrollable>
<Tab.Item
containerStyle={(active) => ({
backgroundColor: active ? "red" : undefined,
})}
>
Tab
</Tab.Item>
<Tab.Item
buttonStyle={(active) => ({
backgroundColor: active ? "red" : undefined,
})}
>
Tab
</Tab.Item>
</Tab>
```

Expand Down
6 changes: 3 additions & 3 deletions website/src/theme/Playground/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function ThemedLiveEditor() {
}

function EditorWithHeader() {
const [open, setOpen] = React.useState(false);
const [open, setOpen] = React.useState(true);

const handleToggle = () => {
setOpen((isOpen) => !isOpen);
Expand All @@ -94,14 +94,14 @@ function EditorWithHeader() {
{open && (
<>
{' '}
<Header>
{/* <Header>
<Translate
id="theme.Playground.liveEditor"
description="The live editor label of the live codeblocks"
>
Live Editor
</Translate>
</Header>
</Header> */}
<ThemedLiveEditor />
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ import { Tab } from "@rneui/themed";
:::note
Includes all [Button](button#props) props.
:::

<div class='table-responsive'>

| Name | Type | Default | Description |
| -------------------- | --------------------------------------------- | ------- | ------------------------------------------------ |
| Name | Type | Default | Description | Usage Example |
| -------------------- | --------------------------------------------- | ------- | ------------------------------------------------ | ------------ |
| `active` | boolean | | Allows to define if TabItem is active. |
| `buttonStyle` | `ViewStyle or (active: boolean) => ViewStyle` | | Additional button style |
| `containerStyle` | ViewStyle or (active: boolean) => ViewStyle | | Additional Styling for button container. |
| `buttonStyle` | `ViewStyle or (active: boolean) => ViewStyle` | | Additional button styles | `buttonStyle={(active) => ({backgroundColor: active ? "red": "blue",})}`
|
| `containerStyle` | ViewStyle or (active: boolean) => ViewStyle | | Additional Styling for button container. | `containerStyle={(active) => ({backgroundColor: active ? "red": "blue",})}` |
| `iconContainerStyle` | ViewStyle or (active: boolean) => ViewStyle | | Additional Styling for Icon Component container. |
| `titleStyle` | TextStyle or (active: boolean) => TextStyle | | Additional button title style |
| `variant` | `primary` \| `default` | | Define the background Variant. |
| `titleStyle` | TextStyle or (active: boolean) => TextStyle | | Additional button title style | `titleStyle={(active) => ({backgroundColor: active ? "red": "blue",})}` |
| `variant` | `primary` \| `default` | | Define the background Variant. |

</div>

0 comments on commit 4dc1c0f

Please sign in to comment.