-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from vtex-apps/feature/custom-events
Add 'customPixelEventId' prop
- Loading branch information
Showing
8 changed files
with
115 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
import React, { Fragment, FC } from 'react' | ||
import React, { FC } from 'react' | ||
import { usePixel } from 'vtex.pixel-manager' | ||
import { PixelData } from 'vtex.pixel-manager/react/PixelContext' | ||
import { useCssHandles } from 'vtex.css-handles' | ||
|
||
const DrawerTrigger: FC = ({ children }) => <Fragment>{children}</Fragment> | ||
interface Props { | ||
customPixelEventId?: string | ||
} | ||
|
||
const CSS_HANDLES = ['drawerTriggerContainer'] as const | ||
|
||
const DrawerTrigger: FC<Props> = ({ children, customPixelEventId }) => { | ||
const { push } = usePixel() | ||
const handles = useCssHandles(CSS_HANDLES) | ||
|
||
const handleInteraction = () => { | ||
if (!customPixelEventId) { | ||
return | ||
} | ||
|
||
const pixelEvent: PixelData = { | ||
id: customPixelEventId, | ||
event: 'openDrawer', | ||
} | ||
|
||
push(pixelEvent) | ||
} | ||
|
||
return ( | ||
<div | ||
role="button" | ||
tabIndex={0} | ||
className={handles.drawerTriggerContainer} | ||
onClick={handleInteraction} | ||
onKeyDown={handleInteraction} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
export default DrawerTrigger |
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 |
---|---|---|
|
@@ -15,8 +15,9 @@ | |
"@types/react-dom": "^16.8.4", | ||
"@vtex/test-tools": "^3.0.0", | ||
"typescript": "3.8.3", | ||
"vtex.css-handles": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.css-handles", | ||
"vtex.render-runtime": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.render-runtime", | ||
"vtex.css-handles": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.css-handles", | ||
"vtex.pixel-manager": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.pixel-manager", | ||
"vtex.responsive-values": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/_types/react", | ||
"vtex.store-icons": "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.store-icons" | ||
}, | ||
"version": "0.13.0" | ||
|
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
/* eslint-disable import/order */ | ||
|
||
import 'vtex.render-runtime' | ||
|
||
declare module 'vtex.render-runtime' { | ||
export const useChildBlock: (opts: { id: string }) => {} | null | ||
export const ExtensionPoint: any | ||
} |
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 |
---|---|---|
|
@@ -4805,13 +4805,17 @@ [email protected]: | |
core-util-is "1.0.2" | ||
extsprintf "^1.2.0" | ||
|
||
"vtex.css-handles@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.css-handles": | ||
version "0.4.2" | ||
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.css-handles#62ee61d1bb9efdc919e5cf4bb44fabcf9050d255" | ||
"vtex.css-handles@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.css-handles": | ||
version "0.4.4" | ||
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.css-handles#8c45c6decf9acd2b944e07261686decff93d6422" | ||
|
||
"vtex.pixel-manager@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.pixel-manager": | ||
version "1.3.0" | ||
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.pixel-manager#84e731e138aa3aaf98dd519e5cff929cdf3745d8" | ||
|
||
"vtex.render-runtime@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.[email protected]/public/@types/vtex.render-runtime": | ||
version "8.95.1" | ||
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.[email protected]/public/@types/vtex.render-runtime#3aae291d0cd239d3059ea8ae8c3c2800ce36d22f" | ||
"vtex.responsive-values@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.[email protected]/public/_types/react": | ||
version "0.0.0" | ||
resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.[email protected]/public/_types/react#fa7a0347e046eab3dd768998fc9252b2c0dd5aef" | ||
|
||
"vtex.store-icons@http://vtex.vtexassets.com/_v/public/typings/v1/[email protected]/public/@types/vtex.store-icons": | ||
version "0.17.0" | ||
|