-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add topbar to inspector (#2805)
- Loading branch information
Melisa Anabella Rossi
authored
Aug 2, 2023
1 parent
ae4d7cc
commit 4c0234f
Showing
22 changed files
with
238 additions
and
50 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
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,22 @@ | ||
import { connect } from 'react-redux' | ||
import { goBack } from 'connected-react-router' | ||
import { RootState } from 'modules/common/types' | ||
import { getCurrentProject } from 'modules/project/selectors' | ||
import { getCurrentMetrics } from 'modules/scene/selectors' | ||
import { isSavingCurrentProject } from 'modules/sync/selectors' | ||
import { openModal } from 'modules/modal/actions' | ||
import { MapStateProps, MapDispatchProps, MapDispatch } from './TopBar.types' | ||
import TopBar from './TopBar' | ||
|
||
const mapState = (state: RootState): MapStateProps => ({ | ||
currentProject: getCurrentProject(state), | ||
metrics: getCurrentMetrics(state), | ||
isUploading: isSavingCurrentProject(state) | ||
}) | ||
|
||
const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({ | ||
onBack: () => dispatch(goBack()), | ||
onOpenModal: (name, metadata) => dispatch(openModal(name, metadata)) | ||
}) | ||
|
||
export default connect(mapState, mapDispatch)(TopBar) |
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,43 @@ | ||
.container { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 10px; | ||
} | ||
|
||
.nameContainer { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.nameContainer :global(.ui.button.basic) { | ||
padding: 0; | ||
text-transform: none; | ||
color: white !important; | ||
font-size: 16px; | ||
} | ||
|
||
.editNameBtn:global(.ui.button) { | ||
display: flex; | ||
gap: 10px; | ||
margin-right: 10px; | ||
} | ||
|
||
.editNameBtn:global(.ui.button .Icon) { | ||
filter: brightness(0) invert(1); | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
gap: 10px; | ||
align-items: center; | ||
} | ||
|
||
.downloadBtn:global(.ui.button) { | ||
min-width: fit-content; | ||
width: fit-content; | ||
} | ||
|
||
.downloadBtn:global(.ui.button) > i:global(.icon.download):not(.button) { | ||
margin: 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { t } from 'decentraland-dapps/dist/modules/translation/utils' | ||
import { Button, Icon, Popup } from 'decentraland-ui' | ||
import OwnIcon from 'components/Icon' | ||
import { Props } from './TopBar.types' | ||
import styles from './TopBar.module.css' | ||
import { useCallback } from 'react' | ||
import DeploymentStatus from 'components/DeploymentStatus' | ||
|
||
export default function TopBar({ currentProject, isUploading, onBack, onOpenModal }: Props) { | ||
const handleEditProject = useCallback(() => { | ||
onOpenModal('EditProjectModal') | ||
}, [onOpenModal]) | ||
|
||
const handlePublish = useCallback(() => { | ||
console.error('TODO: Add publish project action') | ||
}, []) | ||
|
||
const handlePreview = useCallback(() => { | ||
console.error('TODO: Add preview project action') | ||
}, []) | ||
|
||
const handleDownload = useCallback(() => { | ||
console.error('TODO: Add download project action') | ||
}, []) | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<div className={styles.nameContainer}> | ||
<Button basic aria-label={t('inspector.top_bar.back')} onClick={onBack}> | ||
<Icon name="chevron left" /> | ||
</Button> | ||
{currentProject && ( | ||
<Button basic onClick={handleEditProject} disabled={isUploading} className={styles.editNameBtn}> | ||
{currentProject.title} | ||
<OwnIcon name="edit" className="edit-project-icon" /> | ||
</Button> | ||
)} | ||
{isUploading && <OwnIcon name="cloud-upload" className="cloud-upload-indicator is-uploading" />} | ||
</div> | ||
<div className={styles.actions}> | ||
{currentProject ? <DeploymentStatus projectId={currentProject.id} /> : null} | ||
<Popup | ||
content={t('inspector.top_bar.download')} | ||
trigger={ | ||
<Button | ||
secondary | ||
aria-label={t('inspector.top_bar.download')} | ||
size="small" | ||
className={styles.downloadBtn} | ||
disabled={isUploading} | ||
onClick={handleDownload} | ||
> | ||
<Icon name="download" /> | ||
</Button> | ||
} | ||
/> | ||
<Button secondary size="small" disabled={isUploading} onClick={handlePreview}> | ||
<Icon name="eye" /> | ||
{t('inspector.top_bar.preview')} | ||
</Button> | ||
<Button primary size="small" disabled={isUploading} onClick={handlePublish}> | ||
<Icon name="globe" /> | ||
{t('inspector.top_bar.publish')} | ||
</Button> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Dispatch } from 'redux' | ||
import { ModelMetrics } from 'modules/models/types' | ||
import { OpenModalAction, openModal } from 'modules/modal/actions' | ||
import { Project } from 'modules/project/types' | ||
import { CallHistoryMethodAction, goBack } from 'connected-react-router' | ||
|
||
export type Props = { | ||
metrics: ModelMetrics | ||
currentProject: Project | null | ||
isUploading: boolean | ||
onBack: typeof goBack | ||
onOpenModal: typeof openModal | ||
} | ||
|
||
export type MapStateProps = Pick<Props, 'currentProject' | 'metrics' | 'isUploading'> | ||
|
||
export type MapDispatchProps = Pick<Props, 'onBack' | 'onOpenModal'> | ||
export type MapDispatch = Dispatch<CallHistoryMethodAction | OpenModalAction> |
1 change: 0 additions & 1 deletion
1
src/components/TopBar/index.ts → src/components/InspectorPage/TopBar/index.ts
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,2 @@ | ||
import TopBar from './TopBar.container' | ||
|
||
export default TopBar |
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
Oops, something went wrong.
4c0234f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
builder – ./
builder-decentraland1.vercel.app
builder-git-master-decentraland1.vercel.app