JSFiddle - React, Tailwind, and code Playground
by zargyle
HTML
<script src="http://code.angularjs.org/1.1.0/angular.min.js"></script>
<div ng-app="practice" ng-controller="practiceCtrl">
<form ng-submit="add()">
<header> Add a TODO item </header>
<div>
<input type="text" ng-model="item.val">
<div class="submit" ng-click="add()">Submit</div>
</div>
<div class="list">
<div ng-class="{complete:todo.done}" ng-repeat="todo in todos">
<input type="checkbox" ng-model="todo.done"/>
<label>{{todo.val}}</label>
<magic>Test</magic>
</div>
</div>
</form>
</div>
CSS
form {
width: 80%;
min-height: 7%;
padding: 1rem;
margin-left: 10%;
background-color: hsl(0,0%,0%);
}
header {
color: white;
padding-bottom: 1rem;
font-size: 2rem;
text-align: center;
}
input[type='text'] {
width: 75%;
float: left;
padding: .52rem 0;
font-size: 1.2rem
}
.complete {
text-decoration: line-through;
}
.submit {
width:23%;
float: right;
margin-left: 1%;
background-color: white;
text-align: center;
padding: .77rem 0;
}
.submit:hover {
cursor: pointer;
background-color: grey;
}
.list {
margin-top: 4rem;
text-align: left;
}
.list > div {
background-color: white;
border-bottom: 1px solid black;
padding: .52rem;
font-size: 1.2rem;
}
input[type='checkbox'] {
}
JavaScript
var module = angular.module('practice', []);
module.controller('practiceCtrl', function($scope) {
$scope.todos = [];
$scope.add = function() {
$scope.todos.push(angular.copy($scope.item));
$scope.item.val = "";
}
})
.directive('magic', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
console.log(elem.css("opacity"));
elem.bind("click", function() {
var opacity = elem.css("opacity");
while(opacity > 0) {
opacity -= 0.1;
elem.css("opacity", opacity);
}
});
}
}
});