When we were building the first phase of the SUSI Web Chat Application we didn’t consider about the responsiveness as a main goal. The main thing we needed was a working application. This changed at a later stage. In this post I’m going to emphasize how we implemented the responsive design and problems we met while we were developing the design.
When we were moving to Material-UI from static HTML CSS we were able to make most of the parts responsive. As an example App-bar of the application. We added App-bar like as follows: We made a separate component for App-bar and it includes the “searchfield” element. Material-UI app bar handles the responsiveness for some extent. We have to handle responsiveness of other sub-parts of the app bar manually.
In “TopBar.react.js” I returned marterial-ui <Toolbar> element like this.
We have to add the search button inside the element.
In this we added search component.
This field has the ability to expand and collapse like this.
It looks good. But it appears on mobile screen in a different way. This is how it appears on mobile devices.
So we wanted to hide the SUSI logo on small sized screens. For that we wrote medial queries like this.
Even in smaller screens it appears like this.
To avoid that we minimized the width of the search bar in different screen sizes using media queries .
But in even smaller screens it still appears in the same way. We can’t show the search bar on small screens because the screen size is not enough to show the search bar.
So we wrote another media query to hide all the elements of search component in small screens except close button. Because when we collapse the screen on search mode it hides all the search components and messagecomposer. To take it back to the chat mode we have to enable the close button on smaller screens.
We have to define these two classes in “SearchField.react.js” file.
Since we have “Codacy” integrated into our Github Repository we have to change Codacy rules because we used “!important” in media queries to override inline style which comes from Material-UI.
To change codacy rules we can simply login to the codacy and select the “code pattern ” button from the column left side.
It shows the list of rules that Codacy checks. And you can see the “!important” rule under CSSlint category like this.
Just uncheck it. Then codacy will not check your source code for “!important” attributes.
Configuring Codacy: Use Your Own Conventions: https://blog.codacy.com/configuring-codacy-use-your-own-conventions-9272bee5dcdb
Media queries: https://www.w3schools.com/css/css_rwd_mediaqueries.asp