Skip to content

Instantly share code, notes, and snippets.

@3cp
Created March 21, 2020 12:25
Show Gist options
  • Save 3cp/d239d878d3cf6d0d18abb99322a3ccfb to your computer and use it in GitHub Desktop.
Save 3cp/d239d878d3cf6d0d18abb99322a3ccfb to your computer and use it in GitHub Desktop.
bcx-aurelia-reorderable-repeat example: multi-lists
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber gist uses dumber bundler, the default bundle file
is /dist/entry-bundle.js.
The starting module is pointed to aurelia-bootstrapper
(data-main attribute on script) for Aurelia,
The aurelia bootstrapper then loads up user module "main"
(aurelia-app attribute on <body>) which is your src/main.js.
-->
<body aurelia-app="main">
<script src="/dist/entry-bundle.js" data-main="aurelia-bootstrapper"></script>
</body>
</html>
{
"dependencies": {
"aurelia-bootstrapper": "^2.3.3"
}
}
<template>
<require from="./container"></require>
<container></container>
</template>
export class App {
message = 'Hello Aurelia!';
}
.container {
display: flex;
align-items: start;
width: 250px;
margin: 5px;
}
.list {
flex: 1 1 0;
margin: 10px;
padding: 10px;
background-color: #eee;
}
.item {
display: block;
box-sizing: border-box;
border: 1px solid #888;
height: 40px;
text-align: center;
line-height: 40px;
overflow: hidden;
background: white;
}
.item:not(:first-child) {
margin-top: -1px;
}
.item.reorderable-repeat-dragging-me {
visibility: visible; /* unset visibility: hidden */
color: transparent; /* hide text */
background-color: #ddd;
}
<template>
<require from="./container.css"></require>
<div class="container">
<div class="list">
Numbers
<div
class="item"
reorderable-repeat.for="item of numbers"
reorderable-group="alphanumeric">
${item}
</div>
</div>
<div class="list">
Letters
<div
class="item"
reorderable-repeat.for="item of letters"
reorderable-group="alphanumeric">
${item}
</div>
</div>
</div>
</template>
export class Container {
numbers = [0, 1, 2];
letters = ['a', 'b'];
}
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging('info')
.plugin('bcx-aurelia-reorderable-repeat');
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment