aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/button/toggleButton/ToggleButton.tsx
blob: dca6487d8c45eae4a945a87372c6a3c3355903e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React, { Component } from 'react';
import { BoolCast } from '../../../../../fields/Types';
import { Colors } from '../../../global/globalEnums';
import { IButtonProps } from '../ButtonInterface';

export class ToggleButton extends Component<IButtonProps> {
    render() {
        const type = this.props.type;
        // Determine the type of toggle button
        const switchToggle: boolean = BoolCast(this.props.rootDoc.switchToggle);

        if (switchToggle) {
            return (
                <div className={`menuButton ${type} ${'switch'}`}>
                    <label className="switch">
                        <input type="checkbox"
                            checked={this.props.backgroundColor === Colors.MEDIUM_BLUE}
                        />
                        <span className="slider round"></span>
                    </label>
                </div>
            );
        } else {
            return (
                <div className={`menuButton ${type}`}
                    style={{ opacity: 1, backgroundColor: this.props.backgroundColor, color: this.props.color }}>
                    <FontAwesomeIcon className={`fontIconBox-icon-${type}`} icon={this.props.icon} color={this.props.color} />
                    {this.props.label}
                </div>
            );
        }
    }
}