From 80cc037a15381a5f3466a7ea79565e10f05ca129 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Wed, 20 Sep 2023 16:36:42 +0800 Subject: [PATCH 1/3] feat(cascader): add size api --- .changeset/proud-turkeys-call.md | 5 + .changeset/spotty-tools-cross.md | 5 + packages/ui/cascader/src/Cascader.tsx | 8 +- .../ui/cascader/stories/index.stories.tsx | 1 + packages/ui/cascader/stories/size.stories.tsx | 102 ++++++++++++++++++ 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 .changeset/proud-turkeys-call.md create mode 100644 .changeset/spotty-tools-cross.md create mode 100644 packages/ui/cascader/stories/size.stories.tsx diff --git a/.changeset/proud-turkeys-call.md b/.changeset/proud-turkeys-call.md new file mode 100644 index 000000000..768c3949d --- /dev/null +++ b/.changeset/proud-turkeys-call.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/cascader": minor +--- + +feat: add size api diff --git a/.changeset/spotty-tools-cross.md b/.changeset/spotty-tools-cross.md new file mode 100644 index 000000000..eecd2da55 --- /dev/null +++ b/.changeset/spotty-tools-cross.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +Cascader feat: add size api diff --git a/packages/ui/cascader/src/Cascader.tsx b/packages/ui/cascader/src/Cascader.tsx index 017d5c2ca..50983c4d5 100644 --- a/packages/ui/cascader/src/Cascader.tsx +++ b/packages/ui/cascader/src/Cascader.tsx @@ -1,5 +1,5 @@ import React, { forwardRef, useState, useMemo, useEffect } from 'react' -import type { HiBaseAppearanceEnum } from '@hi-ui/core' +import type { HiBaseAppearanceEnum, HiBaseSizeEnum } from '@hi-ui/core' import { cx, getPrefixCls } from '@hi-ui/classname' import { __DEV__ } from '@hi-ui/env' import { useUncontrolledToggle } from '@hi-ui/use-toggle' @@ -52,6 +52,7 @@ export const Cascader = forwardRef((props, data = NOOP_ARRAY, flattedSearchResult = true, visible, + size = 'md', onOpen, onClose, ...rest @@ -221,6 +222,7 @@ export const Cascader = forwardRef((props, onSearch={callAllFuncs(onSearchProp, onSearch)} trigger={ { + const [data] = React.useState([ + { + id: '手机', + title: '手机t', + children: [ + { + id: '小米', + title: '小米t', + children: [ + { + id: '小米3', + title: '小米3t', + }, + { + id: '小米4', + title: '小米4t', + }, + ], + }, + { + id: '红米', + title: '红米t', + children: [ + { + id: '红米3', + title: '红米3t', + }, + { + id: '红米4', + title: '红米4t', + }, + ], + }, + ], + }, + { + id: '电视', + title: '电视t', + children: [ + { + id: '小米电视4A', + title: '小米电视4At', + }, + { + id: '小米电视4C', + title: '小米电视4Ct', + }, + ], + }, + ]) + + return ( + <> +

Size

+
+

sm

+ { + console.log('onChange', ...args) + }} + > +

md

+ { + console.log('onChange', ...args) + }} + > +

lg

+ { + console.log('onChange', ...args) + }} + > +
+ + ) +} From a592e9f681aa940e6f910b1b09a47bef627b9949 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Thu, 21 Sep 2023 16:25:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore(cascader):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/cascader/src/styles/cascader.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/ui/cascader/src/styles/cascader.scss b/packages/ui/cascader/src/styles/cascader.scss index 53812b4b4..f89635430 100644 --- a/packages/ui/cascader/src/styles/cascader.scss +++ b/packages/ui/cascader/src/styles/cascader.scss @@ -81,7 +81,6 @@ $prefix: '#{$component-prefix}-cascader' !default; &-item { width: 100%; - padding: use-spacing(2) 0; position: relative; cursor: pointer; display: flex; From ac4f37aba429a0159dbf3519a2dcc1e3ad406108 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Thu, 21 Sep 2023 21:00:41 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore(cascader):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E9=80=89=E9=A1=B9=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/cascader/src/styles/cascader.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ui/cascader/src/styles/cascader.scss b/packages/ui/cascader/src/styles/cascader.scss index f89635430..7b215ce9e 100644 --- a/packages/ui/cascader/src/styles/cascader.scss +++ b/packages/ui/cascader/src/styles/cascader.scss @@ -81,6 +81,7 @@ $prefix: '#{$component-prefix}-cascader' !default; &-item { width: 100%; + padding: use-spacing(1) 0; position: relative; cursor: pointer; display: flex; @@ -89,7 +90,7 @@ $prefix: '#{$component-prefix}-cascader' !default; &-option { padding: 0 use-spacing(4); box-sizing: border-box; - height: 32px; + height: use-height-size(7); width: 100%; display: flex; align-items: center;