-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sandbox with included React component
- Loading branch information
1 parent
7d64f10
commit dc83541
Showing
13 changed files
with
346 additions
and
57 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<div {{react this.theReactComponent message=this.message onClick=this.toggle}} /> |
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,18 @@ | ||
import { HelloWorld } from 'react-frontend/hello-world.jsx'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class SandboxComponent extends Component { | ||
theReactComponent = HelloWorld; | ||
|
||
@tracked message = 'hello'; | ||
|
||
@action toggle() { | ||
if (this.message === 'hello') { | ||
this.message = 'goodbye'; | ||
} else { | ||
this.message = 'hello'; | ||
} | ||
} | ||
} |
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,14 @@ | ||
import Modifier from 'ember-modifier'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { createElement } from 'react'; | ||
import { registerDestructor } from '@ember/destroyable'; | ||
|
||
export default class ReactModifier extends Modifier { | ||
modify(element, [reactComponent], props) { | ||
if (!this.root) { | ||
this.root = createRoot(element); | ||
registerDestructor(this, () => this.root.unmount()); | ||
} | ||
this.root.render(createElement(reactComponent, { ...props })); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -36,4 +36,5 @@ Router.map(function () { | |
}); | ||
this.route('settings'); | ||
this.route('airshow'); | ||
this.route('sandbox'); | ||
}); |
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,3 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default class SandboxRoute extends Route {} |
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,4 @@ | ||
{{page-title "Sandbox"}} | ||
<div class="container"> | ||
<Sandbox /> | ||
</div> |
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.