Skip to content

Commit d0ca9a5

Browse files
committed
Merge branch 'release/2.0.0-beta.9'
2 parents 9c99e4c + 4802b02 commit d0ca9a5

39 files changed

+955
-302
lines changed

README.md

Lines changed: 13 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,80 +15,23 @@ Install the latest version via NPM:
1515
npm install @studiometa/js-toolkit
1616
```
1717

18-
## Concept
18+
## Documentation
1919

20-
[] todo
20+
This project contains a JavaScript micro-framework and its utility functions whose main objectives are:
2121

22-
## Usage
22+
- Enforcing best-practice and consistency between projects
23+
- Using elements from the DOM easily
24+
- Enabling custom behaviours on component initialization or other user events
25+
- Disabling custom behaviours on component destruction or other user events
26+
- Initializing components in the right place at the right time
27+
- Defining dependencies between components
2328

24-
Import the `Base` class and extend it to create your components:
29+
Visit [js-toolkit.studiometa.dev](https://js-toolkit.studiometa.dev) to learn more.
2530

26-
```js
27-
import { Base, createApp } from '@studiometa/js-toolkit';
31+
## Contributing
2832

29-
class Component extends Base {
30-
static config = {
31-
name: 'Component',
32-
}
33+
This projects follows the [Git Flow](https://github.com/petervanderdoes/gitflow-avh) methodology to manage its branches and features. The packages and their dependencies are managed with NPM workspaces. The files are linted with ESLint, type checked with TypeScript and formatted with Prettier.
3334

34-
sayHello() {
35-
console.log('Hello!');
36-
}
37-
}
35+
## License
3836

39-
class App extends Base {
40-
static config = {
41-
name: 'App',
42-
components: {
43-
Component,
44-
},
45-
refs: ['btn', 'items[]'],
46-
options: {
47-
foo: String,
48-
bar: { type: String, default: 'bar' },
49-
}
50-
};
51-
52-
mounted() {
53-
this.$log('mounted');
54-
55-
// Options
56-
this.$options.name; // 'App'
57-
this.$options.log; // true
58-
this.$options.debug; // false
59-
this.$options.foo // ''
60-
this.$options.bar // 'bar'
61-
62-
// Children
63-
this.$children.Component; // Array<Component>
64-
65-
// DOM references
66-
this.$refs.btn; // <button data-ref="btn"></button>
67-
this.$refs.items[0]; // <li data-ref="items[]"></li>
68-
}
69-
70-
destroyed() {
71-
this.$log('destroyed');
72-
}
73-
74-
scrolled(props) {
75-
this.$log('scrolled', props);
76-
}
77-
78-
resized(props) {
79-
this.$log('resized', props);
80-
}
81-
}
82-
83-
export default createApp(App, document.body);
84-
```
85-
86-
Read the [documentation](https://js-toolkit.studiometa.dev/) to learn more.
87-
88-
## Contribution
89-
90-
This projects follows the [Git Flow](https://github.com/petervanderdoes/gitflow-avh) methodology to manage its branches and features.
91-
92-
The packages from this project are managed with NPM workspaces.
93-
94-
The files are linted with ESLint, type checked with TypeScript and formatted with Prettier.
37+
See [LICENSE](./LICENSE).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@studiometa/js-toolkit-workspace",
3-
"version": "2.0.0-beta.8",
3+
"version": "2.0.0-beta.9",
44
"private": true,
55
"workspaces": [
66
"packages/*"

packages/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@studiometa/js-toolkit-demo",
3-
"version": "2.0.0-beta.8",
3+
"version": "2.0.0-beta.9",
44
"private": true,
55
"type": "commonjs",
66
"scripts": {

packages/docs/.vitepress/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ function getUtilsSidebar() {
231231
children: [
232232
{ text: 'clamp', link: '/utils/math/clamp.html' },
233233
{ text: 'clamp01', link: '/utils/math/clamp01.html' },
234+
{ text: 'createEaseInOut', link: '/utils/math/createEaseInOut.html' },
235+
{ text: 'createEaseOut', link: '/utils/math/createEaseOut.html' },
234236
{ text: 'damp', link: '/utils/math/damp.html' },
237+
{ text: 'ease', link: '/utils/math/ease.html' },
235238
{ text: 'inertiaFinalValue', link: '/utils/math/inertiaFinalValue.html' },
236239
{ text: 'lerp', link: '/utils/math/lerp.html' },
237240
{ text: 'map', link: '/utils/math/map.html' },

packages/docs/.vitepress/theme/custom.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import 'tailwindcss/utilities';
2+
13
h3 + h4 {
24
margin-top: 1.5rem;
35
}

packages/docs/api/decorators/withBreakpointManager.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,29 @@ Use this decorator to create a component that will have the capacity to switch c
44

55
## Usage
66

7-
<label><input type="checkbox">todo</label>
7+
```js{5-8}
8+
import { Base, withBreakpointManager } from '@studiometa/js-toolkit';
9+
import MenuMobile from './MenuMobile';
10+
import MenuDesktop from './MenuDesktop';
11+
12+
export default class Menu extends withBreakpointManager(Base, [
13+
['xxs xs s', MenuMobile],
14+
['m l xl xxl', MenuDesktop],
15+
]) {
16+
static config = {
17+
name: 'Menu',
18+
};
19+
}
20+
```
21+
22+
### Parameters
23+
24+
- `Base` (`BaseConstructor`): The `Base` class or a class extending it.
25+
- `options` (`Array<[string, BaseConstructor]>`): Definition for the components to be used for each breakpoints
26+
27+
### Return value
28+
29+
- `BaseConstructor`: A child class of the given class which will mount the given components based on the current active breakpoint
830

931
## Examples
1032

packages/docs/api/decorators/withBreakpointObserver.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,29 @@ Use this decorator to create a class that will have the capacity to be mounted o
44

55
## Usage
66

7-
<label><input type="checkbox">todo</label>
7+
```js{1,3,7-10}
8+
import { Base, withBreakpointObserver } from '@studiometa/js-toolkit';
9+
10+
export default class MobileComponent extends withBreakpointObserver(Base) {
11+
static config = {
12+
name: 'MobileComponent',
13+
options: {
14+
activeBreakpoints: {
15+
type: String,
16+
default: 'xxs xs s',
17+
},
18+
},
19+
};
20+
}
21+
```
22+
23+
### Parameters
24+
25+
- `Base` (`BaseConstructor`): The `Base` class or a class extending it.
26+
27+
### Return value
28+
29+
- `BaseConstructor`: A child class of the given class which will be mounted when visible and destroyed when invisible.
830

931
## Examples
1032

packages/docs/api/decorators/withIntersectionObserver.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,28 @@ Use this decorator to create a class that will have the capacity to trigger an `
44

55
## Usage
66

7-
<label><input type="checkbox">todo</label>
7+
```js {1,3,8-10}
8+
import { Base, withIntersectionObserver } from '@studiometa/js-toolkit';
9+
10+
class Component extends withIntersectionObserver(Base, { rootMargin: '100%' }) {
11+
static config = {
12+
name: 'Component',
13+
};
14+
15+
intersected(entries) {
16+
// do something with `entries`
17+
}
18+
}
19+
```
20+
21+
### Parameters
22+
23+
- `Base` (`BaseConstructor`): The `Base` class or a class extending it.
24+
- `options` (`IntersectionObserverInit`): Options for the `IntersectionObserver` instance.
25+
26+
### Return value
27+
28+
- `BaseConstructor`: A child class of the given class which will trigger an `intersected` hook when visible.
829

930
## API
1031

packages/docs/api/decorators/withMountWhenInView.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export default withMountWhenInView(Component, { threshold: [0, 1] });
1313

1414
### Parameters
1515

16-
- `BaseClass` (`Base`): The Base class to mount when in view.
17-
- `intersectionObserverOptions` (`IntersectionObserverInit`): Options for the `IntersectionObserver` instance.
16+
- `Base` (`BaseConstructor`): The `Base` class or a class extending it.
17+
- `options` (`IntersectionObserverInit`): Options for the `IntersectionObserver` instance.
1818

1919
### Return value
2020

21-
- `Base`: A child class of the given class which will be mounted when visible and destroyed when invisible
21+
- `BaseConstructor`: A child class of the given class which will be mounted when visible and destroyed when invisible.
2222

2323
## API
2424

0 commit comments

Comments
 (0)