Skip to content

Commit aa04e6d

Browse files
authored
feat(modal): centered variant for any content
There currently is no declarative way to display content of a modal center aligned. Workaround for header is icon header or ui centered header or ui center aligned header Workaround for actions is to create an own theme modifying the @actionAlign variable For the content itself there is no workaround than creating a css class manually (would also work for actions This PR copies over the existing variant from header (which supports centered as well as center aligned already) and applies it to any direct sibling of the modal itself, so header or content or even actions can be displayed centered out of the box in the fomantic way
1 parent 7e3e450 commit aa04e6d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/definitions/modules/modal.less

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@
182182
border-top:none;
183183
}
184184

185+
.ui.modal > .centered,
186+
.ui.modal > .center.aligned {
187+
text-align: center;
188+
&.actions > .button:not(.fluid) {
189+
margin-left: @buttonCenteredDistance;
190+
margin-right: @buttonCenteredDistance;
191+
}
192+
}
193+
185194
/*-------------------
186195
Responsive
187196
--------------------*/
@@ -220,7 +229,7 @@
220229

221230
/* Tablet and Mobile */
222231
@media only screen and (max-width : @largestTabletScreen) {
223-
.ui.modal > .header {
232+
.ui.modal > .close + .header {
224233
padding-right: @closeHitbox;
225234
}
226235
.ui.modal > .close {
@@ -234,8 +243,10 @@
234243
@media only screen and (max-width : @largestMobileScreen) {
235244

236245
.ui.modal > .header {
237-
padding: @mobileHeaderPadding !important;
238-
padding-right: @closeHitbox !important;
246+
padding: @mobileHeaderPadding;
247+
}
248+
.ui.modal > .close + .header {
249+
padding-right: @closeHitbox;
239250
}
240251
.ui.overlay.fullscreen.modal > .content.content.content {
241252
min-height: @overlayFullscreenScrollingContentMaxHeightMobile;
@@ -467,7 +478,7 @@
467478
}
468479
}
469480
.ui.modal > .close.inside + .header,
470-
.ui.fullscreen.modal > .header {
481+
.ui.fullscreen.modal > .close + .header {
471482
padding-right: @closeHitbox;
472483
}
473484
.ui.modal > .close.inside,

src/themes/default/modules/modal.variables

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
@actionAlign: right;
6161

6262
@buttonDistance: 0.75em;
63+
@buttonCenteredDistance: 0.5em;
6364

6465
/* Inner Close Position (Tablet/Mobile) */
6566
@innerCloseTop: (@headerVerticalPadding - @closeHitBoxOffset + (@lineHeight - 1em));

0 commit comments

Comments
 (0)