Skip to content

Commit ec7b722

Browse files
committed
Example and README improvements
1 parent 9b129dd commit ec7b722

File tree

3 files changed

+76
-16
lines changed

3 files changed

+76
-16
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[Demo](https://sortablejs-vue3.maxleiter.com)
44

5-
65
This is a thin wrapper around the great [SortableJS](https://github.com/SortableJS/Sortable) library. I had many issues migrating from Vue.Draggable to vue.draggable.next, and after briefly investigating I decided that it was too complicated and a smaller solution was the answer. This wrapper tries to keep you as close to Sortable as possible (wrapper libaries seem to re-implement or unnecessarily wrap a lot of code).
76

87
Note that this library is small enough (see [Sortable.vue](https://github.com/MaxLeiter/sortablejs-vue3/blob/main/src/components/Sortable.vue) for what you really need) that I recommend including it in your project without using npm and importing it as a local component. All you need is the linked file.

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite App</title>
7+
<title>sortablejs-vue3</title>
8+
9+
<!-- SEO -->
10+
<meta name="description" content="sortablejs-vue3 - A Vue 3 wrapper for SortableJS written in TypeScript." />
11+
<meta name="robots" content="index, follow" />
812
</head>
913
<body>
1014
<div id="app"></div>

src/App.vue

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import HelloWorld from "./components/HelloWorld.vue";
66

77
<template>
88
<h1>SortableJS-vue3 demo</h1>
9+
<h2>Source on <a href="https://github.com/maxleiter/sortablejs-vue3">GitHub</a></h2>
910
<ol class="instructions">
1011
<li>First run <code>yarn add sortablejs-vue3 sortablejs</code></li>
1112
<li>
@@ -206,17 +207,38 @@ main {
206207
</p>
207208

208209
<HelloWorld />
210+
<footer>
211+
<p>
212+
Made by <a href="https://twitter.com/max_leiter">@Max_Leiter</a>
213+
</p>
214+
</footer>
209215
</template>
210216

211217
<style>
218+
:root {
219+
--link: hsl(215, 49%, 49%);
220+
--gap: 8px;
221+
--gap-half: calc(var(--gap) / 2);
222+
--gap-quarter: calc(var(--gap) / 4);
223+
--gap-double: calc(var(--gap) * 2);
224+
--content-width: 800px;
225+
226+
--fg: #2c3e50;
227+
--bg: #ecf0f1;
228+
--bg-emphasis: #bdc3c7;
229+
230+
--border: #ccc;
231+
--border-radius: 4px;
232+
}
233+
212234
#app {
213235
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
214236
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
215237
-webkit-font-smoothing: antialiased;
216238
-moz-osx-font-smoothing: grayscale;
217-
color: #2c3e50;
239+
color: var(--fg);
218240
margin: 0 auto;
219-
max-width: 800px;
241+
max-width: var(--content-width);
220242
}
221243
222244
#app .instructions {
@@ -228,24 +250,24 @@ main {
228250
}
229251
230252
#app .instructions li {
231-
margin-bottom: .5rem;
253+
margin-bottom: var(--gap);
232254
}
233255
234256
#app details {
235-
margin: 20px 0;
236-
max-width: 800px;
237-
padding: 8px 10px;
238-
background: #f5f5f5;
239-
border: 1px solid #ccc;
240-
border-radius: 4px;
257+
margin: var(--gap-double) 0;
258+
/* max-width: var(--content-); */
259+
padding: var(--gap);
260+
background: var(--bg-emphasis);
261+
border: 1px solid var(--border);
262+
border-radius: var(--radius);
241263
cursor: pointer;
242264
}
243265
244266
#app pre {
245267
font-size: 14px;
246-
padding: 10px;
268+
padding: var(--gap);
247269
margin: 0 auto;
248-
max-width: 800px;
270+
/* max-width: var(--); */
249271
text-align: left;
250272
overflow-x: scroll;
251273
max-height: 500px;
@@ -255,15 +277,50 @@ main {
255277
list-style: none;
256278
padding: 0;
257279
text-align: left;
258-
max-width: 800px;
259-
margin: 8px auto;
280+
/* max-width: 800px; */
281+
margin: var(--gap) auto;
260282
}
261283
262284
#app .draggable {
263-
border-radius: 4px;
285+
border-radius: var(--radius);
264286
}
265287
266288
#app summary::after {
267289
content: " (click to expand)";
268290
}
291+
292+
#app h1 {
293+
font-size: 2rem;
294+
}
295+
296+
#app h2 {
297+
font-size: 1.5rem;
298+
}
299+
300+
#app a {
301+
color: var(--link);
302+
padding: var(--gap-quarter);
303+
text-decoration: none;
304+
305+
display: inline-block;
306+
position: relative;
307+
}
308+
309+
#app a:after {
310+
content: '';
311+
position: absolute;
312+
width: 100%;
313+
transform: scaleX(0);
314+
height: 1px;
315+
bottom: 0;
316+
left: 0;
317+
background-color: hsl(215, 83%, 67%);
318+
transform-origin: bottom right;
319+
transition: transform 0.15s ease-in-out;
320+
}
321+
322+
#app a:hover:after {
323+
transform: scaleX(1);
324+
transform-origin: bottom left;
325+
}
269326
</style>

0 commit comments

Comments
 (0)