Skip to content

Commit a0621c0

Browse files
authored
Strip down to only the USED common- v1 components (commontoolsinc#2091)
* Strip down to only the USED `common-` v1 components Preparation before migrating these to v2 * Format * Fix type errors * Restore `common-charm` * Format + lint * Restore `common-code-editor` that supports errors still
1 parent 2d3e51c commit a0621c0

File tree

75 files changed

+153
-4619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+153
-4619
lines changed

docs/common/COMPONENTS.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,22 +207,22 @@ HTML elements (`div`, `span`, `button`, etc.) use JavaScript object syntax for s
207207
208208
## Custom Elements: String Syntax
209209
210-
CommonTools custom elements (`common-hstack`, `common-vstack`, `ct-card`, etc.) use CSS string syntax:
210+
CommonTools custom elements (`ct-hstack`, `ct-vstack`, `ct-card`, etc.) use CSS string syntax:
211211
212212
```tsx
213213
// ✅ CORRECT - String syntax for custom elements
214-
<common-hstack gap="sm" style="align-items: center; padding: 1rem;">
215-
<common-vstack gap="md" style="flex: 1; max-width: 600px;">
214+
<ct-hstack gap="1" style="align-items: center; padding: 1rem;">
215+
<ct-vstack gap="2" style="flex: 1; max-width: 600px;">
216216
<ct-card style="border: 1px solid #ccc; padding: 0.5rem;">
217217
Content here
218218
</ct-card>
219-
</common-vstack>
220-
</common-hstack>
219+
</ct-vstack>
220+
</ct-hstack>
221221

222222
// ❌ WRONG - Object syntax causes errors on custom elements
223-
<common-hstack style={{ alignItems: "center" }}>
223+
<ct-hstack style={{ alignItems: "center" }}>
224224
{/* Error: Custom elements expect string styles */}
225-
</common-hstack>
225+
</ct-hstack>
226226
```
227227
228228
**Properties use kebab-case**: `background-color`, `font-size`, `margin-bottom`
@@ -239,12 +239,12 @@ CommonTools custom elements (`common-hstack`, `common-vstack`, `ct-card`, etc.)
239239
```tsx
240240
// You'll often mix both types in one recipe
241241
<div style={{ display: "flex", gap: "1rem" }}>
242-
<common-vstack gap="md" style="flex: 1; padding: 1rem;">
242+
<ct-vstack gap="2" style="flex: 1; padding: 1rem;">
243243
<span style={{ color: "#333", fontSize: "14px" }}>
244244
Label Text
245245
</span>
246246
<ct-button>Click Me</ct-button>
247-
</common-vstack>
247+
</ct-vstack>
248248
</div>
249249
```
250250
@@ -264,10 +264,10 @@ CommonTools custom elements (`common-hstack`, `common-vstack`, `ct-card`, etc.)
264264

265265
```tsx
266266
// ❌ Problem: Using object on custom element
267-
<common-hstack style={{ padding: "1rem" }}>
267+
<ct-hstack style={{ padding: "1rem" }}>
268268

269269
// ✅ Solution: Use string syntax
270-
<common-hstack style="padding: 1rem;">
270+
<ct-hstack style="padding: 1rem;">
271271
```
272272

273273
## ct-input

docs/common/PATTERNS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,14 +581,14 @@ These are the most frequent mistakes developers make when building patterns:
581581
</div>
582582
583583
// ❌ WRONG - Object style on custom element
584-
<common-hstack style={{ flex: 1 }}>
584+
<ct-hstack style={{ flex: 1 }}>
585585
{/* Error */}
586-
</common-hstack>
586+
</ct-hstack>
587587
588588
// ✅ CORRECT - String style on custom element
589-
<common-hstack style="flex: 1;">
589+
<ct-hstack style="flex: 1;">
590590
{/* Works! */}
591-
</common-hstack>
591+
</ct-hstack>
592592
```
593593

594594
**Rule:** HTML elements use object styles, custom elements use string styles. See "Styling: String vs Object Syntax" in `COMPONENTS.md` for details.
@@ -875,7 +875,7 @@ Remember: HTML elements use object syntax, custom elements use string syntax.
875875
<span style={{ color: "red", fontWeight: "bold" }} />
876876

877877
// ✅ Custom elements - String syntax
878-
<common-hstack style="flex: 1; padding: 1rem;" />
878+
<ct-hstack style="flex: 1; padding: 1rem;" />
879879
<ct-card style="border: 1px solid #ccc;" />
880880

881881
// ❌ Common mistake

docs/common/RECIPES.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -269,31 +269,6 @@ actually creates mini-recipes for each item in the array, constructing a
269269
reactive graph. Each mapped item becomes a reactive node that updates when the
270270
source data changes.
271271

272-
In the todo-list example, this pattern is used to create draggable todo items,
273-
where each item has its own encapsulated recipe:
274-
275-
```typescript
276-
{items.map((item: TodoItem) => (
277-
<common-draggable
278-
$entity={item}
279-
spell={JSON.stringify(
280-
recipe(TodoItemSchema, {}, (item) => ({
281-
[UI]: (
282-
<common-todo
283-
checked={item.done}
284-
value={item.title}
285-
ontodo-checked={updateItem({ item })}
286-
ontodo-input={updateItem({ item })}
287-
/>
288-
),
289-
})),
290-
)}
291-
>
292-
<!-- Component content -->
293-
</common-draggable>
294-
))}
295-
```
296-
297272
This approach allows for efficient updates and encapsulation of item-specific
298273
logic.
299274

packages/html/src/jsx.d.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,7 +3034,7 @@ interface CTSendMessageAttributes<T> extends CTHTMLAttributes<T> {
30343034
"value"?: any;
30353035
"placeholder"?: string;
30363036
"appearance"?: "rounded";
3037-
"onmessagesend"?: EventHandler<{ message: string }>;
3037+
"onct-send"?: EventHandler<{ message: string }>;
30383038
"inline"?: Booleanish;
30393039
}
30403040

@@ -3864,14 +3864,6 @@ declare global {
38643864
CTUpdaterAttributes<CTUpdaterElement>,
38653865
CTUpdaterElement
38663866
>;
3867-
"common-input": CTDOM.DetailedHTMLProps<
3868-
CTInputLegacyAttributes<CTInputLegacyElement>,
3869-
CTInputLegacyElement
3870-
>;
3871-
"common-send-message": CTDOM.DetailedHTMLProps<
3872-
CTSendMessageAttributes<CTSendMessageElement>,
3873-
CTSendMessageElement
3874-
>;
38753867
"common-google-oauth": CTDOM.DetailedHTMLProps<
38763868
CTGoogleOAuthAttributes<CTGoogleOAuthElement>,
38773869
CTGoogleOAuthElement
@@ -3909,14 +3901,6 @@ declare global {
39093901
CTStackAttributes<CTVStackElement>,
39103902
CTVStackElement
39113903
>;
3912-
"common-hstack": CTDOM.DetailedHTMLProps<
3913-
CTStackLegacyAttributes<CTHStackElement>,
3914-
CTHStackElement
3915-
>;
3916-
"common-vstack": CTDOM.DetailedHTMLProps<
3917-
CTStackLegacyAttributes<CTVStackElement>,
3918-
CTVStackElement
3919-
>;
39203904
}
39213905
}
39223906
}

packages/patterns/array-in-cell-ast-nocomponents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ export default recipe<InputSchema>(({ title, items }) => {
3939
items.map((item) => <li>{item.text}</li>)
4040
}
4141
</ul>
42-
<common-send-message
42+
<ct-message-input
4343
name="Send"
4444
placeholder="Type a message..."
4545
appearance="rounded"
46-
onmessagesend={addItem({ items })}
46+
onct-send={addItem({ items })}
4747
/>
4848
</div>
4949
),

packages/patterns/array-in-cell-with-remove-ast-nocomponents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ export default recipe<InputSchema>(
5757
</li>
5858
))}
5959
</ul>
60-
<common-send-message
60+
<ct-message-input
6161
name="Send"
6262
placeholder="Type a message..."
6363
appearance="rounded"
64-
onmessagesend={addItem({ items })}
64+
onct-send={addItem({ items })}
6565
/>
6666
</div>
6767
),

packages/patterns/array-in-cell-with-remove-editable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ export default recipe<InputSchema>(
8282
))}
8383
</div>
8484
<div style={{ marginTop: "1rem" }}>
85-
<common-send-message
85+
<ct-message-input
8686
name="Send"
8787
placeholder="Type a message..."
8888
appearance="rounded"
89-
onmessagesend={addItem({ items })}
89+
onct-send={addItem({ items })}
9090
/>
9191
</div>
9292
</div>

packages/patterns/ct-checkbox-cell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default recipe<CheckboxDemoInput, CheckboxDemoOutput>(
2727
return {
2828
[NAME]: "Checkbox Demo",
2929
[UI]: (
30-
<common-vstack gap="md" style="padding: 2rem; max-width: 600px;">
30+
<ct-vstack gap="2" style="padding: 2rem; max-width: 600px;">
3131
<h3>ct-checkbox Bidirectional Binding Demo</h3>
3232

3333
<ct-card>
@@ -78,7 +78,7 @@ export default recipe<CheckboxDemoInput, CheckboxDemoOutput>(
7878
beyond just updating the value.
7979
</p>
8080
</ct-card>
81-
</common-vstack>
81+
</ct-vstack>
8282
),
8383
simpleEnabled,
8484
trackedEnabled,

packages/patterns/ct-checkbox-handler.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default recipe<CheckboxSimpleInput, CheckboxSimpleOutput>(
1313
return {
1414
[NAME]: "Checkbox Demo",
1515
[UI]: (
16-
<common-vstack gap="md" style="padding: 2rem; max-width: 400px;">
16+
<ct-vstack gap="2" style="padding: 2rem; max-width: 400px;">
1717
<h3>Simple ct-checkbox + ifElse Demo</h3>
1818

1919
<ct-checkbox $checked={enabled}>
@@ -29,7 +29,7 @@ export default recipe<CheckboxSimpleInput, CheckboxSimpleOutput>(
2929
<p data-testid="status">
3030
Status: {ifElse(enabled, "ON", "OFF")}
3131
</p>
32-
</common-vstack>
32+
</ct-vstack>
3333
),
3434
enabled,
3535
};

packages/patterns/ct-list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default recipe<ListInput, ListOutput>(
1818
return {
1919
[NAME]: title,
2020
[UI]: (
21-
<common-vstack gap="md" style="padding: 1rem; max-width: 600px;">
21+
<ct-vstack gap="2" style="padding: 1rem; max-width: 600px;">
2222
<ct-input
2323
$value={title}
2424
placeholder="List title"
@@ -34,7 +34,7 @@ export default recipe<ListInput, ListOutput>(
3434
title="Items"
3535
/>
3636
</ct-card>
37-
</common-vstack>
37+
</ct-vstack>
3838
),
3939
title,
4040
items,

0 commit comments

Comments
 (0)