-
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.
feat: add checkbox in DescriptionForm to allow to add description abo…
…ve (#1050) * feat: add checkbox in DescriptionForm to allow to add description above * feat: use select instead of checkbox for description placement * feat: update query-client to 2.8.0 * feat: remove displaying description above folder * feat: add description placement in settings and edit item * test: add tests to verify description placement feature * feat: remove description of the description's placement setting --------- Co-authored-by: Kim Lan Phan Hoang <[email protected]>
- Loading branch information
Showing
15 changed files
with
299 additions
and
71 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 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,66 @@ | ||
import { MenuItem, Select } from '@mui/material'; | ||
|
||
import { | ||
DescriptionPlacement, | ||
DescriptionPlacementType, | ||
DiscriminatedItem, | ||
} from '@graasp/sdk'; | ||
|
||
import { useBuilderTranslation } from '@/config/i18n'; | ||
import { | ||
ITEM_SETTING_DESCRIPTION_PLACEMENT_SELECT_ID, | ||
buildDescriptionPlacementId, | ||
} from '@/config/selectors'; | ||
import { BUILDER } from '@/langs/constants'; | ||
|
||
import ItemSettingProperty from '../settings/ItemSettingProperty'; | ||
|
||
const DEFAULT_PLACEMENT = DescriptionPlacement.BELOW; | ||
|
||
type DescriptionPlacementFormProps = { | ||
updatedProperties: Partial<DiscriminatedItem>; | ||
onPlacementChanged: (payload: DescriptionPlacementType) => void; | ||
}; | ||
|
||
const DescriptionPlacementForm = ({ | ||
updatedProperties, | ||
onPlacementChanged, | ||
}: DescriptionPlacementFormProps): JSX.Element | null => { | ||
const { t } = useBuilderTranslation(); | ||
|
||
const handlePlacementChanged = (placement: string): void => { | ||
onPlacementChanged(placement as DescriptionPlacementType); | ||
}; | ||
|
||
return ( | ||
<ItemSettingProperty | ||
title={t(BUILDER.ITEM_SETTINGS_DESCRIPTION_PLACEMENT_TITLE)} | ||
inputSetting={ | ||
<Select | ||
id={ITEM_SETTING_DESCRIPTION_PLACEMENT_SELECT_ID} | ||
value={ | ||
updatedProperties.settings?.descriptionPlacement ?? | ||
DEFAULT_PLACEMENT | ||
} | ||
onChange={(e) => handlePlacementChanged(e.target.value)} | ||
size="small" | ||
> | ||
<MenuItem | ||
id={buildDescriptionPlacementId(DescriptionPlacement.ABOVE)} | ||
value={DescriptionPlacement.ABOVE} | ||
> | ||
{t(BUILDER.ITEM_SETTINGS_DESCRIPTION_PLACEMENT_ABOVE)} | ||
</MenuItem> | ||
<MenuItem | ||
id={buildDescriptionPlacementId(DescriptionPlacement.BELOW)} | ||
value={DescriptionPlacement.BELOW} | ||
> | ||
{t(BUILDER.ITEM_SETTINGS_DESCRIPTION_PLACEMENT_BELOW)} | ||
</MenuItem> | ||
</Select> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default DescriptionPlacementForm; |
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
41 changes: 41 additions & 0 deletions
41
src/components/item/settings/ItemSettingCheckBoxProperty.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,41 @@ | ||
import { Switch } from '@mui/material'; | ||
|
||
import ItemSettingProperty from './ItemSettingProperty'; | ||
|
||
type Props = { | ||
onClick: (checked: boolean) => void; | ||
title: string; | ||
checked: boolean; | ||
valueText: string; | ||
id?: string; | ||
disabled?: boolean; | ||
icon?: JSX.Element; | ||
}; | ||
|
||
const ItemSettingCheckBoxProperty = ({ | ||
onClick, | ||
title, | ||
checked = false, | ||
id, | ||
disabled, | ||
icon, | ||
valueText, | ||
}: Props): JSX.Element => ( | ||
<ItemSettingProperty | ||
title={title} | ||
valueText={valueText} | ||
icon={icon} | ||
inputSetting={ | ||
<Switch | ||
id={id} | ||
disabled={disabled} | ||
checked={checked} | ||
onChange={(e) => { | ||
onClick(e.target.checked); | ||
}} | ||
/> | ||
} | ||
/> | ||
); | ||
|
||
export default ItemSettingCheckBoxProperty; |
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
Oops, something went wrong.