Skip to content

Commit c030192

Browse files
author
Eric Olkowski
committed
Added back and repurposed router examples
1 parent 0594e65 commit c030192

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

packages/react-core/src/components/Button/examples/Button.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ Inline links should use `component="span"` and the `isInline` property to wrap i
8585
```ts file="./ButtonInlineSpanLink.tsx"
8686
```
8787

88+
### Custom component
89+
90+
In addition to being able to pass a string to the `component` property, you can provide more fine-tuned customization by passing a callback that returns a component.
91+
92+
```ts file="./ButtonCustomComponent.tsx"
93+
```
94+
8895
### Aria-disabled examples
8996

9097
[Accessible Rich Internet Applications (ARIA)](https://www.w3.org/WAI/standards-guidelines/aria/) is a set of roles and attributes specified by the World Wide Web Consortium. ARIA defines ways to make web content and web applications more accessible to people with disabilities.
@@ -119,7 +126,7 @@ Stateful buttons are ideal for displaying the state of notifications. Use `varia
119126

120127
## Using router links
121128

122-
Router links can be used for in-app linking in React environments to prevent page reloading. To use a `Link` component from a router package, you can pass a callback to the `component` property of the `Button`:
129+
Router links can be used for in-app linking in React environments to prevent page reloading. To use a `Link` component from a router package, you can follow our [custom component example](#custom-component) and pass a callback to the `component` property of the `Button`:
123130

124131
```nolive
125132
<Button variant="link" component={(props: any) => <Link {...props} to="#" />}>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import { Button } from '@patternfly/react-core';
3+
4+
export const ButtonCustomComponent: React.FunctionComponent = () => (
5+
<Button variant="link" component={(props: any) => <a {...props} href="#" />}>
6+
Router link
7+
</Button>
8+
);

packages/react-core/src/components/Masthead/examples/Masthead.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,44 @@ Mastheads contain the `<MastheadMain>` that wraps a `<PageToggleButton>` and `<M
1717
### Basic
1818

1919
```ts file="./MastheadBasic.tsx"
20-
2120
```
2221

2322
### Basic with mixed content
2423

2524
```ts file="./MastheadBasicMixedContent.tsx"
26-
2725
```
2826

2927
### Display inline
3028

3129
```ts file="./MastheadDisplayInline.tsx"
32-
3330
```
3431

3532
### Display stack
3633

3734
```ts file="./MastheadDisplayStack.tsx"
38-
3935
```
4036

4137
### Display stack, display inline responsive
4238

4339
```ts file="./MastheadDisplayStackInlineResponsive.tsx"
44-
4540
```
4641

4742
### Inset
4843

4944
```ts file="./MastheadInsets.tsx"
45+
```
46+
47+
### Custom logo component
48+
49+
In addition to being able to pass a string to the `component` property of `MastheadLogo`, you can provide more fine-tuned customization by passing a callback that returns a component.
50+
5051

52+
```ts file="./MastheadLogoCustomComponent.tsx"
5153
```
5254

5355
## Using router links
5456

55-
Router links can be used for in-app linking in React environments to prevent page reloading. To use a `Link` component from a router package, you can pass a callback to the `component` property of the `MastheadLogo`:
57+
Router links can be used for in-app linking in React environments to prevent page reloading. To use a `Link` component from a router package, you can follow our [custom logo component example](#custom-logo-component) and pass a callback to the `component` property of the `MastheadLogo`:
5658

5759
```nolive
5860
<MastheadLogo component={(props) => <Link {...props} to="#" />}>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import {
3+
Masthead,
4+
MastheadMain,
5+
MastheadToggle,
6+
MastheadBrand,
7+
MastheadLogo,
8+
MastheadContent,
9+
Button,
10+
Brand
11+
} from '@patternfly/react-core';
12+
import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
13+
import pfIcon from '../../assets/PF-HorizontalLogo-Color.svg';
14+
15+
export const MastheadLogoCustomComponent: React.FunctionComponent = () => (
16+
<Masthead id="icon-router-link">
17+
<MastheadMain>
18+
<MastheadToggle>
19+
<Button variant="plain" onClick={() => {}} aria-label="Global navigation" icon={<BarsIcon />} />
20+
</MastheadToggle>
21+
<MastheadBrand>
22+
<MastheadLogo component={(props) => <a {...props} href="#" />}>
23+
<Brand src={pfIcon} alt="PatternFly" heights={{ default: '36px' }} />
24+
</MastheadLogo>
25+
</MastheadBrand>
26+
</MastheadMain>
27+
<MastheadContent>
28+
<span>Content</span>
29+
</MastheadContent>
30+
</Masthead>
31+
);

0 commit comments

Comments
 (0)