`Truncate` component relies on `elementType` instead of `as` (props API inconsistency)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 140
- Forks
- 100
- Avg merge
- 1h 3m
- Merged PRs (30d)
- 30
Description
Improvements
Any component that allows consumers to override its underlying DOM element (e.g., div, span) should rely on an as prop for consistency with the majority of Paragon components (given most rely on react-bootstrap).
The Truncate component uses an elementType component instead of as. At least one engineer assumed as prop would work, and had to rely on the documentation to learner that Truncate uses elementType instead.
Given one of the goals of Paragon is to provide a reasonably consistent props API across components, we should ensure that any component that allows consumers to override its underlying DOM element relies on an as prop.
### Tasks
- [ ] Deprecate the `elementType` prop (`withDeprecatedProps`) in `Truncate` component.
- [ ] Introduce `as` prop instead to replace `elementType` (consistent with other components).
- [ ] Identify any other Paragon components that support consumers overriding element types, ensuring they also use `as` instead of an inconsistent prop name.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Truncate component and its documentation to understand the current elementType API and how comparable Paragon components expose as. Inspect other components that let consumers override their underlying element type. Done means elementType is deprecated, as replaces it consistently in Truncate, and any other inconsistent components are identified and updated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100