This repository was archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlrn-assignment.html
148 lines (140 loc) · 3.12 KB
/
lrn-assignment.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-card/paper-card.html">
<link rel="import" href="../paper-button/paper-button.html">
<!--
`lrn-assignment`
@demo demo/index.html
-->
<dom-module id="lrn-assignment">
<template>
<style>
:host {
display: flex;
width: 100%;
}
paper-card {
width: 100%;
}
</style>
<paper-card heading="[[title]]" image="[[image]]" elevation="1" animated-shadow="false">
<div class="card-content">
[[details]]
<slot></slot>
</div>
<div class="card-actions">
<template is="dom-repeat" items="[[actions]]">
<a href$="[[item.url]]"><paper-button raised>[[item.label]]</paper-button></a>
</template>
</div>
</paper-card>
</template>
<script>
Polymer({
is: 'lrn-assignment',
properties: {
/**
* Title
*/
title: {
type: String
},
/**
* Image url
*/
image: {
type: String
},
/**
* Details of the assignment
*/
details: {
type: String
},
/**
* url
*/
url: {
type: String
},
open: {
type: Boolean,
value: false
},
complete: {
type: Boolean,
value: false
},
actions: {
type: Object
}
}
});
</script>
</dom-module>
<dom-module id="lrn-assignments">
<template>
<style>
:host {
display: flex;
flex-wrap: wrap;
}
:host lrn-assignment {
margin: 1em;
}
:host[layout="wide"] lrn-assignment {
width: calc(100% - 2em);
}
:host[layout="medium"] lrn-assignment {
width: calc(50% - 2em);
}
:host[layout="tight"] lrn-assignment {
width: calc(25% - 2em);
}
</style>
<template is="dom-repeat" items="[[assignments]]">
<lrn-assignment title="[[item.title]]" actions="[[item.actions]]"></lrn-assignment>
</template>
<template is="dom-if" if="[[url]]">
<iron-ajax
auto
url="[[url]]"
handle-as="json"
on-response="handleResponse"></iron-ajax>
</template>
</template>
<script>
Polymer({
is: 'lrn-assignments',
properties: {
assignments: {
type: Object,
reflectToAttribute: true,
observer: 'assignmentsChanged'
},
layout: {
type: String,
reflectToAttribute: true
},
url: {
type: String
}
},
assignmentsChanged: function(assignments) {
if (assignments.length <= 1) {
this.layout = 'wide'
}
else if (assignments.length <= 4) {
this.layout = 'medium'
}
else if (assignments.length <= 6) {
this.layout = 'tight'
}
},
rowItemsChanged: function(items) {
},
handleResponse: function(data) {
this.assignments = data.response;
}
});
</script>
</dom-module>