Skip to content

Commit b932e92

Browse files
committed
feat: add input preset
1 parent 64e141b commit b932e92

File tree

11 files changed

+58
-53
lines changed

11 files changed

+58
-53
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
-moz-osx-font-smoothing: grayscale;
2222
}
2323

24+
.Editor * {
25+
box-sizing: border-box;
26+
}
27+
2428
.Editor-Divider {
2529
width: 1px;
2630
background-color: var(--composify-palette-outline);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
.addButton {
4949
display: inline-flex;
5050
align-items: center;
51-
height: 36px;
51+
height: 32px;
5252
padding: 0 8px;
5353
font-size: 12px;
5454
outline: none;

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

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

packages/react/src/editor/PropertyControlNumber/PropertyControlNumber.tsx

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

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

14-
const getClassName = getClassNameFactory('PropertyControlNumber', styles);
15-
1613
export const PropertyControlNumber = ({ spec, ...props }: Props) => (
1714
<PropertyControl<number>
1815
{...props}
1916
spec={spec}
2017
defaultValue={spec.default ?? 0}
2118
renderInput={(value, onChange) => (
22-
<input
19+
<Input
2320
type="number"
2421
size={undefined}
2522
value={value}
2623
onChange={(event) => onChange(Number(event.target.value))}
27-
className={getClassName()}
2824
/>
2925
)}
3026
/>

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

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

packages/react/src/editor/PropertyControlText/PropertyControlText.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { Input } from '../../preset';
12
import type { TextPropertySpec } from '../../renderer';
2-
import { getClassNameFactory } from '../../utils';
33
import { PropertyControl } from '../PropertyControl';
4-
import styles from './PropertyControlText.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('PropertyControlText', styles);
15-
1613
export const PropertyControlText = ({ spec, ...props }: Props) => (
1714
<PropertyControl<string>
1815
{...props}
1916
spec={spec}
2017
defaultValue={spec.default ?? ''}
2118
renderInput={(value, onChange) => (
22-
<input
19+
<Input
2320
type="text"
2421
placeholder={spec.placeholder}
2522
value={value}
2623
onChange={(event) => onChange(event.target.value)}
27-
className={getClassName()}
2824
/>
2925
)}
3026
/>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
font-weight: 500;
1111
line-height: 1;
1212
white-space: nowrap;
13-
transition-property: background-color, opacity;
14-
transition-duration: 0.15s;
13+
transition:
14+
background-color 0.15s,
15+
opacity 0.15s;
1516
}
1617

1718
.button:disabled {

packages/react/src/preset/Button/ButtonCatalog.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Catalog.register('Button', {
66
props: {
77
variant: {
88
label: 'Variant',
9-
type: 'radio',
9+
type: 'select',
1010
options: [
1111
{
1212
label: 'Primary',
@@ -28,17 +28,17 @@ Catalog.register('Button', {
2828
type: 'radio',
2929
options: [
3030
{
31-
label: 'Extra Small',
32-
value: 'xs',
33-
},
34-
{
35-
label: 'Small',
31+
label: 'S',
3632
value: 'sm',
3733
},
3834
{
39-
label: 'Medium',
35+
label: 'M',
4036
value: 'md',
4137
},
38+
{
39+
label: 'L',
40+
value: 'lg',
41+
},
4242
],
4343
default: 'md',
4444
},
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.input {
2+
width: 100%;
3+
min-width: 0;
4+
height: 32px;
5+
padding: 0 8px;
6+
font-size: 13px;
7+
color: var(--composify-palette-on-surface);
8+
border-radius: 4px;
9+
border: 1px solid var(--composify-palette-outline);
10+
background-color: var(--composify-palette-surface-container-low);
11+
transition: border-color 0.15s;
12+
outline: none;
13+
}
14+
15+
.input:focus-visible {
16+
border-color: var(--composify-palette-primary);
17+
}
18+
19+
.input:disabled {
20+
opacity: 0.7;
21+
cursor: not-allowed;
22+
pointer-events: none;
23+
}
24+
25+
.input::placeholder {
26+
color: var(--composify-palette-on-surface-variant);
27+
}
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 './Input.module.css';
4+
5+
type Props = ComponentProps<'input'>;
6+
7+
const variants = createVariants(styles);
8+
9+
export const Input: FC<Props> = ({ className, ...props }) => (
10+
<input className={variants('input', { className })} {...props} />
11+
);

0 commit comments

Comments
 (0)