-
Notifications
You must be signed in to change notification settings - Fork 84
feat: 14164 implement the legg til ny component for the last four standard choices #14392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jondyr
merged 28 commits into
main
from
14164-implement-the-legg-til-ny-component-for-the-last-four-standard-choices
Feb 13, 2025
Merged
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1a87bcc
render komponentbredde through a button --WIP
JamalAlabdullah 7f1f2ea
Merge remote-tracking branch 'origin/main' into 14164-implement-the-l…
JamalAlabdullah 17897d2
render sortOrder inside a button
JamalAlabdullah 2aa8afe
render validation and preselected props through buttons
JamalAlabdullah b510fde
move CollapsiblePropertyEditor files to an own folder
JamalAlabdullah 90b6cf6
added test fro CollapsiblePropertyEditor
JamalAlabdullah ec78568
added test
JamalAlabdullah 61f9d12
fixed plass for grid button
JamalAlabdullah 8f8be43
Merge remote-tracking branch 'origin/main' into 14164-implement-the-l…
JamalAlabdullah 90aefab
reorder
JamalAlabdullah 4aaeba1
unused textResouce for grid
JamalAlabdullah 7eec7f6
render all strig properites through CollapsiblePropertyEditor
JamalAlabdullah 660230b
render grid inside card
JamalAlabdullah d9cf36b
update test
JamalAlabdullah 4e745a0
test
JamalAlabdullah 06a64ba
Merge branch 'main' into 14164-implement-the-legg-til-ny-component-fo…
JamalAlabdullah 14749f7
Merge remote-tracking branch 'origin/main' into 14164-implement-the-l…
JamalAlabdullah bb758a5
update
JamalAlabdullah b9258b8
add test
JamalAlabdullah 442fc6a
refacture
JamalAlabdullah fe43f1c
Merge branch 'main' into 14164-implement-the-legg-til-ny-component-fo…
JamalAlabdullah b7caecd
fixed css of grid
JamalAlabdullah 18c1102
Merge branch '14164-implement-the-legg-til-ny-component-for-the-last-…
JamalAlabdullah 51e4a2b
fixed comments
JamalAlabdullah 86637a4
Fix Form component config
mlqn aa20758
Merge remote-tracking branch 'origin/main' into 14164-implement-the-l…
mlqn cbbe2c3
Fix tests
mlqn 8b246ec
Merge branch 'main' into 14164-implement-the-legg-til-ny-component-fo…
mlqn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
23 changes: 23 additions & 0 deletions
23
...itor/src/components/config/CollapsiblePropertyEditor/CollapsiblePropertyEditor.module.css
This file contains hidden or 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,23 @@ | ||
.collapsibleContainer { | ||
display: flex; | ||
width: 100%; | ||
flex-direction: row; | ||
align-items: flex-end; | ||
gap: var(--fds-spacing-4); | ||
padding-bottom: var(--fds-spacing-3); | ||
padding-top: var(--fds-spacing-3); | ||
} | ||
|
||
.collapsibleContainerClosed { | ||
padding: 0; | ||
} | ||
|
||
.editorContent { | ||
flex: 1; | ||
} | ||
|
||
.button { | ||
display: flex; | ||
gap: var(--fds-spacing-3); | ||
padding-left: 0; | ||
} |
57 changes: 57 additions & 0 deletions
57
...editor/src/components/config/CollapsiblePropertyEditor/CollapsiblePropertyEditor.test.tsx
This file contains hidden or 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,57 @@ | ||
import React from 'react'; | ||
import { | ||
CollapsiblePropertyEditor, | ||
type CollapsiblePropertyEditorProps, | ||
} from './CollapsiblePropertyEditor'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { screen } from '@testing-library/react'; | ||
import { renderWithProviders } from 'app-development/test/mocks'; | ||
import { textMock } from '@studio/testing/mocks/i18nMock'; | ||
|
||
// Test data | ||
const label = 'Test label'; | ||
const children = <div>Test children</div>; | ||
const icon = <div>Test icon</div>; | ||
|
||
describe('CollapsiblePropertyEditor', () => { | ||
it('should render the label', () => { | ||
renderCollapsiblePropertyEditor({ label: label }); | ||
expect(screen.getByText('Test label')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the icon', () => { | ||
renderCollapsiblePropertyEditor({ icon: <div>Test icon</div> }); | ||
expect(screen.getByText('Test icon')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the children', () => { | ||
renderCollapsiblePropertyEditor(); | ||
expect(screen.queryByText('Test children')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the children when the button is clicked', async () => { | ||
const user = userEvent.setup(); | ||
renderCollapsiblePropertyEditor(); | ||
await user.click(screen.getByText('Test label')); | ||
expect(screen.getByText('Test children')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide the children when the close button is clicked', async () => { | ||
const user = userEvent.setup(); | ||
renderCollapsiblePropertyEditor(); | ||
await user.click(screen.getByText('Test label')); | ||
expect(screen.getByText('Test children')).toBeInTheDocument(); | ||
await user.click(screen.getByRole('button', { name: textMock('general.close') })); | ||
expect(screen.queryByText('Test children')).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
const defaultProps: CollapsiblePropertyEditorProps = { | ||
label, | ||
children, | ||
icon, | ||
}; | ||
|
||
const renderCollapsiblePropertyEditor = (props: Partial<CollapsiblePropertyEditorProps> = {}) => { | ||
renderWithProviders()(<CollapsiblePropertyEditor {...defaultProps} {...props} />); | ||
}; |
50 changes: 50 additions & 0 deletions
50
...s/ux-editor/src/components/config/CollapsiblePropertyEditor/CollapsiblePropertyEditor.tsx
This file contains hidden or 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,50 @@ | ||
import React, { useState } from 'react'; | ||
import { PlusCircleIcon, XMarkIcon } from '@studio/icons'; | ||
import { StudioButton, StudioProperty } from '@studio/components'; | ||
import classes from './CollapsiblePropertyEditor.module.css'; | ||
import { useTranslation } from 'react-i18next'; | ||
import cn from 'classnames'; | ||
|
||
export type CollapsiblePropertyEditorProps = { | ||
label?: string; | ||
children?: React.ReactNode; | ||
icon?: React.ReactNode; | ||
disabledCloseButton?: boolean; | ||
}; | ||
|
||
export const CollapsiblePropertyEditor = ({ | ||
label, | ||
children, | ||
disabledCloseButton = false, | ||
icon = <PlusCircleIcon />, | ||
}: CollapsiblePropertyEditorProps) => { | ||
const { t } = useTranslation(); | ||
const [isVisible, setIsVisible] = useState(false); | ||
|
||
return ( | ||
<div | ||
className={cn(isVisible ? classes.collapsibleContainer : classes.collapsibleContainerClosed)} | ||
> | ||
{!isVisible ? ( | ||
<StudioProperty.Button | ||
className={classes.button} | ||
icon={icon} | ||
onClick={() => setIsVisible(true)} | ||
property={label} | ||
/> | ||
) : ( | ||
<> | ||
<div className={classes.editorContent}>{children}</div> | ||
{!disabledCloseButton && ( | ||
<StudioButton | ||
icon={<XMarkIcon />} | ||
onClick={() => setIsVisible(false)} | ||
title={t('general.close')} | ||
variant='secondary' | ||
/> | ||
JamalAlabdullah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
)} | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
frontend/packages/ux-editor/src/components/config/CollapsiblePropertyEditor/index.ts
This file contains hidden or 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 @@ | ||
export { CollapsiblePropertyEditor } from './CollapsiblePropertyEditor'; |
This file contains hidden or 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 |
---|---|---|
|
@@ -12,3 +12,7 @@ | |
.downIcon { | ||
font-size: var(--fds-sizing-6); | ||
} | ||
|
||
.gridButton { | ||
padding: 0; | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.