mirror of
				https://github.com/lingble/twenty.git
				synced 2025-10-30 20:27:55 +00:00 
			
		
		
		
	fix: New Relation Design hot fix (#7423)
## Description - This PR solves the issue #7353 - [x] Improved layout for mobile and desktop - [ ] Added tooltip on hover --------- Co-authored-by: Nitin Koche <nitinkoche03@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
		| @@ -14,6 +14,7 @@ import { RelationType } from '@/settings/data-model/types/RelationType'; | |||||||
| import { IconPicker } from '@/ui/input/components/IconPicker'; | import { IconPicker } from '@/ui/input/components/IconPicker'; | ||||||
| import { Select } from '@/ui/input/components/Select'; | import { Select } from '@/ui/input/components/Select'; | ||||||
| import { TextInput } from '@/ui/input/components/TextInput'; | import { TextInput } from '@/ui/input/components/TextInput'; | ||||||
|  | import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; | ||||||
| import { RelationDefinitionType } from '~/generated-metadata/graphql'; | import { RelationDefinitionType } from '~/generated-metadata/graphql'; | ||||||
|  |  | ||||||
| export const settingsDataModelFieldRelationFormSchema = z.object({ | export const settingsDataModelFieldRelationFormSchema = z.object({ | ||||||
| @@ -44,13 +45,12 @@ const StyledContainer = styled.div` | |||||||
|   padding: ${({ theme }) => theme.spacing(4)}; |   padding: ${({ theme }) => theme.spacing(4)}; | ||||||
| `; | `; | ||||||
|  |  | ||||||
| const StyledSelectsContainer = styled.div` | const StyledSelectsContainer = styled.div<{ isMobile: boolean }>` | ||||||
|   display: grid; |   display: grid; | ||||||
|   gap: ${({ theme }) => theme.spacing(4)}; |   gap: ${({ theme }) => theme.spacing(4)}; | ||||||
|   grid-template-columns: 1fr 1fr; |   grid-template-columns: ${({ isMobile }) => (isMobile ? '1fr' : '1fr 1fr')}; | ||||||
|   margin-bottom: ${({ theme }) => theme.spacing(4)}; |   margin-bottom: ${({ theme }) => theme.spacing(4)}; | ||||||
| `; | `; | ||||||
|  |  | ||||||
| const StyledInputsLabel = styled.span` | const StyledInputsLabel = styled.span` | ||||||
|   color: ${({ theme }) => theme.font.color.light}; |   color: ${({ theme }) => theme.font.color.light}; | ||||||
|   display: block; |   display: block; | ||||||
| @@ -98,9 +98,11 @@ export const SettingsDataModelFieldRelationForm = ({ | |||||||
|     watchFormValue('relation.objectMetadataId'), |     watchFormValue('relation.objectMetadataId'), | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|  |   const isMobile = useIsMobile(); | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|     <StyledContainer> |     <StyledContainer> | ||||||
|       <StyledSelectsContainer> |       <StyledSelectsContainer isMobile={isMobile}> | ||||||
|         <Controller |         <Controller | ||||||
|           name="relation.type" |           name="relation.type" | ||||||
|           control={control} |           control={control} | ||||||
|   | |||||||
| @@ -14,8 +14,8 @@ import { | |||||||
|   SettingsDataModelFieldPreviewCard, |   SettingsDataModelFieldPreviewCard, | ||||||
|   SettingsDataModelFieldPreviewCardProps, |   SettingsDataModelFieldPreviewCardProps, | ||||||
| } from '@/settings/data-model/fields/preview/components/SettingsDataModelFieldPreviewCard'; | } from '@/settings/data-model/fields/preview/components/SettingsDataModelFieldPreviewCard'; | ||||||
|  | import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; | ||||||
| import { FieldMetadataType } from '~/generated-metadata/graphql'; | import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||||||
|  |  | ||||||
| type SettingsDataModelFieldRelationSettingsFormCardProps = { | type SettingsDataModelFieldRelationSettingsFormCardProps = { | ||||||
|   fieldMetadataItem: Pick<FieldMetadataItem, 'icon' | 'label' | 'type'> & |   fieldMetadataItem: Pick<FieldMetadataItem, 'icon' | 'label' | 'type'> & | ||||||
|     Partial<Omit<FieldMetadataItem, 'icon' | 'label' | 'type'>>; |     Partial<Omit<FieldMetadataItem, 'icon' | 'label' | 'type'>>; | ||||||
| @@ -27,14 +27,23 @@ const StyledFieldPreviewCard = styled(SettingsDataModelFieldPreviewCard)` | |||||||
|   flex: 1 1 100%; |   flex: 1 1 100%; | ||||||
| `; | `; | ||||||
|  |  | ||||||
| const StyledPreviewContent = styled.div` | const StyledPreviewContent = styled.div<{ isMobile: boolean }>` | ||||||
|   display: flex; |   display: flex; | ||||||
|   flex-direction: column; |  | ||||||
|   gap: 6px; |   gap: 6px; | ||||||
|  |   flex-direction: ${({ isMobile }) => (isMobile ? 'column' : 'row')}; | ||||||
| `; | `; | ||||||
|  |  | ||||||
| const StyledRelationImage = styled.img<{ flip?: boolean }>` | const StyledRelationImage = styled.img<{ flip?: boolean; isMobile: boolean }>` | ||||||
|   transform: ${({ flip }) => (flip ? 'scaleX(-1) rotate(270deg)' : 'none')}; |   transform: ${({ flip, isMobile }) => { | ||||||
|  |     let transform = ''; | ||||||
|  |     if (isMobile) { | ||||||
|  |       transform += 'rotate(90deg) '; | ||||||
|  |     } | ||||||
|  |     if (flip === true) { | ||||||
|  |       transform += 'scaleX(-1)'; | ||||||
|  |     } | ||||||
|  |     return transform.trim(); | ||||||
|  |   }}; | ||||||
|   margin: auto; |   margin: auto; | ||||||
|   width: 54px; |   width: 54px; | ||||||
| `; | `; | ||||||
| @@ -46,7 +55,7 @@ export const SettingsDataModelFieldRelationSettingsFormCard = ({ | |||||||
|   const { watch: watchFormValue } = |   const { watch: watchFormValue } = | ||||||
|     useFormContext<SettingsDataModelFieldRelationFormValues>(); |     useFormContext<SettingsDataModelFieldRelationFormValues>(); | ||||||
|   const { findObjectMetadataItemById } = useFilteredObjectMetadataItems(); |   const { findObjectMetadataItemById } = useFilteredObjectMetadataItems(); | ||||||
|  |   const isMobile = useIsMobile(); | ||||||
|   const { |   const { | ||||||
|     initialRelationObjectMetadataItem, |     initialRelationObjectMetadataItem, | ||||||
|     initialRelationType, |     initialRelationType, | ||||||
| @@ -69,7 +78,7 @@ export const SettingsDataModelFieldRelationSettingsFormCard = ({ | |||||||
|   return ( |   return ( | ||||||
|     <SettingsDataModelPreviewFormCard |     <SettingsDataModelPreviewFormCard | ||||||
|       preview={ |       preview={ | ||||||
|         <StyledPreviewContent> |         <StyledPreviewContent isMobile={isMobile}> | ||||||
|           <StyledFieldPreviewCard |           <StyledFieldPreviewCard | ||||||
|             fieldMetadataItem={fieldMetadataItem} |             fieldMetadataItem={fieldMetadataItem} | ||||||
|             shrink |             shrink | ||||||
| @@ -80,6 +89,7 @@ export const SettingsDataModelFieldRelationSettingsFormCard = ({ | |||||||
|             src={relationTypeConfig.imageSrc} |             src={relationTypeConfig.imageSrc} | ||||||
|             flip={relationTypeConfig.isImageFlipped} |             flip={relationTypeConfig.isImageFlipped} | ||||||
|             alt={relationTypeConfig.label} |             alt={relationTypeConfig.label} | ||||||
|  |             isMobile={isMobile} | ||||||
|           /> |           /> | ||||||
|           <StyledFieldPreviewCard |           <StyledFieldPreviewCard | ||||||
|             fieldMetadataItem={{ |             fieldMetadataItem={{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Harshit Singh
					Harshit Singh