Skip to content

Commit 254ac92

Browse files
committed
feat: add textarea preset
1 parent a2b1917 commit 254ac92

File tree

8 files changed

+48
-23
lines changed

8 files changed

+48
-23
lines changed

packages/react/src/editor/PropertyControlTextArea/PropertyControlTextArea.module.css

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/react/src/editor/PropertyControlTextArea/PropertyControlTextArea.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { Textarea } from '../../preset';
12
import type { TextAreaPropertySpec } from '../../renderer';
2-
import { getClassNameFactory } from '../../utils';
33
import { PropertyControl } from '../PropertyControl';
4-
import styles from './PropertyControlTextArea.module.css';
54

65
type Props = {
76
name: string;
@@ -11,20 +10,17 @@ type Props = {
1110
onChange?: (name: string, value?: string) => void;
1211
};
1312

14-
const getClassName = getClassNameFactory('PropertyControlTextArea', styles);
15-
1613
export const PropertyControlTextArea = ({ spec, ...props }: Props) => (
1714
<PropertyControl<string>
1815
{...props}
1916
spec={spec}
2017
defaultValue={spec.default ?? ''}
2118
renderInput={(value, onChange) => (
22-
<textarea
19+
<Textarea
2320
rows={3}
2421
placeholder={spec.placeholder}
2522
value={value}
2623
onChange={(event) => onChange(event.target.value)}
27-
className={getClassName()}
2824
/>
2925
)}
3026
/>

packages/react/src/preset/Input/Input.module.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
border-radius: 4px;
99
border: 1px solid var(--composify-palette-outline);
1010
background-color: var(--composify-palette-surface-container-low);
11-
transition: border-color 0.15s;
1211
outline: none;
12+
transition:
13+
border-color 0.15s,
14+
opacity 0.15s;
1315
}
1416

1517
.input:focus-visible {

packages/react/src/preset/Text/TextCatalog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Catalog.register('Text', {
77
category: 'Content',
88
props: {
99
children: {
10-
label: 'Text',
10+
label: 'Content',
1111
type: 'textarea',
1212
default: 'Text',
1313
},
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.textarea {
2+
width: 100%;
3+
min-height: 65px;
4+
padding: 8px;
5+
font-size: 13px;
6+
color: var(--composify-palette-on-surface);
7+
border-radius: 4px;
8+
border: 1px solid var(--composify-palette-outline);
9+
background-color: var(--composify-palette-surface-container-low);
10+
outline: none;
11+
field-sizing: content;
12+
transition:
13+
border-color 0.15s,
14+
opacity 0.15s;
15+
}
16+
17+
.textarea:focus-visible {
18+
border-color: var(--composify-palette-primary);
19+
}
20+
21+
.textarea:disabled {
22+
opacity: 0.7;
23+
cursor: not-allowed;
24+
pointer-events: none;
25+
}
26+
27+
.textarea::placeholder {
28+
color: var(--composify-palette-on-surface-variant);
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { ComponentProps, FC } from 'react';
2+
import { createVariants } from '../../utils';
3+
import styles from './Textarea.module.css';
4+
5+
const variants = createVariants(styles);
6+
7+
type Props = ComponentProps<'textarea'>;
8+
9+
export const Textarea: FC<Props> = ({ className, ...props }) => (
10+
<textarea className={variants('textarea', { className })} {...props} />
11+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Textarea } from './Textarea';

packages/react/src/preset/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export { Input } from './Input';
44
export { Segment } from './Segment';
55
export { Select } from './Select';
66
export { Text } from './Text';
7+
export { Textarea } from './Textarea';
78
export { VStack } from './VStack';

0 commit comments

Comments
 (0)