Skip to content

Commit

Permalink
docs: add README example
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed May 29, 2024
1 parent 97a577b commit 7af05c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Hyperlink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ categories:
- Buttonlike
status: 'Needs Work'
designStatus: 'Done'
devStatus: 'To Do'
devStatus: 'Done'
notes: |
Improve prop naming. Deprecate content prop.
Use React.forwardRef for ref forwarding.
Expand Down Expand Up @@ -100,3 +100,17 @@ notes: |
</div>
</div>
```

## Compatibility with Router

``Hyperlink`` typically relies on the standard HTML anchor tag (i.e., ``a``); however, this behavior may be overriden when the destination link is to an internal page route where it should be using routing (e.g., ``Link`` from React Router) instead.

```jsx live
<Hyperlink
as={GatsbyLink}
destination="/components/button"
to="/components/button"
>
Button
</Hyperlink>
```
2 changes: 2 additions & 0 deletions src/Hyperlink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import isRequiredIf from 'react-proptype-conditional-require';

Check failure on line 3 in src/Hyperlink/index.tsx

View workflow job for this annotation

GitHub Actions / tests

Could not find a declaration file for module 'react-proptype-conditional-require'. '/home/runner/work/paragon/paragon/node_modules/react-proptype-conditional-require/dist/isRequiredIf.js' implicitly has an 'any' type.
import classNames from 'classnames';
import {
type BsPrefixRefForwardingComponent as ComponentWithAsProp,
Expand Down Expand Up @@ -119,6 +120,7 @@ Hyperlink.defaultProps = {
};

Hyperlink.propTypes = {
/** specifies the component element type to render for the hyperlink */
as: PropTypes.elementType,
/** specifies the URL */
destination: PropTypes.string.isRequired,
Expand Down

0 comments on commit 7af05c8

Please sign in to comment.