|
| 1 | +import React, { Component } from 'react'; |
| 2 | +import cx from 'classnames'; |
| 3 | +import { Button } from 'reactstrap'; |
| 4 | +import PropTypes from 'prop-types'; |
| 5 | +import { connect } from 'react-redux'; |
| 6 | +import { DashboardThemes, SidebarTypes, NavbarTypes } from '../../reducers/layout'; |
| 7 | +import { changeTheme, changeSidebarColor, changeNavbarColor, navbarTypeToggle, sidebarTypeToggle } from '../../actions/layout'; |
| 8 | +import CustomColorPicker from '../ColorPicker'; |
| 9 | +import config from '../../config'; |
| 10 | + |
| 11 | +import Widget from '../Widget'; |
| 12 | + |
| 13 | +import s from './Helper.module.scss'; // eslint-disable-line |
| 14 | + |
| 15 | +class Helper extends Component { |
| 16 | + static propTypes = { |
| 17 | + dispatch: PropTypes.func.isRequired, |
| 18 | + dashboardTheme: PropTypes.string |
| 19 | + }; |
| 20 | + |
| 21 | + static defaultProps = { |
| 22 | + dashboardTheme: DashboardThemes.DARK |
| 23 | + }; |
| 24 | + |
| 25 | + state = { |
| 26 | + isOpened: false, |
| 27 | + } |
| 28 | + |
| 29 | + toggle = () => { |
| 30 | + this.setState({ |
| 31 | + isOpened: !this.state.isOpened, |
| 32 | + }); |
| 33 | + }; |
| 34 | + |
| 35 | + changeTheme = (state) => { |
| 36 | + this.props.dispatch(changeTheme(state)); |
| 37 | + this.props.dispatch(changeSidebarColor(state)) |
| 38 | + }; |
| 39 | + |
| 40 | + navbarStateToggle = (state) => { |
| 41 | + this.props.dispatch(navbarTypeToggle(state)) |
| 42 | + } |
| 43 | + |
| 44 | + sidebarStateToggle = (state) => { |
| 45 | + this.props.dispatch(sidebarTypeToggle(state)) |
| 46 | + } |
| 47 | + |
| 48 | + updateColor = (value) => { |
| 49 | + this.props.dispatch(changeNavbarColor(value)) |
| 50 | + } |
| 51 | + |
| 52 | + render() { |
| 53 | + const { isOpened } = this.state; |
| 54 | + const { navbarColor, sidebarColor, navbarType, sidebarType } = this.props; |
| 55 | + |
| 56 | + return ( |
| 57 | + <div className={cx(s.themeHelper, { [s.themeHelperOpened]: isOpened })}> |
| 58 | + <div className={`${s.themeHelperBtn} bg-primary helper-button`} onClick={this.toggle}> |
| 59 | + <div className={cx(s.themeHelperSpinner, 'text-white')}> |
| 60 | + <i className="la la-cog" /> |
| 61 | + <i className="la la-cog" /> |
| 62 | + </div> |
| 63 | + </div> |
| 64 | + <Widget |
| 65 | + className={s.themeHelperContent} |
| 66 | + > |
| 67 | + <div className={s.helperHeader}> |
| 68 | + <h5 className="m-0">Theme Customizer</h5> |
| 69 | + </div> |
| 70 | + |
| 71 | + <div className="theme-settings"> |
| 72 | + <h5 className="navbar-type-switcher">Navbar Type</h5> |
| 73 | + <div className="form-group row"> |
| 74 | + <div className="abc-radio"> |
| 75 | + <input onChange={() => this.navbarStateToggle(NavbarTypes.STATIC)} type="radio" checked={navbarType === NavbarTypes.STATIC ? true : ''} name="navbar-type" id="navbar_static" /> |
| 76 | + <label htmlFor="navbar_static">Static</label> |
| 77 | + </div> |
| 78 | + |
| 79 | + <div className="abc-radio"> |
| 80 | + <input onChange={() => this.navbarStateToggle(NavbarTypes.FLOATING)} type="radio" checked={navbarType === NavbarTypes.FLOATING ? true : ''} name="navbar-type" id="navbar_floating" /> |
| 81 | + <label htmlFor="navbar_floating">Floating</label> |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + |
| 85 | + <h5 className="mt-4 navbar-color-picker">Navbar Color</h5> |
| 86 | + <CustomColorPicker |
| 87 | + colors={config.app.colors} |
| 88 | + activeColor={navbarColor} |
| 89 | + updateColor={this.updateColor} |
| 90 | + customizationItem={"navbar"} |
| 91 | + /> |
| 92 | + |
| 93 | + <h5 className="mt-4 sidebar-type-switcher">Sidebar Type</h5> |
| 94 | + <div className="form-group row"> |
| 95 | + <div className="abc-radio"> |
| 96 | + <input type="radio" onChange={() => this.sidebarStateToggle(SidebarTypes.TRANSPARENT)} checked={sidebarType === SidebarTypes.TRANSPARENT ? true : ''} name="sidebar-type" id="sidebar_transparent" /> |
| 97 | + <label htmlFor="sidebar_transparent">Transparent</label> |
| 98 | + </div> |
| 99 | + |
| 100 | + <div className="abc-radio"> |
| 101 | + <input type="radio" onChange={() => this.sidebarStateToggle(SidebarTypes.SOLID)} checked={sidebarType === SidebarTypes.SOLID ? true : ''} name="sidebar-type" id="sidebar_solid" /> |
| 102 | + <label htmlFor="sidebar_solid">Solid</label> |
| 103 | + </div> |
| 104 | + </div> |
| 105 | + |
| 106 | + <h5 className="mt-4 sidebar-color-picker">Sidebar Color</h5> |
| 107 | + <CustomColorPicker |
| 108 | + colors={config.app.colors} |
| 109 | + activeColor={sidebarColor} |
| 110 | + updateColor={this.changeTheme} |
| 111 | + customizationItem={"sidebar"} |
| 112 | + /> |
| 113 | + |
| 114 | + </div> |
| 115 | + <div className="mt-5"> |
| 116 | + <Button |
| 117 | + href="https://flatlogic.com/admin-dashboards/sing-app-react" |
| 118 | + target="_blank" |
| 119 | + className="btn-rounded-f btn-block fs-mini purchase-button" |
| 120 | + color="info" |
| 121 | + > |
| 122 | + <span className="text-white">Purchase</span> |
| 123 | + </Button> |
| 124 | + <Button |
| 125 | + href="http://demo.flatlogic.com/sing-app/documentation/" |
| 126 | + target="_blank" |
| 127 | + className="btn-rounded-f btn-block fs-mini text-white" |
| 128 | + color="primary" |
| 129 | + > |
| 130 | + Documentation |
| 131 | + </Button> |
| 132 | + </div> |
| 133 | + <div className="d-flex justify-content-between mt-lg"> |
| 134 | + <Button |
| 135 | + href="https://flatlogic.com/contact" |
| 136 | + target="_blank" |
| 137 | + className="btn-outline-default btn-rounded-f fs-mini text-muted px-2" |
| 138 | + > |
| 139 | + <i className="glyphicon glyphicon-headphones mr-xs" /> |
| 140 | + Support |
| 141 | + </Button> |
| 142 | + <Button |
| 143 | + href="https://github.com/flatlogic/sing-app" |
| 144 | + target="_blank" |
| 145 | + className="btn-outline-default btn-rounded-f fs-mini text-muted px-2" |
| 146 | + > |
| 147 | + <i className="fa fa-github mr-xs" /> |
| 148 | + Github |
| 149 | + </Button> |
| 150 | + </div> |
| 151 | + <div className="mt-lg d-flex flex-column align-items-center theme-helper__sharing"> |
| 152 | + <span className="fs-sm"> |
| 153 | + Thank you for sharing! |
| 154 | + </span> |
| 155 | + <div className="d-flex justify-content-center text-light mt-2"> |
| 156 | + <a |
| 157 | + target="_blank" |
| 158 | + rel="noopener noreferrer" |
| 159 | + href="https://twitter.com/intent/tweet?text=Amazing%20dashboard%20built%20with%20NodeJS,%20React%20and%20Bootstrap!&url=https://github.com/flatlogic/react-dashboard&via=flatlogic" |
| 160 | + > |
| 161 | + <i className="fa fa-twitter pr-1" /> |
| 162 | + </a> |
| 163 | + <a |
| 164 | + href="https://www.facebook.com/search/top/?q=flatlogic%20llc" |
| 165 | + target="_blank" |
| 166 | + rel="noopener noreferrer" |
| 167 | + > |
| 168 | + <i className="fa fa-facebook pl-1" /> |
| 169 | + </a> |
| 170 | + </div> |
| 171 | + </div> |
| 172 | + </Widget> |
| 173 | + </div> |
| 174 | + ); |
| 175 | + } |
| 176 | +} |
| 177 | + |
| 178 | +function mapStateToProps(store) { |
| 179 | + return { |
| 180 | + dashboardTheme: store.layout.dashboardTheme, |
| 181 | + sidebarColor: store.layout.sidebarColor, |
| 182 | + navbarColor: store.layout.navbarColor, |
| 183 | + navbarType: store.layout.navbarType, |
| 184 | + sidebarType: store.layout.sidebarType |
| 185 | + }; |
| 186 | +} |
| 187 | + |
| 188 | +export default connect(mapStateToProps)(Helper); |
0 commit comments