Skip to content

Commit

Permalink
Revert "feat: UITransform pointer filter property (#792)"
Browse files Browse the repository at this point in the history
This reverts commit 887e14c.
  • Loading branch information
pravusjif committed Oct 23, 2023
1 parent 887e14c commit 84b272f
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 113 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
"dependencies": {
"@actions/core": "^1.10.0",
"@dcl/protocol": "1.0.0-6590614146.commit-db4a595",
"@dcl/protocol": "1.0.0-6473373363.commit-d038938",
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
"@dcl/ts-proto": "1.153.0",
"@types/fs-extra": "^9.0.12",
Expand Down
13 changes: 0 additions & 13 deletions packages/@dcl/playground-assets/etc/playground-assets.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2939,7 +2939,6 @@ export interface PBUiTransform {
paddingTopUnit: YGUnit;
// (undocumented)
parent: number;
pointerFilter?: PointerFilterMode | undefined;
// (undocumented)
positionBottom: number;
positionBottomUnit: YGUnit;
Expand Down Expand Up @@ -3126,17 +3125,6 @@ export const enum PointerEventType {
PET_UP = 0
}

// @public (undocumented)
export const enum PointerFilterMode {
// (undocumented)
PFM_BLOCK = 1,
// (undocumented)
PFM_NONE = 0
}

// @public
export type PointerFilterType = 'none' | 'block';

// @public (undocumented)
export const PointerLock: LastWriteWinElementSetComponentDefinition<PBPointerLock>;

Expand Down Expand Up @@ -3953,7 +3941,6 @@ export interface UiTransformProps {
minWidth?: PositionUnit;
overflow?: OverflowType;
padding?: Partial<Position> | PositionShorthand;
pointerFilter?: PointerFilterType;
position?: Partial<Position> | PositionShorthand;
positionType?: PositionType;
width?: PositionUnit;
Expand Down
1 change: 0 additions & 1 deletion packages/@dcl/react-ecs/src/components/Label/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { getFont, getTextAlign } from './utils'
/* @__PURE__ */
export function Label(props: EntityPropTypes & UiLabelProps) {
const { uiTransform, uiBackground, onMouseDown, onMouseUp, ...uiTextProps } = props

const commonProps = parseProps({
uiTransform,
uiBackground,
Expand Down
22 changes: 5 additions & 17 deletions packages/@dcl/react-ecs/src/components/uiTransform/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import {
getAlign,
getDisplay,
getFlexDirection,
getDisplay,
getFlexWrap,
getJustify,
getOverflow,
getPointerFilter,
getPositionType,
getPoistionType,
parsePosition,
parseSize
} from './utils'
import { UiTransformProps } from './types'
import {
PointerFilterMode,
YGAlign,
YGDisplay,
YGFlexDirection,
YGJustify,
YGOverflow,
YGPositionType,
YGUnit
} from '@dcl/ecs'
import { YGAlign, YGDisplay, YGFlexDirection, YGJustify, YGOverflow, YGPositionType, YGUnit } from '@dcl/ecs'
import { PBUiTransform } from '@dcl/ecs/dist/components'

/**
Expand Down Expand Up @@ -75,8 +65,7 @@ const defaultUiTransform: PBUiTransform = {
positionTopUnit: YGUnit.YGU_UNDEFINED,
flexBasisUnit: YGUnit.YGU_UNDEFINED,
widthUnit: YGUnit.YGU_UNDEFINED,
heightUnit: YGUnit.YGU_UNDEFINED,
pointerFilter: PointerFilterMode.PFM_NONE
heightUnit: YGUnit.YGU_UNDEFINED
}

/**
Expand All @@ -103,8 +92,7 @@ export function parseUiTransform(props: UiTransformProps = {}): PBUiTransform {
...getJustify(props.justifyContent),
...getFlexDirection(props.flexDirection),
...getOverflow(props.overflow),
...getPointerFilter(props.pointerFilter),
...getPositionType(props.positionType),
...getPoistionType(props.positionType),
// Optional values
...(alignContent && getAlign('alignContent', alignContent)),
...(alignItems && getAlign('alignItems', alignItems)),
Expand Down
10 changes: 1 addition & 9 deletions packages/@dcl/react-ecs/src/components/uiTransform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type FlexWrapType = 'wrap' | 'nowrap' | 'wrap-reverse'

/**
* @public
* The overflow property controls what happens to content that is too big to fit into an area
* The overflow property controls what happens to content that is too big to fit into an area.
*/
export type OverflowType = 'hidden' | 'scroll' | 'visible'

Expand All @@ -75,12 +75,6 @@ export type OverflowType = 'hidden' | 'scroll' | 'visible'
*/
export type PositionType = 'absolute' | 'relative'

/**
* @public
* The pointer filter property determines if the ui element blocks the pointer or not (elements with pointer events always block the pointer regardless of this property)
*/
export type PointerFilterType = 'none' | 'block'

/**
* Layout props to position things in the canvas
* @public
Expand Down Expand Up @@ -130,6 +124,4 @@ export interface UiTransformProps {
flexShrink?: number
/** The overflow property controls what happens to content that is too big to fit into an area */
overflow?: OverflowType
/** The pointer filter property determines if the ui element blocks the pointer or not (elements with pointer events always block the pointer regardless of this property) **/
pointerFilter?: PointerFilterType
}
32 changes: 3 additions & 29 deletions packages/@dcl/react-ecs/src/components/uiTransform/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
YGAlign,
YGDisplay,
YGFlexDirection,
YGJustify,
YGOverflow,
YGPositionType,
YGUnit,
YGWrap,
PointerFilterMode
} from '@dcl/ecs'
import { YGAlign, YGDisplay, YGFlexDirection, YGJustify, YGOverflow, YGPositionType, YGUnit, YGWrap } from '@dcl/ecs'
import {
AlignType,
FlexDirectionType,
Expand All @@ -19,8 +9,7 @@ import {
Position,
PositionType,
PositionUnit,
PositionShorthand,
PointerFilterType
PositionShorthand
} from './types'

function capitalize<T extends string>(value: T): Capitalize<T> {
Expand Down Expand Up @@ -222,7 +211,7 @@ const parseOverflow: Readonly<Record<OverflowType, YGOverflow>> = {
/**
* @internal
*/
export function getPositionType(position: PositionType | undefined): Record<'positionType', YGPositionType> {
export function getPoistionType(position: PositionType | undefined): Record<'positionType', YGPositionType> {
const value: YGPositionType = position ? parsePositionType[position] : YGPositionType.YGPT_RELATIVE
return { positionType: value }
}
Expand All @@ -231,18 +220,3 @@ const parsePositionType: Readonly<Record<PositionType, YGPositionType>> = {
relative: YGPositionType.YGPT_RELATIVE,
absolute: YGPositionType.YGPT_ABSOLUTE
}

/**
* @internal
*/
export function getPointerFilter(
pointerFilter: PointerFilterType | undefined
): Record<'pointerFilter', PointerFilterMode> {
const value: PointerFilterMode = pointerFilter ? parsePointerFilter[pointerFilter] : PointerFilterMode.PFM_NONE
return { pointerFilter: value }
}

const parsePointerFilter: Readonly<Record<PointerFilterType, PointerFilterMode>> = {
none: PointerFilterMode.PFM_NONE,
block: PointerFilterMode.PFM_BLOCK
}
14 changes: 7 additions & 7 deletions packages/@dcl/sdk-commands/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@dcl/sdk-commands/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@dcl/inspector": "file:../inspector",
"@dcl/linker-dapp": "^0.11.0",
"@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
"@dcl/protocol": "1.0.0-6590614146.commit-db4a595",
"@dcl/protocol": "1.0.0-6473373363.commit-d038938",
"@dcl/quests-manager": "^0.1.2",
"@dcl/rpc": "^1.1.1",
"@dcl/schemas": "^8.2.3-20230718182824.commit-356025c",
Expand Down
7 changes: 3 additions & 4 deletions test/ecs/components/UiComponent.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
PointerFilterMode,
YGAlign,
YGDisplay,
YGFlexDirection,
YGJustify,
YGOverflow,
YGPositionType,
YGUnit
// YGUnit
} from '../../../packages/@dcl/ecs/src/components/generated/pb/decentraland/sdk/components/ui_transform.gen'
import { components, Engine } from '../../../packages/@dcl/ecs/src'
import { Engine, components } from '../../../packages/@dcl/ecs/src'
import { testComponentSerialization } from './assertion'

describe('UiTransform component', () => {
Expand Down Expand Up @@ -66,8 +66,7 @@ describe('UiTransform component', () => {
positionTopUnit: YGUnit.YGU_POINT,
positionType: YGPositionType.YGPT_RELATIVE,
width: 1,
widthUnit: YGUnit.YGU_POINT,
pointerFilter: PointerFilterMode.PFM_NONE
widthUnit: YGUnit.YGU_POINT
})
})
})
25 changes: 1 addition & 24 deletions test/react-ecs/transform.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
YGAlign,
YGDisplay,
YGPositionType,
YGJustify,
PointerFilterMode
YGJustify
} from '../../packages/@dcl/ecs'
import { components } from '../../packages/@dcl/ecs/src'
import { Position, PositionUnit, ReactEcs, UiEntity, UiTransformProps } from '../../packages/@dcl/react-ecs/src'
Expand Down Expand Up @@ -293,26 +292,4 @@ describe('UiTransform React Ecs', () => {
marginBottomUnit: YGUnit.YGU_POINT
})
})

it('should parse pointerFilter correctly', async () => {
const { engine, uiRenderer } = setupEngine()
const UiTransform = components.UiTransform(engine)
const entityIndex = engine.addEntity() as number

// Helpers
const rootDivEntity = (entityIndex + 1) as Entity
const getUiTransform = (entity: Entity) => UiTransform.get(entity)
const ui = () => (
<UiEntity
uiTransform={{
pointerFilter: 'block'
}}
/>
)
uiRenderer.setUiRenderer(ui)
await engine.update(1)
expect(getUiTransform(rootDivEntity)).toMatchObject({
pointerFilter: PointerFilterMode.PFM_BLOCK
})
})
})

0 comments on commit 84b272f

Please sign in to comment.