-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linting
- Loading branch information
Showing
6 changed files
with
178 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...end/packages/ux-editor/src/components/Properties/PropertiesHeader/ComponentMainConfig.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import type { FormItem } from '../../../types/FormItem'; | ||
import { ComponentType } from 'app-shared/types/ComponentType'; | ||
import { Accordion } from '@digdir/designsystemet-react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Summary2Override } from '../../config/componentSpecificContent/Summary2/Override/Summary2Override'; | ||
import type { Summary2OverrideConfig } from 'app-shared/types/ComponentSpecificConfig'; | ||
|
||
export type ComponentMainConfigProps = { | ||
component: FormItem; | ||
handleComponentChange: (component: FormItem) => void; | ||
}; | ||
|
||
export const ComponentMainConfig = ({ | ||
component, | ||
handleComponentChange, | ||
}: ComponentMainConfigProps) => { | ||
const [accordionOpen, setAccordionOpen] = React.useState<string[]>([]); | ||
const { t } = useTranslation(); | ||
|
||
const handleOverridesChange = (updatedOverrides: Summary2OverrideConfig[]): void => { | ||
const updatedComponent = { ...component } as FormItem<ComponentType.Summary2>; | ||
updatedComponent.overrides = updatedOverrides; | ||
handleComponentChange(updatedComponent); | ||
}; | ||
|
||
return ( | ||
<> | ||
{component.type === ComponentType.Summary2 && ( | ||
<Accordion color='subtle'> | ||
<Accordion.Item open={accordionOpen['summary2overrides'] === true}> | ||
<Accordion.Header | ||
onHeaderClick={() => | ||
setAccordionOpen((prev) => { | ||
return { ...prev, summary2overrides: !prev['summary2overrides'] }; | ||
}) | ||
} | ||
> | ||
{t('Overstyr hva som skal vises')} | ||
</Accordion.Header> | ||
<Accordion.Content> | ||
<Summary2Override overrides={component.overrides} onChange={handleOverridesChange} /> | ||
</Accordion.Content> | ||
</Accordion.Item> | ||
</Accordion> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters