From 7c5dde6e0d73dcf521caff636defc65e18d691de Mon Sep 17 00:00:00 2001 From: yisumay <15577506835@163.com> Date: Wed, 9 Jul 2025 17:33:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BC=A0=E5=85=A5class=E3=80=81classList?= =?UTF-8?q?=E3=80=81style=E7=AD=89=E5=B1=9E=E6=80=A7=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/config.json | 11 ---- .../src/components/button/button.taro.tsx | 21 +++++--- .../src/components/button/button.tsx | 8 ++- .../src/components/cell/cell.taro.tsx | 52 +++++++++++-------- .../nutui-solid/src/components/cell/cell.tsx | 52 +++++++++++-------- .../src/components/grid/grid.taro.tsx | 17 +++--- .../nutui-solid/src/components/grid/grid.tsx | 17 +++--- .../components/griditem/grid-item.taro.tsx | 6 ++- .../src/components/griditem/grid-item.tsx | 18 +++---- .../src/components/image/image.tsx | 8 ++- .../src/components/row/row.taro.tsx | 4 ++ .../nutui-solid/src/components/row/row.tsx | 4 ++ .../src/components/space/space.taro.tsx | 4 ++ .../src/components/space/space.tsx | 4 ++ 14 files changed, 134 insertions(+), 92 deletions(-) diff --git a/packages/config.json b/packages/config.json index 888d216..e60de2e 100644 --- a/packages/config.json +++ b/packages/config.json @@ -91,17 +91,6 @@ "exportEmpty": true, "taro": true, "author": "yisumay" - }, - { - "version": "1.0.0", - "name": "Image", - "type": "component", - "cName": "图片", - "desc": "图片", - "sort": 2, - "show": true, - "taro": true, - "author": "yisumay" } ] }, diff --git a/packages/nutui-solid/src/components/button/button.taro.tsx b/packages/nutui-solid/src/components/button/button.taro.tsx index a39ab64..6699349 100644 --- a/packages/nutui-solid/src/components/button/button.taro.tsx +++ b/packages/nutui-solid/src/components/button/button.taro.tsx @@ -1,6 +1,6 @@ +import { Loading } from '@nutui/icons-solid' import { Show, createMemo, mergeProps, splitProps } from 'solid-js' import { type Component, type JSX } from 'solid-js' -import { Loading } from '@nutui/icons-solid' export type ButtonType = | 'default' @@ -13,7 +13,7 @@ export type ButtonSize = 'xlarge' | 'large' | 'normal' | 'small' | 'mini' export type ButtonShape = 'square' | 'round' export type ButtonFill = 'solid' | 'outline' | 'dashed' | 'none' -export interface ButtonProps extends JSX.HTMLAttributes { +export type ButtonProps = Omit, 'style'> & Partial<{ color: string shape: ButtonShape plain: boolean @@ -23,7 +23,8 @@ export interface ButtonProps extends JSX.HTMLAttributes { size: ButtonSize block: boolean icon: JSX.Element -} + style: JSX.CSSProperties +}> const defaultProps: ButtonProps = { color: '', @@ -37,7 +38,7 @@ const defaultProps: ButtonProps = { icon: null, } -export const Button: Component> = (props) => { +export const Button: Component = (props) => { const merged = mergeProps(defaultProps, props) const [local, rest] = splitProps(merged, [ 'color', @@ -54,14 +55,16 @@ export const Button: Component> = (props) => { 'style', 'onClick', 'ref', + 'classList', + 'class', ]) const getStyle = createMemo(() => { let style: JSX.CSSProperties = {} if (local.color) { style = { - color: local.plain ? local.color : '#fff', - background: local.plain ? '#fff' : `border-box ${local.color}`, + color: local.plain ? local.color : 'rgb(255, 255, 255)', + background: local.plain ? 'rgb(255, 255, 255)' : `border-box ${local.color}`, } if (local.color.includes('gradient')) { style['border-color'] = 'transparent' @@ -70,7 +73,7 @@ export const Button: Component> = (props) => { style['border-color'] = local.color } } - return style + return { ...style, ...local.style } }) const handleClick: JSX.EventHandler = (e) => { @@ -92,6 +95,8 @@ export const Button: Component> = (props) => { [`${prefixCls}--block`]: local.block, [`${prefixCls}--disabled`]: local.disabled, [`${prefixCls}--loading`]: local.loading, + ...local.classList, + [local.class]: true, } }) @@ -103,7 +108,7 @@ export const Button: Component> = (props) => { style={getStyle()} onClick={handleClick} > -
+
diff --git a/packages/nutui-solid/src/components/button/button.tsx b/packages/nutui-solid/src/components/button/button.tsx index a8cb054..48b7e83 100644 --- a/packages/nutui-solid/src/components/button/button.tsx +++ b/packages/nutui-solid/src/components/button/button.tsx @@ -13,7 +13,7 @@ export type ButtonSize = 'xlarge' | 'large' | 'normal' | 'small' | 'mini' export type ButtonShape = 'square' | 'round' export type ButtonFill = 'solid' | 'outline' | 'dashed' | 'none' -export type ButtonProps = JSX.HTMLAttributes & Partial<{ +export type ButtonProps = Omit, 'style'> & Partial<{ color: string shape: ButtonShape plain: boolean @@ -23,6 +23,7 @@ export type ButtonProps = JSX.HTMLAttributes & Partial<{ size: ButtonSize block: boolean icon: JSX.Element + style: JSX.CSSProperties }> const defaultProps: ButtonProps = { @@ -54,6 +55,7 @@ export const Button: Component = (props) => { 'style', 'onClick', 'ref', + 'classList', ]) const getStyle = createMemo(() => { @@ -70,7 +72,7 @@ export const Button: Component = (props) => { style['border-color'] = local.color } } - return style + return { ...style, ...local.style } }) const handleClick: JSX.EventHandler = (e) => { @@ -92,6 +94,8 @@ export const Button: Component = (props) => { [`${prefixCls}--block`]: local.block, [`${prefixCls}--disabled`]: local.disabled, [`${prefixCls}--loading`]: local.loading, + ...local.classList, + [local.class]: true, } }) diff --git a/packages/nutui-solid/src/components/cell/cell.taro.tsx b/packages/nutui-solid/src/components/cell/cell.taro.tsx index 8b99cc6..2a1867c 100644 --- a/packages/nutui-solid/src/components/cell/cell.taro.tsx +++ b/packages/nutui-solid/src/components/cell/cell.taro.tsx @@ -4,7 +4,7 @@ import { pxCheck } from '@/utils/px-check' export type CellSize = 'normal' | 'large' -export type CellProps = Omit, 'title'> & Partial<{ +export type CellProps = Omit, 'title' | 'style'> & Partial<{ title: JSX.Element subTitle: JSX.Element desc: JSX.Element @@ -23,6 +23,7 @@ export type CellProps = Omit, 'title'> & Part */ url: string link: JSX.Element + style: JSX.CSSProperties }> const defaultProps: CellProps = { @@ -56,6 +57,9 @@ export const Cell: Component> = (props) => { 'link', 'onClick', 'children', + 'style', + 'classList', + 'class', ]) const classes = createMemo(() => { @@ -65,15 +69,17 @@ export const Cell: Component> = (props) => { [`${prefixCls}--clickable`]: local.isLink, [`${prefixCls}--center`]: local.center, [`${prefixCls}--large`]: local.size === 'large', + ...local.classList, + [local.class]: true, } }) const baseStyle = createMemo(() => { + const style = local.style if (local.roundRadius) { - return { - 'border-radius': pxCheck(local.roundRadius), - } as JSX.CSSProperties + style['border-radius'] = pxCheck(local.roundRadius) } + return style }) const descStyle = createMemo(() => { @@ -102,24 +108,24 @@ export const Cell: Component> = (props) => { {local?.children ? local?.children : ( - <> - -
- {local.icon} -
-
- -
-
{local.title}
- -
{ local.subTitle}
-
-
-
- -
{local.desc}
-
- { + <> + +
+ {local.icon} +
+
+ +
+
{local.title}
+ +
{ local.subTitle}
+
+
+
+ +
{local.desc}
+
+ { local?.link ?? ( @@ -127,7 +133,7 @@ export const Cell: Component> = (props) => { ) } - + )}
) diff --git a/packages/nutui-solid/src/components/cell/cell.tsx b/packages/nutui-solid/src/components/cell/cell.tsx index 8b99cc6..2a1867c 100644 --- a/packages/nutui-solid/src/components/cell/cell.tsx +++ b/packages/nutui-solid/src/components/cell/cell.tsx @@ -4,7 +4,7 @@ import { pxCheck } from '@/utils/px-check' export type CellSize = 'normal' | 'large' -export type CellProps = Omit, 'title'> & Partial<{ +export type CellProps = Omit, 'title' | 'style'> & Partial<{ title: JSX.Element subTitle: JSX.Element desc: JSX.Element @@ -23,6 +23,7 @@ export type CellProps = Omit, 'title'> & Part */ url: string link: JSX.Element + style: JSX.CSSProperties }> const defaultProps: CellProps = { @@ -56,6 +57,9 @@ export const Cell: Component> = (props) => { 'link', 'onClick', 'children', + 'style', + 'classList', + 'class', ]) const classes = createMemo(() => { @@ -65,15 +69,17 @@ export const Cell: Component> = (props) => { [`${prefixCls}--clickable`]: local.isLink, [`${prefixCls}--center`]: local.center, [`${prefixCls}--large`]: local.size === 'large', + ...local.classList, + [local.class]: true, } }) const baseStyle = createMemo(() => { + const style = local.style if (local.roundRadius) { - return { - 'border-radius': pxCheck(local.roundRadius), - } as JSX.CSSProperties + style['border-radius'] = pxCheck(local.roundRadius) } + return style }) const descStyle = createMemo(() => { @@ -102,24 +108,24 @@ export const Cell: Component> = (props) => { {local?.children ? local?.children : ( - <> - -
- {local.icon} -
-
- -
-
{local.title}
- -
{ local.subTitle}
-
-
-
- -
{local.desc}
-
- { + <> + +
+ {local.icon} +
+
+ +
+
{local.title}
+ +
{ local.subTitle}
+
+
+
+ +
{local.desc}
+
+ { local?.link ?? ( @@ -127,7 +133,7 @@ export const Cell: Component> = (props) => { ) } - + )}
) diff --git a/packages/nutui-solid/src/components/grid/grid.taro.tsx b/packages/nutui-solid/src/components/grid/grid.taro.tsx index 4d38796..0bfb3ca 100644 --- a/packages/nutui-solid/src/components/grid/grid.taro.tsx +++ b/packages/nutui-solid/src/components/grid/grid.taro.tsx @@ -4,7 +4,7 @@ import { pxCheck } from '@/utils/px-check' export type GridDirection = 'horizontal' | 'vertical' -export type GridLocalProps = Partial<{ +export type GridProps = Omit, 'style'> & Partial<{ columnNum: string | number border: boolean gutter: string | number @@ -13,10 +13,9 @@ export type GridLocalProps = Partial<{ reverse: boolean direction: GridDirection clickable: boolean + style: JSX.CSSProperties }> -export type GridProps = JSX.HTMLAttributes & GridLocalProps - const defaultProps = { columnNum: 4, border: true, @@ -39,6 +38,10 @@ export const Grid: Component> = (props) => { 'reverse', 'direction', 'clickable', + 'classList', + 'style', + 'children', + 'class', ]) const classes = createMemo(() => { @@ -47,6 +50,8 @@ export const Grid: Component> = (props) => { [prefixCls]: true, [`${prefixCls}-${local.columnNum}`]: true, [`${prefixCls}-border`]: local.border, + ...local.classList, + [local.class]: true, } }) @@ -56,7 +61,7 @@ export const Grid: Component> = (props) => { style['padding-left'] = pxCheck(props.gutter) style['row-gap'] = pxCheck(props.gutter) } - return style + return { ...style, ...local.style } }) return ( @@ -70,8 +75,8 @@ export const Grid: Component> = (props) => { direction={local.direction} clickable={local.clickable} > -
- {rest.children} +
+ {local.children}
) diff --git a/packages/nutui-solid/src/components/grid/grid.tsx b/packages/nutui-solid/src/components/grid/grid.tsx index 4d38796..0bfb3ca 100644 --- a/packages/nutui-solid/src/components/grid/grid.tsx +++ b/packages/nutui-solid/src/components/grid/grid.tsx @@ -4,7 +4,7 @@ import { pxCheck } from '@/utils/px-check' export type GridDirection = 'horizontal' | 'vertical' -export type GridLocalProps = Partial<{ +export type GridProps = Omit, 'style'> & Partial<{ columnNum: string | number border: boolean gutter: string | number @@ -13,10 +13,9 @@ export type GridLocalProps = Partial<{ reverse: boolean direction: GridDirection clickable: boolean + style: JSX.CSSProperties }> -export type GridProps = JSX.HTMLAttributes & GridLocalProps - const defaultProps = { columnNum: 4, border: true, @@ -39,6 +38,10 @@ export const Grid: Component> = (props) => { 'reverse', 'direction', 'clickable', + 'classList', + 'style', + 'children', + 'class', ]) const classes = createMemo(() => { @@ -47,6 +50,8 @@ export const Grid: Component> = (props) => { [prefixCls]: true, [`${prefixCls}-${local.columnNum}`]: true, [`${prefixCls}-border`]: local.border, + ...local.classList, + [local.class]: true, } }) @@ -56,7 +61,7 @@ export const Grid: Component> = (props) => { style['padding-left'] = pxCheck(props.gutter) style['row-gap'] = pxCheck(props.gutter) } - return style + return { ...style, ...local.style } }) return ( @@ -70,8 +75,8 @@ export const Grid: Component> = (props) => { direction={local.direction} clickable={local.clickable} > -
- {rest.children} +
+ {local.children}
) diff --git a/packages/nutui-solid/src/components/griditem/grid-item.taro.tsx b/packages/nutui-solid/src/components/griditem/grid-item.taro.tsx index 0a737a3..ee860f0 100644 --- a/packages/nutui-solid/src/components/griditem/grid-item.taro.tsx +++ b/packages/nutui-solid/src/components/griditem/grid-item.taro.tsx @@ -27,6 +27,8 @@ export const GridItem: Component> = (props) => { 'text', 'url', 'replace', + 'class', + 'children', ]) const rootStyle = createMemo(() => { @@ -66,8 +68,8 @@ export const GridItem: Component> = (props) => { } return ( -
-
{rest.children}
+
+
{local.children}
{local.text}
diff --git a/packages/nutui-solid/src/components/griditem/grid-item.tsx b/packages/nutui-solid/src/components/griditem/grid-item.tsx index 09bbc6c..ee860f0 100644 --- a/packages/nutui-solid/src/components/griditem/grid-item.tsx +++ b/packages/nutui-solid/src/components/griditem/grid-item.tsx @@ -1,5 +1,5 @@ -import { Component, JSX, ParentProps, createMemo, mergeProps, splitProps, useContext } from 'solid-js' -import { GridContext } from '../grid/grid.context' +import { Component, JSX, ParentProps, createMemo, mergeProps, splitProps } from 'solid-js' +import { useGridContext } from '../grid/grid.context' import { pxCheck } from '@/utils/px-check' export type GridItemProps = JSX.HTMLAttributes & Partial<{ @@ -21,12 +21,14 @@ const defaultProps = { export const GridItem: Component> = (props) => { const merged = mergeProps(defaultProps, props) - const parent = useContext(GridContext) || {} + const parent = useGridContext() const [local, rest] = splitProps(merged, [ 'text', 'url', 'replace', + 'class', + 'children', ]) const rootStyle = createMemo(() => { @@ -66,12 +68,10 @@ export const GridItem: Component> = (props) => { } return ( -
-
- {rest.children} -
- {local.text} -
+
+
{local.children}
+
+ {local.text}
) diff --git a/packages/nutui-solid/src/components/image/image.tsx b/packages/nutui-solid/src/components/image/image.tsx index 6884cdc..4987aeb 100644 --- a/packages/nutui-solid/src/components/image/image.tsx +++ b/packages/nutui-solid/src/components/image/image.tsx @@ -6,7 +6,7 @@ import { pxCheck } from '@/utils/px-check' export type ImageFit = 'contain' | 'cover' | 'fill' | 'none' | 'scale-down' export type ImagePosition = 'center' | 'top' | 'right' | 'bottom' | 'left' | string -export type ImageProps = Omit, 'onClick'> & Partial<{ +export type ImageProps = Omit, 'onClick' | 'style'> & Partial<{ src: string fit: ImageFit position: ImagePosition @@ -21,6 +21,7 @@ export type ImageProps = Omit, 'onClick'> & loading: JSX.Element error: JSX.Element onClick: JSX.EventHandlerUnion + style: JSX.CSSProperties }> const defaultProps: ImageProps = { @@ -53,6 +54,8 @@ export const Image: Component> = (props) => { 'onClick', 'onLoad', 'onError', + 'style', + 'class', ]) const [loading, setLoading] = createSignal(true) @@ -112,6 +115,7 @@ export const Image: Component> = (props) => { const styless: JSX.CSSProperties = { 'object-fit': local.fit, 'object-position': local.position, + ...local.style, } return styless @@ -157,7 +161,7 @@ export const Image: Component> = (props) => {
> = (props) => { 'justify', 'align', 'flexWrap', + 'classList', + 'class', ]) const getClass = (prefix: string, type: string) => { @@ -38,6 +40,8 @@ export const Row: Component> = (props) => { [getClass('justify', local.justify)]: true, [getClass('align', local.align)]: true, [getClass('flex', local.flexWrap)]: true, + ...local.classList, + [local.class]: true, } }) diff --git a/packages/nutui-solid/src/components/row/row.tsx b/packages/nutui-solid/src/components/row/row.tsx index b5bcd3b..371741f 100644 --- a/packages/nutui-solid/src/components/row/row.tsx +++ b/packages/nutui-solid/src/components/row/row.tsx @@ -25,6 +25,8 @@ export const Row: Component> = (props) => { 'justify', 'align', 'flexWrap', + 'classList', + 'class', ]) const getClass = (prefix: string, type: string) => { @@ -38,6 +40,8 @@ export const Row: Component> = (props) => { [getClass('justify', local.justify)]: true, [getClass('align', local.align)]: true, [getClass('flex', local.flexWrap)]: true, + ...local.classList, + [local.class]: true, } }) diff --git a/packages/nutui-solid/src/components/space/space.taro.tsx b/packages/nutui-solid/src/components/space/space.taro.tsx index fd03204..ca17b5f 100644 --- a/packages/nutui-solid/src/components/space/space.taro.tsx +++ b/packages/nutui-solid/src/components/space/space.taro.tsx @@ -30,6 +30,8 @@ export const Space: Component> = (props) => { 'wrap', 'fill', 'children', + 'classList', + 'class', ]) // gutter数值转换 @@ -72,6 +74,8 @@ export const Space: Component> = (props) => { [`${prefixCls}-justify-${local.justify}`]: true, [`${prefixCls}-wrap`]: local.wrap, [`${prefixCls}-fill`]: local.fill, + ...local.classList, + [local.class]: true, } }) diff --git a/packages/nutui-solid/src/components/space/space.tsx b/packages/nutui-solid/src/components/space/space.tsx index fd03204..ca17b5f 100644 --- a/packages/nutui-solid/src/components/space/space.tsx +++ b/packages/nutui-solid/src/components/space/space.tsx @@ -30,6 +30,8 @@ export const Space: Component> = (props) => { 'wrap', 'fill', 'children', + 'classList', + 'class', ]) // gutter数值转换 @@ -72,6 +74,8 @@ export const Space: Component> = (props) => { [`${prefixCls}-justify-${local.justify}`]: true, [`${prefixCls}-wrap`]: local.wrap, [`${prefixCls}-fill`]: local.fill, + ...local.classList, + [local.class]: true, } })