Introducing DotVVM Flex Controls

Why we did it?

It all started when I was working on the large-scale information system, where I joined the developer team approximately two years after it started. In the beginning, it was hard to manage all the pages and meet customer’s needs without spending a lot of time on implementation and testing. Each one of us can have different knowledge and skills with CSS language and its ups and downs. Therefore, it is quite easy to find yourself in hard reading and disorganized code. Of course, then you can find a lot of tightly coupled and mixed code with tons of “!important” and style attribute settings, too. And we know it’s not a good thing.

 

From our observation, we found out that frontend developers usually prepare the basic styles and themes at the beginning and by the time they are getting less and less involved in the development. But with long-lasting and agile projects, you’re not able to prepare all possible scenarios at the beginning. That’s why we started generating CSS Flexbox layout classes like “flex-direction-column, flex-size-1” and so on. It made sense to learn such a powerful layout system and be able to use it without writing a CSS code, that would be done differently by each one us. Also, on large projects like this, the size of the page CSS styles could increase enormously.

 

Afterward, we decided to make it much easier by implementing a set of controls with suggestions and features for custom values and responsivity. Usually, elements are displayed in horizontal or vertical orientation, and the modern responsive websites use the space filling and dividing by mixing ratios and other units. Add some spacing, alignments, reordering, and you can achieve almost every scenario you need. So, CSS flexbox seems to be powerful and easy enough to create the most of the commonly used page layouts and its combination with DotVVM allows you to do more. On the other hand, CSS Grid layouts could be more suitable and even powerful for our solution, however, its browsers support in the time when we started this project wasn’t quite satisfying, mainly because of poor support of Internet Explorer.

What FlexControls do?

FlexControls brings a piece of XAML and UWP design language features that help you to save time and de-couple your CSS code. You don’t need to create an extra CSS file and classes for each page, just add new control instead of HTML element and set the desired properties. To start, we recommend you to draw a layout of your page on paper or a whiteboard and divide it into horizontal and vertical sections.

 

If you’re done, you’re ready to start implementing your page layout. It’s all done by combining Wrapper and Element controls, which differs in the number of properties. While Wrapper control displays its children in CSS flexbox and contains more properties like orientation, content alignment, spacing, etc., Element control cares about its position and other settings in Wrapper control.

 

Style and Value resources

Moreover, you can share any values and base styles, which can be bound to controls through resource bindings, as well as you can create the most common layouts as master pages. All those little features can help you to unify the layout language among programmers and rip off the page-specific styles from the rest of your CSS code.

 

Responsivity

Another cool feature that was inspired by UWP is a collection of triggers used to make pages responsive to different sizes of screen. Imagine the previous scenario with a side menu on a mobile device. It is obvious that the page needs to change a little. To be more specific, it would be great to change the orientation of the Wrapper control for menu and content. All we need is to add a collection named Triggers and change the orientation property of a mobile trigger.

 

How it works?

Maybe you ask how this could work with custom values. A small number of values for different properties like size, spacing and order are pre-generated, and when it’s not, FlexControls generates custom CSS code into a page’s style attribute. This style is connected to control with a unique CSS class name.

 

Conclusion

We believe that Flex Controls can help us do great things and may find its place in large-scale applications or generated applications. It is supposed to unify the design language among programmers, simplify it and speed-up its whole process. Even there is no exact day of publishing, FlexControls are almost ready, and we expect them to be released very soon.

Leave a Reply