katalyst-content 2.8.1 → 3.0.0.alpha.1

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -2
  3. data/app/assets/builds/katalyst/content.esm.js +61 -3
  4. data/app/assets/builds/katalyst/content.js +61 -3
  5. data/app/assets/builds/katalyst/content.min.js +1 -1
  6. data/app/assets/builds/katalyst/content.min.js.map +1 -1
  7. data/app/assets/images/katalyst/content/icons/aside.svg +1 -0
  8. data/app/assets/images/katalyst/content/icons/collapse.svg +3 -0
  9. data/app/assets/images/katalyst/content/icons/column.svg +1 -0
  10. data/app/assets/images/katalyst/content/icons/content.svg +1 -0
  11. data/app/assets/images/katalyst/content/icons/edit.svg +1 -0
  12. data/app/assets/images/katalyst/content/icons/expand.svg +3 -0
  13. data/app/assets/images/katalyst/content/icons/figure.svg +1 -0
  14. data/app/assets/images/katalyst/content/icons/group.svg +1 -0
  15. data/app/assets/images/katalyst/content/icons/hidden.svg +1 -0
  16. data/app/assets/images/katalyst/content/icons/indent.svg +3 -0
  17. data/app/assets/images/katalyst/content/icons/outdent.svg +4 -0
  18. data/app/assets/images/katalyst/content/icons/remove.svg +1 -0
  19. data/app/assets/images/katalyst/content/icons/section.svg +1 -0
  20. data/app/assets/images/katalyst/content/icons/table.svg +1 -0
  21. data/app/assets/images/katalyst/content/icons/theme.svg +1 -0
  22. data/app/assets/stylesheets/katalyst/_content.scss +4 -0
  23. data/app/assets/stylesheets/katalyst/content/editor.css +196 -0
  24. data/app/assets/stylesheets/katalyst/content/icons.css +79 -0
  25. data/app/assets/stylesheets/katalyst/content/{editor/_status-bar.scss → status-bar.css} +31 -37
  26. data/app/assets/stylesheets/katalyst/content/{editor/_table.scss → table.css} +3 -5
  27. data/app/assets/stylesheets/katalyst/content.css +4 -0
  28. data/app/components/katalyst/content/editor/base_component.rb +0 -6
  29. data/app/components/katalyst/content/editor/item_component.html.erb +31 -15
  30. data/app/components/katalyst/content/editor/item_component.rb +1 -3
  31. data/app/components/katalyst/content/editor/item_editor_component.rb +8 -22
  32. data/app/components/katalyst/content/editor/new_item_component.html.erb +13 -10
  33. data/app/components/katalyst/content/editor/new_item_component.rb +7 -8
  34. data/app/components/katalyst/content/editor/new_items_component.html.erb +40 -18
  35. data/app/components/katalyst/content/editor/new_items_component.rb +0 -2
  36. data/app/components/katalyst/content/editor/row_component.html.erb +2 -1
  37. data/app/components/katalyst/content/editor/status_bar_component.rb +9 -11
  38. data/app/components/katalyst/content/editor/table_component.html.erb +0 -6
  39. data/app/components/katalyst/content/editor/table_component.rb +12 -12
  40. data/app/components/katalyst/content/editor_component.html.erb +5 -0
  41. data/app/components/katalyst/content/editor_component.rb +12 -11
  42. data/app/controllers/katalyst/content/items_controller.rb +0 -1
  43. data/app/javascript/content/application.js +5 -0
  44. data/app/javascript/content/editor/item.js +1 -1
  45. data/app/javascript/content/editor/item_editor_controller.js +57 -0
  46. data/app/javascript/content/editor/new_items_controller.js +1 -4
  47. data/app/views/katalyst/content/asides/_aside.html+form.erb +22 -26
  48. data/app/views/katalyst/content/columns/_column.html+form.erb +18 -22
  49. data/app/views/katalyst/content/contents/_content.html+form.erb +22 -26
  50. data/app/views/katalyst/content/figures/_figure.html+form.erb +27 -31
  51. data/app/views/katalyst/content/groups/_group.html+form.erb +18 -22
  52. data/app/views/katalyst/content/items/_form.html.erb +6 -0
  53. data/app/views/katalyst/content/items/_item.html+form.erb +18 -22
  54. data/app/views/katalyst/content/items/edit.html.erb +40 -2
  55. data/app/views/katalyst/content/items/edit.turbo_stream.erb +2 -0
  56. data/app/views/katalyst/content/items/update.turbo_stream.erb +0 -1
  57. data/app/views/katalyst/content/sections/_section.html+form.erb +18 -22
  58. data/app/views/katalyst/content/tables/_table.html+form.erb +7 -9
  59. data/lib/katalyst/content/engine.rb +0 -1
  60. metadata +25 -27
  61. data/app/assets/stylesheets/katalyst/content/_index.scss +0 -1
  62. data/app/assets/stylesheets/katalyst/content/editor/_figure.scss +0 -12
  63. data/app/assets/stylesheets/katalyst/content/editor/_icon.scss +0 -17
  64. data/app/assets/stylesheets/katalyst/content/editor/_index.scss +0 -157
  65. data/app/assets/stylesheets/katalyst/content/editor/_item-actions.scss +0 -110
  66. data/app/assets/stylesheets/katalyst/content/editor/_item-rules.scss +0 -19
  67. data/app/assets/stylesheets/katalyst/content/editor/_new-items.scss +0 -160
  68. data/app/assets/stylesheets/katalyst/content/editor/_trix-rails.scss +0 -30
  69. data/app/assets/stylesheets/katalyst/content/editor/_variables.scss +0 -26
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3H1m14 5H1m9.411 5H1"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m10.1 3.1 2.8 2.8m1.522-1.531a1.973 1.973 0 0 0-2.79-2.791l-9.343 9.344a1.4 1.4 0 0 0-.35.581l-.924 3.047a.35.35 0 0 0 .436.435l3.047-.924a1.4 1.4 0 0 0 .58-.348z"/></svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 16" fill="none">
2
+ <path d="M11 10L6 15L1 10M1 6L6 1L11 6" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 10.333-2.4-2.4a1.556 1.556 0 0 0-2.2 0L3.333 15M2.556 1h10.888C14.304 1 15 1.696 15 2.556v10.888c0 .86-.696 1.556-1.556 1.556H2.556C1.696 15 1 14.304 1 13.444V2.556C1 1.696 1.696 1 2.556 1m4.666 4.667a1.556 1.556 0 1 1-3.11 0 1.556 1.556 0 0 1 3.11 0"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 4.111V2.556C1 1.7 1.7 1 2.556 1H4.11m7.778 0h1.555C14.3 1 15 1.7 15 2.556V4.11m0 7.778v1.555C15 14.3 14.3 15 13.444 15H11.89m-7.78 0H2.556A1.56 1.56 0 0 1 1 13.444V11.89m3.889-7.78h3.889c.43 0 .778.348.778.778v2.333c0 .43-.349.778-.778.778h-3.89a.78.78 0 0 1-.777-.778V4.89c0-.43.348-.778.778-.778M7.222 8h3.89c.429 0 .777.348.777.778v2.333c0 .43-.348.778-.778.778H7.222a.78.78 0 0 1-.778-.778V8.778c0-.43.349-.778.778-.778"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7.113 3.153a7.52 7.52 0 0 1 7.843 4.603.7.7 0 0 1 0 .487 7.5 7.5 0 0 1-1.01 1.743M9.458 9.51a2.1 2.1 0 0 1-2.97-2.97m5.346 5.308A7.525 7.525 0 0 1 1.044 8.244a.7.7 0 0 1 0-.488 7.53 7.53 0 0 1 3.112-3.6M1 1l14 14"/></svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none">
2
+ <path d="M15 1V15M6 2L12 8L6 14M10 8H1" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none">
2
+ <path d="M1 1V15M10 2L4 8L10 14M6 8H15" stroke="black" stroke-width="2" stroke-linecap="round"
3
+ stroke-linejoin="round"/>
4
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 4h12m-1.333 0v9.333c0 .667-.667 1.334-1.334 1.334H3.667c-.667 0-1.334-.667-1.334-1.334V4m2 0V2.667C4.333 2 5 1.333 5.667 1.333h2.666C9 1.333 9.667 2 9.667 2.667V4"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2 13.25V2.75c0-.464.198-.91.55-1.237A1.95 1.95 0 0 1 3.874 1h9.375c.199 0 .39.074.53.205s.22.31.22.495v12.6a.68.68 0 0 1-.22.495.78.78 0 0 1-.53.205H3.875c-.497 0-.974-.184-1.326-.513A1.7 1.7 0 0 1 2 13.25m0 0c0-.464.198-.91.55-1.237a1.95 1.95 0 0 1 1.325-.513H14M5 7.3h6M5 4.5h4.5"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 1v14M1 8h14M3 1h10c1 0 2 1 2 2v10c0 1-1 2-2 2H3c-1 0-2-1-2-2V3c0-1 1-2 2-2"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.111 15a3.11 3.11 0 0 0 3.111-3.111V2.556A1.556 1.556 0 0 0 5.667 1H2.556A1.556 1.556 0 0 0 1 2.556v9.333A3.11 3.11 0 0 0 4.111 15m0 0h9.333A1.556 1.556 0 0 0 15 13.444v-3.11a1.556 1.556 0 0 0-1.556-1.556h-1.788m-7.545 3.11h.008m3.103-7L9.012 3.1a1.867 1.867 0 0 1 2.647.003l1.474 1.475a1.867 1.867 0 0 1 .02 2.67l-6.786 6.819"/></svg>
@@ -0,0 +1,4 @@
1
+ @use "content/editor";
2
+ @use "content/icons";
3
+ @use "content/status-bar";
4
+ @use "content/table";
@@ -0,0 +1,196 @@
1
+ .content--editor {
2
+ --row-inset: 2rem;
3
+ --row-hover-bg: var(--color-tint, #fff0eb);
4
+ --row-padding: 0 var(--space-2xs, 0.25rem);
5
+
6
+ position: relative;
7
+ }
8
+
9
+ /* Rows */
10
+
11
+ .content--editor--item {
12
+ /* https://github.com/react-dnd/react-dnd/issues/832 */
13
+ transform: translate3d(0, 0, 0);
14
+
15
+ &:hover {
16
+ background: var(--row-hover-bg);
17
+ }
18
+
19
+ &[draggable] {
20
+ cursor: grab;
21
+ }
22
+
23
+ /* Dragged visuals */
24
+
25
+ &[data-dragging] {
26
+ box-shadow: inset 0 0 0 2px var(--color-tint, #fff0eb);
27
+
28
+ > * {
29
+ visibility: hidden;
30
+ }
31
+ }
32
+
33
+ /* Hidden items */
34
+
35
+ [data-invisible] {
36
+ color: var(--color-mid, #aaa);
37
+ }
38
+
39
+ /* row item controller */
40
+
41
+ > [data-controller] {
42
+ display: grid;
43
+ grid-template-columns: 1fr auto;
44
+ align-items: baseline;
45
+ padding: var(--row-padding);
46
+ }
47
+
48
+ /* row content */
49
+
50
+ .tree {
51
+ display: flex;
52
+ gap: var(--space-xs, 0.5rem);
53
+ align-items: baseline;
54
+
55
+ text-overflow: ellipsis;
56
+ overflow: hidden;
57
+ white-space: nowrap;
58
+ }
59
+
60
+ .actions-group {
61
+ display: flex;
62
+ gap: var(--space-3xs, 0.25em);
63
+ align-items: baseline;
64
+ }
65
+
66
+ /* Theme identifier */
67
+
68
+ .item-background {
69
+ display: inline-flex;
70
+ background-color: var(--theme-background-color);
71
+ color: var(--theme-text-color);
72
+ aspect-ratio: 1;
73
+ padding: var(--space-3xs);
74
+ border-radius: var(--radius-s);
75
+ }
76
+
77
+ .item-background.light {
78
+ --theme-text-color: black;
79
+ --theme-background-color: white;
80
+ }
81
+
82
+ .item-background.dark {
83
+ --theme-text-color: white;
84
+ --theme-background-color: black;
85
+ }
86
+
87
+ /* Depth */
88
+
89
+ &[data-content-depth="1"] .tree {
90
+ padding-left: calc(var(--row-inset) * 1);
91
+ }
92
+
93
+ &[data-content-depth="2"] .tree {
94
+ padding-left: calc(var(--row-inset) * 2);
95
+ }
96
+
97
+ &[data-content-depth="3"] .tree {
98
+ padding-left: calc(var(--row-inset) * 3);
99
+ }
100
+
101
+ &[data-content-depth="4"] .tree {
102
+ padding-left: calc(var(--row-inset) * 4);
103
+ }
104
+
105
+ &[data-content-depth="5"] .tree {
106
+ padding-left: calc(var(--row-inset) * 5);
107
+ }
108
+
109
+ &[data-content-depth="6"] .tree {
110
+ padding-left: calc(var(--row-inset) * 6);
111
+ }
112
+
113
+ /* Lower opacity for buttons you can't use */
114
+
115
+ &[data-deny-de-nest] .button:has([data-icon="outdent"]),
116
+ &[data-deny-nest] .button:has([data-icon="indent"]),
117
+ &[data-deny-remove] .button:has([data-icon="remove"]),
118
+ &[data-deny-drag] .button:has([data-icon="drag"]),
119
+ &[data-deny-edit] .button:has([data-icon="edit"]) {
120
+ opacity: 0.2;
121
+ pointer-events: none;
122
+ }
123
+
124
+ &:not(:hover) .actions-group .button {
125
+ opacity: 0;
126
+ }
127
+
128
+ /* Only show 1 of the collapse / expand button */
129
+
130
+ &[data-deny-collapse] .button:has([data-icon="collapse"]),
131
+ &[data-deny-expand] .button:has([data-icon="expand"]) {
132
+ display: none !important;
133
+ pointer-events: none;
134
+ }
135
+
136
+ /* Always show the expand button when there are hidden children */
137
+
138
+ &:has([data-content-children]) .button:has([data-icon="expand"]) {
139
+ opacity: 1 !important;
140
+ }
141
+ }
142
+
143
+ /* Inline add link */
144
+
145
+ .content--editor--inline-add {
146
+ position: absolute;
147
+ left: 0;
148
+ right: 0;
149
+ top: 0;
150
+ height: 0;
151
+ z-index: 1;
152
+ outline: 1px solid var(--color-dark-glare, #555);
153
+
154
+ button {
155
+ position: absolute;
156
+ top: 0;
157
+ left: 50%;
158
+ margin: 0;
159
+ padding: 0.25rem;
160
+
161
+ animation: content--editor--pulse 200ms ease;
162
+ transform: translate(-50%, -50%) scale(1);
163
+ }
164
+
165
+ button:active {
166
+ transform: translate(-50%, -50%) scale(99%);
167
+ }
168
+
169
+ &[hidden] button {
170
+ transform: translate(-50%, -50%) scale(0);
171
+ }
172
+ }
173
+
174
+ @keyframes content--editor--pulse {
175
+ 0% {
176
+ transform: translate(-50%, -50%) scale(0);
177
+ }
178
+
179
+ 80% {
180
+ transform: translate(-50%, -50%) scale(1.1);
181
+ }
182
+
183
+ 100% {
184
+ transform: translate(-50%, -50%) scale(1);
185
+ }
186
+ }
187
+
188
+ /* New items picker */
189
+
190
+ .content--editor--new-items {
191
+ .items-list {
192
+ display: flex;
193
+ gap: var(--space-2xs, 0.25rem);
194
+ flex-wrap: wrap;
195
+ }
196
+ }
@@ -0,0 +1,79 @@
1
+ .content--editor {
2
+ [data-icon="outdent"] {
3
+ -webkit-mask: url("/katalyst/content/icons/outdent.svg");
4
+ mask: url("/katalyst/content/icons/outdent.svg");
5
+ }
6
+
7
+ [data-icon="indent"] {
8
+ -webkit-mask: url("/katalyst/content/icons/indent.svg");
9
+ mask: url("/katalyst/content/icons/indent.svg");
10
+ }
11
+
12
+ [data-icon="collapse"] {
13
+ -webkit-mask: url("/katalyst/content/icons/collapse.svg");
14
+ mask: url("/katalyst/content/icons/collapse.svg");
15
+ aspect-ratio: 12/16;
16
+ }
17
+
18
+ [data-icon="expand"] {
19
+ -webkit-mask: url("/katalyst/content/icons/expand.svg") no-repeat center;
20
+ mask: url("/katalyst/content/icons/expand.svg") no-repeat center;
21
+ aspect-ratio: 12/16;
22
+ }
23
+
24
+ [data-icon="edit"] {
25
+ -webkit-mask: url("/katalyst/content/icons/edit.svg");
26
+ mask: url("/katalyst/content/icons/edit.svg");
27
+ }
28
+
29
+ [data-icon="remove"] {
30
+ -webkit-mask: url("/katalyst/content/icons/remove.svg");
31
+ mask: url("/katalyst/content/icons/remove.svg");
32
+ aspect-ratio: 14/16;
33
+ }
34
+
35
+ [data-icon="hidden"] {
36
+ -webkit-mask: url("/katalyst/content/icons/hidden.svg");
37
+ mask: url("/katalyst/content/icons/hidden.svg");
38
+ }
39
+
40
+ [data-icon="theme"] {
41
+ -webkit-mask: url("/katalyst/content/icons/theme.svg") no-repeat center;
42
+ mask: url("/katalyst/content/icons/theme.svg") no-repeat center;
43
+ }
44
+
45
+ [data-icon="content"] {
46
+ -webkit-mask: url("/katalyst/content/icons/content.svg");
47
+ mask: url("/katalyst/content/icons/content.svg");
48
+ }
49
+
50
+ [data-icon="figure"] {
51
+ -webkit-mask: url("/katalyst/content/icons/figure.svg") no-repeat center;
52
+ mask: url("/katalyst/content/icons/figure.svg") no-repeat center;
53
+ }
54
+
55
+ [data-icon="table"] {
56
+ -webkit-mask: url("/katalyst/content/icons/table.svg") no-repeat center;
57
+ mask: url("/katalyst/content/icons/table.svg") no-repeat center;
58
+ }
59
+
60
+ [data-icon="section"] {
61
+ -webkit-mask: url("/katalyst/content/icons/section.svg") no-repeat center;
62
+ mask: url("/katalyst/content/icons/section.svg") no-repeat center;
63
+ }
64
+
65
+ [data-icon="group"] {
66
+ -webkit-mask: url("/katalyst/content/icons/group.svg") no-repeat center;
67
+ mask: url("/katalyst/content/icons/group.svg") no-repeat center;
68
+ }
69
+
70
+ [data-icon="column"] {
71
+ -webkit-mask: url("/katalyst/content/icons/column.svg") no-repeat center;
72
+ mask: url("/katalyst/content/icons/column.svg") no-repeat center;
73
+ }
74
+
75
+ [data-icon="aside"] {
76
+ -webkit-mask: url("/katalyst/content/icons/aside.svg") no-repeat center;
77
+ mask: url("/katalyst/content/icons/aside.svg") no-repeat center;
78
+ }
79
+ }
@@ -1,25 +1,39 @@
1
1
  [data-controller="content--editor--status-bar"] {
2
+ --background: #ebf9eb;
3
+ --color: #4dd45c;
4
+ --border: #4dd45c;
5
+
6
+ display: grid;
7
+ grid-template-columns: 1fr auto;
8
+ grid-template-areas: "status actions";
9
+ align-items: baseline;
10
+ grid-column-gap: 2rem;
11
+
2
12
  min-height: 3rem;
3
13
  line-height: 3rem;
4
- padding: 0 1.25rem 0 1.5rem;
14
+ padding-inline: var(--space-m);
5
15
  background: var(--background);
6
16
  color: var(--color);
7
17
  border: 1px solid var(--border);
8
18
  margin-bottom: 1rem;
9
- white-space: nowrap;
10
19
 
11
- display: grid;
12
- grid-template-columns: 1fr auto;
13
- grid-template-areas: "status actions";
14
- align-items: baseline;
20
+ &[data-state="draft"],
21
+ &[data-state="unpublished"] {
22
+ --background: #fefaf3;
23
+ --color: #ffa800;
24
+ --border: #ffa800;
25
+ }
26
+
27
+ &[data-state="dirty"] {
28
+ --background: #eee;
29
+ --color: #aaa;
30
+ --border: #888;
31
+ }
15
32
 
16
33
  .status-text {
17
34
  display: none;
18
35
  grid-area: status;
19
36
  font-weight: bold;
20
- color: var(--color);
21
- overflow: hidden;
22
- text-overflow: ellipsis;
23
37
  }
24
38
 
25
39
  &[data-state="published"] .status-text[data-published],
@@ -29,44 +43,24 @@
29
43
  display: unset;
30
44
  }
31
45
 
46
+ button {
47
+ --button-bg: var(--color);
48
+ --button-hover-bg: var(--color);
49
+ }
50
+
32
51
  menu {
33
- display: inline;
52
+ display: inline-flex;
34
53
  grid-area: actions;
35
54
  margin: 0;
36
55
  padding: 0;
56
+ gap: var(--space-3xs, 0.25rem);
57
+ align-items: baseline;
37
58
  }
38
59
 
39
60
  menu > li {
40
61
  display: inline;
41
62
  }
42
63
 
43
- .button {
44
- color: inherit;
45
- line-height: 1rem;
46
- margin-left: 0.5rem;
47
- }
48
-
49
- .button--primary {
50
- background: var(--color);
51
- border: 1px solid var(--border);
52
- color: white;
53
-
54
- &[disabled] {
55
- background: var(--color);
56
- opacity: 0.8;
57
- }
58
- }
59
-
60
- .button--secondary {
61
- background: var(--background);
62
- border: 1px solid var(--border);
63
- color: var(--color);
64
-
65
- &[disabled] {
66
- background: var(--background);
67
- }
68
- }
69
-
70
64
  &[data-state="published"] {
71
65
  [value="publish"],
72
66
  [value="save"],
@@ -1,5 +1,3 @@
1
- @use "variables" as *;
2
-
3
1
  [data-content--editor--table-target="content"] {
4
2
  position: relative;
5
3
  min-height: 8rem;
@@ -26,17 +24,17 @@
26
24
 
27
25
  th,
28
26
  td {
29
- border: 1px solid $grey;
27
+ border: 1px solid var(--color-mid, #9ca3af);
30
28
  padding: 0.25rem 0.5rem;
31
29
  text-align: left;
32
30
  vertical-align: top;
33
31
  }
34
32
 
35
33
  thead {
36
- background-color: $grey;
34
+ background-color: var(--color-mid, #9ca3af);
37
35
  }
38
36
 
39
37
  tbody th {
40
- background-color: $grey-light;
38
+ background-color: var(--color-tint, #f0ecf3);
41
39
  }
42
40
  }
@@ -0,0 +1,4 @@
1
+ @import url("content/editor.css");
2
+ @import url("content/icons.css");
3
+ @import url("content/status-bar.css");
4
+ @import url("content/table.css");
@@ -6,12 +6,6 @@ module Katalyst
6
6
  class BaseComponent < ViewComponent::Base
7
7
  include Katalyst::HtmlAttributes
8
8
 
9
- CONTAINER_CONTROLLER = "content--editor--container"
10
- LIST_CONTROLLER = "content--editor--list"
11
- ITEM_CONTROLLER = "content--editor--item"
12
- STATUS_BAR_CONTROLLER = "content--editor--status-bar"
13
- NEW_ITEMS_CONTROLLER = "content--editor--new-items"
14
-
15
9
  attr_accessor :container, :item
16
10
 
17
11
  delegate :config, to: ::Katalyst::Content
@@ -1,22 +1,38 @@
1
1
  <%= tag.div(**html_attributes) do %>
2
- <div class="tree" data-invisible="<%= !item.visible? %>">
3
- <div role="toolbar" data-tree-accordion-controls>
4
- <span role="button" value="collapse" data-action="click-><%= CONTAINER_CONTROLLER %>#collapse" title="Collapse tree"></span>
5
- <span role="button" value="expand" data-action="click-><%= CONTAINER_CONTROLLER %>#expand" title="Expand tree"></span>
6
- </div>
2
+ <div class="tree">
3
+ <icon class="icon" data-icon="<%= item.model_name.param_key %>" aria-hidden="true">&nbsp;</icon>
7
4
 
8
- <span role="img" value="<%= item.model_name.param_key %>" title="Type"></span>
9
- <h4 class="heading" title="<%= item.heading %>"><%= item.heading %></h4>
10
- <span role="img" value="invisible" title="Hidden"></span>
11
- </div>
5
+ <strong class="heading" title="<%= item.heading %>"><%= item.heading %></strong>
6
+
7
+ <span class="item-background <%= item.background %>">
8
+ <icon class="icon" data-icon="theme" role="img">&nbsp;</icon>
9
+ </span>
12
10
 
13
- <div class="item-background <%= item.background %>"></div>
11
+ <% unless item.visible? %>
12
+ <icon class="icon" data-icon="hidden" title="Hidden" role="img">&nbsp;</icon>
13
+ <% end %>
14
+ </div>
14
15
 
15
- <div role="toolbar" data-tree-controls>
16
- <span role="button" value="de-nest" data-action="click-><%= CONTAINER_CONTROLLER %>#deNest" title="Outdent"></span>
17
- <span role="button" value="nest" data-action="click-><%= CONTAINER_CONTROLLER %>#nest" title="Indent"></span>
18
- <%= kpop_link_to("", edit_item_link, role: "button", title: "Edit", value: "edit") %>
19
- <span role="button" value="remove" data-action="click-><%= CONTAINER_CONTROLLER %>#remove" title="Remove"></span>
16
+ <div role="toolbar" class="actions-group">
17
+ <button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#collapse" title="Collapse tree">
18
+ <icon class="icon" data-icon="collapse" role="img">&nbsp;</icon>
19
+ </button>
20
+ <button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#expand" title="Expand tree">
21
+ <icon class="icon" data-icon="expand" role="img">&nbsp;</icon>
22
+ </button>
23
+ <button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#deNest" title="Outdent">
24
+ <icon class="icon" data-icon="outdent" role="img">&nbsp;</icon>
25
+ </button>
26
+ <button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#nest" title="Indent">
27
+ <icon class="icon" data-icon="indent" role="img">&nbsp;</icon>
28
+ </button>
29
+ <%= link_to(edit_item_link, class: "button", title: "Edit", value: "edit",
30
+ data: { text_button: "", button_padding: "tight", turbo_frame: "content--editor--item-editor" }) do %>
31
+ <icon class="icon" data-icon="edit" role="img">&nbsp;</icon>
32
+ <% end %>
33
+ <button class="button" data-button-padding="tight" data-text-button data-action="content--editor--container#remove" title="Remove">
34
+ <icon class="icon" data-icon="remove" role="img">&nbsp;</icon>
35
+ </button>
20
36
  </div>
21
37
 
22
38
  <input autocomplete="off" type="hidden" name="<%= attributes_scope %>[id]" value="<%= item.id %>">
@@ -4,8 +4,6 @@ module Katalyst
4
4
  module Content
5
5
  module Editor
6
6
  class ItemComponent < BaseComponent
7
- include KpopHelper
8
-
9
7
  def edit_item_link
10
8
  if item.persisted?
11
9
  helpers.katalyst_content.edit_item_path(item)
@@ -20,7 +18,7 @@ module Katalyst
20
18
  {
21
19
  id: dom_id(item),
22
20
  data: {
23
- controller: ITEM_CONTROLLER,
21
+ controller: "content--editor--item",
24
22
  },
25
23
  }
26
24
  end
@@ -6,25 +6,18 @@ module Katalyst
6
6
  class ItemEditorComponent < BaseComponent
7
7
  include ::Turbo::FramesHelper
8
8
 
9
- module Helpers
10
- def prefix_partial_path_with_controller_namespace
11
- false
12
- end
13
-
14
- def content_routes
15
- katalyst_content
16
- end
17
- end
9
+ alias_method :model, :item
18
10
 
19
11
  def call
20
- tag.div(**html_attributes) do
21
- helpers.extend(Helpers)
22
- helpers.render(item, path:)
23
- end
12
+ render("form", model:, scope:, url:, id:)
24
13
  end
25
14
 
26
15
  def id
27
- "item-editor-#{item.id}"
16
+ dom_id(item, :form)
17
+ end
18
+
19
+ def scope
20
+ :item
28
21
  end
29
22
 
30
23
  def title
@@ -35,20 +28,13 @@ module Katalyst
35
28
  end
36
29
  end
37
30
 
38
- def path
31
+ def url
39
32
  if item.persisted?
40
33
  view_context.katalyst_content.item_path(item)
41
34
  else
42
35
  view_context.katalyst_content.items_path
43
36
  end
44
37
  end
45
-
46
- def default_html_attributes
47
- {
48
- id:,
49
- class: "content--item-editor",
50
- }
51
- end
52
38
  end
53
39
  end
54
40
  end
@@ -1,12 +1,15 @@
1
- <%= tag.button(**html_attributes) do %>
2
- <%= label %>
3
- <%#
1
+ <li>
2
+ <%= tag.button(**html_attributes) do %>
3
+ <icon class="icon" data-icon="<%= icon_name %>" role="img">&nbsp;</icon>
4
+ <%= label %>
5
+ <%#
4
6
  # Template is stored inside the new item dom, and copied into the dom when
5
7
  # the user selects the item.
6
- %>
7
- <template>
8
- <%= render row_component do %>
9
- <%= render item_component %>
10
- <% end %>
11
- </template>
12
- <% end %>
8
+ %>
9
+ <template>
10
+ <%= render row_component do %>
11
+ <%= render item_component %>
12
+ <% end %>
13
+ </template>
14
+ <% end %>
15
+ </li>
@@ -8,10 +8,6 @@ module Katalyst
8
8
 
9
9
  with_collection_parameter :item
10
10
 
11
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
12
- #{NEW_ITEMS_CONTROLLER}#add
13
- ACTIONS
14
-
15
11
  def initialize(item:, container: item.container)
16
12
  super
17
13
  end
@@ -32,14 +28,17 @@ module Katalyst
32
28
  item.model_name.param_key
33
29
  end
34
30
 
31
+ alias icon_name item_type
32
+
35
33
  private
36
34
 
37
35
  def default_html_attributes
38
36
  {
39
- role: "listitem",
40
- data: {
41
- item_type:,
42
- action: ACTIONS,
37
+ class: "button",
38
+ role: "listitem",
39
+ data: {
40
+ ghost_button: "",
41
+ action: "content--editor--new-items#add",
43
42
  },
44
43
  }
45
44
  end