-
Notifications
You must be signed in to change notification settings - Fork 34
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 #626 from 3DStreet/action-bar
[wip] Action bar
- Loading branch information
Showing
15 changed files
with
194 additions
and
72 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
55 changes: 55 additions & 0 deletions
55
src/editor/components/components/ActionBar/ActionBar.component.jsx
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,55 @@ | ||
import { | ||
faHand, | ||
faHandPointer, | ||
faPlusSquare | ||
} from '@fortawesome/free-regular-svg-icons'; | ||
import { AwesomeIcon } from '../AwesomeIcon'; | ||
import classNames from 'classnames'; | ||
import Events from '../../../lib/Events'; | ||
import styles from './ActionBar.module.scss'; | ||
import { Button } from '../Button'; | ||
import { useState } from 'react'; | ||
|
||
const ActionBar = ({ handleAddClick, isAddLayerPanelOpen }) => { | ||
const [cursorEnabled, setCursorEnabled] = useState( | ||
AFRAME.INSPECTOR.cursor.isPlaying | ||
); | ||
|
||
const handleHandClick = () => { | ||
Events.emit('hidecursor'); | ||
setCursorEnabled(false); | ||
}; | ||
|
||
const handleSelectClick = () => { | ||
Events.emit('showcursor'); | ||
setCursorEnabled(true); | ||
}; | ||
|
||
return ( | ||
<div> | ||
{!isAddLayerPanelOpen && ( | ||
<div className={styles.wrapper}> | ||
<Button | ||
variant="toolbtn" | ||
className={classNames({ [styles.active]: cursorEnabled })} | ||
onClick={handleSelectClick} | ||
> | ||
<AwesomeIcon icon={faHandPointer} /> | ||
</Button> | ||
<Button | ||
variant="toolbtn" | ||
className={classNames({ [styles.active]: !cursorEnabled })} | ||
onClick={handleHandClick} | ||
> | ||
<AwesomeIcon icon={faHand} /> | ||
</Button> | ||
<Button variant="toolbtn" onClick={handleAddClick}> | ||
<AwesomeIcon icon={faPlusSquare} /> | ||
</Button> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export { ActionBar }; |
26 changes: 26 additions & 0 deletions
26
src/editor/components/components/ActionBar/ActionBar.module.scss
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,26 @@ | ||
@use '../../../style/variables.scss'; | ||
|
||
.wrapper { | ||
position: absolute; | ||
transform: translateX(-50%); | ||
bottom: 15%; | ||
left: 50%; | ||
border: unset; | ||
height: 40px; | ||
border-radius: 16px; | ||
align-items: center; | ||
display: flex; | ||
column-gap: 8px; | ||
padding: 8px 12px; | ||
transition: 0.2s ease-in-out; | ||
|
||
button { | ||
border-radius: 50%; | ||
width: 43px; | ||
height: 43px; | ||
|
||
&.active { | ||
border: 1px solid variables.$white; | ||
} | ||
} | ||
} |
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 @@ | ||
export { ActionBar } from './ActionBar.component.jsx'; |
19 changes: 0 additions & 19 deletions
19
src/editor/components/components/AddLayerButton/AddLayerButton.component.jsx
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/editor/components/components/AddLayerButton/AddLayerButton.module.scss
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/editor/components/components/AwesomeIcon/AwesomeIcon.component.js
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,57 @@ | ||
/* | ||
Use <AwesomeIcon icon={faEye} /> instead of <FontAwesomeIcon icon={faEye} /> from @fortawesome/react-fontawesome | ||
Using FontAwesomeIcon component adds 66 kB minified to the bundle. | ||
Our AwesomeIcon does the same but less than 2 kB minified. | ||
svg-inline--fa class has been added to AwesomeIcon.scss | ||
*/ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import './AwesomeIcon.scss'; | ||
|
||
function asIcon(icon) { | ||
const width = icon[0]; | ||
const height = icon[1]; | ||
const vectorData = icon[4]; | ||
let element; | ||
|
||
if (Array.isArray(vectorData)) { | ||
element = ( | ||
<g> | ||
{vectorData.map((pathData, index) => ( | ||
<path key={index} fill="currentColor" d={pathData} /> | ||
))} | ||
</g> | ||
); | ||
} else { | ||
element = <path fill="currentColor" d={vectorData} />; | ||
} | ||
|
||
return { | ||
width: width, | ||
height: height, | ||
icon: element | ||
}; | ||
} | ||
|
||
export class AwesomeIcon extends React.Component { | ||
static propTypes = { | ||
icon: PropTypes.object.isRequired, | ||
size: PropTypes.number | ||
}; | ||
|
||
render() { | ||
const { width, height, icon } = asIcon(this.props.icon.icon); | ||
return ( | ||
<svg | ||
role="img" | ||
className={`svg-inline--fa fa-${this.props.icon.iconName}`} | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox={`0 0 ${width} ${height}`} | ||
width={this.props.size ?? 20} | ||
height={this.props.size ?? 20} | ||
> | ||
{icon} | ||
</svg> | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/editor/components/components/AwesomeIcon/AwesomeIcon.scss
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,12 @@ | ||
/* CSS rules from the original FontAwesomeIcon component */ | ||
svg:not(:root).svg-inline--fa, | ||
svg:not(:host).svg-inline--fa { | ||
overflow: visible; | ||
box-sizing: content-box; | ||
} | ||
|
||
.svg-inline--fa { | ||
display: inline-block; | ||
overflow: visible; | ||
vertical-align: -0.125em; | ||
} |
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 @@ | ||
export { AwesomeIcon } from './AwesomeIcon.component.js'; |
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