Skip to content

Commit

Permalink
Add summary2 for header and paragraph (#2621)
Browse files Browse the repository at this point in the history
* add header summary2

* add summer2 for paragraph
  • Loading branch information
Magnusrm authored Oct 22, 2024
1 parent 629aae0 commit e25af39
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/layout/Header/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { CG } from 'src/codegen/CG';
import { CompCategory } from 'src/layout/common';

export const HEADER_SUMMARY_OVERRIDE_PROPS = new CG.obj()
.extends(CG.common('ISummaryOverridesCommon'))
.optional()
.setTitle('Summary properties')
.setDescription('Properties for how to display the summary of the component')
.exportAs('HeaderSummaryOverrideProps');

export const Config = new CG.component({
category: CompCategory.Presentation,
capabilities: {
Expand Down
10 changes: 10 additions & 0 deletions src/layout/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { JSX } from 'react';
import { HeaderDef } from 'src/layout/Header/config.def.generated';
import { HeaderComponent } from 'src/layout/Header/HeaderComponent';
import type { PropsFromGenericComponent } from 'src/layout';
import type { Summary2Props } from 'src/layout/Summary2/SummaryComponent2/types';

export type IHeaderProps = PropsFromGenericComponent<'Header'>;

Expand All @@ -13,4 +14,13 @@ export class Header extends HeaderDef {
return <HeaderComponent {...props} />;
},
);

renderSummary2(props: Summary2Props<'Header'>): JSX.Element | null {
return (
<HeaderComponent
node={props.target}
containerDivRef={React.createRef()}
/>
);
}
}
7 changes: 7 additions & 0 deletions src/layout/Paragraph/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { CG } from 'src/codegen/CG';
import { CompCategory } from 'src/layout/common';

export const PARAGRAPH_SUMMARY_OVERRIDE_PROPS = new CG.obj()
.extends(CG.common('ISummaryOverridesCommon'))
.optional()
.setTitle('Summary properties')
.setDescription('Properties for how to display the summary of the component')
.exportAs('ParagraphSummaryOverrideProps');

export const Config = new CG.component({
category: CompCategory.Presentation,
capabilities: {
Expand Down
10 changes: 10 additions & 0 deletions src/layout/Paragraph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ import type { JSX } from 'react';
import { ParagraphDef } from 'src/layout/Paragraph/config.def.generated';
import { ParagraphComponent } from 'src/layout/Paragraph/ParagraphComponent';
import type { PropsFromGenericComponent } from 'src/layout';
import type { Summary2Props } from 'src/layout/Summary2/SummaryComponent2/types';

export class Paragraph extends ParagraphDef {
render = forwardRef<HTMLElement, PropsFromGenericComponent<'Paragraph'>>(
function LayoutComponentParagraphRender(props, _): JSX.Element | null {
return <ParagraphComponent {...props} />;
},
);

renderSummary2(props: Summary2Props<'Paragraph'>): JSX.Element | null {
return (
<ParagraphComponent
node={props.target}
containerDivRef={React.createRef()}
/>
);
}
}
4 changes: 4 additions & 0 deletions src/layout/Summary2/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { CompCategory } from 'src/layout/common';
import { DATEPICKER_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Datepicker/config';
import { DROPDOWN_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Dropdown/config';
import { GROUP_SUMMARY_PROPS } from 'src/layout/Group/config';
import { HEADER_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Header/config';
import { INPUT_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Input/config';
import { LIKERT_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Likert/config';
import { LIST_SUMMARY_OVERRIDE_PROPS } from 'src/layout/List/config';
import { MAP_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Map/config';
import { MULTIPLE_SELECT_SUMMARY_OVERRIDE_PROPS } from 'src/layout/MultipleSelect/config';
import { PARAGRAPH_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Paragraph/config';
import { PAYMENT_SUMMARY_OVERRIDE_PROPS } from 'src/layout/Payment/config';
import { RADIO_SUMMARY_OVERRIDE_PROPS } from 'src/layout/RadioButtons/config';
import { REPEATING_GROUP_SUMMARY_OVERRIDE_PROPS } from 'src/layout/RepeatingGroup/config';
Expand Down Expand Up @@ -82,6 +84,8 @@ export const Config = new CG.component({
SUBFORM_SUMMARY_OVERRIDE_PROPS,
LIKERT_SUMMARY_OVERRIDE_PROPS,
PAYMENT_SUMMARY_OVERRIDE_PROPS,
HEADER_SUMMARY_OVERRIDE_PROPS,
PARAGRAPH_SUMMARY_OVERRIDE_PROPS,
).exportAs('AnySummaryOverrideProps'),
).optional(),
),
Expand Down

0 comments on commit e25af39

Please sign in to comment.