Skip to content

Commit c8238a2

Browse files
feat: z index and opacity for UI elements (#1133)
* fix play video not updaing src property (#1129) * add default emotes (#1132) * feat: 4088 add z-index support for ui elements (#1127) * Updated protocol pointers to dev branch * Added zIndex to the react-ecs component and test (cherry picked from commit 7ea5cfd) * Added opacity property to ui elements * Fixed tests * Updated protocol * Updated snapshots * Removed redundant definitions. Added test coverage * Adjusted the default value in test * ui transform test wip * Added more tests. Refactored parseUiTransform utility function to properly handle the new properties * Deep clean and snapshot * Removed redundant tests, removed redundant defaults definitions. * Updated snapshots * Updated default value for opacity and updated snapshots * Updated protocol and snapshots --------- Co-authored-by: Gon Pombo <[email protected]>
1 parent 579887d commit c8238a2

File tree

27 files changed

+300
-135
lines changed

27 files changed

+300
-135
lines changed

package-lock.json

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
77
"dependencies": {
88
"@actions/core": "^1.10.0",
9-
"@dcl/protocol": "1.0.0-15463532285.commit-444eb93",
9+
"@dcl/protocol": "1.0.0-15561894653.commit-9a42a0f",
1010
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
1111
"@dcl/ts-proto": "1.153.0",
1212
"@types/fs-extra": "^9.0.12",

packages/@dcl/inspector/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@dcl/inspector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@dcl/inspector",
33
"version": "0.1.0",
44
"dependencies": {
5-
"@dcl/asset-packs": "2.4.2",
5+
"@dcl/asset-packs": "2.4.3",
66
"ts-deepmerge": "^7.0.0"
77
},
88
"devDependencies": {

packages/@dcl/inspector/src/components/EntityInspector/ActionInspector/ActionInspector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ const ActionMapOption: Record<string, string> = {
8080
[ActionType.OPEN_LINK]: 'Open Link',
8181
[ActionType.PLAY_AUDIO_STREAM]: 'Play Audio Stream',
8282
[ActionType.STOP_AUDIO_STREAM]: 'Stop Audio Stream',
83-
[ActionType.PLAY_VIDEO_STREAM]: 'Play Video Stream',
84-
[ActionType.STOP_VIDEO_STREAM]: 'Stop Video Stream',
83+
[ActionType.PLAY_VIDEO_STREAM]: 'Play Video',
84+
[ActionType.STOP_VIDEO_STREAM]: 'Stop Video',
8585
[ActionType.SHOW_TEXT]: 'Show Text',
8686
[ActionType.HIDE_TEXT]: 'Hide Text',
8787
[ActionType.START_DELAY]: 'Start Delay',

packages/@dcl/inspector/src/components/EntityInspector/ActionInspector/PlayDefaultEmoteAction/PlayDefaultEmoteAction.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,23 @@ const emoteOptions = [
2828
{ value: 'shrug', label: 'Shrug' },
2929
{ value: 'disco', label: 'Disco' },
3030
{ value: 'dab', label: 'Dab' },
31-
{ value: 'headexplode', label: 'Head Explode' }
31+
{ value: 'headexplode', label: 'Head Explode' },
32+
{ value: 'buttonDown', label: 'Button Down' },
33+
{ value: 'buttonFront', label: 'Button Front' },
34+
{ value: 'getHit', label: 'Get Hit' },
35+
{ value: 'knockOut', label: 'Knock Out' },
36+
{ value: 'lever', label: 'Lever' },
37+
{ value: 'openChest', label: 'Open Chest' },
38+
{ value: 'openDoor', label: 'Open Door' },
39+
{ value: 'punch', label: 'Punch' },
40+
{ value: 'push', label: 'Push' },
41+
{ value: 'swingWeaponOneHand', label: 'Swing Weapon One Hand' },
42+
{ value: 'swingWeaponTwoHands', label: 'Swing Weapon Two Hands' },
43+
{ value: 'throw', label: 'Throw' },
44+
{ value: 'sittingChair1', label: 'Sitting Chair 1' },
45+
{ value: 'sittingChair2', label: 'Sitting Chair 2' },
46+
{ value: 'sittingGround1', label: 'Sitting Ground 1' },
47+
{ value: 'sittingGround2', label: 'Sitting Ground 2' }
3248
]
3349

3450
const PlayDefaultEmoteAction: React.FC<Props> = ({ value, onUpdate }: Props) => {

packages/@dcl/inspector/src/components/EntityInspector/ActionInspector/PlayVideoStreamAction/PlayVideoStreamAction.tsx

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,6 @@ const playModeOptions = [
2626
}
2727
]
2828

29-
enum VIDEO_SOURCE {
30-
DCL_CAST = 'dcl-cast',
31-
URL = 'url'
32-
}
33-
34-
const videoSourceOptions = [
35-
{
36-
label: 'DCL Cast',
37-
value: VIDEO_SOURCE.DCL_CAST
38-
},
39-
{
40-
label: 'URL',
41-
value: VIDEO_SOURCE.URL
42-
}
43-
]
44-
4529
const PlayVideoStreamAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
4630
const [payload, setPayload] = useState<Partial<ActionPayload<ActionType.PLAY_VIDEO_STREAM>>>({
4731
...value
@@ -52,13 +36,6 @@ const PlayVideoStreamAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
5236
onUpdate(payload)
5337
}, [payload, onUpdate])
5438

55-
const handleChangeVideoSource = useCallback(
56-
({ target: { value } }: React.ChangeEvent<HTMLSelectElement>) => {
57-
setPayload({ ...payload, dclCast: value === VIDEO_SOURCE.DCL_CAST })
58-
},
59-
[payload, setPayload]
60-
)
61-
6239
const handleChangeSrc = useCallback(
6340
({ target: { value } }: React.ChangeEvent<HTMLInputElement>) => {
6441
setPayload({ ...payload, src: value })
@@ -96,42 +73,17 @@ const PlayVideoStreamAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
9673

9774
return (
9875
<div className="PlayVideoStreamActionContainer">
76+
<Block>
77+
<TextField label={<>URL {renderUrlInfo()}</>} value={payload.src} onChange={handleChangeSrc} autoSelect />
78+
</Block>
9979
<Block>
10080
<Dropdown
101-
label="Video Source"
102-
value={payload.dclCast ? VIDEO_SOURCE.DCL_CAST : VIDEO_SOURCE.URL}
103-
options={videoSourceOptions}
104-
onChange={handleChangeVideoSource}
105-
info={
106-
payload.dclCast && (
107-
<>
108-
DCL Cast only works when your scene is deployed to a World.{' '}
109-
<a
110-
href="https://docs.decentraland.org/creator/development-guide/sdk7/video-playing/#streaming-using-decentraland-cast"
111-
target="_blank"
112-
>
113-
Learn More
114-
</a>
115-
</>
116-
)
117-
}
81+
label="Play Mode"
82+
value={payload.loop ? PLAY_MODE.LOOP : PLAY_MODE.PLAY_ONCE}
83+
options={playModeOptions}
84+
onChange={handleChangePlayMode}
11885
/>
11986
</Block>
120-
{!payload.dclCast ? (
121-
<>
122-
<Block>
123-
<TextField label={<>URL {renderUrlInfo()}</>} value={payload.src} onChange={handleChangeSrc} autoSelect />
124-
</Block>
125-
<Block>
126-
<Dropdown
127-
label="Play Mode"
128-
value={payload.loop ? PLAY_MODE.LOOP : PLAY_MODE.PLAY_ONCE}
129-
options={playModeOptions}
130-
onChange={handleChangePlayMode}
131-
/>
132-
</Block>
133-
</>
134-
) : null}
13587
<Block>
13688
<RangeField
13789
label="Volume"

packages/@dcl/playground-assets/etc/playground-assets.api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,6 +3260,7 @@ export interface PBUiTransform {
32603260
// (undocumented)
32613261
minWidth: number;
32623262
minWidthUnit: YGUnit;
3263+
opacity?: number | undefined;
32633264
overflow: YGOverflow;
32643265
// (undocumented)
32653266
paddingBottom: number;
@@ -3294,6 +3295,7 @@ export interface PBUiTransform {
32943295
// (undocumented)
32953296
width: number;
32963297
widthUnit: YGUnit;
3298+
zIndex?: number | undefined;
32973299
}
32983300

32993301
// @public (undocumented)
@@ -4445,12 +4447,14 @@ export interface UiTransformProps {
44454447
maxWidth?: PositionUnit;
44464448
minHeight?: PositionUnit;
44474449
minWidth?: PositionUnit;
4450+
opacity?: number;
44484451
overflow?: OverflowType;
44494452
padding?: Partial<Position> | PositionShorthand;
44504453
pointerFilter?: PointerFilterType;
44514454
position?: Partial<Position> | PositionShorthand;
44524455
positionType?: PositionType;
44534456
width?: PositionUnit | 'auto';
4457+
zIndex?: number;
44544458
}
44554459

44564460
// @public (undocumented)

packages/@dcl/react-ecs/src/components/uiTransform/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ const defaultUiTransform: PBUiTransform = {
7979
flexBasisUnit: YGUnit.YGU_UNDEFINED,
8080
widthUnit: YGUnit.YGU_AUTO,
8181
heightUnit: YGUnit.YGU_UNDEFINED,
82-
pointerFilter: PointerFilterMode.PFM_NONE
82+
pointerFilter: PointerFilterMode.PFM_NONE,
83+
opacity: 1,
84+
zIndex: 0
8385
}
8486

8587
/**

packages/@dcl/react-ecs/src/components/uiTransform/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,9 @@ export interface UiTransformProps {
150150
borderColor?: Record<keyof Partial<Position>, Color4> | Color4 | undefined
151151
borderRadius?: Partial<BorderRadius> | PositionUnit
152152
borderWidth?: Partial<Position> | PositionUnit
153+
154+
/** The opacity property sets the opacity level for an element, it's accumulated across children @defaultValue 1 */
155+
opacity?: number
156+
/** default 0 */
157+
zIndex?: number
153158
}

packages/@dcl/sdk-commands/package-lock.json

Lines changed: 9 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@dcl/sdk-commands/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@dcl/inspector": "file:../inspector",
1414
"@dcl/linker-dapp": "^0.14.2",
1515
"@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
16-
"@dcl/protocol": "1.0.0-15463532285.commit-444eb93",
16+
"@dcl/protocol": "1.0.0-15561894653.commit-9a42a0f",
1717
"@dcl/quests-client": "^1.0.3",
1818
"@dcl/quests-manager": "^0.1.4",
1919
"@dcl/rpc": "^1.1.1",

test/ecs/components/UiComponent.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ describe('UiTransform component', () => {
8787
borderTopColor: undefined,
8888
borderBottomColor: undefined,
8989
borderLeftColor: undefined,
90-
borderRightColor: undefined
90+
borderRightColor: undefined,
91+
opacity: undefined,
92+
zIndex: undefined
9193
})
9294
})
9395
})

0 commit comments

Comments
 (0)