-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yxh01132861
committed
Sep 20, 2023
1 parent
b9f06e4
commit 5d2265f
Showing
5 changed files
with
156 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/li-p2/src/LayerAttribute/components/ScaleSelector/demos/default.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ScaleSelector } from '@antv/li-p2'; | ||
import { Form, FormItem } from '@formily/antd-v5'; | ||
import type { Form as FormInstance } from '@formily/core'; | ||
import { createForm, onFormValuesChange } from '@formily/core'; | ||
import { createSchemaField, FormConsumer } from '@formily/react'; | ||
import React from 'react'; | ||
|
||
const form = createForm({ | ||
initialValues: {}, | ||
effects() { | ||
onFormValuesChange((formIns: FormInstance<any>) => { | ||
console.log('formIns.values: ', formIns.values); | ||
}); | ||
}, | ||
}); | ||
|
||
const SchemaField = createSchemaField({ | ||
components: { | ||
FormItem, | ||
ScaleSelector, | ||
}, | ||
}); | ||
|
||
const schema = { | ||
type: 'object', | ||
properties: { | ||
fillColorScale: { | ||
type: 'string', | ||
title: '颜色划分', | ||
'x-decorator': 'FormItem', | ||
'x-component': 'ScaleSelector', | ||
'x-component-props': { | ||
placeholder: '请选择', | ||
type: 'number', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default () => { | ||
return ( | ||
<Form form={form} style={{ width: '300px' }}> | ||
<SchemaField schema={schema} /> | ||
<FormConsumer> | ||
{() => ( | ||
<code> | ||
<pre>{JSON.stringify(form.values, null, 2)}</pre> | ||
</code> | ||
)} | ||
</FormConsumer> | ||
</Form> | ||
); | ||
}; |
24 changes: 24 additions & 0 deletions
24
packages/li-p2/src/LayerAttribute/components/ScaleSelector/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
toc: content | ||
order: 10 | ||
group: | ||
title: formily 组件 | ||
order: 1 | ||
nav: | ||
title: 组件 | ||
path: /components | ||
--- | ||
|
||
# 颜色选择器 - ColorPicker | ||
|
||
## 介绍 | ||
|
||
用于单个颜色选择场景 | ||
|
||
## 代码演示 | ||
|
||
### 默认示例 | ||
|
||
<code src="./demos/default.tsx"></code> | ||
|
||
<API></API> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/li-p2/src/LayerAttribute/components/ScaleSelector/style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { genStyleHook } from '@formily/antd-v5/esm/__builtins__'; | ||
|
||
export default genStyleHook('scale-selector', (token) => { | ||
const { componentCls, antCls, controlItemBgHover, controlItemBgActive, colorTextBase } = token; | ||
|
||
return { | ||
[componentCls]: {}, | ||
|
||
[`${componentCls}-dropdown`]: { | ||
padding: '4px', | ||
}, | ||
|
||
[`${componentCls}-select-option`]: { | ||
cursor: 'pointer', | ||
height: '32px', | ||
padding: '5px 12px', | ||
borderRadius: '4px', | ||
fontSize: '14px', | ||
color: colorTextBase, | ||
|
||
'&:hover': { | ||
background: controlItemBgHover, | ||
}, | ||
}, | ||
|
||
[`${componentCls}-select-option-selected`]: { | ||
background: controlItemBgActive, | ||
}, | ||
}; | ||
}); |