Coder Social home page Coder Social logo

sw-responsive's Introduction

SW-responsive

Responsive Layout for CUBA Platform

license Download Build Status

Based on Responsive Layout Vaadin Add-on: https://github.com/JarekToro/responsive-layout

Demo

Installation

The add-on can be added to your project in one of the ways described below. Installation from the Marketplace is the simplest way. The last version of the add-on compatible with the used version of the platform will be installed. Also, you can install the add-on by coordinates choosing the required version of the add-on from the table.

In case you want to install the add-on by manual editing or by building from sources see the complete add-ons installation guide in CUBA Platform documentation.

From the Marketplace

  1. Open your application in CUBA Studio. Check the latest version of CUBA Studio on the CUBA Platform site.
  2. Go to CUBA -> Marketplace in the main menu.

marketplace

  1. Find the SW-responsive add-on there.

addons

  1. Click Install and apply the changes. The add-on corresponding to the used platform version will be installed.

By Coordinates

  1. Open your application in CUBA Studio. Check the latest version of CUBA Studio on the CUBA Platform site.
  2. Go to CUBA -> Marketplace in the main menu.
  3. Click the icon in the upper-right corner.

by-coordinates

  1. Paste the add-on coordinates in the corresponding field as follows:

org.strangeway.responsive:sw-responsive-global:<add-on version>

where <add-on version> is compatible with the used version of the CUBA platform.

Platform Version Add-on Version
7.2.x 1.5.0
7.1.x 1.4.0
7.0.x 1.3.0
6.10.x 1.2.0
6.9.x 1.1.0
6.8.x 1.0.0
  1. Click Install and apply the changes. The add-on will be installed to your project.

Quick Start

Let's say you want to implement responsive dashboard in a screen.

First of all, add xmlns http://strangeway.org/xsd/responsive/sw-responsive.xsd reference to the screen XML:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        caption="msg://caption"
        xmlns:swr="http://strangeway.org/xsd/responsive/sw-responsive.xsd"
        class="com.company.demo.web.screens.Dashboard"
        messagesPack="com.company.demo.web.screens">
    <layout>

    </layout>
</window>

The main UI component of the app component is ResponsiveLayout. Let's define one:

<swr:responsiveLayout width="100%">

</swr:responsiveLayout>

ResponsiveLauyout may contain only row components. We will have 2 rows in this example:

<swr:responsiveLayout width="100%">
    <swr:row>

    </swr:row>
    <swr:row>

    </swr:row>
</swr:responsiveLayout>

Each row may contain one or more columns:

<swr:responsiveLayout width="100%">
    <swr:row>
        <swr:column>

        </swr:column>
        <swr:column>

        </swr:column>
        <swr:column>

        </swr:column>
        <swr:column>

        </swr:column>
    </swr:row>
    <swr:row>
        <swr:column>

        </swr:column>
    </swr:row>
</swr:responsiveLayout>

Column elements define layout constraints for different resolutions:

<swr:column>
    <swr:content>
        <groupBox caption="Area"
                  height="150px"
                  width="100%">
            <label stylename="big-number"
                   align="MIDDLE_CENTER"
                   value="541.382 km^2"/>
        </groupBox>
    </swr:content>

    <swr:display xs="12" sm="6" md="6" lg="3"/>
</swr:column>

Here we set 12 columns width for XS resolution (mobile) and only 3 columns width for large resolutions (desktop).

Row elements have additional options, such as minHeight, maxHeight, shrink, grow, etc:

<swr:row stylename="map-row"
         margin="false"
         minHeight="50vh"
         grow="true">
    <swr:column height="100%">
        <swr:content>
            <browserFrame width="100%"
                          height="100%">
                <url url="https://en.wikipedia.org/wiki/Samara#/media/File:Outline_Map_of_Samara_Oblast.svg"/>
            </browserFrame>
        </swr:content>

        <swr:display xs="12" sm="12" md="12" lg="12"/>
    </swr:column>
</swr:row>

Finally, we could create simple responsive dashboard:

Demo

See demo project: https://github.com/strangeway-org/sw-responsive-demo

Read more

See also the original docs on Grid System from Vaadin Add-on: https://github.com/JarekToro/responsive-layout/wiki/The-Grid-System

sw-responsive's People

Contributors

flaurite avatar glebshalyganov avatar jreznot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

douit

sw-responsive's Issues

Form fields are squashed inside of Responsive layout

Example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/screen/window.xsd"
        caption="Responsive Form"
        xmlns:swr="http://strangeway.org/xsd/responsive/sw-responsive.xsd">

    <data>
        <instance id="userDc" class="com.haulmont.cuba.security.entity.User" view="_local">
            <loader>
                <query>
                    <![CDATA[
                    select u from sec$User u
                    where u.loginLowerCase = 'admin'
                    ]]>
                </query>
            </loader>
        </instance>
    </data>

    <layout height="AUTO" spacing="true">
        <swr:responsiveLayout width="100%">
            <swr:row width="100%"
                     horizontalSpacing="true"
                     horizontalSpacingSize="SMALL">
                <swr:column width="100%">
                    <swr:content>
                        <groupBox width="100%">
                            <form dataContainer="userDc" width="100%">
                                <column width="100%">
                                    <textField property="login" width="100%"/>
                                    <checkBox property="active" width="100%"/>
                                </column>
                            </form>
                        </groupBox>
                    </swr:content>
                    <swr:display xs="12" sm="12" md="6" lg="6"/>
                </swr:column>
            </swr:row>
        </swr:responsiveLayout>

        <button id="closeBtn"
                caption="Close"/>
    </layout>
</window>

Result:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.