[OH3] Main UI - New „main_widget“ - development and testing [deprecated]

Nope, css alignment and spacing is just a big topic with a lot to learn. You’ll be at it for a very long while before it becomes comfortable.

There are really only two issues keeping this from being what you want:

  1. In the block you’ve defined as the flex parent, you have given it a flex direction so the items are properly in a column. However, you have not told it how to space the children out. By default a flex box will take up the minimum space required to show the children as they are defined, so right now your column is the minimum height, not the entire height of the page. Take a look at the justify-content section of the flexbox guide (you are probably looking for something like space-between or space-evenly).

  2. Even if you set the justify-content property, you won’t yet see any changes because the block that is doing the flex spacing will try to fill the entire height of it’s parent, but it’s parent is not the page! You have an extra f7-block at the beginning of the widget (which again, without any other setting, is trying to be as small as it can be and still hold all its children). So the flexbox will fill 100% of its parent but it’s parent is smaller than the page so you won’t see the effects you are expecting.

Note the earlier post when I showed that you really only need a single f7-block to house the rest of the widget.

Combine the two f7-blocks into one with the flex styling and add the correct justify-content and you’ll be off to the races.

Hey Friends!

@Nic0205 Hope that helps -see attachment: It’s just what i have in my mind from a user point of view re alignment and justification under Justin’s direction, advice and support. Pls tell me what you think.

@JustinG -Thanks for helping us Master Justin!
Cheers
Allign.pdf (69.9 KB)

Hey @JustinG ,

it’s a hard way but I get forward :wink:

Actual one thing drives me crazy.

I managed to put the footer on the bottom.

But a new problem occurs. I put the widget in a cell of a page:

config:
  label: f
  sidebar: true
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-cells
          config: {}
          slots:
            default:
              - component: widget:demo:segmented
                config: {}
masonry: []
grid: []
canvas: []

that results in

The footer is at the bottom of the widget - that’s good. But it is not a the bottom of the page - that’s not good.

If I set the size within my demo.widget to for example 1024px then the footer grows - that’s good - that’s what I wanted to try.

But of course this is not responsive.

Could you give me a hint, how to achieve that the widget uses the complete page as a height?

Here is the simple demo-widget:

uid: demo:segmented
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Aug 22, 2022, 8:27:36 AM
component: f7-block
config:
  style:
    height: 1024px
    display: flex
    flex-direction: column
    justify-content: space-evenly
slots:
  default:
    - component: f7-segmented
      config:
        style:
          flex: 0
          background-color: green
      slots:
        default:
          - component: oh-button
            config:
              action: variable
              actionVariableValue: SECTION1
              actionVariable: selectSection
              text: One
              large: true
              style:
                flex: 1
    - component: oh-toggle-card
      config:
        style:
          flex: 0
    - component: f7-segmented
      config:
        style:
          flex: 1
          background-color: yellow
      slots:
        default:
          - component: oh-button
            config:
              action: variable
              actionVariableValue: THING1
              actionVariable: selectThing
              text: Thing One
              style:
                flex: 1
                position: relative
                overflow-y: auto


@Nic0205 I have a feeling that your development nightmares will continue! C’mon, must be!

I have started to create the icon set(s). For the next week I’ll be working on this.
All will be .svg. Regarding states, I’m planning to follow OH rules for dynamic icons.

For anything you need, pls let me know
Cheers :grinning:

2 Likes

@Nic0205 One last thing…Pls tell me when to stop!.

You haven’t even started =) Doors, windows, motion, leakage, lights, dimmers, colorpickers, media, temperature, humidity, co, gates, crops watering, energy, battery and so on, and so on, and everything with dynamic icons-colors-pictures.

Before starting to create so many custom icons, we should check for existing ones in the possible sources…

cc @Dimitris

I suspect this is the exact same problem as before. With css, unless you set properties that mean otherwise, every element is always just looking at it’s direct parent and direct children for sizing information. In this case, by adding the widget to a page inside the cell grid, the cell grid is now the parent of the widget. Unless you give the widget a definite height, the cell grid is just going to be the minimum height it needs to be to contain the widget at it’s minimum spacing. So to make sure that your widget also fills a page you have to make sure 1) that the widget always fills the full height of the cell grid and 2) the cell grid fills the full height of the page. The problem here is that OH puts a lot of other pieces “under the hood” so a cell grid is not just a single element.

So, your instinct was correct; you want to set the actual height of the widget, but to a responsive value, not an absolute value. In this case I would the css length unit of vh which equals 1% of the height of the browser window. So 100vh equals the whole height of the browser window. However, there are some pieces of the OH MainUI that are in the way (the top and bottom toolbar) so you have to subtract those elements that are already taking up some space on the window. If you use the page inspector in your browser, eventually you will find that those have heights set by some f7 variables. So to calculate the exact, responsive height the widget should be you would need something like this:

uid: demo:responsive_height
tags: []
props:
  parameters: []
  parameterGroups: []
component: f7-block
config:
  style:
    height: calc(100vh - var(--f7-toolbar-height) - var(--f7-safe-area-bottom) - var(--f7-navbar-height) - var(--f7-safe-area-top))
    width: 100%
    margin: 0
    padding: 0
    display: flex
    flex-direction: column
    justify-content: space-between
slots:
  default:
    - component: Label
      config:
        text: The top of the block
        style:
          flex: 0 0 0
    - component: f7-block
      config:
        style:
          flex: 1 1 auto
      slots:
        default:
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
    - component: Label
      config:
        text: The bottom of the block
        style:
          flex: 0 0 0


2 Likes

Good evening @hmerk ,
If you define as sources the standard OH or f7 icons, i have checked both thoroughly failed to find ones suitable for our design.
f7 provides extremely well designed and directly accessible icons but the collection misses a lot -if not all- of the equipment specific icons - that’s exactly what we need now.
If you have a hint for us to find commercial free - well designed icons pls let us know!
I appreciate your response.

No, there are more sources through iconify, see here

Very good info. Thank you.
I missed that cause i’m always going through official OH documentation!

1 Like

@JustinG cool- that makes things clearer.

While testing the code I noticed a challenge:

All is fine as long as the content is not longer than the block / the screen. The footer is still at the bottom - but at the bottom of the page and not the actual screen.

For example this code:

uid: demo:responsive_height1
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Aug 22, 2022, 10:41:05 PM
component: f7-block
config:
  style:
    height: calc(100vh - var(--f7-toolbar-height) - var(--f7-safe-area-bottom) - var(--f7-navbar-height) - var(--f7-safe-area-top))
    width: 100%
    margin: 0
    padding: 0
    display: flex
    flex-direction: column
    justify-content: space-between
slots:
  default:
    - component: Label
      config:
        text: The top of the block
        style:
          flex: 0 0 0
    - component: f7-block
      config:
        style:
          flex: 1 1 auto
      slots:
        default:
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
    - component: Label
      config:
        text: The bottom of the block
        style:
          flex: 0 0 0

You’re going to have to tell the block that holds the middle pieces what to do when it’s content overflows. See the css overflow property.

Iconify has limited usage, cause it requires internet connection. Check @martiniman icons, or feed Openhab with your own, i totally agree with you that f7 are better styled, but not designed for smart home use case.

Generally yes, but if your read @ysc post , openHAB is caching the icons and you can import the font files for offline usage.
Therefore there is no need for a permanent internet connection.

Hey @JustinG,

great tip! I tried to put the three entries (header, content, footer) in separate block - if this is clever I will see…

This code now works:

uid: demo:responsive_height1
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Aug 22, 2022, 10:41:05 PM
component: f7-block
config:
  style:
    height: calc(100vh - var(--f7-toolbar-height) - var(--f7-safe-area-bottom) - var(--f7-navbar-height) - var(--f7-safe-area-top))
    margin: 0
    padding: 0
    display: flex
    flex-direction: column
    justify-content: space-between
    
slots:
  default:

#Header
    - component: f7-block
      config:
        style:
          flex: 0 0 auto
          overflow: scroll
      slots:
        default:

        - component: f7-segmented
          config:
            style:
              flex: 1 1 auto
              
          slots:
            default:
              - component: oh-button
                config:
                  action: variable
                  actionVariable: selectSection
                  actionVariableValue: SECTION1
                  large: true
                  style:
                    color: '=vars.selectSection=="SECTION1" ? "black" : "#8C8C8C"'
                    font-size: 30px
                    font-weight: 200
                    text-decoration: underline
                    text-decoration-color: '=vars.selectSection=="SECTION1" ? "#F8BB00" : "transparent"'
                    text-underline-offset: 4px
                  text: Home


              - component: oh-button
                config:
                  action: variable
                  actionVariable: selectSection
                  actionVariableValue: SECTION2
                  large: true
                  style:
                    color: '=vars.selectSection=="SECTION2" ? "black" : "#8C8C8C"'
                    font-size: 30px
                    font-weight: 200
                    text-decoration: underline
                    text-decoration-color: '=vars.selectSection=="SECTION2" ? "#F8BB00" : "transparent"'
                    text-underline-offset: 4px
                  text: Rooms
                  
              - component: oh-button
                config:
                  action: variable
                  actionVariable: selectSection
                  actionVariableValue: SECTION3
                  large: true
                  style:
                    color: '=vars.selectSection=="SECTION3" ? "black" : "#8C8C8C"'
                    font-size: 30px
                    font-weight: 200
                    text-decoration: underline
                    text-decoration-color: '=vars.selectSection=="SECTION3" ? "#F8BB00" : "transparent"'
                    text-underline-offset: 4px
                  text: Floors



# Middle
    - component: f7-block
      config:
        style:
          flex: 1 1 auto
          overflow: scroll
      slots:
        default:
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
          - component: f7-card
            config:
              title: The middle content
              content: With some stuff
          - component: f7-card
            config:
              title: The middle content
              content: and some other some stuff
              
              
# Footer              
    - component: f7-block
      config:
        style:
          flex: 0 0 auto
          overflow: scroll
      slots:
        default:

        - component: f7-segmented
          config:
            style:
              flex: 1 1 auto
              
          slots:
            default:
              - component: oh-button
                config:
                  action: variable
                  actionVariable: selectSection
                  actionVariableValue: SECTION1
                  large: true
                  style:
                    color: '=vars.selectSection=="SECTION1" ? "black" : "#8C8C8C"'
                    font-size: 30px
                    font-weight: 200
                    text-decoration: underline
                    text-decoration-color: '=vars.selectSection=="SECTION1" ? "#F8BB00" : "transparent"'
                    text-underline-offset: 4px
                  text: Home


In the widget-editor it looks great:

But on the iPhone / responsive mode it looks squeezed:

I think the problem is the width of the first block which holds the other blocks is not wide enough and I need another time a relative width. Is there something like for the height to be noted?

1 Like

Hey @Nic0205 . With a setup like:

Screenshot 2022-08-23 at 11.52.41 AM

I’m getting this result:

Thank you!

A german saying is “den Wald vor lauter Bäumen nicht gesehen” (did not see the forrest cause of all the trees).

1 Like

Hey there,

developing the UI / Design goes further and further.

To avoid overloading this thread I will create a GitHub Repo and a new Thread only for this Topic.

I hope that all of you guys will join the new thread too and this okay for you.

I will post the thread and the GitHub Repo later, as soon as I could manage a few things…

@Dimitris: Do you have a short Name for our Project? My first thought was NewUI but feel free to give a better name :wink:

I’m working on widgets for this NewUI. What do you think if i will join new topic and post also those new widgets?

1 Like