Skip to content

Commit 37a3c55

Browse files
committed
Fix styling in instance selector embed
1 parent dd6962c commit 37a3c55

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

example/example_project/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
USE_TZ = True
118118

119-
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
119+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
120120

121121

122122
# Static files (CSS, JavaScript, Images)

instance_selector/static/instance_selector/instance_selector.css

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@
66
display: none;
77
}
88

9-
.is-instance-selector-embed .header-title .right {
10-
float: left;
9+
/* Hide the add button */
10+
.is-instance-selector-embed .w-header .right {
11+
display: none;
12+
}
13+
14+
/* Override wagtail styles [smaller screens] to make sure the title appears in line with the rows */
15+
@media (max-width: 50em) {
16+
.is-instance-selector-embed .w-header.w-header--with-padding,
17+
.is-instance-selector-embed .w-header>.row {
18+
padding-inline-start: 3rem !important;
19+
padding-inline-end: 3rem !important;
20+
}
21+
}
22+
23+
/* Override wagtail styles to make sure extra padding isn't added to the title */
24+
.is-instance-selector-embed .w-header.w-header--with-padding,
25+
.is-instance-selector-embed .w-header>.row {
26+
padding-top: 0.5rem;
1127
}
1228

1329
.instance-selector__success-message__select-button {
@@ -22,6 +38,13 @@
2238
cursor: pointer;
2339
}
2440

41+
.instance-selector-widget {
42+
padding: 12px;
43+
border: 1px solid #e8e8e8;
44+
border-radius: 4px;
45+
background-color: #fafafa;
46+
}
47+
2548
.instance-selector-widget .unchosen:before {
2649
margin-right: 0;
2750
}
@@ -40,10 +63,11 @@
4063
left: 0;
4164
width: 100%;
4265
height: 100%;
66+
padding: 10px;
4367
}
4468

4569
.instance-selector-widget-modal .button.close {
46-
right: 25px;
70+
right: 10px;
4771
color: var(--w-color-primary);
4872
}
4973

@@ -85,7 +109,11 @@
85109
}
86110

87111
.instance-selector-widget__display {
88-
margin-bottom: 10px;
112+
margin-bottom: 8px;
113+
padding: 8px;
114+
border: 1px solid #ddd;
115+
border-radius: 3px;
116+
background-color: #ffffff;
89117
}
90118

91119
.instance-selector-widget__display--no-image .instance-selector-widget__display__image-wrap {

instance_selector/widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def build_attrs(self, *args, **kwargs):
155155
# Add Stimulus controller attributes for InstanceSelectorPanel usage.
156156
# Skip during telepath serialisation for InstanceSelectorBlock
157157
# (when id_ hasn't been set yet).
158-
if hasattr(self, 'id_') and hasattr(self, 'name'):
158+
if hasattr(self, "id_") and hasattr(self, "name"):
159159
attrs["data-controller"] = "instance-selector"
160160
attrs["data-instance-selector-config-value"] = json.dumps(
161161
self.get_js_config(self.id_, self.name)

0 commit comments

Comments
 (0)