Skip to content

Commit 984586a

Browse files
committed
chore: use Button and Segment component
1 parent e709cba commit 984586a

File tree

7 files changed

+43
-66
lines changed

7 files changed

+43
-66
lines changed
8.4 KB
Loading

packages/react/src/editor/PropertyControl/PropertyControl.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { createVariants } from '../../utils';
55
import { useEditing } from '../EditingContext';
66
import styles from './PropertyControl.module.css';
77

8+
const variants = createVariants(styles);
9+
810
type Props<SpecValue, Value = SpecValue> = {
911
name: string;
1012
spec: PropertySpec<SpecValue>;
@@ -16,8 +18,6 @@ type Props<SpecValue, Value = SpecValue> = {
1618
renderInput: (value: Value, onChange: (value?: Value) => void) => ReactNode;
1719
};
1820

19-
const variants = createVariants(styles);
20-
2121
export const PropertyControl = <SpecValue, Value = SpecValue>({
2222
name,
2323
spec,

packages/react/src/editor/PropertyControlArray/PropertyControlArray.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/** biome-ignore-all lint/suspicious/noExplicitAny: for arbitrary values */
22
/** biome-ignore-all lint/suspicious/noArrayIndexKey: array item should use index as a key */
3+
import { PlusIcon } from 'lucide-react';
4+
import { Button, VStack } from '../../preset';
35
import type { ArrayPropertySpec } from '../../renderer';
46
import { getClassNameFactory } from '../../utils';
57
import { PropertyControl } from '../PropertyControl';
@@ -44,7 +46,7 @@ export const PropertyControlArray = ({ name, spec, ...props }: Props) => (
4446
};
4547

4648
return (
47-
<div className={getClassName()}>
49+
<VStack gap={8}>
4850
{values.map((value, index) => (
4951
<div
5052
key={`${name}-${index}`}
@@ -164,12 +166,10 @@ export const PropertyControlArray = ({ name, spec, ...props }: Props) => (
164166
</button>
165167
</div>
166168
))}
167-
<button type="button" onClick={handleClickAdd} className={getClassName('AddButton')}>
168-
<svg xmlns="http://www.w3.org/2000/svg" width={16} height={16} viewBox="0 0 640 640">
169-
<path d="M352 128C352 110.3 337.7 96 320 96C302.3 96 288 110.3 288 128L288 288L128 288C110.3 288 96 302.3 96 320C96 337.7 110.3 352 128 352L288 352L288 512C288 529.7 302.3 544 320 544C337.7 544 352 529.7 352 512L352 352L512 352C529.7 352 544 337.7 544 320C544 302.3 529.7 288 512 288L352 288L352 128z" />
170-
</svg>
171-
</button>
172-
</div>
169+
<Button variant="secondary" size="sm" onClick={handleClickAdd}>
170+
<PlusIcon />
171+
</Button>
172+
</VStack>
173173
);
174174
}}
175175
/>

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

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import { Segment } from '../../preset';
12
import type { BooleanPropertySpec } from '../../renderer';
2-
import { getClassNameFactory } from '../../utils';
33
import { PropertyControl } from '../PropertyControl';
4-
import styles from './PropertyControlBoolean.module.css';
54

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

14-
const getClassName = getClassNameFactory('PropertyControlBoolean', styles);
15-
1613
export const PropertyControlBoolean = ({ spec, ...props }: Props) => (
1714
<PropertyControl<boolean>
1815
{...props}
1916
spec={spec}
2017
defaultValue={spec.default ?? false}
2118
renderInput={(value, onChange) => (
22-
<div className={getClassName('ButtonGroup')}>
23-
<button
24-
type="button"
25-
className={getClassName('Button', { active: value === true })}
26-
onClick={() => onChange(true)}
27-
>
28-
Yes
29-
</button>
30-
<button
31-
type="button"
32-
className={getClassName('Button', { active: value === false })}
33-
onClick={() => onChange(false)}
34-
>
35-
No
36-
</button>
37-
</div>
19+
<Segment
20+
size="sm"
21+
options={[
22+
{ label: 'Yes', value: true },
23+
{ label: 'No', value: false },
24+
]}
25+
value={value}
26+
onChange={onChange}
27+
/>
3828
)}
3929
/>
4030
);

packages/react/src/editor/PropertyControlCustom/PropertyControlCustom.stories.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,33 @@ export const BasicUsage = () => {
1313
spec={{
1414
type: 'custom',
1515
label: 'Image',
16+
default: '',
1617
render: (value, onChange) => (
1718
<>
1819
<style>
1920
{`
2021
.file-input {
2122
display: block;
2223
width: 100%;
23-
font-size: 0.875rem;
24-
line-height: 1.4;
25-
color: var(--docs-color-secondary);
26-
border: 1px solid var(--docs-color-outline);
24+
font-size: 13px;
25+
color: var(--composify-palette-secondary);
26+
border: 1px solid var(--composify-palette-outline);
2727
border-radius: 4px;
2828
cursor: pointer;
29-
background-color: var(--docs-color-surface-container-low);
29+
background-color: var(--composify-palette-surface-container-low);
3030
padding: 0;
3131
}
3232
3333
.file-input::file-selector-button {
34+
height: 32px;
3435
margin-right: 16px;
35-
padding: 8px 16px;
36+
padding: 0 16px;
3637
border: 0;
3738
border-top-left-radius: 4px;
3839
border-bottom-left-radius: 4px;
39-
font-size: 0.875rem;
40-
line-height: 1.4;
40+
font-size: 13px;
4141
font-weight: 600;
42-
background-color: var(--docs-color-secondary);
42+
background-color: var(--composify-palette-secondary);
4343
color: white;
4444
cursor: pointer;
4545
transition: opacity 0.1s;

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,31 @@
5555
font-size: 12px;
5656
}
5757

58+
.button--size-sm > svg {
59+
width: 16px;
60+
height: 16px;
61+
}
62+
5863
.button--size-md {
5964
height: 36px;
6065
padding: 0 12px;
6166
gap: 6px;
6267
font-size: 14px;
6368
}
6469

70+
.button--size-md > svg {
71+
width: 18px;
72+
height: 18px;
73+
}
74+
6575
.button--size-lg {
6676
height: 42px;
6777
padding: 0 16px;
6878
gap: 8px;
6979
font-size: 14px;
7080
}
81+
82+
.button--size-lg > svg {
83+
width: 20px;
84+
height: 20px;
85+
}

0 commit comments

Comments
 (0)