-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(composer): refactor scene modal rendering
- Loading branch information
1 parent
da7281a
commit 1d797b1
Showing
27 changed files
with
328 additions
and
3,531 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
packages/scene-composer/src/common/componentTypeStings.spec.ts
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,38 @@ | ||
import { useIntl } from 'react-intl'; | ||
|
||
import { KnownComponentType } from '../interfaces'; | ||
import { Component } from '../models/SceneModels'; | ||
import { IDataOverlayComponentInternal, ISceneComponentInternal } from '../store'; | ||
|
||
import { getLocalizedComponentType } from './componentTypeStings'; | ||
|
||
describe('getLocalizedComponentType', () => { | ||
const intl = useIntl(); | ||
|
||
it('should get correct string for EntityBinding', () => { | ||
const component: ISceneComponentInternal = { ref: 'entity-binding-ref', type: KnownComponentType.EntityBinding }; | ||
expect(getLocalizedComponentType(component, intl)).toEqual('Entity data binding'); | ||
}); | ||
|
||
it('should get correct string for Overlay', () => { | ||
const component: IDataOverlayComponentInternal = { | ||
ref: 'overlay-ref', | ||
type: KnownComponentType.DataOverlay, | ||
subType: Component.DataOverlaySubType.OverlayPanel, | ||
dataRows: [], | ||
valueDataBindings: [], | ||
}; | ||
expect(getLocalizedComponentType(component, intl)).toEqual('Overlay'); | ||
}); | ||
|
||
it('should get correct string for Annotation', () => { | ||
const component: IDataOverlayComponentInternal = { | ||
ref: 'annotation-ref', | ||
type: KnownComponentType.DataOverlay, | ||
subType: Component.DataOverlaySubType.TextAnnotation, | ||
dataRows: [], | ||
valueDataBindings: [], | ||
}; | ||
expect(getLocalizedComponentType(component, intl)).toEqual('Annotation'); | ||
}); | ||
}); |
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,65 @@ | ||
import { IntlShape, defineMessages } from 'react-intl'; | ||
|
||
import { IDataOverlayComponent, KnownComponentType } from '../interfaces'; | ||
import { Component } from '../models/SceneModels'; | ||
import { ISceneComponentInternal } from '../store'; | ||
|
||
export const i18nKnownComponentTypesStrings = defineMessages({ | ||
[KnownComponentType.ModelRef]: { | ||
defaultMessage: 'Model Reference', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.SubModelRef]: { | ||
defaultMessage: 'Model Reference', | ||
description: 'Expandable Section Title', | ||
}, | ||
[KnownComponentType.Camera]: { | ||
defaultMessage: 'Camera', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.Light]: { | ||
defaultMessage: 'Light', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.Tag]: { | ||
defaultMessage: 'Tag', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.EntityBinding]: { | ||
defaultMessage: 'Entity data binding', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.ModelShader]: { | ||
defaultMessage: 'Model Shader', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.MotionIndicator]: { | ||
defaultMessage: 'Motion Indicator', | ||
description: 'Expandable Section title', | ||
}, | ||
[Component.DataOverlaySubType.TextAnnotation]: { | ||
defaultMessage: 'Annotation', | ||
description: 'Expandable Section title', | ||
}, | ||
[Component.DataOverlaySubType.OverlayPanel]: { | ||
defaultMessage: 'Overlay', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.Animation]: { | ||
defaultMessage: 'Animation', | ||
description: 'Expandable Section title', | ||
}, | ||
[KnownComponentType.PlaneGeometry]: { | ||
defaultMessage: 'Plane Geometry', | ||
description: 'Expandable Section title', | ||
}, | ||
}); | ||
|
||
export const getLocalizedComponentType = (component: ISceneComponentInternal, intl: IntlShape): string => { | ||
return ( | ||
(component.type === KnownComponentType.DataOverlay | ||
? intl.formatMessage(i18nKnownComponentTypesStrings[(component as IDataOverlayComponent).subType]) || | ||
(component as IDataOverlayComponent).subType | ||
: intl.formatMessage(i18nKnownComponentTypesStrings[component.type])) || component.type | ||
); | ||
}; |
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
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.