alchemy-chimera 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.0.2 (2022-02-20)
2
+
3
+ * Improve editor styling
4
+ * Put editor errors in the Widget context
5
+ * Add TOC to editor
6
+ * Make sidebar sticky
7
+
1
8
  ## 1.0.1 (2022-01-28)
2
9
 
3
10
  * Allow setting a simple menu sidebar in the config
File without changes
@@ -10,6 +10,7 @@ body {
10
10
  --text-color: #475466;
11
11
  --main-bg-color: #ebedf0;
12
12
  --main-border-color: #dadee0;
13
+
13
14
  --button-bg-color: #F4F5F9;
14
15
  --button-bg-hover-color: #e7e9f2;
15
16
  --button-text-color: #3699FF;
@@ -31,27 +32,97 @@ body {
31
32
  }
32
33
 
33
34
  .btn {
35
+ //--button-bg-color: var(--context-background-color, --button-bg-color);
36
+ --local-text-color: var(--context-color, var(--button-text-color));
37
+ --local-border-color: var(--context-border-color, var(--button-border-color));
38
+
34
39
  background-color: var(--button-bg-color);
40
+ color: var(--local-text-color);
41
+ border: 1px solid;
42
+ border-color: var(--local-border-color);
43
+
35
44
  text-decoration: none;
36
- color: var(--button-text-color);
37
45
  line-height: 2rem;
38
46
  min-width: 10rem;
39
47
  text-align: center;
40
48
  border-radius: 2px;
41
49
  font-weight: 500;
42
50
  cursor: pointer;
43
- border: 1px solid;
44
51
 
45
52
  &:hover {
46
53
  background-color: var(--button-bg-hover-color);
54
+ //filter: brightness(1.05);
47
55
  }
48
56
  }
49
57
 
58
+ .primary {
59
+ --context-color: #084298;
60
+ --context-background-color: #cfe2ff;
61
+ --context-border-color: #b6d4fe;
62
+ }
63
+
64
+ .secondary {
65
+ --context-color: #41464b;
66
+ --context-background-color: #e2e3e5;
67
+ --context-border-color: #d3d6d8;
68
+ }
69
+
70
+ .success {
71
+ --context-color: #0f5132;
72
+ --context-background-color: #d1e7dd;
73
+ --context-border-color: #badbcc;
74
+ }
75
+
76
+ .danger,
77
+ .error {
78
+ --context-color: #842029;
79
+ --context-background-color: #f8d7da;
80
+ --context-border-color: #f5c2c7;
81
+ }
82
+
83
+ .warning {
84
+ --context-color: #664d03;
85
+ --context-background-color: #fff3cd;
86
+ --context-border-color: #ffecb5;
87
+ }
88
+
89
+ .info {
90
+ --context-color: #055160;
91
+ --context-background-color: #cff4fc;
92
+ --context-border-color: #b6effb;
93
+ }
94
+
95
+ .light {
96
+ --context-color: #636464;
97
+ --context-background-color: #fefefe;
98
+ --context-border-color: #fdfdfe;
99
+ }
100
+
101
+ .dark {
102
+ --context-color: #141619;
103
+ --context-background-color: #d3d3d4;
104
+ --context-border-color: #bcbebf;
105
+ }
106
+
107
+ .alert-box {
108
+ color: var(--context-color);
109
+ background-color: var(--context-background-color);
110
+ border: 1px solid;
111
+ border-color: var(--context-border-color);
112
+ padding: 1rem;
113
+ margin: 1rem 0 1rem;
114
+ }
115
+
50
116
  .chimera-sidebar {
51
117
  background-color: var(--sidebar-bg-color);
52
118
  flex: 0 0 14rem;
53
119
  display: flex;
54
120
  flex-flow: column;
121
+
122
+ .sidebar-widgets {
123
+ position: sticky;
124
+ top: 1rem;
125
+ }
55
126
  }
56
127
 
57
128
  .chimera-content {
@@ -92,6 +163,12 @@ body {
92
163
  .chimera-main {
93
164
  flex: 1;
94
165
  padding: 0.5rem;
166
+
167
+ &[data-he-template="chimera/widgets"] {
168
+ h1 {
169
+ padding-top: 0;
170
+ }
171
+ }
95
172
  }
96
173
 
97
174
  .main-widgets {
@@ -182,11 +259,21 @@ alchemy-table .aft-column-filters input {
182
259
  width: 100%;
183
260
  }
184
261
 
262
+ alchemy-form {
263
+ .error-area:not(:empty) {
264
+ @extend .error, .alert-box;
265
+ margin-top: 0;
266
+ }
267
+ }
268
+
185
269
  alchemy-field {
186
270
  border: 1px solid var(--color-box-border);
187
271
  background-color: white;
188
272
  border-radius: 4px;
189
273
 
274
+ // In case something goes wrong:
275
+ min-height: 1rem;
276
+
190
277
  alchemy-label {
191
278
  padding-left: 1rem;
192
279
  line-height: 3rem;
@@ -232,6 +319,7 @@ alchemy-field {
232
319
  .field {
233
320
  display: flex;
234
321
  padding: 1rem;
322
+ flex: 1;
235
323
 
236
324
  > * {
237
325
  flex: 1;
@@ -243,17 +331,107 @@ alchemy-field {
243
331
  }
244
332
  }
245
333
 
246
- .field input[type="text"],
247
- .field input[type="number"],
248
- .field input[type="color"] {
249
- @extend .chimera-input-field;
250
- height: 3rem;
334
+ .field {
335
+ input[type="text"],
336
+ input[type="number"],
337
+ input[type="color"],
338
+ input[type="datetime-local"],
339
+ input[type="password"] {
340
+ @extend .chimera-input-field;
341
+ height: 3rem;
342
+ }
343
+
344
+ textarea {
345
+ @extend .chimera-input-field;
346
+ min-height: 5rem;
347
+ padding: 1rem;
348
+ }
349
+
350
+ input[type="color"] {
351
+ background-color: transparent;
352
+ border: none;
353
+ padding: 0;
354
+ }
355
+ }
356
+ }
357
+
358
+ alchemy-field-array {
359
+ .add-entry {
360
+ @extend .btn;
361
+ margin: 1rem 0 0 1rem;
251
362
  }
252
363
 
253
- .field input[type="color"] {
254
- background-color: transparent;
364
+ button.remove {
365
+ @extend .btn;
366
+ @extend .danger;
367
+ min-width: 6rem;
368
+ margin: 0 1rem 1rem 0;
369
+ }
370
+
371
+ .entries {
372
+ margin-top: 0.5rem;
373
+ }
374
+
375
+ alchemy-field-array-entry:not(:last-of-type) {
376
+ //border-bottom: 1px solid gray;
377
+ position: relative;
378
+
379
+ &::after {
380
+ display: block;
381
+ content: " ";
382
+ background-color: lightgray;
383
+ position: absolute;
384
+ bottom: 0;
385
+ height: 1px;
386
+ left: 50%;
387
+ transform: translateX(-50%);
388
+ width: 80%;
389
+ }
390
+ }
391
+
392
+ alchemy-field-array-entry:not(:first-of-type) {
393
+ margin-top: 1rem;
394
+ }
395
+ }
396
+
397
+ .chimera-editor-widgets {
398
+
399
+ alchemy-widgets-column.toc-col {
400
+ flex: 1 1;
401
+ }
402
+
403
+ table-of-contents[elements-selector="alchemy-field"] {
404
+ align-self: start;
405
+ top: 2rem;
406
+ position: sticky;
407
+
408
+ ol {
409
+ list-style: none;
410
+ margin: 0 0 0 2rem;
411
+ padding: 0;
412
+
413
+ li {
414
+ a {
415
+ display: block;
416
+ line-height: 2rem;
417
+ border-bottom: 1px solid #aaa;
418
+ text-decoration: none;
419
+ opacity: 0.5;
420
+ color: #0070e4;
421
+ }
422
+ }
423
+
424
+ li a.visible {
425
+ opacity: 1;
426
+ }
427
+ }
428
+ }
429
+ }
430
+
431
+ alchemy-field-schema {
432
+ alchemy-field {
255
433
  border: none;
256
- padding: 0;
434
+ margin-bottom: 1rem;
257
435
  }
258
436
  }
259
437
 
File without changes
@@ -69,7 +69,7 @@ Editor.setAction(function index(conduit, model_name) {
69
69
  *
70
70
  * @author Jelle De Loecker <jelle@elevenways.be>
71
71
  * @since 0.1.0
72
- * @version 1.0.1
72
+ * @version 1.0.2
73
73
  *
74
74
  * @param {Conduit} conduit
75
75
  * @param {String} model_name
@@ -97,10 +97,8 @@ Editor.setAction(async function add(conduit, model_name) {
97
97
 
98
98
  return conduit.redirect(url);
99
99
  } catch (err) {
100
- // @TODO: set this in the context somehow?
101
- this.set('record_violations', err);
102
-
103
100
  this.set('context_variables', {
101
+ form_violations : err,
104
102
  record : record
105
103
  });
106
104
  }
@@ -125,7 +123,7 @@ Editor.setAction(async function add(conduit, model_name) {
125
123
  *
126
124
  * @author Jelle De Loecker <jelle@elevenways.be>
127
125
  * @since 0.1.0
128
- * @version 1.0.1
126
+ * @version 1.0.2
129
127
  *
130
128
  * @param {Conduit} conduit
131
129
  * @param {String} model_name
@@ -140,9 +138,9 @@ Editor.setAction(async function edit(conduit, model_name, pk_val) {
140
138
  let record = await model.findByPk(pk_val);
141
139
  let message_type = conduit.param('message');
142
140
 
143
- this.set('context_variables', {
144
- record : record
145
- });
141
+ let context_variables = {
142
+ record,
143
+ };
146
144
 
147
145
  if (conduit.method == 'post') {
148
146
 
@@ -152,11 +150,12 @@ Editor.setAction(async function edit(conduit, model_name, pk_val) {
152
150
  await record.save();
153
151
  message_type = 'saved';
154
152
  } catch (err) {
155
- // @TODO: set this in the context somehow?
156
- this.set('record_violations', err);
153
+ context_variables.form_violations = err;
157
154
  }
158
155
  }
159
156
 
157
+ this.set('context_variables', context_variables);
158
+
160
159
  let widget_config = model.chimera.getWidgetConfig('edit', conduit);
161
160
 
162
161
  if (!widget_config.class_names) {
File without changes
@@ -65,7 +65,7 @@ Config.setMethod(function getFieldSet(name) {
65
65
  *
66
66
  * @author Jelle De Loecker <jelle@elevenways.be>
67
67
  * @since 1.0.0
68
- * @version 1.0.0
68
+ * @version 1.0.2
69
69
  *
70
70
  * @param {String} action
71
71
  * @param {Conduit} conduit
@@ -118,12 +118,43 @@ Config.setMethod(function getWidgetConfig(action, conduit) {
118
118
  "level": 1,
119
119
  "content": this.ModelClass.title + ' edit',
120
120
  }
121
- }, {
122
- "type": "alchemy_form",
123
- "config": {
124
- model : this.ModelClass.type_name,
125
- view_type : 'edit',
126
- widgets : field_widgets
121
+ },
122
+ {
123
+ type: "row",
124
+ config: {
125
+ widgets: [
126
+ {
127
+ type: "column",
128
+ config: {
129
+ widgets: [
130
+ {
131
+ "type": "alchemy_form",
132
+ "config": {
133
+ model : this.ModelClass.type_name,
134
+ view_type : 'edit',
135
+ widgets : field_widgets
136
+ }
137
+ }
138
+ ]
139
+ }
140
+ },
141
+ {
142
+ type: 'column',
143
+ config: {
144
+ wrapper_class_names: 'toc-col',
145
+ widgets: [
146
+ {
147
+ type: "table_of_contents",
148
+ config: {
149
+ parent_selector: 'alchemy-widgets-row',
150
+ elements_selector: 'alchemy-field',
151
+ title_selector: 'alchemy-label'
152
+ }
153
+ }
154
+ ]
155
+ }
156
+ }
157
+ ]
127
158
  }
128
159
  }
129
160
  ]
package/model/model.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "alchemy-chimera",
3
3
  "description": "Chimera plugin for Alchemy MVC",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes