├── .gitignore ├── CHANGELOG.md ├── spec ├── encourage-view-spec.js └── encourage-spec.js ├── README.md ├── package.json ├── appveyor.yml ├── styles └── encourage.less ├── lib ├── config-schema.json ├── encourage-view.js └── encourage.js ├── LICENSE.md └── CODE_OF_CONDUCT.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /spec/encourage-view-spec.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import EncourageAtomView from '../lib/encourage-view'; 4 | 5 | describe('EncourageAtomView', () => { 6 | // it('has one valid test', () => { 7 | // expect('life').toBe('easy'); 8 | // }); 9 | }); 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Encourage package 2 | 3 | Coding can be hard, your text editor should encourage you! 4 | 5 | ![encourage at work](https://cloud.githubusercontent.com/assets/19977/15810806/21421734-2b57-11e6-9979-8a5092e6b417.png) 6 | 7 | Encourage is a silly little extension that provides a bit of encouragement every time you save your document. 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "encourage", 3 | "main": "./lib/encourage.js", 4 | "version": "0.4.0", 5 | "description": "Let Atom encourage you while you work", 6 | "keywords": [], 7 | "repository": "https://github.com/haacked/encourage-atom", 8 | "license": "MIT", 9 | "engines": { 10 | "atom": ">=1.0.0 <2.0.0" 11 | }, 12 | "dependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | platform: x64 4 | 5 | branches: 6 | only: 7 | - master 8 | 9 | clone_depth: 10 10 | 11 | skip_tags: true 12 | 13 | environment: 14 | APM_TEST_PACKAGES: 15 | 16 | matrix: 17 | - ATOM_CHANNEL: stable 18 | - ATOM_CHANNEL: beta 19 | 20 | install: 21 | - ps: Install-Product node 5 22 | 23 | build_script: 24 | - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/atom/ci/master/build-package.ps1')) 25 | 26 | test: off 27 | deploy: of 28 | -------------------------------------------------------------------------------- /styles/encourage.less: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | 7 | .encourage { 8 | opacity: 0.9; 9 | top: 40px !important; 10 | width: 15% !important; 11 | text-align: center; 12 | margin-left: -10px !important; 13 | } 14 | 15 | .encourage .message { 16 | font-size: 1.2em !important; 17 | } 18 | 19 | .encourage-hidden { 20 | opacity: 0; 21 | transition: visibility 0s 1s, opacity 1s ease-in-out; 22 | } 23 | 24 | // Centering for the One themes 25 | .theme-one-dark-ui, 26 | .theme-one-light-ui { 27 | .encourage { 28 | margin-left: auto !important; 29 | } 30 | } 31 | 32 | // Remove dark background for the One themes 33 | .theme-one-dark-ui, 34 | .theme-one-light-ui { 35 | .encourage.modal:after { 36 | display: none; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/config-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "encouragementList": { 3 | "title": "Encouragement List", 4 | "description": "The list from which encouragements will be selected.", 5 | "type": "array", 6 | "default": [ 7 | "Nice Job! 🎇", 8 | "Way to go! ✨", 9 | "Wow, nice change! 💗", 10 | "So good! 💖", 11 | "Bravo! 👏", 12 | "You rock! 🚀", 13 | "Well done! 🎉", 14 | "I see what you did there! 🙏", 15 | "Genius work! 🍩", 16 | "Thumbs up! 👍", 17 | "Coding win! 🍸", 18 | "FTW! ⚡️", 19 | "Yep! 🙆", 20 | "Nnnnnnnailed it! ✌", 21 | "You\"re good enough! 😎", 22 | "You\"re smart enough! 💫", 23 | "People like you! 💞" 24 | ], 25 | "items": { 26 | "type": "string" 27 | } 28 | }, 29 | "displayDurationMs": { 30 | "title": "Display Duration in Milliseconds", 31 | "description": "How long to display the encouragement before it fades out", 32 | "type": "integer", 33 | "default": 1500 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/encourage-view.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | export default class EncourageAtomView { 4 | message = null; 5 | 6 | constructor(serializedState) { 7 | // Create root element 8 | this.element = document.createElement('div'); 9 | 10 | // Create message element 11 | const message = document.createElement('div'); 12 | message.textContent = 'Be encouraged!'; // This will replaced. 13 | message.classList.add('message'); 14 | this.element.appendChild(message); 15 | } 16 | 17 | fadeOut() { 18 | this.element.parentElement.classList.add('encourage-hidden'); 19 | } 20 | 21 | setMessage(text) { 22 | this.element.firstChild.textContent = text; 23 | this.element.parentElement.classList.remove('encourage-hidden'); 24 | } 25 | 26 | // Returns an object that can be retrieved when package is activated 27 | serialize() {} 28 | 29 | // Tear down any state and detach 30 | destroy() { 31 | this.element.remove(); 32 | } 33 | 34 | getElement() { 35 | return this.element; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Phil Haack 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /spec/encourage-spec.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import EncourageAtom from '../lib/encourage'; 4 | 5 | // Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 6 | // 7 | // To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 8 | // or `fdescribe`). Remove the `f` to unfocus the block. 9 | 10 | describe('EncourageAtom', () => { 11 | let workspaceElement, activationPromise; 12 | 13 | beforeEach(() => { 14 | workspaceElement = atom.views.getView(atom.workspace); 15 | 16 | waitsForPromise(() => { 17 | return atom.packages.activatePackage('encourage'); 18 | }); 19 | }); 20 | 21 | it('defaults to hidden', () => { 22 | expect(EncourageAtom.modalPanel.isVisible()).toBe(false); 23 | }); 24 | 25 | describe('when a file is saved', () => { 26 | beforeEach(() => { 27 | EncourageAtom.encourage(); 28 | }); 29 | 30 | it('shows the modal panel', () => { 31 | expect(EncourageAtom.modalPanel.isVisible()).toBe(true); 32 | }); 33 | 34 | it('hides the panel again after a short delay', () => { 35 | runs(() => { 36 | setTimeout(() => { 37 | expect(EncourageAtom.modalPanel.isVisible()).toBe(false); 38 | }, 1200); 39 | }) 40 | }) 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /lib/encourage.js: -------------------------------------------------------------------------------- 1 | 'use babel'; 2 | 3 | import EncourageAtomView from './encourage-view'; 4 | import { CompositeDisposable } from 'atom'; 5 | import packageConfig from './config-schema.json'; 6 | 7 | export default { 8 | 9 | encourageAtomView: null, 10 | modalPanel: null, 11 | config: packageConfig, 12 | subscriptions: null, 13 | encouragements: [], // Initial state can be drawn from config 14 | displayDurationMs: 1000, // Default in case config is broken. 15 | 16 | activate(state) { 17 | this.encourageAtomView = new EncourageAtomView(state.encourageAtomViewState); 18 | this.modalPanel = atom.workspace.addModalPanel({ 19 | item: this.encourageAtomView.getElement(), 20 | visible: false, 21 | className: 'encourage' 22 | }); 23 | 24 | // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable 25 | this.subscriptions = new CompositeDisposable(); 26 | 27 | // Register event to watch save and show the encouragement. 28 | this.subscriptions.add( 29 | atom.workspace.observeTextEditors(editor => { 30 | const savedSubscription = editor.onDidSave(event => this.encourage()); 31 | this.subscriptions.add(savedSubscription); 32 | this.subscriptions.add(editor.onDidDestroy(() => savedSubscription.dispose())); 33 | })); 34 | 35 | this.subscriptions.add(this.subscribeToConfigChanges()); 36 | }, 37 | 38 | deactivate() { 39 | this.modalPanel.destroy(); 40 | this.subscriptions.dispose(); 41 | this.encourageAtomView.destroy(); 42 | }, 43 | 44 | serialize() { 45 | return { 46 | encourageAtomViewState: this.encourageAtomView.serialize() 47 | }; 48 | }, 49 | 50 | subscribeToConfigChanges() { 51 | const subscriptions = new CompositeDisposable(); 52 | 53 | const encouragementListObserver = atom.config.observe( 54 | 'encourage.encouragementList', 55 | (value) => { 56 | console.log('EncourageAtom detected a config change in the setting `encouragementList`!'); 57 | this.encouragements = value; 58 | }); 59 | subscriptions.add(encouragementListObserver); 60 | 61 | const encouragementDurationObserver = atom.config.observe( 62 | 'encourage.displayDurationMs', 63 | (value) => { 64 | console.log('EncourageAtom detected a config change in the setting `displayDurationMs`!'); 65 | this.displayDurationMs = value; 66 | }); 67 | subscriptions.add(encouragementListObserver); 68 | 69 | return subscriptions; 70 | }, 71 | 72 | getRandomEncouragement() { 73 | return this.encouragements[Math.floor(Math.random() * this.encouragements.length)] 74 | }, 75 | 76 | encourage() { 77 | console.log('EncourageAtom was invoked due to a document save!'); 78 | this.encourageAtomView.setMessage(this.getRandomEncouragement()); 79 | this.modalPanel.hide(); // Hide existing one, if any. 80 | setTimeout(() => { 81 | this.encourageAtomView.fadeOut(); 82 | setTimeout(() => this.modalPanel.hide(), this.displayDurationMs); 83 | }, this.displayDurationMs); 84 | this.modalPanel.show(); 85 | } 86 | }; 87 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at haacked@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | --------------------------------------------------------------------------------