@@ -4,36 +4,30 @@ import Polyglot
44import api.isPackagesServerUp
55import api.isTerminologyServerUp
66import context.AppScreenContext
7+ import context.LocalizationContext
78import css.const.HEADER_SHADOW
89import css.const.HIGHLIGHT_GRAY
910import css.const.WHITE
10- import web.dom.document
11- import web.window.window
1211import kotlinx.coroutines.launch
1312import kotlinx.css.*
1413import kotlinx.css.properties.borderBottom
1514import kotlinx.css.properties.boxShadow
1615import mainScope
1716import model.AppScreen
18- import web.events.Event
1917import react.*
2018import styled.StyleSheet
2119import styled.css
2220import styled.styledDiv
2321import styled.styledImg
22+ import ui.components.header.LanguageOption.languageSelect
2423import ui.components.header.SiteStatus.SiteState
2524import ui.components.header.SiteStatus.siteStatus
26- import ui.components.header.LanguageOption.languageSelect
2725import utils.Language
28- import model.ValidationContext
26+ import web.dom.document
27+ import web.window.window
2928
3029external interface HeaderProps : Props {
31- var appScreen: AppScreen
32- var selectedLanguage: Language
33- var polyglot: Polyglot
34-
35- var validationContext: ValidationContext
36- var updateValidationContext: (ValidationContext , Boolean ) -> Unit
30+ // Empty - all data now from contexts
3731}
3832
3933class HeaderState : State {
@@ -68,63 +62,69 @@ class Header (props : HeaderProps): RComponent<HeaderProps, HeaderState>() {
6862 }
6963
7064 override fun RBuilder.render () {
71- AppScreenContext .Consumer { contextValue ->
72- styledDiv {
73- css {
74- + HeaderStyle .headerContainer
75- if (state.currentScroll > 0 ) {
76- boxShadow(color = HEADER_SHADOW , offsetX = 0 .px, offsetY = 10 .px, blurRadius = 10 .px)
77- }
78- }
79- styledImg(src = " images/fhir-logo.png" ) {
80- css {
81- + HeaderStyle .headerImage
82- }
83- }
84- styledDiv {
85- css {
86- + HeaderStyle .headerButtonsContainer
87- }
88- AppScreen .values().forEach { screen ->
89- headerTabButton {
90- name = screen.name
91- label = props.polyglot.t(screen.polyglotKey)
92- selected = props.appScreen == screen
93- onSelected = { buttonName ->
94- AppScreen .fromDisplay(buttonName)?.let { screen ->
95- contextValue?.setAppScreen?.invoke(screen)
96- }
97- }
98- }
99- }
100- }
65+ AppScreenContext .Consumer { screenContext ->
66+ LocalizationContext .Consumer { localizationContext ->
67+ context.ValidationContext .Consumer { validationContext ->
68+ // Extract values with null-safety defaults
69+ val appScreen = screenContext?.appScreen ? : AppScreen .VALIDATOR
70+ val polyglot = localizationContext?.polyglot ? : Polyglot ()
71+ val selectedLanguage = localizationContext?.selectedLanguage ? : Language .ENGLISH
10172
102- styledDiv {
103- css {
104- + HeaderStyle .sideOptions
105- }
10673 styledDiv {
10774 css {
108- + HeaderStyle .languageOptionDiv
109- }
110- languageSelect{
111- polyglot = props.polyglot
112- selectedLanguage = props.selectedLanguage
113- validationContext = props.validationContext
114- updateValidationContext = props.updateValidationContext
75+ + HeaderStyle .headerContainer
76+ if (state.currentScroll > 0 ) {
77+ boxShadow(color = HEADER_SHADOW , offsetX = 0 .px, offsetY = 10 .px, blurRadius = 10 .px)
78+ }
11579 }
116- }
117- styledDiv {
118- css {
119- + HeaderStyle .siteStatusDiv
80+ styledImg(src = " images/fhir-logo.png " ) {
81+ css {
82+ + HeaderStyle .headerImage
83+ }
12084 }
121- siteStatus {
122- label = " tx.fhir.org"
123- status = state.terminologyServerState
85+ styledDiv {
86+ css {
87+ + HeaderStyle .headerButtonsContainer
88+ }
89+ AppScreen .values().forEach { screen ->
90+ headerTabButton {
91+ name = screen.name
92+ label = polyglot.t(screen.polyglotKey)
93+ selected = appScreen == screen
94+ onSelected = { buttonName ->
95+ AppScreen .fromDisplay(buttonName)?.let { screen ->
96+ screenContext?.setAppScreen?.invoke(screen)
97+ }
98+ }
99+ }
100+ }
124101 }
125- siteStatus {
126- label = " packages2.fhir.org"
127- status = state.packageServerState
102+
103+ styledDiv {
104+ css {
105+ + HeaderStyle .sideOptions
106+ }
107+ styledDiv {
108+ css {
109+ + HeaderStyle .languageOptionDiv
110+ }
111+ languageSelect {
112+ // No attrs needed - component consumes contexts directly
113+ }
114+ }
115+ styledDiv {
116+ css {
117+ + HeaderStyle .siteStatusDiv
118+ }
119+ siteStatus {
120+ label = " tx.fhir.org"
121+ status = state.terminologyServerState
122+ }
123+ siteStatus {
124+ label = " packages2.fhir.org"
125+ status = state.packageServerState
126+ }
127+ }
128128 }
129129 }
130130 }
0 commit comments