-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): component selecting
- Loading branch information
1 parent
234b140
commit 402c4d3
Showing
17 changed files
with
271 additions
and
11 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,27 @@ | ||
/** | ||
* @file component.js | ||
* Exports actions related to components. | ||
*/ | ||
|
||
import { put, takeLatest } from 'redux-saga/effects'; | ||
|
||
import { COMPONENT_SELECT } from '../constants'; | ||
|
||
/** | ||
* Sets the currently selected component. | ||
* | ||
* @param {object} payload - Payload for this saga action. | ||
* @param {string} payload.id - ID of the component that should be selected. | ||
*/ | ||
export function* componentSelect({ id }) { | ||
yield put({ | ||
type: `${COMPONENT_SELECT}_SUCCESS`, | ||
payload: { | ||
id | ||
} | ||
}); | ||
} | ||
|
||
export function* watchComponentActions() { | ||
yield takeLatest(COMPONENT_SELECT, componentSelect); | ||
} |
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,48 @@ | ||
/** | ||
* @file isExitable.js | ||
* AFrame component that allows for components to be selected for editing. | ||
*/ | ||
|
||
/* globals AFRAME */ | ||
|
||
import { COMPONENT_SELECT, MODE_COMPONENT_SELECTING } from '../../constants'; | ||
import connectRedux from '../utils/connectRedux'; | ||
import connectRouter from '../utils/connectRouter'; | ||
|
||
const isEditable = { | ||
multiple: true, | ||
clickHandler() { | ||
const id = this.el.getAttribute('id'); | ||
const { dispatch } = this.props; | ||
const { | ||
match: { | ||
params: { editorMode } | ||
} | ||
} = this.router; | ||
|
||
if (id && editorMode === MODE_COMPONENT_SELECTING) { | ||
dispatch({ | ||
type: COMPONENT_SELECT, | ||
id | ||
}); | ||
} | ||
}, | ||
init() { | ||
this.el.addEventListener('click', this.clickHandler.bind(this)); | ||
}, | ||
remove() { | ||
this.el.removeEventListener('click', this.clickHandler.bind(this)); | ||
} | ||
}; | ||
|
||
AFRAME.registerComponent( | ||
'is-editable', | ||
connectRedux(state => ({ | ||
experience: state.openExperience.item | ||
}))( | ||
connectRouter( | ||
isEditable, | ||
'/experience/vreditor/:experienceSlug/:sceneSlug/:editorMode?' | ||
) | ||
) | ||
); |
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,19 @@ | ||
/** | ||
* @file ComponentForm.container.js | ||
* Exports a redux-connected ComponentForm component. | ||
*/ | ||
|
||
import { connect } from 'react-redux'; | ||
|
||
import ComponentForm from './ComponentForm'; | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
dispatch | ||
}); | ||
|
||
const mapState = ({ user, openExperience }) => ({ | ||
user, | ||
experience: openExperience | ||
}); | ||
|
||
export default connect(mapState, mapDispatchToProps)(ComponentForm); |
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,24 @@ | ||
/** | ||
* @file ComponentForm.js | ||
* Exports a component that allows users to operate on scene components. | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withFormik } from 'formik'; | ||
import { withStyles } from '@material-ui/core'; | ||
|
||
import ComponentFormStyles from './ComponentForm.style'; | ||
|
||
const ComponentForm = ({ id }) => <form>{id}</form>; | ||
|
||
ComponentForm.propTypes = { | ||
id: PropTypes.string.isRequired | ||
}; | ||
|
||
const FormikComponentForm = withFormik({ | ||
displayName: 'ComponentForm', | ||
enableReinitialize: true | ||
})(ComponentForm); | ||
|
||
export default withStyles(ComponentFormStyles)(FormikComponentForm); |
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,6 @@ | ||
/** | ||
* @file ComponentForm.style.js | ||
* Exports ComponentForm component styles. | ||
*/ | ||
|
||
export default () => ({}); |
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,6 @@ | ||
/** | ||
* @file component.js | ||
* Exports component-related constants. | ||
*/ | ||
|
||
export const COMPONENT_SELECT = 'COMPONENT_SELECT'; |
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,3 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<VREditor /> Matches its snapshot 1`] = `"<div class=\\"MuiGrid-container-11 VREditorLayout-wrapper-6\\" id=\\"editor__wrapper\\" align=\\"stretch\\"><div></div><header class=\\"MuiPaper-root-110 MuiPaper-elevation4-116 MuiAppBar-root-102 MuiAppBar-positionFixed-103 MuiAppBar-colorPrimary-108 mui-fixed VREditorLayout-appBar-9\\"><div class=\\"MuiToolbar-root-137 MuiToolbar-gutters-138\\"><a tabindex=\\"0\\" class=\\"MuiButtonBase-root-145 MuiIconButton-root-139 MuiIconButton-colorInherit-140\\" role=\\"button\\" aria-label=\\"Back to Dashboard\\" href=\\"/dashboard\\"><span class=\\"MuiIconButton-label-144\\"><svg class=\\"MuiSvgIcon-root-148\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\"><g><path d=\\"M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z\\"></path></g></svg></span><span class=\\"MuiTouchRipple-root-154\\"></span></a><img src=\\"editvr-logo.svg\\" alt=\\"EditVR logo\\" class=\\"VREditorLayout-logo-10\\"><h2 class=\\"MuiTypography-root-161 MuiTypography-title-167\\">Editing test Experience</h2></div></header><div class=\\"MuiGrid-item-12 MuiGrid-grid-xs-3-40 VREditorLayout-aside-7\\" id=\\"VREditorLayout--left\\"><div class=\\"MuiGrid-container-11\\" align=\\"stretch\\"><div class=\\"MuiGrid-item-12 MuiGrid-grid-xs-3-40 VREditor-columnLeft-2\\" id=\\"column--left_aside\\"><h2 class=\\"MuiTypography-root-161 MuiTypography-title-167\\">Tools</h2><p class=\\"MuiTypography-root-161 MuiTypography-body1-170\\">You must create or select an existing scene before being able to use scene editing tools.</p></div><div class=\\"MuiGrid-item-12 MuiGrid-grid-xs-9-46 VREditor-columnRight-1\\" id=\\"column--left_aside\\"><h2 class=\\"MuiTypography-root-161 MuiTypography-title-167\\">Scenes</h2><div></div></div></div></div><div class=\\"MuiGrid-item-12 MuiGrid-grid-xs-6-43 VREditorLayout-middle-8\\" id=\\"VREditorLayout--middle\\"><div class=\\"VREditor-mainColumn-3\\"><h1 class=\\"MuiTypography-root-161 MuiTypography-headline-166\\">Select or create a scene to continue.</h1></div></div><div class=\\"MuiGrid-item-12 MuiGrid-grid-xs-3-40 VREditorLayout-aside-7\\" id=\\"VREditorLayout--right\\">Right Sidebar</div></div>"`; | ||
exports[`<VREditor /> Matches its snapshot 1`] = `"<div class=\\"MuiGrid-container-13 VREditorLayout-wrapper-8\\" id=\\"editor__wrapper\\" align=\\"stretch\\"><div></div><header class=\\"MuiPaper-root-112 MuiPaper-elevation4-118 MuiAppBar-root-104 MuiAppBar-positionFixed-105 MuiAppBar-colorPrimary-110 mui-fixed VREditorLayout-appBar-11\\"><div class=\\"MuiToolbar-root-139 MuiToolbar-gutters-140\\"><a tabindex=\\"0\\" class=\\"MuiButtonBase-root-147 MuiIconButton-root-141 MuiIconButton-colorInherit-142\\" role=\\"button\\" aria-label=\\"Back to Dashboard\\" href=\\"/dashboard\\"><span class=\\"MuiIconButton-label-146\\"><svg class=\\"MuiSvgIcon-root-150\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\"><g><path d=\\"M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z\\"></path></g></svg></span><span class=\\"MuiTouchRipple-root-156\\"></span></a><img src=\\"editvr-logo.svg\\" alt=\\"EditVR logo\\" class=\\"VREditorLayout-logo-12\\"><h2 class=\\"MuiTypography-root-163 MuiTypography-title-169\\">Editing test Experience</h2></div></header><div class=\\"MuiGrid-item-14 MuiGrid-grid-xs-3-42 VREditorLayout-aside-9\\" id=\\"VREditorLayout--left\\"><div class=\\"MuiGrid-container-13\\" align=\\"stretch\\"><div class=\\"MuiGrid-item-14 MuiGrid-grid-xs-3-42 VREditor-columnLeft-2\\" id=\\"column--left_aside\\"><h2 class=\\"MuiTypography-root-163 MuiTypography-title-169\\">Tools</h2><p class=\\"MuiTypography-root-163 MuiTypography-body1-172\\">You must create or select an existing scene before being able to use scene editing tools.</p></div><div class=\\"MuiGrid-item-14 MuiGrid-grid-xs-9-48 VREditor-columnRight-1\\" id=\\"column--left_aside\\"><h2 class=\\"MuiTypography-root-163 MuiTypography-title-169\\">Scenes</h2><div></div></div></div></div><div class=\\"MuiGrid-item-14 MuiGrid-grid-xs-6-45 VREditorLayout-middle-10\\" id=\\"VREditorLayout--middle\\"><div class=\\"VREditor-mainColumn-5\\"><h1 class=\\"MuiTypography-root-163 MuiTypography-headline-168\\">Select or create a scene to continue.</h1></div></div><div class=\\"MuiGrid-item-14 MuiGrid-grid-xs-3-42 VREditorLayout-aside-9\\" id=\\"VREditorLayout--right\\"><div class=\\"VREditor-columnRight-1\\"><h2 class=\\"MuiTypography-root-163 MuiTypography-title-169 VREditor-columnRightTitle-3\\">Previewing<svg class=\\"MuiSvgIcon-root-150 VREditor-columnRightIcon-4\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\"><g><path d=\\"M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z\\"></path></g></svg></h2><p class=\\"MuiTypography-root-163 MuiTypography-body1-172\\">You are currently previewing your scene. You can use your mouse to grab the scene area, and drag it around to view different portions of your scene.</p></div></div></div>"`; |
Oops, something went wrong.