feat: add CustomScrollView.Tint#9359
Conversation
a85a9af to
886c55f
Compare
size-limit report 📦
|
e2e tests |
👀 Docs deployed
📦 Package ✅yarn add @vkontakte/vkui@https://development.s3.prodcloud.vk.team/pull/9359/ad82164d2e5497fcb51b9ae27b746ec0b3c89c4e/pkg/@vkontakte/vkui/_pkg.tgzCommit ad82164 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9359 +/- ##
==========================================
+ Coverage 94.73% 94.80% +0.07%
==========================================
Files 440 441 +1
Lines 11898 11922 +24
Branches 4386 4394 +8
==========================================
+ Hits 11271 11303 +32
+ Misses 627 619 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| <div | ||
| ref={getRootRef} | ||
| className={classNames(className, styles.host)} | ||
| style={mergeStyle( | ||
| style, | ||
| tintColor ? { '--vkui_internal--CustomScrollView_tint_color': tintColor } : undefined, | ||
| )} | ||
| {...restProps} | ||
| > |
There was a problem hiding this comment.
| <div | |
| ref={getRootRef} | |
| className={classNames(className, styles.host)} | |
| style={mergeStyle( | |
| style, | |
| tintColor ? { '--vkui_internal--CustomScrollView_tint_color': tintColor } : undefined, | |
| )} | |
| {...restProps} | |
| > | |
| <RootComponent | |
| baseClassName={styles.host} | |
| baseStyle={tintColor ? { '--vkui_internal--CustomScrollView_tint_color': tintColor } : undefined} | |
| {...restProps} | |
| > |
Можно использовать RootComponent, чтобы не деструктуризировать getRootRef, className и style
| const onScroll = (e: React.UIEvent<HTMLDivElement>) => { | ||
| const target = e.currentTarget; | ||
| updateTint(target); | ||
| }; |
There was a problem hiding this comment.
Пересчет теней происходит только при скролле, но при изменении размеров контейнера не происходит пересчет. Может добавить useResizeObserver?
There was a problem hiding this comment.
Я тут подумал, размер контейнера CustomScrollView может и не измениться при изменении реального размера содержимого, так что тут useResizeObserver будет бесполезным. Тут либо добавлять еще один контейнер, у которого будет меняться размер, при изменении размеров содержимого, либо забить надо это и вовсе убрать useResizeObserver, но тогда могут появиться баги в будущем
| )} | ||
| {...restProps} | ||
| > | ||
| {children({ getRootRef: scrollRef, onScroll })} |
There was a problem hiding this comment.
У нас вроде не очень приветствуется использование renderFn подхода, потому что нужно мемоизировать children функцию снаружи и свойства прокидываемые в функцию. Может лучше использовать контекст как в Accordion.
There was a problem hiding this comment.
Хочется сделать компонент CustomScrollViewTint более независимым. При использовании контекста разработчики могут начать писать такой код, который не работает:
const props = React.use(CustomScrollView.Tint.Context); // {getRootRef, onScroll}
<CustomScrollView.Tint tintColor="var(--vkui--color_background)">
<CustomScrollView {...props}>
{["Say", "Hello", "To", "My", "Little", "Friend"].map((item) => (
<Cell key={item} before={<Avatar />}>
{item}
</Cell>
))}
</CustomScrollView>
</CustomScrollView.Tint>There was a problem hiding this comment.
А mask-composite: intersect + mask-image работает только с доп оберткой?
Просто если нет, то хорошо бы встал хук нежели подкомпонент
const scrollTintProps = useScrollTint("var(--vkui--color_background)")
// ...
<CustomScrollView {...scrollTintProps}>
{["Say", "Hello", "To", "My", "Little", "Friend"].map((item) => (
<Cell key={item} before={<Avatar />}>
{item}
</Cell>
))}
</CustomScrollView>9be823d to
a778ed1
Compare
698fda9 to
021b56a
Compare

Описание
Добавляем компонент для создания теней к прокручиваемой области
Release notes
Новые компоненты