Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ’„ improve(ui): LightFilter style #554

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ export default defineConfig({
},
{
title: 'ProComponents ็ป„ไปถ',
children: [{ title: 'ProTable ้ซ˜็บง่กจๆ ผ', link: '/biz-components/pro-table' }],
children: [
{ title: 'ProTable ้ซ˜็บง่กจๆ ผ', link: '/biz-components/pro-table' },
{ title: 'LightFilter ่ฝป้‡็ญ›้€‰', link: '/biz-components/light-filter' },
],
},
{
title: 'ๅฏ่ง†ๅŒ–',
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"dependencies": {
"@ant-design/cssinjs": "^1.19.1",
"@ant-design/pro-components": "^2.7.0",
"@ant-design/pro-layout": "^7.19.0",
"@oceanbase/design": "workspace:^",
"@oceanbase/icons": "workspace:^",
"@oceanbase/util": "workspace:^",
Expand All @@ -58,6 +57,8 @@
"screenfull": "^6.0.2"
},
"devDependencies": {
"@ant-design/pro-form": "^2.25.1",
"@ant-design/pro-layout": "^7.19.0",
"@antv/g6": "3.4.10"
},
"peerDependencies": {
Expand Down
197 changes: 197 additions & 0 deletions packages/ui/src/LightFilter/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import React from 'react';
import { Radio, TreeSelect } from '@oceanbase/design';
import type { SizeType } from 'antd/lib/config-provider/SizeContext';
import {
LightFilter,
ProFormCascader,
ProFormCheckbox,
ProFormDatePicker,
ProFormDateRangePicker,
ProFormDateTimePicker,
ProFormDateTimeRangePicker,
ProFormDigit,
ProFormFieldSet,
ProFormSelect,
ProFormSlider,
ProFormSwitch,
ProFormText,
ProFormTimePicker,
ProFormTreeSelect,
} from '@oceanbase/ui';
import dayjs from 'dayjs';

const treeData = [
{
title: 'Node1',
value: '0-0',
key: '0-0',
children: [
{
title: 'Child Node1',
value: '0-0-0',
key: '0-0-0',
},
],
},
{
title: 'Node2',
value: '0-1',
key: '0-1',
children: [
{
title: 'Child Node3',
value: '0-1-0',
key: '0-1-0',
},
{
title: 'Child Node4',
value: '0-1-1',
key: '0-1-1',
},
{
title: 'Child Node5',
value: '0-1-2',
key: '0-1-2',
},
],
},
];

export default () => {
const [size, setSize] = React.useState<SizeType>('middle');
return (
<div>
<Radio.Group
value={size}
onChange={e => {
setSize(e.target.value);
}}
>
<Radio.Button value="middle">Middle</Radio.Button>
<Radio.Button value="small">Small</Radio.Button>
</Radio.Group>
<br />
<br />
<LightFilter<{
sex: string;
}>
initialValues={{
sex: 'man',
name: 'Jack',
range: [20, 80],
slider: 20,
date: '2020-08-19',
datetimeRanger: [
dayjs('2019-11-16 12:50:26').add(-1, 'd').valueOf(),
dayjs('2019-11-16 12:50:26').valueOf(),
],
timeRanger: [
dayjs('2019-11-16 12:50:26').add(-1, 'd').valueOf(),
dayjs('2019-11-16 12:50:26').valueOf(),
],
}}
size={size}
onFinish={async values => console.log(values.sex)}
>
<ProFormSelect
name="sex"
label="ๆ€งๅˆซ"
showSearch
allowClear={false}
fieldProps={{
labelInValue: true,
}}
valueEnum={{
man: '็”ท',
woman: 'ๅฅณ',
}}
/>
<ProFormSelect
name="region"
label="ๅœฐๅŒบ"
mode="multiple"
valueEnum={{
beijing: 'ๅŒ—ไบฌ',
shanghai: 'ไธŠๆตท',
hangzhou: 'ๆญๅทž',
long: '่ฟ™ๆ˜ฏไธ€ไธชๅพˆ้•ฟ็š„็”จๆฅๆต‹่ฏ•ๆบขๅ‡บ็š„้กน็›ฎ',
}}
/>
<ProFormCheckbox.Group
name="checkbox-group"
label="Checkbox.Group"
options={['A', 'B', 'C', 'D', 'E', 'F']}
/>
<ProFormTreeSelect
initialValue={['0-0', '0-1']}
label="ๆ ‘ๅฝขไธ‹ๆ‹‰้€‰ๆ‹ฉๅ™จ"
fieldProps={{
fieldNames: {
label: 'title',
},
treeData,
treeCheckable: true,
showCheckedStrategy: TreeSelect.SHOW_PARENT,
placeholder: 'Please select',
}}
name="treeSelect"
/>
<ProFormCascader
width="md"
request={async () => [
{
value: 'zhejiang',
label: 'ๆต™ๆฑŸ',
children: [
{
value: 'hangzhou',
label: 'ๆญๅทž',
children: [
{
value: 'xihu',
label: '่ฅฟๆน–',
},
],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [
{
value: 'zhonghuamen',
label: 'Zhong Hua Men',
},
],
},
],
},
]}
name="area"
label="ๅŒบๅŸŸ"
initialValue={['zhejiang', 'hangzhou', 'xihu']}
/>
<ProFormSwitch name="open" label="ๅผ€ๅ…ณ" />
<ProFormDigit name="count" label="ๆ•ฐ้‡" />
<ProFormSlider name="range" label="่Œƒๅ›ด" range />
<ProFormSlider name="slider" label="่Œƒๅ›ด" />
<ProFormText name="name" label="ๅ็งฐ" />
<ProFormDatePicker name="date" label="ๆ—ฅๆœŸ" />
<ProFormDateRangePicker name="dateRanger" label="ๆ—ฅๆœŸ่Œƒๅ›ด" />
<ProFormDateTimePicker name="datetime" label="ๆ—ฅๆœŸๆ—ถ้—ด" />
<ProFormDateTimeRangePicker name="datetimeRanger" label="ๆ—ฅๆœŸๆ—ถ้—ด่Œƒๅ›ด" />
<ProFormTimePicker name="time" label="ๆ—ถ้—ด" />
<ProFormTimePicker.RangePicker name="timeRanger" label="ๆ—ถ้—ด่Œƒๅ›ด" />
<ProFormFieldSet name="name" label="ๅง“ๅ">
<ProFormText />
<ProFormText />
</ProFormFieldSet>
</LightFilter>
</div>
);
};
17 changes: 17 additions & 0 deletions packages/ui/src/LightFilter/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: LightFilter ่ฝป้‡็ญ›้€‰
nav:
title: ไธšๅŠก็ป„ไปถ
path: /biz-components
---

- ๐Ÿ”ฅ ๅฎŒๅ…จ็ปงๆ‰ฟ pro-components [LightFilter](https://procomponents.ant.design/components/query-filter#%E8%BD%BB%E9%87%8F%E7%AD%9B%E9%80%89) ็š„่ƒฝๅŠ›ๅ’Œ API๏ผŒๅฏๆ— ็ผๅˆ‡ๆขใ€‚
- ๐Ÿ’„ ๅฎšๅˆถไธป้ข˜ๅ’Œๆ ทๅผ๏ผŒ็ฌฆๅˆ OceanBase Design ่ฎพ่ฎก่ง„่Œƒใ€‚

## ไปฃ็ ๆผ”็คบ

<code src="./demo/basic.tsx" title="ๅŸบๆœฌ"></code>

## API

- ่ฏฆ่ง pro-components LightFilter ๆ–‡ๆกฃ: https://procomponents.ant.design/components/query-filter#lightfilter
17 changes: 17 additions & 0 deletions packages/ui/src/LightFilter/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { useContext } from 'react';
import { LightFilter as AntLightFilter } from '@ant-design/pro-components';
import type { LightFilterProps } from '@ant-design/pro-components';
import { ConfigProvider } from '@oceanbase/design';
import useStyle from './style';

export type { LightFilterProps };

function LightFilter<T>({ prefixCls: customizePrefixCls, ...restProps }: LightFilterProps<T>) {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('pro-form-light-filter', customizePrefixCls);
const { wrapSSR } = useStyle(prefixCls);

return wrapSSR(<AntLightFilter prefixCls={customizePrefixCls} {...restProps} />);
}

export default LightFilter;
39 changes: 39 additions & 0 deletions packages/ui/src/LightFilter/style/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { CSSObject } from '@ant-design/cssinjs';
import type { LightFilterToken } from '@ant-design/pro-form/es/layouts/LightFilter/style';
import type { GenerateStyle } from '@oceanbase/design/es/theme';
import { genComponentStyleHook } from '../../_util/genComponentStyleHook';

export const genLightFilterStyle: GenerateStyle<LightFilterToken> = (
token: LightFilterToken
): CSSObject => {
const { componentCls, proComponentsCls } = token;

return {
[`${componentCls}`]: {
[`${proComponentsCls}-core-field-label`]: {
'&-active, &:hover': {
backgroundColor: token.controlItemBgActive,
},
},
},
[`${componentCls}-middle`]: {
[`${proComponentsCls}-core-field-label`]: {
paddingInline: token.paddingSM,
borderRadius: token.borderRadius,
},
},
[`${componentCls}${componentCls}-small`]: {
[`${proComponentsCls}-core-field-label`]: {
paddingInline: token.paddingXS,
borderRadius: token.borderRadiusSM,
},
},
};
};

export default (prefixCls: string) => {
const useStyle = genComponentStyleHook('LightFilter', token => {
return [genLightFilterStyle(token as LightFilterToken)];
});
return useStyle(prefixCls);
};
3 changes: 3 additions & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export type { FooterToolbarProps } from './FooterToolbar';
export { default as ProTable } from './ProTable';
export type { ProTableProps } from './ProTable';

export { default as LightFilter } from './LightFilter';
export type { LightFilterProps } from './LightFilter';

export { default as Password } from './Password';
export type { PasswordProps } from './Password';

Expand Down
Loading
Loading