Skip to content

Commit 2c8d3ee

Browse files
authored
Merge pull request #55 from stan-donarise/fixes-2
_cif_warning support
2 parents 8d8ac3c + c2162b2 commit 2c8d3ee

File tree

9 files changed

+82
-20
lines changed

9 files changed

+82
-20
lines changed

app/app.web.view.css.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace $.$$ {
5555
flex: {
5656
direction: 'column',
5757
grow: 1,
58+
shrink: 1,
5859
},
5960
},
6061

matinfio/cif/cif.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ namespace $ {
100100
continue
101101

102102
} else if( fingerprt.startsWith( '_cif_error' ) ) { // custom tag
103-
const error_message = cur_line.substr( 12, cur_line.length - 13 )
103+
const error_message = cur_line.substr( 11, cur_line.length - 11 )
104104
return this.$mol_fail( new $mol_data_error( error_message ) )
105105

106+
} else if( fingerprt.startsWith( '_cif_warning' ) ) { // custom tag
107+
cur_structure.warning = cur_line.substr( 13, cur_line.length - 13 )
108+
continue
109+
106110
} else if( fingerprt.startsWith( '_pauling_file_entry' ) ) { // custom tag
107111
cur_structure.mpds_data = true
108112
continue

matinfio/matinfio.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ namespace $ {
5454
cartesian: boolean,
5555
mpds_demo: boolean,
5656
mpds_data: boolean,
57+
58+
warning?: string,
5759
}
5860

5961
export type $optimade_cifplayer_matinfio_player_obj = {
@@ -69,6 +71,8 @@ namespace $ {
6971
info: string,
7072
mpds_demo: boolean,
7173
mpds_data: boolean,
74+
75+
warning?: string,
7276
}
7377

7478
export class $optimade_cifplayer_matinfio extends $mol_object2 {

matinfio/player/player.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ namespace $ {
3535
ng_name: parseInt( crystal.ng_name ),
3636
info: crystal.info,
3737
mpds_data: crystal.mpds_data,
38-
mpds_demo: crystal.mpds_demo
38+
mpds_demo: crystal.mpds_demo,
39+
40+
warning: crystal.warning,
3941
}
4042

4143
const groups: { fpos: number[] | null, cpos: number[], atoms: $optimade_cifplayer_matinfio_internal_obj_atom[] }[] = []

player/player.view.css.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
namespace $.$$ {
22

3+
const Message_card = {
4+
position: 'absolute',
5+
zIndex: 1,
6+
top: '6rem',
7+
width: '100%',
8+
align: {
9+
items: 'center'
10+
},
11+
background: {
12+
color: 'transparent',
13+
},
14+
boxShadow: 'none',
15+
} as const
16+
317
$mol_style_define( $optimade_cifplayer_player, {
418

519
background: {
@@ -136,19 +150,24 @@ namespace $.$$ {
136150
height: '2rem',
137151
},
138152

139-
Message: {
140-
position: 'absolute',
141-
zIndex: 1,
142-
top: '6rem',
143-
left: 0,
144-
right: 0,
153+
Error_card: {
154+
...Message_card,
155+
156+
Content: {
157+
background: {
158+
color: $optimade_cifplayer_theme.error,
159+
},
160+
},
145161
},
146162

147-
Message_card: {
148-
background: {
149-
color: $mol_theme.back,
163+
Warning_card: {
164+
...Message_card,
165+
166+
Content: {
167+
background: {
168+
color: $optimade_cifplayer_theme.warning,
169+
},
150170
},
151-
margin: 'auto',
152171
},
153172

154173
Three: {

player/player.web.view.tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ $optimade_cifplayer_player $mol_view
118118
\
119119
\display none
120120
S \elements
121-
^ message_visible / <= Message $mol_view
122-
sub /
123-
<= Message_card $mol_card
124-
theme \$mol_theme_special
125-
title <= message \
121+
^ message_visible /
122+
<= Error_card $mol_card
123+
title <= error \
124+
<= Warning_card $mol_card
125+
title <= warning \
126126
colors_light *
127127
a \#990000
128128
b \#009900

player/player.web.view.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,28 @@ namespace $.$$ {
9999

100100
@ $mol_mem
101101
message_visible() {
102-
return this.message() ? super.message_visible() : []
102+
if( this.error() ) return [ this.Error_card() ]
103+
if( this.warning() ) return [ this.Warning_card() ]
104+
return []
103105
}
104106

105107
@ $mol_mem
106-
message(): string {
108+
warning(): string {
109+
try {
110+
return this.structure_3d_data()?.warning ?? ''
111+
} catch( error ) {
112+
return ''
113+
}
114+
}
115+
116+
@ $mol_mem
117+
error(): string {
107118
try {
108119
this.structure_3d_data()
109120
return ''
110121

111-
} catch ( error: any ) {
122+
} catch( error: any ) {
123+
this.$.$mol_fail_log( error )
112124
return error.message || error
113125
}
114126
}

theme/theme.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[mol_theme="$mol_theme_light"] {
2+
--optimade_cifplayer_theme_error: hsl(0, 87%, 69%);
3+
--optimade_cifplayer_theme_warning: hsl(290, 61%, 80%);
4+
}
5+
6+
[mol_theme="$mol_theme_dark"] {
7+
--optimade_cifplayer_theme_error: hsl(0, 59%, 26%);
8+
--optimade_cifplayer_theme_warning: hsl(290, 53%, 28%);
9+
}

theme/theme.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace $ {
2+
3+
export const $optimade_cifplayer_theme = $mol_style_prop(
4+
'optimade_cifplayer_theme',
5+
[
6+
'error',
7+
'warning',
8+
] as const
9+
)
10+
11+
}

0 commit comments

Comments
 (0)