未验证 提交 12c7ed6f 编写于 作者: E eiinu 提交者: GitHub

chore(backtop): icon 组件替换 (#774)

上级 88f7bd06
import React, { FunctionComponent, useState } from 'react' import React, { FunctionComponent, ReactNode, useState } from 'react'
import { usePageScroll, pageScrollTo } from '@tarojs/taro' import { usePageScroll, pageScrollTo } from '@tarojs/taro'
import Icon from '@/packages/icon/index.taro' import { Top } from '@nutui/icons-react-taro'
import { BasicComponent, ComponentDefaults } from '@/utils/typings' import { BasicComponent, ComponentDefaults } from '@/utils/typings'
declare const window: any declare const window: any
...@@ -15,7 +14,7 @@ export interface BackTopProps extends BasicComponent { ...@@ -15,7 +14,7 @@ export interface BackTopProps extends BasicComponent {
zIndex: number zIndex: number
isAnimation: boolean isAnimation: boolean
duration: number duration: number
children?: HTMLElement | any children?: ReactNode
style?: React.CSSProperties style?: React.CSSProperties
onClick?: (event: MouseEvent) => void onClick?: (event: MouseEvent) => void
} }
...@@ -46,8 +45,6 @@ export const BackTop: FunctionComponent< ...@@ -46,8 +45,6 @@ export const BackTop: FunctionComponent<
duration, duration,
style, style,
onClick, onClick,
iconClassPrefix,
iconFontClassName,
} = { } = {
...defaultProps, ...defaultProps,
...props, ...props,
...@@ -85,13 +82,7 @@ export const BackTop: FunctionComponent< ...@@ -85,13 +82,7 @@ export const BackTop: FunctionComponent<
}} }}
> >
{children || ( {children || (
<Icon <Top width={19} height={19} className="nut-backtop-main" />
classPrefix={iconClassPrefix}
fontClassName={iconFontClassName}
size="19px"
className="nut-backtop-main"
name="top"
/>
)} )}
</div> </div>
</> </>
......
import React, { FunctionComponent, useEffect, useState, useRef } from 'react' import React, {
FunctionComponent,
import Icon from '@/packages/icon' useEffect,
useState,
useRef,
ReactNode,
} from 'react'
import { Top } from '@nutui/icons-react'
import { BasicComponent, ComponentDefaults } from '@/utils/typings' import { BasicComponent, ComponentDefaults } from '@/utils/typings'
declare const window: any declare const window: any
...@@ -14,7 +19,7 @@ export interface BackTopProps extends BasicComponent { ...@@ -14,7 +19,7 @@ export interface BackTopProps extends BasicComponent {
zIndex: number zIndex: number
isAnimation: boolean isAnimation: boolean
duration: number duration: number
children?: HTMLElement | any children?: ReactNode
style?: React.CSSProperties style?: React.CSSProperties
onClick?: (event: MouseEvent) => void onClick?: (event: MouseEvent) => void
} }
...@@ -45,8 +50,6 @@ export const BackTop: FunctionComponent< ...@@ -45,8 +50,6 @@ export const BackTop: FunctionComponent<
duration, duration,
style, style,
onClick, onClick,
iconClassPrefix,
iconFontClassName,
} = { } = {
...defaultProps, ...defaultProps,
...props, ...props,
...@@ -152,15 +155,7 @@ export const BackTop: FunctionComponent< ...@@ -152,15 +155,7 @@ export const BackTop: FunctionComponent<
goTop(e) goTop(e)
}} }}
> >
{children || ( {children || <Top width={19} height={19} className="nut-backtop-main" />}
<Icon
classPrefix={iconClassPrefix}
fontClassName={iconFontClassName}
size="19px"
className="nut-backtop-main"
name="top"
/>
)}
</div> </div>
) )
} }
......
import React from 'react' import React from 'react'
import { BackTop, Icon } from '@/packages/nutui.react.taro' import Taro from '@tarojs/taro'
import { Top } from '@nutui/icons-react-taro'
import { BackTop } from '@/packages/nutui.react.taro'
import { useTranslate } from '@/sites/assets/locale/taro' import { useTranslate } from '@/sites/assets/locale/taro'
import Header from '@/sites/components/header' import Header from '@/sites/components/header'
import Taro from '@tarojs/taro'
interface T { interface T {
title: string title: string
...@@ -141,7 +142,7 @@ const BackTopDemo = () => { ...@@ -141,7 +142,7 @@ const BackTopDemo = () => {
alignItems: 'center', alignItems: 'center',
}} }}
> >
<Icon size="12px" className="nut-backtop-main" name="top" /> <Top width={12} height={12} className="nut-backtop-main" />
<div style={{ fontSize: '12px' }}>{translated.backText}</div> <div style={{ fontSize: '12px' }}>{translated.backText}</div>
</div> </div>
</BackTop> </BackTop>
......
import React from 'react' import React from 'react'
import { Top } from '@nutui/icons-react'
import { BackTop } from './backtop' import { BackTop } from './backtop'
import { useTranslate } from '../../sites/assets/locale' import { useTranslate } from '../../sites/assets/locale'
import Icon from '@/packages/icon'
interface T { interface T {
title: string title: string
...@@ -136,11 +136,11 @@ const BackTopDemo = () => { ...@@ -136,11 +136,11 @@ const BackTopDemo = () => {
alignItems: 'center', alignItems: 'center',
}} }}
> >
<Icon size="12px" className="nut-backtop-main" name="top" /> <Top width={12} height={12} />
<div style={{ fontSize: '12px' }}>{translated.backText}</div> <div style={{ fontSize: '12px' }}>{translated.backText}</div>
</div> </div>
</BackTop> </BackTop>
<BackTop elId="elId" distance={200} bottom={50} onClick={handleClick} /> {/* <BackTop elId="elId" distance={200} bottom={50} onClick={handleClick} /> */}
</div> </div>
</> </>
) )
......
...@@ -129,7 +129,8 @@ export default App; ...@@ -129,7 +129,8 @@ export default App;
```tsx ```tsx
import React from "react"; import React from "react";
import { BackTop, Icon } from '@nutui/nutui-react'; import { BackTop } from '@nutui/nutui-react';
import { Top } from '@nutui/icons-react';
const App = () => { const App = () => {
const cellStyle = { const cellStyle = {
...@@ -183,7 +184,7 @@ const App = () => { ...@@ -183,7 +184,7 @@ const App = () => {
alignItems: 'center', alignItems: 'center',
}} }}
> >
<Icon size="12px" className="nut-backtop-main" name="top" /> <Top width={12} height={12} className="nut-backtop-main" />
<div style={{ fontSize: '12px' }}>TOP</div> <div style={{ fontSize: '12px' }}>TOP</div>
</div> </div>
</BackTop> </BackTop>
......
...@@ -132,7 +132,8 @@ export default App; ...@@ -132,7 +132,8 @@ export default App;
```tsx ```tsx
import React from "react"; import React from "react";
import { BackTop,Icon } from '@nutui/nutui-react'; import { BackTop } from '@nutui/nutui-react';
import { Top } from '@nutui/icons-react';
const App = () => { const App = () => {
const cellStyle = { const cellStyle = {
...@@ -186,7 +187,7 @@ const App = () => { ...@@ -186,7 +187,7 @@ const App = () => {
alignItems: 'center', alignItems: 'center',
}} }}
> >
<Icon size="12px" className="nut-backtop-main" name="top" /> <Top width={12} height={12} className="nut-backtop-main" />
<div style={{ fontSize: '12px' }}>顶部</div> <div style={{ fontSize: '12px' }}>顶部</div>
</div> </div>
</BackTop> </BackTop>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
### 安装 ### 安装
```javascript ```javascript
import { BackTop } from '@/packages/nutui.react.taro' import { BackTop } from '@nutui/nutui-react-taro'
``` ```
## 代码演示 ## 代码演示
...@@ -18,7 +18,7 @@ import { BackTop } from '@/packages/nutui.react.taro' ...@@ -18,7 +18,7 @@ import { BackTop } from '@/packages/nutui.react.taro'
```tsx ```tsx
import React from "react"; import React from "react";
import { BackTop } from '@/packages/nutui.react.taro' import { BackTop } from '@nutui/nutui-react-taro'
const App = () => { const App = () => {
const cellStyle = { const cellStyle = {
...@@ -74,7 +74,7 @@ export default App; ...@@ -74,7 +74,7 @@ export default App;
```tsx ```tsx
import React from "react"; import React from "react";
import { BackTop} from '@/packages/nutui.react.taro' import { BackTop} from '@nutui/nutui-react-taro';
const App = () => { const App = () => {
const cellStyle = { const cellStyle = {
...@@ -129,7 +129,8 @@ export default App; ...@@ -129,7 +129,8 @@ export default App;
```tsx ```tsx
import React from "react"; import React from "react";
import { BackTop, Icon } from '@/packages/nutui.react.taro' import { BackTop } from '@nutui/nutui-react-taro';
import { Top } from '@nutui/icons-react-taro';
const App = () => { const App = () => {
const cellStyle = { const cellStyle = {
...@@ -179,7 +180,7 @@ const App = () => { ...@@ -179,7 +180,7 @@ const App = () => {
alignItems: 'center', alignItems: 'center',
}} }}
> >
<Icon size="12px" className="nut-backtop-main" name="top" /> <Top width={12} height={12} className="nut-backtop-main" />
<div style={{ fontSize: '12px' }}>顶部</div> <div style={{ fontSize: '12px' }}>顶部</div>
</div> </div>
</BackTop> </BackTop>
...@@ -197,7 +198,7 @@ export default App; ...@@ -197,7 +198,7 @@ export default App;
```tsx ```tsx
import React from "react"; import React from "react";
import { BackTop} from '@/packages/nutui.react.taro' import { BackTop} from '@nutui/nutui-react-taro'
const App = () => { const App = () => {
const cellStyle = { const cellStyle = {
......
...@@ -131,8 +131,8 @@ export default App; ...@@ -131,8 +131,8 @@ export default App;
```tsx ```tsx
import React from "react"; import React from "react";
import { BackTop,Icon } from '@nutui/nutui-react'; import { BackTop } from '@nutui/nutui-react';
import { Top } from '@nutui/icons-react';
const App = () => { const App = () => {
const cellStyle = { const cellStyle = {
...@@ -186,7 +186,7 @@ const App = () => { ...@@ -186,7 +186,7 @@ const App = () => {
alignItems: 'center', alignItems: 'center',
}} }}
> >
<Icon size="12px" className="nut-backtop-main" name="top" /> <Top width={12} height={12} className="nut-backtop-main" />
<div style={{ fontSize: '12px' }}>顶部</div> <div style={{ fontSize: '12px' }}>顶部</div>
</div> </div>
</BackTop> </BackTop>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册