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 fa72a7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 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,18 @@ notes: |
</div>
</div>
```

## with custom link element

``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 route where it should be using routing instead (e.g., ``Link`` from React Router).

```jsx live
<Hyperlink
as={GatsbyLink}
// `destination` is still a required prop even though the `to` takes precedence.
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 fa72a7d

Please sign in to comment.