styling corpus example components in main view
This commit is contained in:
parent
599338a775
commit
0bc7ea0c4b
|
@ -238,6 +238,18 @@
|
||||||
border: 1px @gray solid;
|
border: 1px @gray solid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comp-text {
|
||||||
|
margin-left: 0.5ch; // half width of '0'
|
||||||
|
}
|
||||||
|
|
||||||
|
.comp-role {
|
||||||
|
color: @red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comp-role-headword {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,5 @@ class ExampleClusterAdd(NoReset):
|
||||||
if cnum is not None:
|
if cnum is not None:
|
||||||
max_example_cluster_num = max(max_example_cluster_num, cnum)
|
max_example_cluster_num = max(max_example_cluster_num, cnum)
|
||||||
|
|
||||||
console.log(max_example_cluster_num, example.text())
|
|
||||||
example.set_cluster(max_example_cluster_num + 1)
|
example.set_cluster(max_example_cluster_num + 1)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from model.editable import Editable
|
from model.editable import Editable
|
||||||
from model.translation import from_container_list
|
from model.translation import from_container_list
|
||||||
from model.example_clusters import ExampleClusters
|
from model.example_clusters import ExampleClusters
|
||||||
|
from lib.snabbdom import h
|
||||||
|
|
||||||
|
|
||||||
class Example(Editable):
|
class Example(Editable):
|
||||||
|
@ -29,8 +30,8 @@ class Example(Editable):
|
||||||
result.appendChild(inner)
|
result.appendChild(inner)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def text(self):
|
def view(self):
|
||||||
return " ".join([comp.text for comp in self.components])
|
return self.inner.view(self.components)
|
||||||
|
|
||||||
def get_cluster(self):
|
def get_cluster(self):
|
||||||
return self.inner.get_cluster()
|
return self.inner.get_cluster()
|
||||||
|
@ -79,6 +80,9 @@ class CorpusExample:
|
||||||
def get_structure(self):
|
def get_structure(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def view(self, components):
|
||||||
|
return [h("span" + comp.view_style(), {}, comp.text) for comp in components]
|
||||||
|
|
||||||
|
|
||||||
class MultiwordExample:
|
class MultiwordExample:
|
||||||
def __init__(self, example_xml):
|
def __init__(self, example_xml):
|
||||||
|
@ -125,6 +129,9 @@ class MultiwordExample:
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def view(self, components):
|
||||||
|
return " ".join([comp.text for comp in components])
|
||||||
|
|
||||||
|
|
||||||
class ComponentLexeme(Editable):
|
class ComponentLexeme(Editable):
|
||||||
def __init__(self, xml):
|
def __init__(self, xml):
|
||||||
|
@ -159,4 +166,13 @@ class ComponentLexeme(Editable):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def view_style(self):
|
||||||
|
result = ".comp-text"
|
||||||
|
if self.role is not None:
|
||||||
|
result += ".comp-role"
|
||||||
|
if self.role == "headword":
|
||||||
|
result += ".comp-role-headword"
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class View:
|
||||||
example_content.append(h("span.example-cluster", {}, str(cluster + 1)))
|
example_content.append(h("span.example-cluster", {}, str(cluster + 1)))
|
||||||
|
|
||||||
example_text_inner_tag = "span.example-text-{}".format(example.get_view_type())
|
example_text_inner_tag = "span.example-text-{}".format(example.get_view_type())
|
||||||
example_content.append(h(example_text_inner_tag, {}, example.text()))
|
example_content.append(h(example_text_inner_tag, {}, example.view()))
|
||||||
|
|
||||||
other_attributes = example.get_other_attributes()
|
other_attributes = example.get_other_attributes()
|
||||||
if "frequency" in other_attributes:
|
if "frequency" in other_attributes:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user