aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search/ToggleBar.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-12-14 00:07:52 -0500
committerbobzel <zzzman@gmail.com>2023-12-14 00:07:52 -0500
commitcebe9d2a567c20b99c8c394cfa598ee9d4d53ece (patch)
treec33df9a3dc80cb199002610cc38645976023eff9 /src/client/views/search/ToggleBar.tsx
parent1cf241544f8063e3d71406238a584299b6ced794 (diff)
a bunch more fixes to making things observable. fixed calling super.componentDidUpdate on subsclasses
Diffstat (limited to 'src/client/views/search/ToggleBar.tsx')
-rw-r--r--src/client/views/search/ToggleBar.tsx85
1 files changed, 0 insertions, 85 deletions
diff --git a/src/client/views/search/ToggleBar.tsx b/src/client/views/search/ToggleBar.tsx
deleted file mode 100644
index 466822eba..000000000
--- a/src/client/views/search/ToggleBar.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import * as React from 'react';
-import { observer } from 'mobx-react';
-import { observable, action, runInAction, computed } from 'mobx';
-import "./SearchBox.scss";
-import "./ToggleBar.scss";
-import * as anime from 'animejs';
-
-export interface ToggleBarProps {
- originalStatus: boolean;
- optionOne: string;
- optionTwo: string;
- handleChange(): void;
- getStatus(): boolean;
-}
-
-@observer
-export class ToggleBar extends React.Component<ToggleBarProps>{
- static Instance: ToggleBar;
-
- @observable private _forwardTimeline: anime.AnimeTimelineInstance;
- @observable private _toggleButton: React.RefObject<HTMLDivElement>;
- @observable private _originalStatus: boolean = this.props.originalStatus;
-
- constructor(props: ToggleBarProps) {
- super(props);
- ToggleBar.Instance = this;
- this._toggleButton = React.createRef();
- this._forwardTimeline = anime.timeline({
- loop: false,
- autoplay: false,
- direction: "reverse",
- });
- }
-
- componentDidMount = () => {
- const totalWidth = 265;
-
- if (this._originalStatus) {
- this._forwardTimeline.add({
- targets: this._toggleButton.current,
- translateX: totalWidth,
- easing: "easeInOutQuad",
- duration: 500
- });
- }
- else {
- this._forwardTimeline.add({
- targets: this._toggleButton.current,
- translateX: -totalWidth,
- easing: "easeInOutQuad",
- duration: 500
- });
- }
- }
-
- @action.bound
- onclick() {
- this._forwardTimeline.play();
- this._forwardTimeline.reverse();
- this.props.handleChange();
- }
-
- @action.bound
- public resetToggle = () => {
- if (!this.props.getStatus()) {
- this._forwardTimeline.play();
- this._forwardTimeline.reverse();
- this.props.handleChange();
- }
- }
-
- render() {
- return (
- <div>
- <div className="toggle-title">
- <div className="toggle-option" style={{ opacity: (this.props.getStatus() ? 1 : .4) }}>{this.props.optionOne}</div>
- <div className="toggle-option" style={{ opacity: (this.props.getStatus() ? .4 : 1) }}>{this.props.optionTwo}</div>
- </div>
- <div className="toggle-bar" id="toggle-bar" onClick={this.onclick} style={{ flexDirection: (this._originalStatus ? "row" : "row-reverse") }}>
- <div className="toggle-button" id="toggle-button" ref={this._toggleButton} />
- </div>
- </div>
- );
- }
-} \ No newline at end of file