-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-components): Add buttons for 360 image actions (#4830)
* Initial commit * Update package.json * Update package.json * Update package.json * Fixes * Rename
- Loading branch information
1 parent
e27ecd4
commit 935e576
Showing
6 changed files
with
87 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
63 changes: 63 additions & 0 deletions
63
...onents/src/architecture/base/concreteCommands/image360Collection/Image360ActionCommand.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
import { Image360Action } from '@cognite/reveal'; | ||
import { RenderTargetCommand } from '../../commands/RenderTargetCommand'; | ||
import { type TranslateKey } from '../../utilities/TranslateKey'; | ||
import { type IconName } from '../../utilities/IconName'; | ||
import { type BaseCommand } from '../../commands/BaseCommand'; | ||
|
||
export class Image360ActionCommand extends RenderTargetCommand { | ||
private readonly _action: Image360Action; | ||
|
||
public constructor(action: Image360Action) { | ||
super(); | ||
this._action = action; | ||
} | ||
|
||
public override equals(other: BaseCommand): boolean { | ||
if (!(other instanceof Image360ActionCommand)) { | ||
return false; | ||
} | ||
return this._action === other._action; | ||
} | ||
|
||
public override get icon(): IconName { | ||
switch (this._action) { | ||
case Image360Action.Backward: | ||
return 'ArrowLeft'; | ||
case Image360Action.Forward: | ||
return 'ArrowRight'; | ||
case Image360Action.Enter: | ||
return 'View360'; | ||
case Image360Action.Exit: | ||
return 'CloseLarge'; | ||
default: | ||
throw new Error('Unknown action'); | ||
} | ||
} | ||
|
||
public override get tooltip(): TranslateKey { | ||
switch (this._action) { | ||
case Image360Action.Backward: | ||
return { fallback: 'Go one 360 image back' }; | ||
case Image360Action.Forward: | ||
return { fallback: 'Go one 360 image forward' }; | ||
case Image360Action.Enter: | ||
return { fallback: 'Enter last exited 360 image' }; | ||
case Image360Action.Exit: | ||
return { fallback: 'Exit 360 image' }; | ||
default: | ||
throw new Error('Unknown action'); | ||
} | ||
} | ||
|
||
public override get isEnabled(): boolean { | ||
return this.renderTarget.viewer.canDo360Action(this._action); | ||
} | ||
|
||
public override invokeCore(): boolean { | ||
void this.renderTarget.viewer.do360Action(this._action); | ||
return true; | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.