Exelord / dark-mode

Package for Atom Editor which allows you to switch to dark mode and light mode theme.
MIT License
16 stars 4 forks source link

Allow to add easily new sensors #10

Closed Exelord closed 5 years ago

Exelord commented 5 years ago

To define a new sensor use following template and create it in sensors folder:

import Sensor from './sensor';

export default class extends Sensor {
   constructor() {
     super(...arguments);
     this.sensorOptionName = 'yourSensorConfigOptionName';
   }

   activate() {
     // activate the sensor
   }

   deactivate() {
     // deactivate the sensor
   }
}

Next go to dark-mode/lib/dark-mode.js and add a new sensor to the sensor const.

import MySuperSensor from './sensors/my-super-sensor.js'

const sensors = [
 AmbientLightSensor,
 MySuperSensor
]

The last thing is to add a config option in `lib/config.js

  mySuperSensor: {
    order: 6,
    description: 'Determine if themes should be automatically changed by my super sensor',
    type: 'boolean',
    default: true,
  },

6 #7

@kleineroscar @dapetcu21 This PR may help you with further development :)