-
Notifications
You must be signed in to change notification settings - Fork 45
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
feat(segmented-control): add component #528
Conversation
🦋 Changeset detectedLatest commit: 87d1bfe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Pull Request Test Coverage Report for Build 4204832423
💛 - Coveralls |
Собрана новая демка. |
Changeset |
const selectedBoxRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
handler.current = onChange; |
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.
Не понял чего ты этим добился. Замемоизировал контекст? А смысл?
contentClassName: | ||
isPositionFounded && children[selectedSegmentPosition].props.contentClassName, | ||
}; | ||
}, [selectedId, children]); |
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.
children всегда новые будут, этот useMemo никогда не будет работать
selectedBoxRef.current.style.width = `${width}px`; | ||
selectedBoxRef.current.style.transform = `translateX(${selectedSegment.offsetLeft}px)`; | ||
} | ||
}, [children, selectedId]); |
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.
Тоже самое, из-за children useEffect будет на каждый рендер срабатывать
</div> | ||
</div> | ||
</div> | ||
<div className={cn(contentClassName)}>{content}</div> |
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.
content && <div.... Контента ведь может и не быть
} | ||
|
||
.xs { | ||
height: 40px; |
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.
Заюзать переменную --size-xs-height
} | ||
|
||
.xxs { | ||
height: 32px; |
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.
Заюзать переменную --size-xxs-height
|
||
## Количество сегментов | ||
|
||
Контрол может содержать от двух до пяти сегментов. |
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.
А если 6 указать?))
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.
Должно ли быть ограничение или нет? Если нет, то не ясно зачем в описании так написано
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.
должно быть ограничение, если нужно больше вариантов, то нужно искать другой компонент. Не принято использовать эту штуку с больше чем пятью сегментами, да и 5 уже почти криминал))
44683f4
to
7b121bf
Compare
@@ -0,0 +1,25 @@ | |||
{ | |||
"name": "@alfalab/core-components-segmented-control", | |||
"version": "1.0.0", |
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.
0.0.0
/** | ||
* Вид компонента | ||
*/ | ||
view?: 'rounded' | 'rect'; |
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.
Сейчас у Tag есть shape (rounded/rectangular), может тут сделаем аналогично?
Тесты нужно добавить |
useEffect(() => { | ||
if (!wrapperRef.current) return undefined; | ||
|
||
const observer = new ResizeObserver(() => setSelectedBoxStylesRef.current()); |
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.
Нужно полифил заиспользовать. Можно в других компонентах посмотреть как сделано
|
||
## Количество сегментов | ||
|
||
Контрол может содержать от двух до пяти сегментов. |
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.
Должно ли быть ограничение или нет? Если нет, то не ясно зачем в описании так написано
7b121bf
to
ae3d3c1
Compare
Собрана новая демка. |
ae3d3c1
to
b496da4
Compare
Собрана новая демка. |
b496da4
to
8745bfc
Compare
Собрана новая демка. |
Собрана новая демка. |
Скриншоты бы еще) |
2f8384d
to
48aaa62
Compare
Собрана новая демка. |
48aaa62
to
9e09740
Compare
Собрана новая демка. |
9e09740
to
87d1bfe
Compare
Собрана новая демка. |
Добавление компонента SegmentedControl