From 7f357ba7a8ab7335403d32b84d6f9cd05a5d83a9 Mon Sep 17 00:00:00 2001 From: Waleed ASHRAF Date: Fri, 22 May 2020 14:19:38 +0200 Subject: [PATCH 1/5] feat: make payload example collapsible --- partials/example.html | 62 ++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/partials/example.html b/partials/example.html index 0caed57d3..d2d65049c 100644 --- a/partials/example.html +++ b/partials/example.html @@ -1,4 +1,4 @@ -{% macro example(msg, channelName) %} +{% macro example(msg, channelName, open=false) %}
@@ -8,28 +8,48 @@ -
- {% if msg | getPayloadExamples | length %} - {% for ex in msg | getPayloadExamples %} -
Example #{{loop.index}}
-
{{ex | dump(2) | safe }}
- {% endfor %} - {% elif msg.payload() %} -
{{ msg.payload().json() | generateExample | safe }}
-
This example has been generated automatically.
- {% endif %} +
+
+ {% if msg.payload() | isExpandable %} + + + + {% endif %} +
+
+ {% if msg | getPayloadExamples | length %} + {% for ex in msg | getPayloadExamples %} +
Example #{{loop.index}}
+
{{ex | dump(2) | safe }}
+ {% endfor %} + {% elif msg.payload() %} +
{{ msg.payload().json() | generateExample | safe }}
+
This example has been generated automatically.
+ {% endif %} +
-
- {% if msg | getHeadersExamples | length %} - {% for ex in msg | getHeadersExamples %} -
Example #{{loop.index}}
-
{{ ex | dump(2) | safe  }}
- {% endfor %} - {% elif msg.headers() %} -
{{ msg.headers().json() | generateExample | safe }}
-
This example has been generated automatically.
- {% endif %} +
+
+ {% if msg.payload() | isExpandable %} + + + + {% endif %} +
+
+ {% if msg | getHeadersExamples | length %} + {% for ex in msg | getHeadersExamples %} +
Example #{{loop.index}}
+
{{ ex | dump(2) | safe  }}
+ {% endfor %} + {% elif msg.headers() %} +
{{ msg.headers().json() | generateExample | safe }}
+
This example has been generated automatically.
+ {% endif %} +
From d6aff6352162f6ec30c48ea8260883005d58db42 Mon Sep 17 00:00:00 2001 From: Waleed ASHRAF Date: Wed, 27 May 2020 12:26:56 +0200 Subject: [PATCH 2/5] fix: fix colors in css and div class --- partials/example.html | 5 +++-- template/css/main.css | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/partials/example.html b/partials/example.html index d2d65049c..32651c0ad 100644 --- a/partials/example.html +++ b/partials/example.html @@ -1,6 +1,7 @@ {% macro example(msg, channelName, open=false) %}
+
{{msg.uid()}}
@@ -8,7 +9,7 @@ -
+
{% if msg.payload() | isExpandable %} This example has been gene
-
+
{% if msg.payload() | isExpandable %} Date: Wed, 27 May 2020 13:53:26 +0200 Subject: [PATCH 3/5] fix: always show headers and payload --- partials/example.html | 17 ++++++----------- template/css/main.css | 11 +++++------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/partials/example.html b/partials/example.html index 32651c0ad..15c7daca0 100644 --- a/partials/example.html +++ b/partials/example.html @@ -2,15 +2,9 @@
{{msg.uid()}}
- - - - - - -
-
+
+
+ Payload {% if msg.payload() | isExpandable %} @@ -31,8 +25,9 @@
This example has been gene
-
-
+
+
+ Headers {% if msg.payload() | isExpandable %} diff --git a/template/css/main.css b/template/css/main.css index 2c482c32f..5d6a9e699 100644 --- a/template/css/main.css +++ b/template/css/main.css @@ -77,11 +77,6 @@ a:hover { /* EXAMPLES */ -.payload-examples, -.headers-examples { - display: none; -} - .examples-payload-tab:checked + label { background-color: #38a89d; border-color: #38a89d; @@ -100,10 +95,14 @@ a:hover { display: block; } -.payload-examples, .headers-examples polygon { +.payload-examples polygon, .headers-examples polygon { fill: #fff; } +.payload-examples .text-grey-lightest, .headers-examples .text-grey-lightest { + align-self: center; +} + .examples-uid { color: #fff; } From f6a27780ec77233bfaa0d4b09f9eb1b6bc58dd37 Mon Sep 17 00:00:00 2001 From: Waleed ASHRAF Date: Wed, 27 May 2020 16:04:37 +0200 Subject: [PATCH 4/5] fix: adjust margins and text color --- partials/example.html | 6 +++--- template/css/main.css | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/partials/example.html b/partials/example.html index 15c7daca0..e85a6750c 100644 --- a/partials/example.html +++ b/partials/example.html @@ -1,8 +1,8 @@ {% macro example(msg, channelName, open=false) %}
-
{{msg.uid()}}
-
+
{{msg.uid()}}
+
Payload {% if msg.payload() | isExpandable %} @@ -25,7 +25,7 @@
This example has been gene
-
+
Headers {% if msg.payload() | isExpandable %} diff --git a/template/css/main.css b/template/css/main.css index 5d6a9e699..f241f2feb 100644 --- a/template/css/main.css +++ b/template/css/main.css @@ -103,10 +103,6 @@ a:hover { align-self: center; } -.examples-uid { - color: #fff; -} - /* PANELS */ .sidebar-panel { From 8a15a76e1b30d2180a09515d901bd46aff4337de Mon Sep 17 00:00:00 2001 From: Waleed ASHRAF Date: Thu, 28 May 2020 10:39:10 +0200 Subject: [PATCH 5/5] fix: only show headers/payload when available --- partials/example.html | 88 ++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/partials/example.html b/partials/example.html index e85a6750c..dd2e14fce 100644 --- a/partials/example.html +++ b/partials/example.html @@ -2,51 +2,55 @@
{{msg.uid()}}
-
-
- Payload - {% if msg.payload() | isExpandable %} - - - - {% endif %} + {% if msg.payload() %} +
+
+ Payload + {% if msg.payload() | isExpandable %} + + + + {% endif %} +
+
+ {% if msg | getPayloadExamples | length %} + {% for ex in msg | getPayloadExamples %} +
Example #{{loop.index}}
+
{{ex | dump(2) | safe }}
+ {% endfor %} + {% elif msg.payload() %} +
{{ msg.payload().json() | generateExample | safe }}
+
This example has been generated automatically.
+ {% endif %} +
-
- {% if msg | getPayloadExamples | length %} - {% for ex in msg | getPayloadExamples %} -
Example #{{loop.index}}
-
{{ex | dump(2) | safe }}
- {% endfor %} - {% elif msg.payload() %} -
{{ msg.payload().json() | generateExample | safe }}
-
This example has been generated automatically.
- {% endif %} -
-
+ {% endif %} -
-
- Headers - {% if msg.payload() | isExpandable %} - - - - {% endif %} -
-
- {% if msg | getHeadersExamples | length %} - {% for ex in msg | getHeadersExamples %} -
Example #{{loop.index}}
-
{{ ex | dump(2) | safe  }}
- {% endfor %} - {% elif msg.headers() %} -
{{ msg.headers().json() | generateExample | safe }}
-
This example has been generated automatically.
- {% endif %} + {% if msg.headers() %} +
+
+ Headers + {% if msg.payload() | isExpandable %} + + + + {% endif %} +
+
+ {% if msg | getHeadersExamples | length %} + {% for ex in msg | getHeadersExamples %} +
Example #{{loop.index}}
+
{{ ex | dump(2) | safe  }}
+ {% endfor %} + {% elif msg.headers() %} +
{{ msg.headers().json() | generateExample | safe }}
+
This example has been generated automatically.
+ {% endif %} +
-
+ {% endif %} {% endmacro %}