|
| 1 | +"use strict"; |
| 2 | +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
| 3 | + if (k2 === undefined) k2 = k; |
| 4 | + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); |
| 5 | +}) : (function(o, m, k, k2) { |
| 6 | + if (k2 === undefined) k2 = k; |
| 7 | + o[k2] = m[k]; |
| 8 | +})); |
| 9 | +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { |
| 10 | + Object.defineProperty(o, "default", { enumerable: true, value: v }); |
| 11 | +}) : function(o, v) { |
| 12 | + o["default"] = v; |
| 13 | +}); |
| 14 | +var __importStar = (this && this.__importStar) || function (mod) { |
| 15 | + if (mod && mod.__esModule) return mod; |
| 16 | + var result = {}; |
| 17 | + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |
| 18 | + __setModuleDefault(result, mod); |
| 19 | + return result; |
| 20 | +}; |
| 21 | +var __importDefault = (this && this.__importDefault) || function (mod) { |
| 22 | + return (mod && mod.__esModule) ? mod : { "default": mod }; |
| 23 | +}; |
| 24 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 25 | +exports.styles = void 0; |
| 26 | +const react_1 = __importStar(require("../../../modules/react")); |
| 27 | +const dayjs_1 = __importDefault(require("../modules/dayjs")); |
| 28 | +class StateComponent extends react_1.Component { |
| 29 | + constructor(props) { |
| 30 | + super(props); |
| 31 | + } |
| 32 | + startClock() { |
| 33 | + const timeFormat = this.props.userConfig.getValue('widgets', 'hyper_clock', 'text'); |
| 34 | + const timeContainer = document.querySelector('.hyperclock.wrapper .time'); |
| 35 | + timeContainer.textContent = (0, dayjs_1.default)().format(timeFormat); |
| 36 | + setTimeout(() => { |
| 37 | + this.startClock(); |
| 38 | + }, 1000); |
| 39 | + } |
| 40 | + componentDidMount() { |
| 41 | + // decided to go with useEffect / didMount |
| 42 | + // don't want the entire react rendering after each sec |
| 43 | + this.startClock(); |
| 44 | + } |
| 45 | + render() { |
| 46 | + const showCallendar = this.props.userConfig.getValue('widgets', 'hyper_clock', 'showcallendar'); |
| 47 | + return (react_1.default.createElement("div", { className: "hyperclock wrapper" }, |
| 48 | + react_1.default.createElement("p", { className: "time" }))); |
| 49 | + } |
| 50 | +} |
| 51 | +// Hyper carries our api & other stuff inside `this` context. |
| 52 | +// React contructor doesn't pass the values, so we call it as a function |
| 53 | +// Check hyper-menu module for a stateless component example |
| 54 | +function default_1() { |
| 55 | + return react_1.default.createElement(StateComponent, Object.assign({ key: 'hyper-clock', userConfig: this.config, ipcRenderer: this.api.ipcRenderer }, this.props)); |
| 56 | +} |
| 57 | +exports.default = default_1; |
| 58 | +exports.styles = ['styles/index.css']; |
0 commit comments