From e9bd84fb7d1ad3330506ff045380a362bfaa4d99 Mon Sep 17 00:00:00 2001 From: shalvah Date: Fri, 18 Nov 2022 22:59:36 +0100 Subject: [PATCH] Styling improvements for default theme; show example with description --- resources/css/theme-default.style.css | 4 +-- .../views/components/field-details.blade.php | 10 +++++-- .../views/components/nested-fields.blade.php | 29 ++++++++++--------- .../views/themes/default/endpoint.blade.php | 12 ++++---- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/resources/css/theme-default.style.css b/resources/css/theme-default.style.css index 93a01c70..82635f4d 100644 --- a/resources/css/theme-default.style.css +++ b/resources/css/theme-default.style.css @@ -1085,8 +1085,8 @@ button { scrollbar-color: #3c4c67 transparent); } *::-webkit-scrollbar { /* Background */ - width: 7px; - height: 7px; + width: 10px; + height: 10px; background: transparent; } diff --git a/resources/views/components/field-details.blade.php b/resources/views/components/field-details.blade.php index ae4e85c7..ab31d087 100644 --- a/resources/views/components/field-details.blade.php +++ b/resources/views/components/field-details.blade.php @@ -1,7 +1,7 @@ @php $html ??= []; $class = $html['class'] ?? null; @endphp -{{ $name }}   +{{ $name }}   @if($type){{ $type }}@endif  @if($isInput && !$required)optional@endif   @if($isInput && empty($hasChildren)) @@ -57,4 +57,10 @@ @endif @endif
-{!! Parsedown::instance()->text($description) !!} +@php +if($example !== null && $example !== '' && !is_array($example)) { + $exampleAsString = $example === false ? "false" : $example; + $description .= " Example: `$example`"; + } +@endphp +{!! Parsedown::instance()->text(trim($description)) !!} diff --git a/resources/views/components/nested-fields.blade.php b/resources/views/components/nested-fields.blade.php index b8089e99..2cc8ad39 100644 --- a/resources/views/components/nested-fields.blade.php +++ b/resources/views/components/nested-fields.blade.php @@ -1,22 +1,23 @@ @php - $isInput ??= true + $isInput ??= true; + $level ??= 0; @endphp @foreach($fields as $name => $field) @if($name === '[]') @php $description = "The request body is an array ({$field['type']}`)"; $description .= !empty($field['description']) ? ", representing ".lcfirst($field['description'])."." : '.'; + if(count($field['__fields'])) $description .= " Each item has the following properties:"; @endphp -

- {!! Parsedown::instance()->text($description) !!} -

+ {!! Parsedown::instance()->text($description) !!} + @foreach($field['__fields'] as $subfieldName => $subfield) @if(!empty($subfield['__fields'])) @else -

+

@component('scribe::components.field-details', [ 'name' => $subfield['name'], 'type' => $subfield['type'] ?? 'string', @@ -29,11 +30,11 @@ 'isInput' => $isInput, ]) @endcomponent -

+
@endif @endforeach @elseif(!empty($field['__fields'])) -

+

@component('scribe::components.field-details', [ @@ -52,10 +53,10 @@ @foreach($field['__fields'] as $subfieldName => $subfield) @if(!empty($subfield['__fields'])) @else -

+

@component('scribe::components.field-details', [ 'name' => $subfield['name'], 'type' => $subfield['type'] ?? 'string', @@ -68,13 +69,13 @@ 'isInput' => $isInput, ]) @endcomponent -

+
@endif @endforeach
-

+
@else -

+

@component('scribe::components.field-details', [ 'name' => $field['name'], 'type' => $field['type'] ?? 'string', @@ -87,6 +88,6 @@ 'isInput' => $isInput, ]) @endcomponent -

+
@endif @endforeach diff --git a/resources/views/themes/default/endpoint.blade.php b/resources/views/themes/default/endpoint.blade.php index 8f0914aa..89d561a0 100644 --- a/resources/views/themes/default/endpoint.blade.php +++ b/resources/views/themes/default/endpoint.blade.php @@ -101,7 +101,7 @@ $htmlOptions = [ 'class' => 'auth-value', ]; } ?> -

+

@component('scribe::components.field-details', [ 'name' => $name, 'type' => null, @@ -114,13 +114,13 @@ 'html' => $htmlOptions, ]) @endcomponent -

+
@endforeach @endif @if(count($endpoint->urlParameters))

URL Parameters

@foreach($endpoint->urlParameters as $attribute => $parameter) -

+

@component('scribe::components.field-details', [ 'name' => $parameter->name, 'type' => $parameter->type ?? 'string', @@ -132,7 +132,7 @@ 'isInput' => true, ]) @endcomponent -

+
@endforeach @endif @if(count($endpoint->queryParameters)) @@ -144,7 +144,7 @@ $htmlOptions = [ 'class' => 'auth-value', ]; } ?> -

+

@component('scribe::components.field-details', [ 'name' => $parameter->name, 'type' => $parameter->type, @@ -157,7 +157,7 @@ 'html' => $htmlOptions, ]) @endcomponent -

+
@endforeach @endif @if(count($endpoint->nestedBodyParameters))