Skip to content

Commit

Permalink
feat(component): 新增 H5 组件,并新增共同样式 (#10841)
Browse files Browse the repository at this point in the history
* feat(component): add h5 component error tips

* feat(types): 补齐新增组件相关类型

* feat(route): taro-page 滚动条共享问题 fix #7974

Co-authored-by: chenjiajian <[email protected]>
  • Loading branch information
ZakaryCode and Chen-jj authored Dec 9, 2021
1 parent 10c9648 commit 67eba7d
Show file tree
Hide file tree
Showing 34 changed files with 670 additions and 61 deletions.
17 changes: 17 additions & 0 deletions packages/taro-components/src/components/ad-custom/ad-custom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-ad-custom-core'
})
export class AdCustom {
componentDidLoad () {
console.error('H5 暂不支持 AdCustom 组件!')
}

render () {
return (
<Host />
)
}
}
17 changes: 17 additions & 0 deletions packages/taro-components/src/components/ad/ad.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-ad-core'
})
export class Ad {
componentDidLoad () {
console.error('H5 暂不支持 Ad 组件!')
}

render () {
return (
<Host />
)
}
}
17 changes: 17 additions & 0 deletions packages/taro-components/src/components/editor/editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-editor-core'
})
export class Editor {
componentDidLoad () {
console.error('H5 暂不支持 Editor 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-functional-page-navigator-core'
})
export class FunctionalPageNavigator {
componentDidLoad () {
console.error('H5 暂不支持 FunctionalPageNavigator 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-keyboard-accessory-core'
})
export class KeyboardAccessory {
componentDidLoad () {
console.error('H5 暂不支持 KeyboardAccessory 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-live-player-core'
})
export class LivePlayer {
componentDidLoad () {
console.error('H5 暂不支持 LivePlayer 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-live-pusher-core'
})
export class LivePusher {
componentDidLoad () {
console.error('H5 暂不支持 LivePusher 组件!')
}

render () {
return (
<Host />
)
}
}
17 changes: 17 additions & 0 deletions packages/taro-components/src/components/map/map.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-map-core'
})
export class Map {
componentDidLoad () {
console.error('H5 暂不支持 Map 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-match-media-core'
})
export class MatchMedia {
componentDidLoad () {
console.error('H5 暂不支持 MatchMedia 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-navigation-bar-core'
})
export class NavigationBar {
componentDidLoad () {
console.error('H5 暂不支持 NavigationBar 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-official-account-core'
})
export class OfficialAccount {
componentDidLoad () {
console.error('H5 暂不支持 OfficialAccount 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-page-container-core'
})
export class PageContainer {
componentDidLoad () {
console.error('H5 暂不支持 PageContainer 组件!')
}

render () {
return (
<Host />
)
}
}
17 changes: 17 additions & 0 deletions packages/taro-components/src/components/page-meta/page-meta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-page-meta-core'
})
export class PageMeta {
componentDidLoad () {
console.error('H5 暂不支持 PageMeta 组件!')
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-share-element-core'
})
export class ShareElement {
componentDidLoad () {
console.error('H5 暂不支持 ShareElement 组件!')
}

render () {
return (
<Host />
)
}
}
17 changes: 17 additions & 0 deletions packages/taro-components/src/components/slot/slot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-slot-core'
})
export class Slot {
componentDidLoad () {
console.error('H5 暂不支持 Slot 组件!')
}

render () {
return (
<Host />
)
}
}
17 changes: 17 additions & 0 deletions packages/taro-components/src/components/voip-room/voip-room.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, h, Host } from '@stencil/core'

@Component({
tag: 'taro-voip-room-core'
})
export class VoipRoom {
componentDidLoad () {
console.error('H5 暂不支持 VoipRoom 组件!')
}

render () {
return (
<Host />
)
}
}
7 changes: 7 additions & 0 deletions packages/taro-components/src/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import url(../node_modules/weui/dist/style/weui.min.css);

.taro_page {
max-height: 100vh;
overflow-x: hidden;
overflow-y: scroll;
}
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/taro-components/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { jsWithTs: tsjPreset } = require('ts-jest/presets')

export const config: Config = {
namespace: 'taro-components',
globalStyle: './node_modules/weui/dist/style/weui.min.css',
globalStyle: './src/global.css',
plugins: [
sass()
],
Expand Down
12 changes: 6 additions & 6 deletions packages/taro-components/types/Ad.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ interface AdProps extends StandardProps {
* @supported weapp
*/
adIntervals?: number

/** 广告类型,默认为展示`banner`,可通过设置该属性为`video`展示视频广告, `grid`为格子广告
* @supported weapp
*/
adType?: 'banner' | 'video' | 'grid'

/** 广告主题样式设置
* @supported weapp
*/
Expand All @@ -42,9 +42,9 @@ declare namespace AdProps {
interface onErrorEventDetail {
errCode: keyof AdErrCode
}
/**
/**
* 广告错误码
*
*
* 错误码是通过onError获取到的错误信息。调试期间,可以通过异常返回来捕获信息。
* 在小程序发布上线之后,如果遇到异常问题,可以在[“运维中心“](https://mp.weixin.qq.com/)里面搜寻错误日志,还可以针对异常返回加上适当的监控信息。
*/
Expand Down Expand Up @@ -116,8 +116,8 @@ declare namespace AdProps {
* render () {
* return (
* <Ad
* unit-id=''
* ad-intervals={60}
* unitId=''
* adIntervals={60}
* onLoad={() => console.log('ad onLoad')}
* onError={() => console.log('ad onError')}
* onClose={() => console.log('ad onClose')}
Expand Down
50 changes: 50 additions & 0 deletions packages/taro-components/types/AdCustom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ComponentType } from 'react'
import { StandardProps, CommonEventFunction } from './common'
import { AdProps } from './Ad'

interface AdCustomProps extends StandardProps {
/** 广告单元id,可在[小程序管理后台](https://mp.weixin.qq.com/)的流量主模块新建
* @supported weapp
*/
unitId: string

/** 广告自动刷新的间隔时间,单位为秒,参数值必须大于等于30(该参数不传入时 Banner 广告不会自动刷新)
* @supported weapp
*/
adIntervals?: number

/** 广告加载成功的回调
* @supported weapp
*/
onLoad?: CommonEventFunction

/** 当广告发生错误时,触发的事件,可以通过该事件获取错误码及原因,事件对象event.detail = {errCode: 1002}
* @supported weapp
*/
onError?: CommonEventFunction<AdProps.onErrorEventDetail>
}

/** Banner 广告
* @classification open
* @supported weapp
* @example
* ```tsx
* class App extends Component {
* render () {
* return (
* <AdCustom
* unitId=''
* adIntervals={60}
* onLoad={() => console.log('ad onLoad')}
* onError={() => console.log('ad onError')}
* onClose={() => console.log('ad onClose')}
* />
* )
* }
* }
* ```
* @see https://developers.weixin.qq.com/miniprogram/dev/component/ad.html
*/
declare const AdCustom: ComponentType<AdCustomProps>

export { AdCustom, AdCustomProps }
Loading

0 comments on commit 67eba7d

Please sign in to comment.