Skip to content

Commit

Permalink
Merge pull request #5645 from kianamcc/SWC-7189
Browse files Browse the repository at this point in the history
SWC-7189: SWC <b:Modal> updates on mobile (inside PromptForValuesModalViewImpl for example)
  • Loading branch information
kianamcc authored Feb 26, 2025
2 parents 7697d20 + 85e28c2 commit b6670ab
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class MarkdownEditorWidget
// units are px
public static final int MIN_TEXTAREA_HEIGHT = 100;
public static final int OTHER_EDITOR_COMPONENTS_HEIGHT = 270;
public static final int XS_BREAKPOINT = 796;

private SynapseClientAsync synapseClient;
private CookieProvider cookies;
Expand Down Expand Up @@ -203,9 +204,15 @@ private void setMarkdownTextAreaHandlers() {
}

public void resizeMarkdownTextArea() {
int viewportWidth = view.getClientWidth();
int clientHeight = view.getClientHeight();
int newHeight = view.getClientHeight() - OTHER_EDITOR_COMPONENTS_HEIGHT;
newHeight =
newHeight > MIN_TEXTAREA_HEIGHT ? newHeight : MIN_TEXTAREA_HEIGHT;
if (viewportWidth < XS_BREAKPOINT) {
newHeight = (int) (clientHeight * 0.4);
} else {
newHeight =
newHeight > MIN_TEXTAREA_HEIGHT ? newHeight : MIN_TEXTAREA_HEIGHT;
}
view.setMarkdownTextAreaHeight(newHeight);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public interface MarkdownEditorWidgetView extends IsWidget, SynapseView {

int getClientHeight();

int getClientWidth();

void setMarkdownTextAreaHeight(int heightPx);

void setFocus(boolean focused);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ public int getClientHeight() {
return Window.getClientHeight();
}

@Override
public int getClientWidth() {
return Window.getClientWidth();
}

@Override
public void setMarkdownTextAreaHeight(int heightPx) {
lazyConstruct();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public UploadTableModalWidgetImpl(
this.modalWizarWidget.setModalSize(ModalSize.LARGE);
this.uploadCSVFileWidget = uploadCSVFileWidget;
this.modalWizarWidget.configure(this.uploadCSVFileWidget);
this.modalWizarWidget.asWidget().addStyleName("full-size-modal-xs-only");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</g:FocusPanel>
<b:Modal
ui:field="modal"
addStyleNames="full-size-modal-xs-only"
closable="true"
dataBackdrop="STATIC"
dataKeyboard="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
closable="true"
dataBackdrop="STATIC"
dataKeyboard="false"
addStyleNames="modal-fullscreen"
addStyleNames="modal-fullscreen full-size-modal-xs-only"
>
<b:ModalBody>
<b:TextBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
closable="true"
dataBackdrop="STATIC"
dataKeyboard="true"
addStyleNames="modal"
addStyleNames="modal-fullscreen full-size-modal-xs-only"
>
<b:ModalBody>
<bh:Span addStyleNames="font-size-18">Repository Name</bh:Span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
closable="true"
dataBackdrop="STATIC"
dataKeyboard="true"
addStyleNames="full-size-modal-xs-only"
>
<b:ModalHeader closable="true">
<b:Heading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<bh:Div>
<b:Modal
ui:field="editorDialog"
addStyleNames="modal-fullscreen"
addStyleNames="modal-fullscreen full-size-modal-xs-only"
closable="true"
dataBackdrop="STATIC"
dataKeyboard="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
closable="true"
dataBackdrop="STATIC"
dataKeyboard="true"
addStyleNames="modal-fullscreen"
addStyleNames="modal-fullscreen full-size-modal-xs-only"
>
<b:ModalBody>
<b:Pre ui:field="infoDialogText" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
dataBackdrop="STATIC"
dataKeyboard="false"
size="LARGE"
addStyleNames="newFolderDialog"
addStyleNames="newFolderDialog full-size-modal-xs-only"
>
<b:ModalBody>
<b:FormGroup>
Expand Down
16 changes: 16 additions & 0 deletions src/main/webapp/sass/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,22 @@ input[type='text'].padding-0 {
flex-flow: inherit;
}

@media (max-width: 768px) {
.full-size-modal-xs-only .modal-dialog {
width: 95%;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: auto;
max-height: 90vh;
}

.full-size-modal-xs-only .modal-content {
max-height: 90vh;
}
}

.glyphicon {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,35 @@ public void testResizeMarkdown() {
String markdown = "";

when(mockView.getClientHeight()).thenReturn(0);
when(mockView.getClientWidth()).thenReturn(1000);
presenter.resizeMarkdownTextArea();
verify(mockView)
.setMarkdownTextAreaHeight(MarkdownEditorWidget.MIN_TEXTAREA_HEIGHT);

reset(mockView);
when(mockView.getClientWidth()).thenReturn(1000);
when(mockView.getClientHeight())
.thenReturn(MarkdownEditorWidget.MIN_TEXTAREA_HEIGHT);
presenter.resizeMarkdownTextArea();
verify(mockView)
.setMarkdownTextAreaHeight(MarkdownEditorWidget.MIN_TEXTAREA_HEIGHT);

reset(mockView);
when(mockView.getClientWidth()).thenReturn(1000);
when(mockView.getClientHeight()).thenReturn(1000);
presenter.resizeMarkdownTextArea();
verify(mockView)
.setMarkdownTextAreaHeight(
1000 - MarkdownEditorWidget.OTHER_EDITOR_COMPONENTS_HEIGHT
);

// For mobile screen sizes (below XS_BREAKPOINT), set height to 40% of client height
reset(mockView);
when(mockView.getClientWidth())
.thenReturn(MarkdownEditorWidget.XS_BREAKPOINT - 100);
when(mockView.getClientHeight()).thenReturn(1000);
presenter.resizeMarkdownTextArea();
verify(mockView).setMarkdownTextAreaHeight(400);
}

@Test
Expand Down

0 comments on commit b6670ab

Please sign in to comment.