Skip to content

Commit 42a7d08

Browse files
committed
docs: improve demo on mobile devices and reduce package readmes
1 parent b01ae1f commit 42a7d08

File tree

5 files changed

+55
-219
lines changed

5 files changed

+55
-219
lines changed

docs/pages/quickstart.md

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,44 +49,44 @@ const selection = new SelectionArea({
4949

5050
```css [styles.css]
5151
.container {
52-
display: flex;
53-
flex-wrap: wrap;
54-
justify-content: space-evenly;
55-
border-radius: 15px;
56-
padding: 15px;
57-
margin: 15px 0;
58-
user-select: none;
52+
display: flex;
53+
flex-wrap: wrap;
54+
justify-content: center;
55+
border-radius: 15px;
56+
padding: 10px;
57+
margin: 15px 0;
58+
user-select: none;
5959
}
6060

6161
.container div {
62-
height: 50px;
63-
width: 50px;
64-
margin: 3px;
65-
background: rgba(66, 68, 90, 0.075);
66-
border-radius: 10px;
67-
cursor: pointer;
62+
height: 50px;
63+
width: 50px;
64+
margin: 3px;
65+
background: rgba(66, 68, 90, 0.075);
66+
border-radius: 5px;
67+
cursor: pointer;
6868
}
6969

7070
.container.blue {
71-
border: 2px dashed #a8b1ff;
71+
border: 2px dashed #a8b1ff;
7272
}
7373

7474
.container.purple {
75-
border: 2px dashed #c8abfa;
75+
border: 2px dashed #c8abfa;
7676
}
7777

7878
.container.blue div.selected {
79-
background: #5c73e7;
79+
background: #5c73e7;
8080
}
8181

8282
.container.purple div.selected {
83-
background: #a879e6;
83+
background: #a879e6;
8484
}
8585

8686
.selectionArea {
87-
background: rgba(102, 110, 255, 0.16);
88-
border: 1px solid rgb(62, 99, 221);
89-
border-radius: 0.15em;
87+
background: rgba(102, 110, 255, 0.16);
88+
border: 1px solid rgb(62, 99, 221);
89+
border-radius: 0.15em;
9090
}
9191
```
9292

@@ -99,21 +99,31 @@ const selection = new SelectionArea({
9999

100100
Which will give you something like this:
101101

102-
<div :class="[$style.container, $style.purple]"/>
102+
<div ref="container" :class="[$style.container, $style.purple]"/>
103103
<div :class="[$style.container, $style.blue]"/>
104104

105105
<script setup>
106-
import { useCssModule, onMounted } from 'vue';
106+
import {useCssModule, onMounted, useTemplateRef} from 'vue';
107107
import SelectionArea from '@viselect/vanilla';
108108

109109
const styles = useCssModule();
110+
const container = useTemplateRef('container');
111+
const { matches: mobile } = window.matchMedia('(max-width: 430px)');
110112

111113
onMounted(() => {
112-
[[styles.purple, 33], [styles.blue, 33]].forEach(([selector, items]) => {
114+
const { width } = container.value.getBoundingClientRect();
115+
const boxes = 33;
116+
const rows = 3;
117+
const totalBoxMargin = 3 * 2 * (boxes / rows);
118+
const boxWidth = (width - 20 - 4 - totalBoxMargin) / ((boxes / rows));
119+
120+
[[styles.purple, boxes], [styles.blue, boxes]].forEach(([selector, items]) => {
113121
const container = document.querySelector(`.${selector}`);
114122

115123
for (let i = 0; i < items; i++) {
116-
container.appendChild(document.createElement('div'));
124+
const div = document.createElement('div');
125+
div.style.width = div.style.height = `${Math.floor(boxWidth)}px`;
126+
container.appendChild(div);
117127
}
118128
});
119129

@@ -123,8 +133,8 @@ onMounted(() => {
123133
selectionAreaClass: styles.selectionArea
124134
}).on('start', ({ store, event }) => {
125135
if (!event.ctrlKey && !event.metaKey) {
126-
store.stored.forEach(el => el.classList.remove(styles.selected));
127-
selection.clearSelection();
136+
store.stored.forEach(el => el.classList.remove(styles.selected));
137+
selection.clearSelection();
128138
}
129139
}).on('move', ({ store: { changed: { added, removed } } }) => {
130140
added.forEach(el => el.classList.add(styles.selected));
@@ -137,19 +147,17 @@ onMounted(() => {
137147
.container {
138148
display: flex;
139149
flex-wrap: wrap;
140-
justify-content: space-evenly;
150+
justify-content: center;
141151
border-radius: 15px;
142-
padding: 15px;
152+
padding: 10px;
143153
margin: 15px 0;
144154
user-select: none;
145155
}
146156

147157
.container div {
148-
height: 50px;
149-
width: 50px;
150158
margin: 3px;
151159
background: rgba(66, 68, 90, 0.075);
152-
border-radius: 10px;
160+
border-radius: 5px;
153161
cursor: pointer;
154162
}
155163

packages/preact/README.md

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,7 @@
1-
<h3 align="center">
2-
<img alt="Logo" src="https://user-images.githubusercontent.com/30767528/123517467-622b0f80-d6a1-11eb-9bf3-abcb4928a89e.png" width="300"/>
3-
</h3>
4-
5-
<h3 align="center">
6-
Viselect - Preact
7-
</h3>
8-
91
<p align="center">
10-
<a href="https://choosealicense.com/licenses/mit/"><img
11-
alt="License MIT"
12-
src="https://img.shields.io/badge/license-MIT-ae15cc.svg"></a>
13-
<img alt="No dependencies"
14-
src="https://img.shields.io/badge/dependencies-none-8115cc.svg">
15-
<a href="https://github.com/sponsors/Simonwep"><img
16-
alt="Support me"
17-
src="https://img.shields.io/badge/github-support-6a15cc.svg"></a>
18-
<a href="https://www.buymeacoffee.com/aVc3krbXQ"><img
19-
alt="Buy me a coffee"
20-
src="https://img.shields.io/badge/%F0%9F%8D%BA-buy%20me%20a%20beer-%23FFDD00"></a>
21-
<a href="https://github.com/simonwep/viselect/actions?query=workflow%3ACI"><img
22-
alt="Build Status"
23-
src="https://github.com/simonwep/viselect/workflows/CI/badge.svg"></a>
24-
<img alt="gzip size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/preact/dist/viselect.mjs?compression=gzip">
25-
<img alt="brotli size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/preact/dist/viselect.mjs?compression=brotli">
26-
<a href="https://v3.vuejs.org"><img
27-
alt="Vue support"
28-
src="https://img.shields.io/badge/✔-vue-%2340B581"></a>
29-
<a href="https://preactjs.com/"><img
30-
alt="Preact support"
31-
src="https://img.shields.io/badge/✔-preact-%236337B1"></a>
32-
<a href="https://reactjs.org"><img
33-
alt="React support"
34-
src="https://img.shields.io/badge/✔-react-%2359D7FF"></a>
35-
<a href="https://svelte.dev"><img
36-
alt="Svelte support"
37-
src="https://img.shields.io/badge/%E2%9A%99-svelte-%23F83C00"></a>
38-
<a href="https://lit-element.polymer-project.org"><img
39-
alt="Lit-Element support"
40-
src="https://img.shields.io/badge/%E2%9A%99-lit--element-%233CA4F6"></a>
41-
<a href="https://lit-element.polymer-project.org"><img
42-
alt="Lit-Element support"
43-
src="https://img.shields.io/badge/%E2%9A%99-angular-%23c3002f"></a>
2+
<code>@viselect/preact</code>
443
</p>
454

46-
<br>
47-
48-
### Getting started
49-
50-
Head over to [the documentation](https://simonwep.github.io/viselect) to get started 🚀
5+
<p align="center">
6+
<a href="https://simonwep.github.io/viselect">Go Here For Documentation</a>
7+
</p>

packages/react/README.md

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,7 @@
1-
<h3 align="center">
2-
<img alt="Logo" src="https://user-images.githubusercontent.com/30767528/123517467-622b0f80-d6a1-11eb-9bf3-abcb4928a89e.png" width="300"/>
3-
</h3>
4-
5-
<h3 align="center">
6-
Viselect - React
7-
</h3>
8-
91
<p align="center">
10-
<a href="https://choosealicense.com/licenses/mit/"><img
11-
alt="License MIT"
12-
src="https://img.shields.io/badge/license-MIT-ae15cc.svg"></a>
13-
<img alt="No dependencies"
14-
src="https://img.shields.io/badge/dependencies-none-8115cc.svg">
15-
<a href="https://github.com/sponsors/Simonwep"><img
16-
alt="Support me"
17-
src="https://img.shields.io/badge/github-support-6a15cc.svg"></a>
18-
<a href="https://www.buymeacoffee.com/aVc3krbXQ"><img
19-
alt="Buy me a coffee"
20-
src="https://img.shields.io/badge/%F0%9F%8D%BA-buy%20me%20a%20beer-%23FFDD00"></a>
21-
<a href="https://github.com/simonwep/viselect/actions?query=workflow%3ACI"><img
22-
alt="Build Status"
23-
src="https://github.com/simonwep/viselect/workflows/CI/badge.svg"></a>
24-
<img alt="gzip size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/react/dist/viselect.mjs?compression=gzip">
25-
<img alt="brotli size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/react/dist/viselect.mjs?compression=brotli">
26-
<a href="https://v3.vuejs.org"><img
27-
alt="Vue support"
28-
src="https://img.shields.io/badge/✔-vue-%2340B581"></a>
29-
<a href="https://preactjs.com/"><img
30-
alt="Preact support"
31-
src="https://img.shields.io/badge/✔-preact-%236337B1"></a>
32-
<a href="https://reactjs.org"><img
33-
alt="React support"
34-
src="https://img.shields.io/badge/✔-react-%2359D7FF"></a>
35-
<a href="https://svelte.dev"><img
36-
alt="Svelte support"
37-
src="https://img.shields.io/badge/%E2%9A%99-svelte-%23F83C00"></a>
38-
<a href="https://lit-element.polymer-project.org"><img
39-
alt="Lit-Element support"
40-
src="https://img.shields.io/badge/%E2%9A%99-lit--element-%233CA4F6"></a>
41-
<a href="https://lit-element.polymer-project.org"><img
42-
alt="Lit-Element support"
43-
src="https://img.shields.io/badge/%E2%9A%99-angular-%23c3002f"></a>
2+
<code>@viselect/react</code>
443
</p>
454

46-
<br>
47-
48-
### Getting started
49-
50-
Head over to [the documentation](https://simonwep.github.io/viselect) to get started 🚀
5+
<p align="center">
6+
<a href="https://simonwep.github.io/viselect">Go Here For Documentation</a>
7+
</p>

packages/vanilla/README.md

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,7 @@
1-
<h3 align="center">
2-
<img alt="Logo" src="https://user-images.githubusercontent.com/30767528/123517467-622b0f80-d6a1-11eb-9bf3-abcb4928a89e.png" width="300"/>
3-
</h3>
4-
5-
<h3 align="center">
6-
Viselect - Vanilla
7-
</h3>
8-
91
<p align="center">
10-
<a href="https://choosealicense.com/licenses/mit/"><img
11-
alt="License MIT"
12-
src="https://img.shields.io/badge/license-MIT-ae15cc.svg"></a>
13-
<img alt="No dependencies"
14-
src="https://img.shields.io/badge/dependencies-none-8115cc.svg">
15-
<a href="https://github.com/sponsors/Simonwep"><img
16-
alt="Support me"
17-
src="https://img.shields.io/badge/github-support-6a15cc.svg"></a>
18-
<a href="https://www.buymeacoffee.com/aVc3krbXQ"><img
19-
alt="Buy me a coffee"
20-
src="https://img.shields.io/badge/%F0%9F%8D%BA-buy%20me%20a%20beer-%23FFDD00"></a>
21-
<a href="https://github.com/simonwep/viselect/actions?query=workflow%3ACI"><img
22-
alt="Build Status"
23-
src="https://github.com/simonwep/viselect/workflows/CI/badge.svg"></a>
24-
<img alt="gzip size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/vanilla/dist/viselect.mjs?compression=gzip">
25-
<img alt="brotli size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/vanilla/dist/viselect.mjs?compression=brotli">
26-
<a href="https://v3.vuejs.org"><img
27-
alt="Vue support"
28-
src="https://img.shields.io/badge/✔-vue-%2340B581"></a>
29-
<a href="https://preactjs.com/"><img
30-
alt="Preact support"
31-
src="https://img.shields.io/badge/✔-preact-%236337B1"></a>
32-
<a href="https://reactjs.org"><img
33-
alt="React support"
34-
src="https://img.shields.io/badge/✔-react-%2359D7FF"></a>
35-
<a href="https://svelte.dev"><img
36-
alt="Svelte support"
37-
src="https://img.shields.io/badge/%E2%9A%99-svelte-%23F83C00"></a>
38-
<a href="https://lit-element.polymer-project.org"><img
39-
alt="Lit-Element support"
40-
src="https://img.shields.io/badge/%E2%9A%99-lit--element-%233CA4F6"></a>
41-
<a href="https://lit-element.polymer-project.org"><img
42-
alt="Lit-Element support"
43-
src="https://img.shields.io/badge/%E2%9A%99-angular-%23c3002f"></a>
2+
<code>@viselect/vanilla</code>
443
</p>
454

46-
<br>
47-
48-
### Getting started
49-
50-
Head over to [the documentation](https://simonwep.github.io/viselect) to get started 🚀
5+
<p align="center">
6+
<a href="https://simonwep.github.io/viselect">Go Here For Documentation</a>
7+
</p>

packages/vue/README.md

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,7 @@
1-
<h3 align="center">
2-
<img alt="Logo" src="https://user-images.githubusercontent.com/30767528/123517467-622b0f80-d6a1-11eb-9bf3-abcb4928a89e.png" width="300"/>
3-
</h3>
4-
5-
<h3 align="center">
6-
Viselect - Vue
7-
</h3>
8-
91
<p align="center">
10-
<a href="https://choosealicense.com/licenses/mit/"><img
11-
alt="License MIT"
12-
src="https://img.shields.io/badge/license-MIT-ae15cc.svg"></a>
13-
<img alt="No dependencies"
14-
src="https://img.shields.io/badge/dependencies-none-8115cc.svg">
15-
<a href="https://github.com/sponsors/Simonwep"><img
16-
alt="Support me"
17-
src="https://img.shields.io/badge/github-support-6a15cc.svg"></a>
18-
<a href="https://www.buymeacoffee.com/aVc3krbXQ"><img
19-
alt="Buy me a coffee"
20-
src="https://img.shields.io/badge/%F0%9F%8D%BA-buy%20me%20a%20beer-%23FFDD00"></a>
21-
<a href="https://github.com/simonwep/viselect/actions?query=workflow%3ACI"><img
22-
alt="Build Status"
23-
src="https://github.com/simonwep/viselect/workflows/CI/badge.svg"></a>
24-
<img alt="gzip size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/vue/dist/viselect.mjs?compression=gzip">
25-
<img alt="brotli size" src="https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@viselect/vue/dist/viselect.mjs?compression=brotli">
26-
<a href="https://v3.vuejs.org"><img
27-
alt="Vue support"
28-
src="https://img.shields.io/badge/✔-vue-%2340B581"></a>
29-
<a href="https://preactjs.com/"><img
30-
alt="Preact support"
31-
src="https://img.shields.io/badge/✔-preact-%236337B1"></a>
32-
<a href="https://reactjs.org"><img
33-
alt="React support"
34-
src="https://img.shields.io/badge/✔-react-%2359D7FF"></a>
35-
<a href="https://svelte.dev"><img
36-
alt="Svelte support"
37-
src="https://img.shields.io/badge/%E2%9A%99-svelte-%23F83C00"></a>
38-
<a href="https://lit-element.polymer-project.org"><img
39-
alt="Lit-Element support"
40-
src="https://img.shields.io/badge/%E2%9A%99-lit--element-%233CA4F6"></a>
41-
<a href="https://lit-element.polymer-project.org"><img
42-
alt="Lit-Element support"
43-
src="https://img.shields.io/badge/%E2%9A%99-angular-%23c3002f"></a>
2+
<code>@viselect/vue</code>
443
</p>
454

46-
<br>
47-
48-
### Getting started
49-
50-
Head over to [the documentation](https://simonwep.github.io/viselect) to get started 🚀
5+
<p align="center">
6+
<a href="https://simonwep.github.io/viselect">Go Here For Documentation</a>
7+
</p>

0 commit comments

Comments
 (0)