diff --git a/matinfio/cif/cif.ts b/matinfio/cif/cif.ts index 5e10fea..49208f8 100644 --- a/matinfio/cif/cif.ts +++ b/matinfio/cif/cif.ts @@ -100,9 +100,13 @@ namespace $ { continue } else if( fingerprt.startsWith( '_cif_error' ) ) { // custom tag - const error_message = cur_line.substr( 12, cur_line.length - 13 ) + const error_message = cur_line.substr( 11, cur_line.length - 11 ) return this.$mol_fail( new $mol_data_error( error_message ) ) + } else if( fingerprt.startsWith( '_cif_warning' ) ) { // custom tag + cur_structure.warning = cur_line.substr( 13, cur_line.length - 13 ) + continue + } else if( fingerprt.startsWith( '_pauling_file_entry' ) ) { // custom tag cur_structure.mpds_data = true continue diff --git a/matinfio/matinfio.ts b/matinfio/matinfio.ts index 413c48f..07e25f0 100644 --- a/matinfio/matinfio.ts +++ b/matinfio/matinfio.ts @@ -54,6 +54,8 @@ namespace $ { cartesian: boolean, mpds_demo: boolean, mpds_data: boolean, + + warning?: string, } export type $optimade_cifplayer_matinfio_player_obj = { @@ -69,6 +71,8 @@ namespace $ { info: string, mpds_demo: boolean, mpds_data: boolean, + + warning?: string, } export class $optimade_cifplayer_matinfio extends $mol_object2 { diff --git a/matinfio/player/player.ts b/matinfio/player/player.ts index d1c3ce7..4bce1e5 100644 --- a/matinfio/player/player.ts +++ b/matinfio/player/player.ts @@ -35,7 +35,9 @@ namespace $ { ng_name: parseInt( crystal.ng_name ), info: crystal.info, mpds_data: crystal.mpds_data, - mpds_demo: crystal.mpds_demo + mpds_demo: crystal.mpds_demo, + + warning: crystal.warning, } const groups: { fpos: number[] | null, cpos: number[], atoms: $optimade_cifplayer_matinfio_internal_obj_atom[] }[] = [] diff --git a/player/player.view.css.ts b/player/player.view.css.ts index 19c6bfa..44f1d6b 100644 --- a/player/player.view.css.ts +++ b/player/player.view.css.ts @@ -1,5 +1,19 @@ namespace $.$$ { + const Message_card = { + position: 'absolute', + zIndex: 1, + top: '6rem', + width: '100%', + align: { + items: 'center' + }, + background: { + color: 'transparent', + }, + boxShadow: 'none', + } as const + $mol_style_define( $optimade_cifplayer_player, { background: { @@ -136,19 +150,24 @@ namespace $.$$ { height: '2rem', }, - Message: { - position: 'absolute', - zIndex: 1, - top: '6rem', - left: 0, - right: 0, + Error_card: { + ...Message_card, + + Content: { + background: { + color: $optimade_cifplayer_theme.error, + }, + }, }, - Message_card: { - background: { - color: $mol_theme.back, + Warning_card: { + ...Message_card, + + Content: { + background: { + color: $optimade_cifplayer_theme.warning, + }, }, - margin: 'auto', }, Three: { diff --git a/player/player.web.view.tree b/player/player.web.view.tree index 1fbeace..6a73334 100644 --- a/player/player.web.view.tree +++ b/player/player.web.view.tree @@ -118,11 +118,11 @@ $optimade_cifplayer_player $mol_view \ \display none S \elements - ^ message_visible / <= Message $mol_view - sub / - <= Message_card $mol_card - theme \$mol_theme_special - title <= message \ + ^ message_visible / + <= Error_card $mol_card + title <= error \ + <= Warning_card $mol_card + title <= warning \ colors_light * a \#990000 b \#009900 diff --git a/player/player.web.view.ts b/player/player.web.view.ts index 7d1f7f7..b5c7897 100644 --- a/player/player.web.view.ts +++ b/player/player.web.view.ts @@ -99,16 +99,27 @@ namespace $.$$ { @ $mol_mem message_visible() { - return this.message() ? super.message_visible() : [] + if( this.error() ) return [ this.Error_card() ] + if( this.warning() ) return [ this.Warning_card() ] + return [] } @ $mol_mem - message(): string { + warning(): string { + try { + return this.structure_3d_data()?.warning ?? '' + } catch( error ) { + return '' + } + } + + @ $mol_mem + error(): string { try { this.structure_3d_data() return '' - } catch ( error: any ) { + } catch( error: any ) { return error.message || error } } diff --git a/theme/theme.css b/theme/theme.css new file mode 100644 index 0000000..03675f4 --- /dev/null +++ b/theme/theme.css @@ -0,0 +1,9 @@ +[mol_theme="$mol_theme_light"] { + --optimade_cifplayer_theme_error: hsl(0, 87%, 69%); + --optimade_cifplayer_theme_warning: hsl(290, 61%, 80%); +} + +[mol_theme="$mol_theme_dark"] { + --optimade_cifplayer_theme_error: hsl(0, 59%, 26%); + --optimade_cifplayer_theme_warning: hsl(290, 53%, 28%); +} diff --git a/theme/theme.ts b/theme/theme.ts new file mode 100644 index 0000000..33820e2 --- /dev/null +++ b/theme/theme.ts @@ -0,0 +1,11 @@ +namespace $ { + + export const $optimade_cifplayer_theme = $mol_style_prop( + 'optimade_cifplayer_theme', + [ + 'error', + 'warning', + ] as const + ) + +}