Skip to content

Commit

Permalink
imp: project
Browse files Browse the repository at this point in the history
  • Loading branch information
Tardo committed Jan 4, 2024
1 parent 5e2925c commit 8d8d75c
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/dist

# Caches
/node_modules

Expand Down
13 changes: 13 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.github/
.husky/
examples/
node_modules/
tests/
.editorconfig
.eslintignore
.prettierignore
mirlo.code-workspace
mirlo.png
package-lock.json
rollup.config.mjs
setup-jest.mjs
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ app.registerComponent('demo01', Demo01);

### Available Services:

- requests: Do HTTP operations
- localStorage: Do local storage operations
- sessionStorage: Do session storage operations
- requests: HTTP operations (always included)
- localStorage: Local storage operations
- sessionStorage: Session storage operations

### Example

Expand All @@ -66,14 +66,12 @@ app.registerComponent('demo01', Demo01);
import {Component} from 'mirlo';

export default class Demo01 extends Component {
useServices = ['requests'];
useServices = ['localStorage'];

onStart() {
super.onStart();
this.dom_el.innerHTML = '<strong>Hello World!</strong>';
this.requests
.postJSON('/demo01')
.then(result => (this.dom_el.innerHTML = result));
const username = this.localStorage.getItem('username');
this.dom_el.innerHTML = `<strong>Hello ${username}!</strong>`;
}
}
```
Expand Down
1 change: 0 additions & 1 deletion dist/mirlo.mjs

This file was deleted.

9 changes: 4 additions & 5 deletions src/js/components/lazy.mjs → examples/components/lazy.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import domSetAttributes from '../utils/dom_set_attributes';
import Component from '../base/component';
import $ from 'jquery-slim';
import {Component} from 'mirlo';

export default class LazyComponent extends Component {
LAZY_ELEMENT_CLASS = 'lazy';
Expand Down Expand Up @@ -29,11 +29,10 @@ export default class LazyComponent extends Component {
dom_el.removeClass(this.LAZY_ELEMENT_CLASS);
const attrs = this.getNormalizedAttributes(dom_el, true);
if (dom_el?.dataset.createTag) {
const new_dom_elm = document.createElement(dom_el.dataset.createTag);
domSetAttributes(new_dom_elm, attrs);
const new_dom_elm = $(`<${dom_el.dataset.createTag}>`, attrs);
dom_el.replaceWith(new_dom_elm);
} else {
domSetAttributes(dom_el, attrs);
$(dom_el).attr(attrs);
}
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce from '../utils/debounce';
import $ from 'jquery-slim';
import LazyComponent from './lazy';

export default class LazyScrollComponent extends LazyComponent {
Expand All @@ -17,7 +17,7 @@ export default class LazyScrollComponent extends LazyComponent {
},
this.options,
);
this.load = debounce(
this.load = $.debounce(
this.#doLazyLoad.bind(this),
this.options.bounce_time_scroll,
);
Expand All @@ -37,7 +37,8 @@ export default class LazyScrollComponent extends LazyComponent {
});
}

#getDimensions($elm) {
#getDimensions(dom_el) {
const $elm = $(dom_el);
const $offset = $elm.offset();
const left = $offset.left;
const top = $offset.top;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirlo",
"version": "0.0.3",
"version": "0.1.0",
"type": "module",
"keywords": [
"initiator",
Expand Down
10 changes: 1 addition & 9 deletions src/js/mirlo.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
// Copyright (C) 2022 Alexandre Díaz
// Copyright (C) 2024 Alexandre D. Díaz
import {app} from './base/app';
import Component from './base/component';
import Service from './base/service';

import {LocalStorageService, SessionStorageService} from './services/storage';
import RequestsService from './services/requests';

import LazyClickComponent from './components/lazy_click';
import LazyScrollComponent from './components/lazy_scroll';

app.registerService('requests', RequestsService);
app.registerService('localStorage', LocalStorageService);
app.registerService('sessionStorage', SessionStorageService);

app.registerComponent('lazyClick', LazyClickComponent);
app.registerComponent('lazyScroll', LazyScrollComponent);

// On Start APP
window.addEventListener('load', () => {
app.onWillStart().then(() => {
Expand All @@ -29,7 +23,5 @@ export {
LocalStorageService,
SessionStorageService,
RequestsService,
LazyClickComponent,
LazyScrollComponent,
};
export default app;
9 changes: 0 additions & 9 deletions src/js/utils/debounce.mjs

This file was deleted.

5 changes: 0 additions & 5 deletions src/js/utils/dom_set_attributes.mjs

This file was deleted.

0 comments on commit 8d8d75c

Please sign in to comment.