From aa3b385c68ce98ef327341adde809b135f98d66d Mon Sep 17 00:00:00 2001 From: xiaoyatong <84436086+xiaoyatong@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:21:06 +0800 Subject: [PATCH] feat(backtop): rtl (#2051) Co-authored-by: xiaoyatong --- src/packages/backtop/backtop.taro.tsx | 4 +++- src/packages/backtop/backtop.tsx | 4 +++- src/packages/badge/badge.taro.tsx | 2 -- src/packages/badge/badge.tsx | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/packages/backtop/backtop.taro.tsx b/src/packages/backtop/backtop.taro.tsx index 343353b1de..3de7a30ddd 100644 --- a/src/packages/backtop/backtop.taro.tsx +++ b/src/packages/backtop/backtop.taro.tsx @@ -4,6 +4,7 @@ import { usePageScroll, pageScrollTo } from '@tarojs/taro' import { Top } from '@nutui/icons-react-taro' import classNames from 'classnames' import { BasicComponent, ComponentDefaults } from '@/utils/typings' +import { useRtl } from '@/packages/configprovider/index.taro' export interface BackTopProps extends BasicComponent { threshold: number @@ -22,6 +23,7 @@ const defaultProps = { export const BackTop: FunctionComponent< Partial & Omit, 'onClick'> > = (props) => { + const rtl = useRtl() const { children, threshold, zIndex, className, duration, style, onClick } = { ...defaultProps, ...props, @@ -53,7 +55,7 @@ export const BackTop: FunctionComponent< ...style, } : { - right: '10px', + [rtl ? 'left' : 'right']: '10px', bottom: '20px', zIndex, } diff --git a/src/packages/backtop/backtop.tsx b/src/packages/backtop/backtop.tsx index 7cc2447516..d3ee8e735f 100644 --- a/src/packages/backtop/backtop.tsx +++ b/src/packages/backtop/backtop.tsx @@ -4,6 +4,7 @@ import { Top } from '@nutui/icons-react' import classNames from 'classnames' import { BasicComponent, ComponentDefaults } from '@/utils/typings' import requestAniFrame from '@/utils/raf' +import { useRtl } from '@/packages/configprovider' declare const window: any @@ -26,6 +27,7 @@ const defaultProps = { export const BackTop: FunctionComponent< Partial & Omit, 'onClick'> > = (props) => { + const rtl = useRtl() const { children, target, @@ -121,7 +123,7 @@ export const BackTop: FunctionComponent< ...style, } : { - right: '10px', + [rtl ? 'left' : 'right']: '10px', bottom: '20px', zIndex, } diff --git a/src/packages/badge/badge.taro.tsx b/src/packages/badge/badge.taro.tsx index e8658affa3..a0bf0c2cb7 100644 --- a/src/packages/badge/badge.taro.tsx +++ b/src/packages/badge/badge.taro.tsx @@ -1,11 +1,9 @@ import React, { CSSProperties, FunctionComponent, ReactNode } from 'react' import classNames from 'classnames' - import { BasicComponent, ComponentDefaults } from '@/utils/typings' import { useRtl } from '@/packages/configprovider/index.taro' export type BadgeFill = 'solid' | 'outline' - export interface BadgeProps extends BasicComponent { value: ReactNode dot: boolean diff --git a/src/packages/badge/badge.tsx b/src/packages/badge/badge.tsx index f61e105223..be30f25a39 100644 --- a/src/packages/badge/badge.tsx +++ b/src/packages/badge/badge.tsx @@ -1,6 +1,5 @@ import React, { CSSProperties, FunctionComponent, ReactNode } from 'react' import classNames from 'classnames' - import { BasicComponent, ComponentDefaults } from '@/utils/typings' import { useRtl } from '@/packages/configprovider'