Skip to content
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 dots #20

Merged
merged 4 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .storybook/stories/other/Example/DotsExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Button, Dots, rem, View} from '@lad-tech/mobydick-core';
const DotsExample = ({length}: {length: number}) => {
const [activeDot, setActiveDot] = useState(0);
const [activeDotFirstHalf, setActiveDotFirstHalf] = useState(2);
const [activeDotSecondHalf, setActiveDotSecondHalf] = useState(7);
const [activeDotSecondHalf, setActiveDotSecondHalf] = useState(3);

const onPressPrevFirstHalf = useCallback(() => {
if (activeDotFirstHalf !== 0) {
Expand Down Expand Up @@ -68,7 +68,12 @@ const DotsExample = ({length}: {length: number}) => {
paddingHorizontal: rem(20),
}}>
<Button text={'Prev'} onPress={onPressPrevSecondHalf} />
<Dots length={length} activeDot={activeDotSecondHalf} />
<Dots
length={length}
activeDot={activeDotSecondHalf}
fixedSize={rem(6)}
activeDotColor={'red'}
/>
<Button text={'Next'} onPress={onPressNextSecondHalf} />
</View>
</View>
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/other/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ maxLength —— по default 2, отображает максимальное

isLoop – бесконечная карусель, вы должны понимать, что элементов в ней лучше немного использовать
isDots – не использовать, они еще в работе


## ***Dots***
fixedSize – будет работать, если элементов меньше 7
8 changes: 8 additions & 0 deletions packages/core/src/other/components/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const Carousel = <T,>({
isScrolling = false,
ms = 2000,
indexScroll,
dotSize,
activeDotColor,
passiveDotColor,
dotsStyles,
...otherProps
}: ICarouselProps<T>): JSX.Element => {
const ref = useRef<FlatList>(null);
Expand Down Expand Up @@ -231,6 +235,10 @@ const Carousel = <T,>({
length={data.length}
activeDot={currIndex}
animateAutoScroll={animateAutoScroll}
fixedSize={dotSize}
activeDotColor={activeDotColor}
passiveDotColor={passiveDotColor}
dotsStyles={dotsStyles}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,25 @@ describe('Carousel', () => {
},
});
});
it('render Carousel isDots with props', () => {
const {toJSON} = render(
<SafeAreaProvider>
<Carousel
data={data}
sliderItem={sliderItem}
keyExtractor={keyExtractor}
isDots={true}
activeItemId={'1'}
itemWidth={itemWidth}
align={ICarouselAlign.start}
dotSize={4}
activeDotColor={'red'}
passiveDotColor={'black'}
/>
</SafeAreaProvider>,
);
expect(toJSON()).toMatchSnapshot();
});
it('render Carousel onActiveChange', () => {
const {toJSON} = render(
<SafeAreaProvider>
Expand Down
Loading