-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove on prefix on Angular Events
- Loading branch information
Showing
15 changed files
with
269 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ export const COMPONENT_PATHS = [ | |
'/special-tags/', | ||
'/signals/', | ||
'/disabled-input/', | ||
'/event-listener/', | ||
]; |
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,25 @@ | ||
import { useStore } from '@builder.io/mitosis'; | ||
|
||
export interface EventChildProps { | ||
onConfirm: (name: string) => void; | ||
onCancel: () => void; | ||
} | ||
|
||
export default function EventChild(props: EventChildProps) { | ||
const state = useStore({ | ||
_onCancel() { | ||
props.onCancel(); | ||
}, | ||
|
||
_onConfirm() { | ||
props.onConfirm('Joe'); | ||
}, | ||
}); | ||
|
||
return ( | ||
<> | ||
<button onClick={() => state._onCancel()}>Cancel</button> | ||
<button onClick={() => state._onConfirm()}>Confirm</button> | ||
</> | ||
); | ||
} |
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,28 @@ | ||
import { useState, useStore } from '@builder.io/mitosis'; | ||
import EventChild from './event-child.lite'; | ||
|
||
export default function EventParent() { | ||
const [eventLog, setEventLog] = useState<string>(''); | ||
|
||
const state = useStore({ | ||
_onCancel() { | ||
const newEventLog = eventLog + 'Cancel event called <br>'; | ||
setEventLog(newEventLog); | ||
}, | ||
|
||
_onConfirm(name: string) { | ||
const newEventLog = eventLog + `Confirm event called with parameter: ${name} <br>`; | ||
setEventLog(newEventLog); | ||
}, | ||
}); | ||
|
||
return ( | ||
<> | ||
<EventChild | ||
onConfirm={(name) => state._onConfirm(name)} | ||
onCancel={() => state._onCancel()} | ||
></EventChild> | ||
<p data-testid="event-log" innerHTML={eventLog}></p> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {useStore} from '@builder.io/mitosis'; | ||
|
||
export interface ModalProps { | ||
onConfirm: (name: string) => void; | ||
onCancel: () => void; | ||
} | ||
|
||
export default function Modal(props: ModalProps) { | ||
|
||
const state = useStore({ | ||
_onCancel() { | ||
props.onCancel() | ||
}, | ||
|
||
_onConfirm() { | ||
props.onConfirm('Joe') | ||
}, | ||
}); | ||
|
||
|
||
return ( | ||
<> | ||
<button onClick={() => state._onCancel()}>Cancel</button> | ||
<button onClick={() => state._onConfirm()}>Confirm</button> | ||
</> | ||
); | ||
} |
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,2 +1,2 @@ | ||
export { default as Button } from '../blocks/button.lite'; | ||
export { default as Image } from '../blocks/image.lite'; | ||
export { default as Image } from '../blocks/image.lite'; |
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.