active_admin_prism 0.1.1 → 0.1.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.
data/scss-src/_forms.scss CHANGED
@@ -162,12 +162,28 @@ form {
162
162
  }
163
163
  }
164
164
 
165
+ // ActiveAdmin's own CSS lays these out via `float: left` on each `li`
166
+ // (mixins/_buttons.scss's basic-button + _forms.scss's `fieldset.buttons
167
+ // li, fieldset.actions li { float: left; }`) — fragile in practice: it
168
+ // only takes one host app's own CSS reset (or a form with an unusually
169
+ // long submit label, or a differently-structured actions bar) for that
170
+ // float to be lost, at which point every `li` (a block-level list item
171
+ // by default) stacks vertically instead of sitting in a row. Flexbox
172
+ // sidesteps this rather than trying to out-specificity AA's float rule:
173
+ // per spec, `float` has no effect on a flex item at all, so this simply
174
+ // wins outright regardless of load order/specificity, and doesn't
175
+ // depend on every button happening to fit on one line the way floats do.
165
176
  .buttons,
166
177
  .actions {
167
- input[type="submit"],
168
- input[type="button"],
169
- button {
170
- margin-right: 10px;
178
+ > ol {
179
+ display: flex;
180
+ flex-wrap: wrap;
181
+ align-items: center;
182
+ gap: 10px;
183
+ }
184
+
185
+ li {
186
+ padding: 0;
171
187
  }
172
188
  }
173
189
  }
@@ -156,6 +156,15 @@ body:has(.prism-collapsible-panel):not(.prism-filters-open) {
156
156
  }
157
157
 
158
158
  &.open {
159
+ // Both this element and .panel_contents inherit overflow:hidden from
160
+ // the collapsed state above (needed there to clip the height-0
161
+ // content and, on .panel itself, to keep the base .panel rule's
162
+ // rounded-corner clipping) — reset to visible once open, otherwise a
163
+ // filter using a Select2 dropdown (e.g. a belongs_to filter's
164
+ // .select_and_search field) gets its open dropdown list clipped/
165
+ // garbled against this panel's own bounds, since Select2 renders its
166
+ // dropdown as a sibling near the input rather than inside it.
167
+ overflow: visible;
159
168
  background: $prism-bg-card;
160
169
  border-color: $prism-border-color;
161
170
  box-shadow: $prism-shadow-card;
@@ -186,6 +195,7 @@ body:has(.prism-collapsible-panel):not(.prism-filters-open) {
186
195
  }
187
196
 
188
197
  .panel_contents {
198
+ overflow: visible;
189
199
  max-height: 1200px;
190
200
  opacity: 1;
191
201
  padding-top: 20px;
@@ -200,6 +210,7 @@ body:has(.prism-collapsible-panel):not(.prism-filters-open) {
200
210
  // filters_sidebar.rb skips adding the icon/label markup entirely, so this
201
211
  // rule is mostly a no-op safety net rather than the primary mechanism).
202
212
  body.prism-filters-collapsible-disabled .prism-collapsible-panel {
213
+ overflow: visible;
203
214
  background: $prism-bg-card;
204
215
  border-color: $prism-border-color;
205
216
  box-shadow: $prism-shadow-card;
@@ -0,0 +1,264 @@
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% - padding) 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). Rather than hardcode an equivalent, giving the container
208
+ // its own block formatting context (overflow: hidden, no explicit width)
209
+ // gets the same result for free: per the CSS spec, a BFC-establishing box
210
+ // must not overlap a preceding float's margin box, so the browser sizes it
211
+ // to exactly the remaining space automatically. Without this, the default
212
+ // 100% width above would render full-width *underneath* the floated
213
+ // label, visually painting over it — this is the fix for that, not just a
214
+ // visual nicety.
215
+ fieldset.inputs .select2-container {
216
+ overflow: hidden;
217
+ }
218
+
219
+ // The dropdown panel itself is appended to <body> (or wherever
220
+ // `dropdownParent` points), not inside the field/panel — its own popover
221
+ // styling, independent of whatever container it happens to render in.
222
+ .select2-dropdown {
223
+ border: 1px solid $prism-border-color;
224
+ border-radius: $prism-radius-sm;
225
+ box-shadow: $prism-shadow-popover;
226
+ overflow: hidden;
227
+ }
228
+
229
+ .select2-search--dropdown {
230
+ padding: 8px;
231
+
232
+ .select2-search__field {
233
+ border: 1px solid $prism-border-color-strong;
234
+ border-radius: $prism-radius-sm;
235
+ padding: 7px 10px;
236
+ color: $prism-text-heading;
237
+
238
+ &:focus {
239
+ border-color: $prism-color-primary;
240
+ box-shadow: 0 0 0 3px rgba($prism-color-primary, 0.15);
241
+ }
242
+ }
243
+ }
244
+
245
+ .select2-results__option {
246
+ padding: 8px 12px;
247
+ color: $prism-text-body;
248
+
249
+ &--highlighted {
250
+ background: $prism-color-primary-light !important;
251
+ color: $prism-color-primary-dark !important;
252
+ }
253
+
254
+ &[aria-selected="true"] {
255
+ background: $prism-bg-page;
256
+ color: $prism-text-heading;
257
+ font-weight: 600;
258
+ }
259
+ }
260
+
261
+ .select2-results__message {
262
+ color: $prism-text-muted;
263
+ padding: 8px 12px;
264
+ }