diff --git a/demo/iterate.html b/demo/iterate.html index 8b1ee64c..62ea9aa4 100644 --- a/demo/iterate.html +++ b/demo/iterate.html @@ -25,6 +25,9 @@ background: var(--paper-orange-500); display: block; } + input.widget{ + display:inline; + } diff --git a/demo/switch/switch-with-src.html b/demo/switch/switch-with-src.html index 4d5c2ab0..9b5db368 100644 --- a/demo/switch/switch-with-src.html +++ b/demo/switch/switch-with-src.html @@ -18,14 +18,16 @@ background: #76ff03; } - main{ - height:calc(100% - 2rem); - background:#dddddd; + main { + height: calc(100% - 2rem); + background: #dddddd; } - fx-switch, fx-case{ - width:100vw; - height:100vh; + + fx-switch, fx-case { + width: 100vw; + height: 100vh; } + fx-case { width: 100vw; height: 100%; @@ -48,10 +50,12 @@ [unresolved] { display: none; } - #home > div{ - max-width:64rem; - padding:0 2rem; + + #home > div { + max-width: 64rem; + padding: 0 2rem; } + #two { background: #ffca28; } @@ -63,27 +67,30 @@ fx-control { display: block; } - nav{ - padding:1rem 0; - fx-trigger{ - padding:0 1rem; + nav { + padding: 1rem 0; + + fx-trigger { + padding: 0 1rem; } } - #source{ - position:fixed; - top:0; - right:0; - z-index:5; - width:40vw; - height:20rem; - background:lightblue; - border:thin solid; - } - #three{ - fx-control{ - max-width:64rem; - } + + #source { + position: fixed; + top: 0; + right: 0; + z-index: 5; + width: 40vw; + height: 20rem; + background: lightblue; + border: thin solid; + } + + #three { + fx-control { + max-width: 64rem; + } } @@ -93,136 +100,96 @@ - - - - - - - - - - - - - - - - - - -
- - -
-
- - -
-

Lazy-loading views with the src attribute

-

This is the recommended approach if you plan to build more complex UIs with several - interchangeable views.

- -

fx-switch cannot just be used for tabcontainers but can manage - a set of views and lazy-load them as needed.

- -

Using the src on fx-case has two effects:

-
    -
  • it loads the activated case only when it becomes activated (lazy-loading)
  • -
  • it loads the content from an external HTML page which may either just be the snippet or - a full standalone page. By default the first fx-case element will be selected - but you can specify a CSS selector to fetch a specific target from that page.
  • -
-

By styling a switch to take the full viewport you can easily build a bare-bone Single-Page-Application (SPA) - where the host page is only loaded once and views are swapped in and out as needed.

-

Using this technique also allows to split up big pages into chunks making them - easier to extend and maintain.

- -

The first case will always be displayed and resolved by default. If you inspect the page right after - loading you will notice that the cases 'one', 'two', 'three' won't have been loaded yet.

- -

Markup of current page:

- - - - -

The home view is what you're looking at. See the other pages for details.

- - - - -
-
- - - View1 selected - -
only seen if page1.html fails to load.
-
- -

VIEW 2

-

Oh - you were not supposed to see me...

-

- I'm just fallback content when my src - can't be resolved. -

-

page2.html doesn't exist.

-
- - -
-
- -
- - - +

The home view is what you're looking at. See the other pages for details.

+ + + + + + + View1 selected + +
only seen if page1.html fails to load.
+
+ +

VIEW 2

+

Oh - you were not supposed to see me...

+

+ I'm just fallback content when my src + can't be resolved. +

+

page2.html doesn't exist.

+
+ + + + + + \ No newline at end of file