mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
832cffcdf9
* refactor: support type update * chore: update clear style * chore: bump color picker * chore: use slider * chore: bump color picker * chore: range slider * chore: layout * chore: useModeColor * chore: simplify * chore: bump color picker * refactor: event * chore: tmp lock check * chore: of it * chore: update ts def * chore: update ts def * chore: remove useless ts * chore: linear * chore: adjust style * chore: rm useless code * chore: fill color * chore: basic linear * chore: support toStr * chore: limit minCount * chore: use cache * chore: drag support: * chore: yes * chore: update demo * chore: useLayoutEffect instead * chore: fix click to add point * chore: add smmoth * chore: support of locale * chore: add locale * chore: fix lint * chore: adjust style * chore: fix lint * chore: fix style * test: fix test case * chore: fix popover * test: fix test case * chore: fix test * test: clean up * chore: fix lint * chore: fix lint * chore: fix lint * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * test: coverage * chore: fix docs * docs: update demo desc * chore: enhance hover range * fix: delete not working * chore: fix lint * test: coverage * test: coverage * chore: clean up * chore: adjust * chore: highlight * chore: adjust style * chore: fix lint * chore: update demo * chore: memo perf * refactor: up to down colors * test: update snapshot
125 lines
4.7 KiB
TypeScript
125 lines
4.7 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { ColorPicker, Flex, Form, Input, InputNumber, Slider, Typography, Watermark } from 'antd';
|
|
import type { ColorPickerProps, GetProp, WatermarkProps } from 'antd';
|
|
|
|
type Color = Extract<GetProp<ColorPickerProps, 'value'>, string | { cleared: any }>;
|
|
|
|
const { Paragraph } = Typography;
|
|
|
|
interface WatermarkConfig {
|
|
content: string;
|
|
color: string | Color;
|
|
fontSize: number;
|
|
zIndex: number;
|
|
rotate: number;
|
|
gap: [number, number];
|
|
offset?: [number, number];
|
|
}
|
|
|
|
const App: React.FC = () => {
|
|
const [form] = Form.useForm();
|
|
const [config, setConfig] = useState<WatermarkConfig>({
|
|
content: 'Ant Design',
|
|
color: 'rgba(0, 0, 0, 0.15)',
|
|
fontSize: 16,
|
|
zIndex: 11,
|
|
rotate: -22,
|
|
gap: [100, 100],
|
|
offset: undefined,
|
|
});
|
|
const { content, color, fontSize, zIndex, rotate, gap, offset } = config;
|
|
|
|
const watermarkProps: WatermarkProps = {
|
|
content,
|
|
zIndex,
|
|
rotate,
|
|
gap,
|
|
offset,
|
|
font: { color: typeof color === 'string' ? color : color.toRgbString(), fontSize },
|
|
};
|
|
|
|
return (
|
|
<Flex gap="middle">
|
|
<Watermark {...watermarkProps}>
|
|
<Typography>
|
|
<Paragraph>
|
|
The light-speed iteration of the digital world makes products more complex. However,
|
|
human consciousness and attention resources are limited. Facing this design
|
|
contradiction, the pursuit of natural interaction will be the consistent direction of
|
|
Ant Design.
|
|
</Paragraph>
|
|
<Paragraph>
|
|
Natural user cognition: According to cognitive psychology, about 80% of external
|
|
information is obtained through visual channels. The most important visual elements in
|
|
the interface design, including layout, colors, illustrations, icons, etc., should fully
|
|
absorb the laws of nature, thereby reducing the user's cognitive cost and bringing
|
|
authentic and smooth feelings. In some scenarios, opportunely adding other sensory
|
|
channels such as hearing, touch can create a richer and more natural product experience.
|
|
</Paragraph>
|
|
<Paragraph>
|
|
Natural user behavior: In the interaction with the system, the designer should fully
|
|
understand the relationship between users, system roles, and task objectives, and also
|
|
contextually organize system functions and services. At the same time, a series of
|
|
methods such as behavior analysis, artificial intelligence and sensors could be applied
|
|
to assist users to make effective decisions and reduce extra operations of users, to
|
|
save users' mental and physical resources and make human-computer interaction more
|
|
natural.
|
|
</Paragraph>
|
|
</Typography>
|
|
<img
|
|
style={{ zIndex: 10, width: '100%', maxWidth: 800, position: 'relative' }}
|
|
src="https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*zx7LTI_ECSAAAAAAAAAAAABkARQnAQ"
|
|
alt="img"
|
|
/>
|
|
</Watermark>
|
|
<Form
|
|
style={{ width: 280, flexShrink: 0, borderLeft: '1px solid #eee', paddingInlineStart: 16 }}
|
|
form={form}
|
|
layout="vertical"
|
|
initialValues={config}
|
|
onValuesChange={(_, values) => {
|
|
setConfig(values);
|
|
}}
|
|
>
|
|
<Form.Item name="content" label="Content">
|
|
<Input placeholder="请输入" />
|
|
</Form.Item>
|
|
<Form.Item name="color" label="Color">
|
|
<ColorPicker />
|
|
</Form.Item>
|
|
<Form.Item name="fontSize" label="FontSize">
|
|
<Slider step={1} min={1} max={100} />
|
|
</Form.Item>
|
|
<Form.Item name="zIndex" label="zIndex">
|
|
<Slider step={1} min={0} max={100} />
|
|
</Form.Item>
|
|
<Form.Item name="rotate" label="Rotate">
|
|
<Slider step={1} min={-180} max={180} />
|
|
</Form.Item>
|
|
<Form.Item label="Gap" style={{ marginBottom: 0 }}>
|
|
<Flex gap="small">
|
|
<Form.Item name={['gap', 0]}>
|
|
<InputNumber placeholder="gapX" style={{ width: '100%' }} />
|
|
</Form.Item>
|
|
<Form.Item name={['gap', 1]}>
|
|
<InputNumber placeholder="gapY" style={{ width: '100%' }} />
|
|
</Form.Item>
|
|
</Flex>
|
|
</Form.Item>
|
|
<Form.Item label="Offset" style={{ marginBottom: 0 }}>
|
|
<Flex gap="small">
|
|
<Form.Item name={['offset', 0]}>
|
|
<InputNumber placeholder="offsetLeft" style={{ width: '100%' }} />
|
|
</Form.Item>
|
|
<Form.Item name={['offset', 1]}>
|
|
<InputNumber placeholder="offsetTop" style={{ width: '100%' }} />
|
|
</Form.Item>
|
|
</Flex>
|
|
</Form.Item>
|
|
</Form>
|
|
</Flex>
|
|
);
|
|
};
|
|
|
|
export default App;
|