@@ -6,8 +6,7 @@ import FontStyles from '@/styles/font-styles';
6
6
import InputStyles from '@/styles/input-styles' ;
7
7
import FlexStyles from '@/styles/flex-styles' ;
8
8
import TableStyles from '@/styles/table-styles' ;
9
- import setTheme from '@/utils/theme' ;
10
- import ColorUtils from '@/utils/color-utils' ;
9
+ import SetTheme from '@/utils/theme' ;
11
10
import ProcessSpec from '@/utils/spec-parser' ;
12
11
13
12
import '@/components/m-logo' ;
@@ -64,6 +63,8 @@ export default class RapiDoc extends LitElement {
64
63
65
64
// Main Colors and Font
66
65
theme : { type : String } ,
66
+ bgColor : { type : String , attribute : 'bg-color' } ,
67
+ textColor : { type : String , attribute : 'text-color' } ,
67
68
headerColor : { type : String , attribute : 'header-color' } ,
68
69
primaryColor : { type : String , attribute : 'primary-color' } ,
69
70
regularFont : { type : String , attribute : 'regular-font' } ,
@@ -103,30 +104,26 @@ export default class RapiDoc extends LitElement {
103
104
104
105
/* eslint-disable indent */
105
106
render ( ) {
107
+ const newTheme = {
108
+ bg1 : this . bgColor ,
109
+ fg1 : this . textColor ,
110
+ headerColor : this . headerColor ,
111
+ primaryColor : this . primaryColor ,
112
+ navBgColor : this . navBgColor ,
113
+ navTextColor : this . navTextColor ,
114
+ navHoverBgColor : this . navHoverBgColor ,
115
+ navHoverTextColor : this . navHoverTextColor ,
116
+ navAccentColor : this . navAccentColor ,
117
+ } ;
106
118
return html `
107
119
${ FontStyles }
108
120
${ InputStyles }
109
121
${ FlexStyles }
110
122
${ TableStyles }
111
- ${ this . theme === 'dark' ? setTheme ( 'dark' , {
112
- bg1 : '#36312C' ,
113
- fg1 : '#EBD1B7' ,
114
- lightFg : '#7A7267' ,
115
- } ) : setTheme ( 'light' ) }
123
+
124
+ ${ this . theme === 'dark' ? SetTheme ( 'dark' , newTheme ) : SetTheme ( 'light' , newTheme ) }
116
125
< style >
117
126
: host {
118
- - - primary- color : ${ this . primaryColor ? `${ this . primaryColor } ` : '#FF791A' } ;
119
- - - dark- primary- color : ${ ColorUtils . color . brightness ( this . primaryColor ? this . primaryColor : '#FF791A' , - 30 ) } ;
120
- - - primary- text: ${ this . primaryColor ? `${ ColorUtils . color . invert ( this . primaryColor ) } ` : '#ffffff' } ;
121
- - - header- bg: ${ this . headerColor ? `${ this . headerColor } ` : '#444' } ;
122
- - - header- fg: ${ this . headerColor ? `${ ColorUtils . color . invert ( this . headerColor ) } ` : '#ccc' } ;
123
-
124
- - - nav- bg- color : ${ this . navBgColor ? `${ this . navBgColor } ` : 'var(--bg2)' } ;
125
- - - nav- text- color : ${ this . navTextColor ? `${ this . navTextColor } ` : 'var(--fg3)' } ;
126
- - - nav- hover- bg- color : ${ this . navHoverBgColor ? `${ this . navHoverBgColor } ` : 'var(--hover-color)' } ;
127
- - - nav- hover- text- color : ${ this . navHoverTextColor ? `${ this . navHoverTextColor } ` : 'var(--fg3)' } ;
128
- - - nav- accent- color : ${ this . navAccentColor ? `${ this . navAccentColor } ` : 'var(--primary-color)' } ;
129
-
130
127
- - layout: ${ this . layout ? `${ this . layout } ` : 'row' } ;
131
128
- - font- mono: ${ this . monoFont ? `${ this . monoFont } ` : 'Monaco, "Andale Mono", "Roboto Mono", Consolas' } ;
132
129
- - font- regular: ${ this . regularFont ? `${ this . regularFont } ` : 'rapidoc, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' } ;
@@ -190,7 +187,7 @@ export default class RapiDoc extends LitElement {
190
187
}
191
188
192
189
.nav-scroll : hover ::-webkit-scrollbar {
193
- width : 30 px ;
190
+ width : 24 px ;
194
191
}
195
192
196
193
.nav-bar-tag {
@@ -273,9 +270,9 @@ export default class RapiDoc extends LitElement {
273
270
}
274
271
275
272
input .header-input {
276
- background : ${ this . headerColor ? ColorUtils . color . brightness ( this . headerColor , - 20 ) : ColorUtils . color . inputReverseBg } ;
273
+ background : var ( --header- color-darker ) ;
277
274
color : var (--header-fg );
278
- border : 1px solid var (--dark-primary- color );
275
+ border : 1px solid var (--header- color-border );
279
276
flex : 1 ;
280
277
padding-right : 24px ;
281
278
border-radius : 3px ;
@@ -657,6 +654,15 @@ export default class RapiDoc extends LitElement {
657
654
this . loadSpec ( newVal ) ;
658
655
}
659
656
}
657
+ if ( name === 'render-style' ) {
658
+ if ( newVal === 'read' ) {
659
+ window . setTimeout ( ( ) => {
660
+ this . observeExpandedContent ( ) ;
661
+ } , 100 ) ;
662
+ } else {
663
+ this . intersectionObserver . disconnect ( ) ;
664
+ }
665
+ }
660
666
super . attributeChangedCallback ( name , oldVal , newVal ) ;
661
667
}
662
668
@@ -707,6 +713,12 @@ export default class RapiDoc extends LitElement {
707
713
this . matchPaths = '' ;
708
714
}
709
715
716
+ // Public Method
717
+ updateTheme ( baseTheme , objTheme = { } ) {
718
+ SetTheme ( baseTheme , objTheme ) ;
719
+ }
720
+
721
+ // Public Method
710
722
async loadSpec ( specUrl ) {
711
723
if ( ! specUrl ) {
712
724
return ;
@@ -750,14 +762,15 @@ export default class RapiDoc extends LitElement {
750
762
this . selectedServer = this . resolvedSpec . servers [ 0 ] . url ;
751
763
}
752
764
}
765
+
766
+ this . requestUpdate ( ) ;
753
767
// Put it at the end of event loop, to allow loading all the child elements (must for larger specs)
754
768
this . intersectionObserver . disconnect ( ) ;
755
769
if ( this . renderStyle === 'read' ) {
756
770
window . setTimeout ( ( ) => {
757
771
this . observeExpandedContent ( ) ;
758
772
} , 100 ) ;
759
773
}
760
- this . requestUpdate ( ) ;
761
774
}
762
775
763
776
onIntersect ( entries ) {
0 commit comments