-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split edit and create folder, remove setChanges (#1557)
* refactor: split edit and create folder, remove setChanges * refactor: remove showPlacement prop * refactor: add item name regex * refactor: fix syntax * refactor: fix tests * refactor: update deps
- Loading branch information
Showing
18 changed files
with
377 additions
and
183 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
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
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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
34 changes: 34 additions & 0 deletions
34
src/components/item/form/description/DescriptionAndPlacementForm.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,34 @@ | ||
import { Stack } from '@mui/material'; | ||
|
||
import { DescriptionPlacementType } from '@graasp/sdk'; | ||
|
||
import { DescriptionForm, type DescriptionFormProps } from './DescriptionForm'; | ||
import DescriptionPlacementForm from './DescriptionPlacementForm'; | ||
|
||
type DescriptionAndPlacementFormProps = { | ||
id?: string; | ||
description?: string; | ||
descriptionPlacement?: DescriptionPlacementType; | ||
onPlacementChange: (v: DescriptionPlacementType) => void; | ||
onDescriptionChange: DescriptionFormProps['onChange']; | ||
}; | ||
|
||
export const DescriptionAndPlacementForm = ({ | ||
id, | ||
description = '', | ||
descriptionPlacement, | ||
onPlacementChange, | ||
onDescriptionChange, | ||
}: DescriptionAndPlacementFormProps): JSX.Element => ( | ||
<Stack spacing={2}> | ||
<DescriptionForm | ||
id={id} | ||
value={description} | ||
onChange={onDescriptionChange} | ||
/> | ||
<DescriptionPlacementForm | ||
descriptionPlacement={descriptionPlacement} | ||
onPlacementChange={onPlacementChange} | ||
/> | ||
</Stack> | ||
); |
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,36 @@ | ||
import { Box, FormLabel, Typography } from '@mui/material'; | ||
|
||
import TextEditor from '@graasp/ui/text-editor'; | ||
|
||
import { useBuilderTranslation } from '@/config/i18n'; | ||
import { BUILDER } from '@/langs/constants'; | ||
|
||
export type DescriptionFormProps = { | ||
id?: string; | ||
value?: string; | ||
onChange: (v: string) => void; | ||
}; | ||
|
||
export function DescriptionForm({ | ||
id, | ||
value = '', | ||
onChange, | ||
}: DescriptionFormProps): JSX.Element { | ||
const { t: translateBuilder } = useBuilderTranslation(); | ||
|
||
return ( | ||
<Box> | ||
<FormLabel> | ||
<Typography variant="caption"> | ||
{translateBuilder(BUILDER.DESCRIPTION_LABEL)} | ||
</Typography> | ||
</FormLabel> | ||
<TextEditor | ||
id={id} | ||
value={value} | ||
onChange={onChange} | ||
showActions={false} | ||
/> | ||
</Box> | ||
); | ||
} |
Oops, something went wrong.