-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove prop type warning and use only CSS for threshold dot #1380
Changes from 2 commits
37b590c
bd6ab97
5b0294e
ee5ffe0
717904c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { useEffect } from 'react'; | ||
import React, { useCallback, useEffect } from 'react'; | ||
import ProgressBarBase from 'react-bootstrap/ProgressBar'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
@@ -37,11 +37,21 @@ const ProgressBarAnnotated = ({ | |
const progressColor = VARIANTS.includes(variant) ? variant : PROGRESS_DEFAULT_VARIANT; | ||
const thresholdColor = VARIANTS.includes(thresholdVariant) ? thresholdVariant : THRESHOLD_DEFAULT_VARIANT; | ||
|
||
useEffect(() => { | ||
const positionAnnotations = useCallback(() => { | ||
placeInfoAtZero(progressInfoRef, isProgressHintAfter, ANNOTATION_CLASS); | ||
placeInfoAtZero(thresholdInfoRef, isThresholdHintAfter, ANNOTATION_CLASS); | ||
}, [isProgressHintAfter, isThresholdHintAfter]); | ||
|
||
useEffect(() => { | ||
positionAnnotations(); | ||
const observer = new ResizeObserver(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This helps keep the annotation info positioned more accurately when the progress bar itself changes widths (e.g., when the Paragon documentation site theme changes). |
||
positionAnnotations(); | ||
}); | ||
const progressInfoEl = progressInfoRef.current; | ||
observer.observe(progressInfoEl); | ||
return () => progressInfoEl && progressInfoEl.unobserve(progressInfoEl); | ||
}, [positionAnnotations]); | ||
|
||
const getHint = (text) => ( | ||
<span className="pgn__progress-hint"> | ||
{text} | ||
|
@@ -80,12 +90,6 @@ const ProgressBarAnnotated = ({ | |
srOnly | ||
/> | ||
)} | ||
{!!threshold && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used CSS only for this threshold dot instead of a DOM element. |
||
<div | ||
className={`pgn__progress-threshold-dot--${thresholdColor}`} | ||
style={{ left: `${threshold}%` }} | ||
/> | ||
)} | ||
</ProgressBarBase> | ||
{(!!threshold && !!thresholdLabel) && ( | ||
<div | ||
|
@@ -116,8 +120,6 @@ ProgressBarAnnotated.propTypes = { | |
variant: PropTypes.oneOf(VARIANTS), | ||
/** Specifies an additional `className` to add to the base element. */ | ||
className: PropTypes.string, | ||
/** Hide's the label visually. */ | ||
visuallyHidden: PropTypes.bool, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This prop doesn't do anything for the annotated progress bar, and is currently causing a prop type warning. |
||
/** Threshold current value. */ | ||
threshold: PropTypes.number, | ||
/** Specifies label for `threshold`. */ | ||
|
@@ -135,7 +137,6 @@ ProgressBarAnnotated.defaultProps = { | |
label: undefined, | ||
variant: PROGRESS_DEFAULT_VARIANT, | ||
className: undefined, | ||
visuallyHidden: false, | ||
threshold: undefined, | ||
thresholdLabel: undefined, | ||
thresholdVariant: THRESHOLD_DEFAULT_VARIANT, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing required
id
props