Skip to content

Commit

Permalink
Adapt to refactor in react-components
Browse files Browse the repository at this point in the history
  • Loading branch information
ComLock committed Dec 10, 2024
1 parent bb5cb25 commit 81bbc82
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/main/resources/react4xp/entries/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { AppProps } from '/types/AppProps';

import * as React from 'react';
import {XpComponent} from '@enonic/react-components';
import {BaseComponent} from '@enonic/react-components';
import {componentRegistry} from '../componentRegistry';

const App: React.FC<AppProps> = (props) => {
return (
<XpComponent componentRegistry={componentRegistry} {...props}/>
<BaseComponent componentRegistry={componentRegistry} {...props}/>
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/react4xp/layouts/TwoColumnsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type {ComponentRegistry} from '@enonic/react-components';

// import { toStr } from '@enonic/js-utils/value/toStr';
import {XpLayout} from '@enonic/react-components';
import {Layout} from '@enonic/react-components';
import * as React from 'react';

export interface TwoColumnsLayoutProps {
Expand All @@ -16,8 +16,8 @@ export function TwoColumnsLayout (props: TwoColumnsLayoutProps) {
// console.debug('TwoColumnsLayout props:', toStr(props));
return (
// @ts-expect-error regions not compatible
<XpLayout
// Needed by XpBaseLayout to add
<Layout
// Needed by BaseLayout to add
// data-portal-component-type='layout'
// when request.mode === 'edit'.
{...props}
Expand All @@ -28,6 +28,6 @@ export function TwoColumnsLayout (props: TwoColumnsLayoutProps) {
display: 'grid',
gridTemplateColumns: '1fr 1fr'
}}>
</XpLayout>
</Layout>
);
}
8 changes: 4 additions & 4 deletions src/main/resources/react4xp/pages/DefaultPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import './default.sass'; // Create Error reference failed
// import { toStr } from '@enonic/js-utils/value/toStr';
import {
ComponentRegistry,
XpPage
Page
} from '@enonic/react-components';
// import dayjs from 'dayjs';
import * as React from 'react';
Expand All @@ -23,8 +23,8 @@ export function DefaultPage(props: DefaultPageProps) {
// console.info('DefaultPage props:', toStr(props));
return (
// @ts-expect-error regions not compatible
<XpPage
// Needed by XpBasePage to add
<Page
// Needed by BasePage to add
// data-portal-component-type='page'
// when request.mode === 'edit'.
{...props}
Expand All @@ -35,6 +35,6 @@ export function DefaultPage(props: DefaultPageProps) {
{/* Warning: Text content did not match. Server: "2024-11-08T09:36:59+01:00" Client: "2024-11-08T09:37:00+01:00" */}
{/* Uncaught Error: Text content does not match server-rendered HTML. */}
{/* <div>Page: {dayjs().format()}</div> */}
</XpPage>
</Page>
);
}
8 changes: 4 additions & 4 deletions src/main/resources/react4xp/parts/ExamplePart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import './example.sass';
import * as React from 'react';
import {
RichText,
XpPart,
Part,
} from '@enonic/react-components';

export interface ExampleProps {
Expand All @@ -31,8 +31,8 @@ export function ExamplePart(props: ExampleProps) {
return <div>Example Part: Please fill in the htmlArea.</div>;
}
return (
<XpPart
// Needed by XpBasePart to add
<Part
// Needed by BasePart to add
// data-portal-component-type='part'
// when request.mode === 'edit'.
{...autoProps}
Expand All @@ -45,6 +45,6 @@ export function ExamplePart(props: ExampleProps) {
componentRegistry={componentRegistry}
data={myHtmlArea}
/>
</XpPart>
</Part>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ type BaseShortcutContent = Content<{
target: string;
}, 'base:shortcut'>;

// declare global {
// interface XpContent {
// 'base:shortcut': BaseShortcutContent;
// }
// }

export const baseShortcutProcessorWrapper = (dataFetcher): ContentTypeProcessorFunction<BaseShortcutContent> => (params) => {
// log.info('baseShortcutProcessor params:%s', toStr(params));
const {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/site/controllers/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function get(request: Request) {
}
log.info('ComponentUrl component:%s', toStr(component));

// Props for XpComponent
// Props for BaseComponent
const props: Record<string, unknown> = {};
// if (type === 'text') {
// props.component = component;
Expand Down

0 comments on commit 81bbc82

Please sign in to comment.