Skip to content

Commit

Permalink
fix(weapp): support skyline components
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKonka committed Feb 23, 2024
1 parent 18dfb18 commit 3215675
Show file tree
Hide file tree
Showing 48 changed files with 1,936 additions and 1,160 deletions.
25 changes: 25 additions & 0 deletions packages/taro-components/__tests__/span.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { h } from '@stencil/core'
import { newSpecPage, SpecPage } from '@stencil/core/testing'

import { Span } from '../src/components/span/span'
import { printUnimplementedWarning } from './utils'

const logError = jest.fn()
console.error = logError

describe('Span', () => {
let page: SpecPage

it('unimplemented', async () => {
page = await newSpecPage({
components: [Span],
template: () => <taro-span-core />,
})
await page.waitForChanges()

expect(page.root).toEqualHtml(`
<taro-span-core></taro-span-core>
`)
expect(logError).toHaveBeenCalledWith(printUnimplementedWarning(page.root))
})
})
8 changes: 8 additions & 0 deletions packages/taro-components/src/components/span/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# taro-span-core

<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
16 changes: 16 additions & 0 deletions packages/taro-components/src/components/span/span.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-span-core',
})
export class Span implements ComponentInterface {
componentDidLoad() {
notSupport('Span', this)
}

render() {
return <Host />
}
}
17 changes: 16 additions & 1 deletion packages/taro-components/types/GridView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface GridViewProps extends StandardProps {
* @supported weapp
* @default "aligned"
*/
type: string
type: keyof GridViewProps.Type
/** 交叉轴元素数量
* @supported weapp
* @default 2
Expand All @@ -26,6 +26,21 @@ interface GridViewProps extends StandardProps {
* @default 0
*/
maxCrossAxisExtent?: number
/**
* 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距
* @supported weapp
* @default [0, 0, 0, 0]
*/
padding?: [number, number, number, number]
}

declare namespace GridViewProps {
interface Type {
/** 瀑布流,根据子元素高度自动布局 */
masonry
/** 每行高度由同一行中最大高度子节点决定 */
aligned
}
}
/**
* 网格布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
Expand Down
9 changes: 8 additions & 1 deletion packages/taro-components/types/ListView.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'
interface ListViewProps extends StandardProps {}
interface ListViewProps extends StandardProps {
/**
* 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距
* @supported weapp
* @default [0, 0, 0, 0]
*/
padding?: [number, number, number, number]
}

/**
* 列表布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
Expand Down
16 changes: 15 additions & 1 deletion packages/taro-components/types/Snapshot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@ import { ComponentType } from 'react'
import { StandardProps } from './common'

interface SnapshotProps extends StandardProps {
id: string
/**
* 渲染模式
* @supported weapp
* @default 'view'
*/
mode: keyof SnapshotProps.Mode
}

declare namespace SnapshotProps {
interface Mode {
/** 以真实节点渲染 */
view
/** 对子节点生成的内容截图渲染 */
picture
}
}

/** 截图组件。
Expand Down
14 changes: 14 additions & 0 deletions packages/taro-components/types/Span.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ComponentType } from 'react'

import { StandardProps } from './common'

interface SpanProps extends StandardProps { }

/**
* 用于支持内联文本和 image / navigator 的混排
* @classification skyline
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/span.html
*/
declare const Span: ComponentType<SpanProps>
export { Span, SpanProps }
15 changes: 14 additions & 1 deletion packages/taro-components/types/StickyHeader.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'
interface StickyHeaderProps extends StandardProps {}
interface StickyHeaderProps extends StandardProps {
/**
* 吸顶时与顶部的距(px)
* @supported weapp
* @default 0
*/
offsetTop?: number
/**
* 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距
* @supported weapp
* @default [0, 0, 0, 0]
*/
padding?: [number, number, number, number]
}

/**
* 吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
Expand Down
6 changes: 6 additions & 0 deletions packages/taro-components/types/StickySection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ interface StickySectionProps extends StandardProps {
* @default true
*/
pushPinnedHeader?: boolean
/**
* 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距
* @supported weapp
* @default [0, 0, 0, 0]
*/
padding?: [number, number, number, number]
}
/**
* 吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点。仅 Skyline 支持。
Expand Down
16 changes: 16 additions & 0 deletions packages/taro-components/types/Text.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ interface TextProps extends StandardProps {
* @supported alipay
*/
numberOfLines?: number
/**
* 文本溢出处理
* @supported weapp-skyline
* @default 'visible'
*/
overflow?: keyof TextProps.Overflow
/** 限制文本最大行数
* @supported weapp
*/
Expand All @@ -40,6 +46,16 @@ declare namespace TextProps {
/** 根据字体设置的空格大小 */
nbsp
}
interface Overflow {
/** 修剪文本 */
clip
/** 淡出 */
fade
/** 显示省略号 */
ellipsis
/** 文本不截断 */
visible
}
}
/** 文本
* @classification base
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export { GridView } from './GridView'
export { ListView } from './ListView'
export { ShareElement } from './ShareElement'
export { Snapshot } from './SnapShot'
export { Span } from './Span'
export { StickyHeader } from './StickyHeader'
export { StickySection } from './StickySection'

Expand Down
4 changes: 4 additions & 0 deletions packages/taro-components/types/index.vue3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { ShareElementProps } from './ShareElement'
import { SliderProps } from './Slider'
import { SlotProps } from './Slot'
import { SnapshotProps } from './SnapShot'
import { SpanProps } from './Span'
import { StickyHeaderProps } from './StickyHeader'
import { StickySectionProps } from './StickySection'
import { SwiperProps } from './Swiper'
Expand Down Expand Up @@ -144,6 +145,7 @@ export declare const Textarea: VueComponentType<TextareaProps>
export declare const GridView: VueComponentType<GridViewProps>
export declare const ListView: VueComponentType<ListViewProps>
export declare const Snapshot: VueComponentType<SnapshotProps>
export declare const Span: VueComponentType<SpanProps>
export declare const ShareElement: VueComponentType<ShareElementProps>
export declare const StickyHeader: VueComponentType<StickyHeaderProps>
export declare const StickySection: VueComponentType<StickySectionProps>
Expand Down Expand Up @@ -266,6 +268,8 @@ declare global {
'taro-share-element-core': ElementAttrs<TransformReact2VueType<ShareElementProps>>
'snapshot': ElementAttrs<TransformReact2VueType<SnapshotProps>>
'taro-snapshot-core': ElementAttrs<TransformReact2VueType<SnapshotProps>>
'span': ElementAttrs<TransformReact2VueType<SpanProps>>
'taro-span-core': ElementAttrs<TransformReact2VueType<SpanProps>>
'sticky-header': ElementAttrs<TransformReact2VueType<StickyHeaderProps>>
'taro-sticky-header-core': ElementAttrs<TransformReact2VueType<StickyHeaderProps>>
'sticky-section': ElementAttrs<TransformReact2VueType<StickySectionProps>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ require("./taro");
</template>
<template name="tmpl_0_6">
<text selectable="{{xs.b(i.p1,!1)}}" space="{{i.p2}}" decode="{{xs.b(i.p0,!1)}}" style="{{i.st}}" class="{{i.cl}}" onTap="eh" onTouchMove="eh" onTouchEnd="eh" onTouchCancel="eh" onLongTap="eh" id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">
<text selectable="{{xs.b(i.p1,!1)}}" space="{{i.p2}}" decode="{{xs.b(i.p0,!1)}}" onTouchStart="eh" onTouchMove="eh" onTouchEnd="eh" onTouchCancel="eh" onLongTap="eh" style="{{i.st}}" class="{{i.cl}}" onTap="eh" id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">
<block a:for="{{i.cn}}" a:key="sid">
<template is="{{xs.a(0, item.nn)}}" data="{{i:item}}" />
</block>
Expand Down
Loading

0 comments on commit 3215675

Please sign in to comment.