Skip to content

Commit 20e4ee2

Browse files
committed
Add semantic layout components to renderer
Introduced a new semantic.tsx file that registers semantic HTML elements (aside, main, header, nav, footer, section, article) as components in the ComponentRegistry. Updated the layout index to include the new semantic components for improved semantic structure in layouts.
1 parent b0d56fd commit 20e4ee2

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

packages/components/src/renderers/layout/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import './flex';
55
import './stack';
66
import './container';
77
import './page';
8+
import './semantic';
89

910

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { ComponentRegistry } from '@object-ui/core';
2+
import { renderChildren } from '../../lib/utils';
3+
import { forwardRef } from 'react';
4+
5+
const tags = ['aside', 'main', 'header', 'nav', 'footer', 'section', 'article'] as const;
6+
7+
tags.forEach(tag => {
8+
const Component = forwardRef<HTMLElement, any>(({ schema, className, ...props }, ref) => {
9+
// Extract designer-related props
10+
const {
11+
'data-obj-id': dataObjId,
12+
'data-obj-type': dataObjType,
13+
style,
14+
...restProps
15+
} = props;
16+
17+
const Tag = tag;
18+
19+
return (
20+
<Tag
21+
ref={ref}
22+
className={className}
23+
{...restProps}
24+
{...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
25+
>
26+
{renderChildren(schema.children || schema.body)}
27+
</Tag>
28+
);
29+
});
30+
Component.displayName = `Semantic${tag.charAt(0).toUpperCase() + tag.slice(1)}`;
31+
32+
ComponentRegistry.register(tag, Component, {
33+
label: tag.charAt(0).toUpperCase() + tag.slice(1),
34+
category: 'layout',
35+
inputs: [
36+
{ name: 'className', type: 'string', label: 'CSS Class' }
37+
]
38+
});
39+
});

0 commit comments

Comments
 (0)