active_admin_prism 0.1.1 → 0.1.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +121 -0
- data/INTEGRATION.md +324 -14
- data/README.md +49 -0
- data/app/assets/javascripts/active_admin_prism/prism.js +3 -1
- data/app/assets/stylesheets/active_admin_prism/prism.css +1 -1
- data/app/views/layouts/active_admin_logged_out.html.erb +76 -0
- data/js-src/prism.js +141 -6
- data/lib/active_admin/views/active_filters_bar.rb +94 -0
- data/lib/active_admin/views/flash_messages.rb +45 -25
- data/lib/active_admin/views/prism_sidebar.rb +35 -3
- data/lib/active_admin_prism/configuration.rb +53 -0
- data/lib/active_admin_prism/version.rb +1 -1
- data/lib/active_admin_prism.rb +1 -0
- data/lib/prism_icons.rb +26 -1
- data/scss-src/_base.scss +161 -24
- data/scss-src/_forms.scss +35 -4
- data/scss-src/_login.scss +5 -4
- data/scss-src/_panels.scss +172 -0
- data/scss-src/_select2.scss +281 -0
- data/scss-src/_select2_vendor.scss +695 -0
- data/scss-src/_sidebar.scss +145 -4
- data/scss-src/_variables.scss +3 -0
- data/scss-src/prism.scss +2 -0
- data/vendor/select2/LICENSE.md +21 -0
- data/vendor/select2/select2.full.min.js +2 -0
- metadata +9 -6
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// Reskins Select2 (https://select2.org) — the jQuery widget commonly wired
|
|
2
|
+
// up for searchable belongs_to filters/inputs (host apps opt individual
|
|
3
|
+
// selects in with `input_html: { class: "your-select2-class" }` plus their
|
|
4
|
+
// own `.select2()` call; this gem does not ship the JS itself, only the
|
|
5
|
+
// CSS, since Select2 is an opt-in add-on rather than something AA bundles).
|
|
6
|
+
//
|
|
7
|
+
// Select2 replaces the (now hidden) <select> with its own
|
|
8
|
+
// `.select2-container` markup, so the plain `select { ... }` rules in
|
|
9
|
+
// _forms.scss (and the `.sidebar_section select` / `.filter_form_field`
|
|
10
|
+
// width rules) never reach it — every width/sizing/theming rule the
|
|
11
|
+
// original select relied on needs a `.select2-container` equivalent here.
|
|
12
|
+
// Without this file, a Select2-enhanced select renders at its unstyled
|
|
13
|
+
// default size (far narrower than the surrounding fields) and its open
|
|
14
|
+
// dropdown can visually clash with the theme entirely.
|
|
15
|
+
.select2-container {
|
|
16
|
+
display: block;
|
|
17
|
+
font-family: $prism-font-family;
|
|
18
|
+
|
|
19
|
+
.select2-selection--single {
|
|
20
|
+
height: auto;
|
|
21
|
+
border: 1px solid $prism-border-color-strong;
|
|
22
|
+
border-radius: $prism-radius-sm;
|
|
23
|
+
background: $prism-bg-card;
|
|
24
|
+
padding: 9px 32px 9px 12px;
|
|
25
|
+
transition: border-color $prism-transition-fast, box-shadow $prism-transition-fast;
|
|
26
|
+
|
|
27
|
+
.select2-selection__rendered {
|
|
28
|
+
padding: 0;
|
|
29
|
+
color: $prism-text-heading;
|
|
30
|
+
line-height: 1.4;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.select2-selection__placeholder {
|
|
34
|
+
color: $prism-text-muted;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.select2-selection__arrow {
|
|
38
|
+
height: 100%;
|
|
39
|
+
top: 0;
|
|
40
|
+
right: 8px;
|
|
41
|
+
|
|
42
|
+
b {
|
|
43
|
+
border-color: $prism-text-muted transparent transparent transparent;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&--open .select2-selection--single {
|
|
49
|
+
border-color: $prism-color-primary;
|
|
50
|
+
box-shadow: 0 0 0 3px rgba($prism-color-primary, 0.15);
|
|
51
|
+
|
|
52
|
+
.select2-selection__arrow b {
|
|
53
|
+
border-color: transparent transparent $prism-text-muted transparent;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&--disabled .select2-selection--single {
|
|
58
|
+
background: $prism-bg-page;
|
|
59
|
+
color: $prism-text-muted;
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.select2-selection__clear {
|
|
64
|
+
position: static;
|
|
65
|
+
margin: 0 4px 0 0;
|
|
66
|
+
height: auto;
|
|
67
|
+
color: $prism-text-muted;
|
|
68
|
+
font-weight: 700;
|
|
69
|
+
|
|
70
|
+
&:hover {
|
|
71
|
+
color: $prism-color-danger;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Multi-select ("tags") mode — e.g. `f.input :subjects, as: :select2,
|
|
76
|
+
// multiple: true` in place of `as: :check_boxes`. Select2's own default
|
|
77
|
+
// theme lays this out with absolute-positioned remove buttons and
|
|
78
|
+
// per-choice margins (see its own select2-selection--multiple rules) —
|
|
79
|
+
// overridden wholesale here with a flex-wrapped row of pill chips,
|
|
80
|
+
// consistent with the toggle/badge look elsewhere in this theme, rather
|
|
81
|
+
// than patched piecemeal on top of that positioning.
|
|
82
|
+
.select2-selection--multiple {
|
|
83
|
+
min-height: auto;
|
|
84
|
+
border: 1px solid $prism-border-color-strong;
|
|
85
|
+
border-radius: $prism-radius-sm;
|
|
86
|
+
background: $prism-bg-card;
|
|
87
|
+
padding: 6px 8px;
|
|
88
|
+
cursor: text;
|
|
89
|
+
transition: border-color $prism-transition-fast, box-shadow $prism-transition-fast;
|
|
90
|
+
|
|
91
|
+
.select2-selection__rendered {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-wrap: wrap;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: 6px;
|
|
96
|
+
padding: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.select2-selection__placeholder {
|
|
100
|
+
color: $prism-text-muted;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.select2-selection__choice {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 4px;
|
|
107
|
+
position: static;
|
|
108
|
+
max-width: 100%;
|
|
109
|
+
margin: 0;
|
|
110
|
+
padding: 3px 6px 3px 10px;
|
|
111
|
+
border: none;
|
|
112
|
+
border-radius: $prism-radius-pill;
|
|
113
|
+
background: $prism-color-primary-light;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.select2-selection__choice__display {
|
|
118
|
+
padding: 0;
|
|
119
|
+
color: $prism-color-primary-dark;
|
|
120
|
+
font-weight: 600;
|
|
121
|
+
font-size: 0.85em;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
text-overflow: ellipsis;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.select2-selection__choice__remove {
|
|
127
|
+
position: static;
|
|
128
|
+
border: none;
|
|
129
|
+
border-radius: 50%;
|
|
130
|
+
background: transparent;
|
|
131
|
+
color: $prism-color-primary-dark;
|
|
132
|
+
font-weight: 700;
|
|
133
|
+
line-height: 1;
|
|
134
|
+
padding: 2px;
|
|
135
|
+
|
|
136
|
+
&:hover,
|
|
137
|
+
&:focus {
|
|
138
|
+
background: rgba($prism-color-primary-dark, 0.15);
|
|
139
|
+
color: $prism-color-primary-dark;
|
|
140
|
+
outline: none;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.select2-selection__clear {
|
|
145
|
+
position: static;
|
|
146
|
+
margin: 0 0 0 auto;
|
|
147
|
+
height: auto;
|
|
148
|
+
color: $prism-text-muted;
|
|
149
|
+
font-weight: 700;
|
|
150
|
+
|
|
151
|
+
&:hover {
|
|
152
|
+
color: $prism-color-danger;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.select2-search--inline .select2-search__field {
|
|
157
|
+
margin: 0;
|
|
158
|
+
padding: 3px 2px;
|
|
159
|
+
min-height: 0;
|
|
160
|
+
height: auto;
|
|
161
|
+
color: $prism-text-heading;
|
|
162
|
+
font-family: $prism-font-family;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&--focus .select2-selection--multiple,
|
|
167
|
+
&--open .select2-selection--multiple {
|
|
168
|
+
border-color: $prism-color-primary;
|
|
169
|
+
box-shadow: 0 0 0 3px rgba($prism-color-primary, 0.15);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&--disabled .select2-selection--multiple {
|
|
173
|
+
background: $prism-bg-page;
|
|
174
|
+
|
|
175
|
+
.select2-selection__choice {
|
|
176
|
+
opacity: 0.75;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.select2-selection__choice__remove {
|
|
180
|
+
display: none;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Sidebar Filters panel and the standalone filter form both stack the
|
|
186
|
+
// label above the field (no float) and size the underlying <select> to
|
|
187
|
+
// fill it — same treatment for its Select2 replacement (see the
|
|
188
|
+
// equivalent `select` rules in _forms.scss).
|
|
189
|
+
.sidebar_section .select2-container,
|
|
190
|
+
form.filter_form .select2-container {
|
|
191
|
+
width: 100% !important;
|
|
192
|
+
box-sizing: border-box;
|
|
193
|
+
max-width: 100%;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
form.filter_form .filter_form_field.select_and_search .select2-container {
|
|
197
|
+
width: auto !important;
|
|
198
|
+
min-width: 0;
|
|
199
|
+
flex: 1 1 0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Main "fieldset.inputs" form: ActiveAdmin's own _forms.scss floats the
|
|
203
|
+
// label left at 20% width and gives text inputs an explicit
|
|
204
|
+
// width: calc(80% - 22px) so they sit in the remaining space beside it —
|
|
205
|
+
// a value this gem has no access to at compile time (it's compiled
|
|
206
|
+
// standalone, without AA's own SCSS variables/mixins in its load path; see
|
|
207
|
+
// bin/build-css), so it's matched here as a literal instead.
|
|
208
|
+
//
|
|
209
|
+
// A block-formatting-context trick (overflow: hidden, no explicit width)
|
|
210
|
+
// looks like it should get the same result for free — per the CSS spec, a
|
|
211
|
+
// BFC-establishing box must not overlap a preceding float's margin box —
|
|
212
|
+
// but it only actually sizes the box when its width is auto. Select2 sets
|
|
213
|
+
// an inline `width: 100%` directly on `.select2-container` itself
|
|
214
|
+
// (prism.js's own auto-init passes `{ width: "100%" }`, and jQuery's
|
|
215
|
+
// .css("width", ...) call is what select2.js uses under the hood even for
|
|
216
|
+
// a host's own manual `.select2()` call left at its default width option),
|
|
217
|
+
// so that inline 100% is never auto and the BFC sizing never kicks in —
|
|
218
|
+
// the container renders full-width *underneath* the floated label instead
|
|
219
|
+
// of beside it. `!important` is required here to beat that inline style.
|
|
220
|
+
form fieldset.inputs li.select > .select2-container {
|
|
221
|
+
display: inline-block;
|
|
222
|
+
width: calc(80% - 22px) !important;
|
|
223
|
+
vertical-align: middle;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Any select Select2 has not (yet) enhanced — it hides the real one via a
|
|
227
|
+
// 1px offscreen technique once active, so this only matches before that,
|
|
228
|
+
// or if it's disabled/skipped entirely — needs the same geometry so the
|
|
229
|
+
// row doesn't jump once Select2 does attach.
|
|
230
|
+
form fieldset.inputs li.select > select:not(.select2-hidden-accessible) {
|
|
231
|
+
display: inline-block;
|
|
232
|
+
width: calc(80% - 22px);
|
|
233
|
+
vertical-align: middle;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// The dropdown panel itself is appended to <body> (or wherever
|
|
237
|
+
// `dropdownParent` points), not inside the field/panel — its own popover
|
|
238
|
+
// styling, independent of whatever container it happens to render in.
|
|
239
|
+
.select2-dropdown {
|
|
240
|
+
border: 1px solid $prism-border-color;
|
|
241
|
+
border-radius: $prism-radius-sm;
|
|
242
|
+
box-shadow: $prism-shadow-popover;
|
|
243
|
+
overflow: hidden;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.select2-search--dropdown {
|
|
247
|
+
padding: 8px;
|
|
248
|
+
|
|
249
|
+
.select2-search__field {
|
|
250
|
+
border: 1px solid $prism-border-color-strong;
|
|
251
|
+
border-radius: $prism-radius-sm;
|
|
252
|
+
padding: 7px 10px;
|
|
253
|
+
color: $prism-text-heading;
|
|
254
|
+
|
|
255
|
+
&:focus {
|
|
256
|
+
border-color: $prism-color-primary;
|
|
257
|
+
box-shadow: 0 0 0 3px rgba($prism-color-primary, 0.15);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.select2-results__option {
|
|
263
|
+
padding: 8px 12px;
|
|
264
|
+
color: $prism-text-body;
|
|
265
|
+
|
|
266
|
+
&--highlighted {
|
|
267
|
+
background: $prism-color-primary-light !important;
|
|
268
|
+
color: $prism-color-primary-dark !important;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
&[aria-selected="true"] {
|
|
272
|
+
background: $prism-bg-page;
|
|
273
|
+
color: $prism-text-heading;
|
|
274
|
+
font-weight: 600;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.select2-results__message {
|
|
279
|
+
color: $prism-text-muted;
|
|
280
|
+
padding: 8px 12px;
|
|
281
|
+
}
|