Skip to content

Commit a6addc2

Browse files
✨ feat: Add new components, modify existing components, and export components
This commit introduces new components, modifies existing components, and exports components. It also includes changes to the styling algorithm, such as the addition of a new color variable and modifications to code blocks and lists. Additionally, it updates the demo and API documentation for each file.
1 parent 8ec934e commit a6addc2

File tree

13 files changed

+312
-6
lines changed

13 files changed

+312
-6
lines changed

src/ChatHeader/ChatHeaderTitle.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { createStyles } from 'antd-style';
2+
import { ReactNode, memo } from 'react';
3+
import { Flexbox } from 'react-layout-kit';
4+
5+
const useStyles = createStyles(({ css, token }) => ({
6+
container: css`
7+
position: relative;
8+
overflow: hidden;
9+
flex: 1;
10+
max-width: 100%;
11+
`,
12+
desc: css`
13+
overflow: hidden;
14+
15+
width: 100%;
16+
17+
font-size: 12px;
18+
color: ${token.colorTextTertiary};
19+
text-overflow: ellipsis;
20+
white-space: nowrap;
21+
`,
22+
tag: css`
23+
flex: none;
24+
`,
25+
title: css`
26+
overflow: hidden;
27+
28+
font-size: 16px;
29+
font-weight: bold;
30+
text-overflow: ellipsis;
31+
white-space: nowrap;
32+
`,
33+
titleContainer: css`
34+
flex: 1;
35+
`,
36+
titleWithDesc: css`
37+
overflow: hidden;
38+
font-weight: bold;
39+
text-overflow: ellipsis;
40+
white-space: nowrap;
41+
`,
42+
}));
43+
44+
export interface ChatHeaderTitleProps {
45+
desc?: string | ReactNode;
46+
tag?: ReactNode;
47+
title: string | ReactNode;
48+
}
49+
50+
const ChatHeaderTitle = memo<ChatHeaderTitleProps>(({ title, desc, tag }) => {
51+
const { styles } = useStyles();
52+
if (desc)
53+
return (
54+
<Flexbox className={styles.container}>
55+
<Flexbox align={'center'} className={styles.titleContainer} gap={8} horizontal>
56+
<div className={styles.titleWithDesc}>{title}</div>
57+
<Flexbox className={styles.tag} horizontal>
58+
{tag}
59+
</Flexbox>
60+
</Flexbox>
61+
<Flexbox align={'center'} horizontal>
62+
<div className={styles.desc}>{desc}</div>
63+
</Flexbox>
64+
</Flexbox>
65+
);
66+
return (
67+
<Flexbox align={'center'} className={styles.container} gap={8} horizontal>
68+
<div className={styles.title}>{title}</div>
69+
<Flexbox className={styles.tag} horizontal>
70+
{tag}
71+
</Flexbox>
72+
</Flexbox>
73+
);
74+
});
75+
76+
export default ChatHeaderTitle;

src/Form/components/FormTitle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Tag } from 'antd';
21
import { ReactNode, memo } from 'react';
32
import { Flexbox } from 'react-layout-kit';
43

4+
import Tag from '@/Tag';
55
import { DivProps } from '@/types';
66

77
import { useStyles } from './style';

src/Icon/icons/DiscordIcon.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { type LucideIcon, createLucideIcon } from 'lucide-react';
2+
3+
const Discord: LucideIcon = createLucideIcon('Discord', [
4+
[
5+
'path',
6+
{
7+
d: 'M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z',
8+
key: '18tl5t',
9+
},
10+
],
11+
]);
12+
13+
const DiscordIcon = (props: LucideIcon) => <Discord style={{ overflow: 'visible' }} {...props} />;
14+
15+
export default DiscordIcon as LucideIcon;

src/Icon/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as DiscordIcon } from './DiscordIcon';

src/Markdown/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const Markdown = memo<MarkdownProps>(({ children, className, style, ...props })
2525
a: Typography.Link,
2626
code: Code,
2727
details: Collapse,
28-
hr: Divider,
28+
hr: () => <Divider style={{ marginBottom: '1em', marginTop: 0 }} />,
2929
pre: CodeBlock,
3030
};
3131

src/SliderWithInput/demos/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { SliderWithInput } from '@lobehub/ui';
2+
3+
export default () => {
4+
return <SliderWithInput />;
5+
};

src/SliderWithInput/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
nav: Components
3+
group: Data Entry
4+
title: SliderWithInput
5+
---
6+
7+
## Default
8+
9+
<code src="./demos/index.tsx" center></code>
10+
11+
## APIs
12+
13+
<API></API>

src/SliderWithInput/index.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { InputNumber, type InputNumberProps, Slider } from 'antd';
2+
import { SliderSingleProps } from 'antd/es/slider';
3+
import { isNull } from 'lodash-es';
4+
import { memo, useCallback } from 'react';
5+
import { Flexbox } from 'react-layout-kit';
6+
7+
export interface SliderWithInputProps extends SliderSingleProps {
8+
controls?: InputNumberProps['controls'];
9+
size?: InputNumberProps['size'];
10+
}
11+
12+
const SliderWithInput = memo<SliderWithInputProps>(
13+
({
14+
step,
15+
value,
16+
onChange,
17+
max,
18+
min,
19+
defaultValue,
20+
size,
21+
controls,
22+
style,
23+
className,
24+
disabled,
25+
...props
26+
}) => {
27+
const handleOnchange = useCallback((value: number | null) => {
28+
if (Number.isNaN(value) || isNull(value)) return;
29+
onChange?.(value);
30+
}, []);
31+
32+
return (
33+
<Flexbox
34+
align={'center'}
35+
className={className}
36+
direction={'horizontal'}
37+
gap={8}
38+
style={style}
39+
>
40+
<Slider
41+
defaultValue={defaultValue}
42+
disabled={disabled}
43+
max={max}
44+
min={min}
45+
onChange={handleOnchange}
46+
step={step}
47+
style={size === 'small' ? { flex: 1, margin: 0 } : { flex: 1 }}
48+
tooltip={{ open: false }}
49+
value={typeof value === 'number' ? value : 0}
50+
{...props}
51+
/>
52+
<InputNumber
53+
controls={size !== 'small' || controls}
54+
defaultValue={defaultValue}
55+
disabled={disabled}
56+
max={max}
57+
min={min}
58+
onChange={handleOnchange}
59+
size={size}
60+
step={Number.isNaN(step) || isNull(step) ? undefined : step}
61+
style={{ flex: 1, maxWidth: size === 'small' ? 40 : 64 }}
62+
value={typeof value === 'number' ? value : 0}
63+
/>
64+
</Flexbox>
65+
);
66+
},
67+
);
68+
69+
export default SliderWithInput;

src/Tag/demos/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { DiscordIcon, Icon, Tag } from '@lobehub/ui';
2+
3+
export default () => {
4+
return <Tag icon={<Icon icon={DiscordIcon} />}>discord</Tag>;
5+
};

src/Tag/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
nav: Components
3+
group: Data Display
4+
title: Tag
5+
---
6+
7+
## Default
8+
9+
<code src="./demos/index.tsx" center></code>
10+
11+
## APIs
12+
13+
<API></API>

0 commit comments

Comments
 (0)