cluster toggling

This commit is contained in:
2020-02-03 06:11:26 +01:00
parent 51fb697690
commit 5f298cd185
4 changed files with 20 additions and 4 deletions

View File

@@ -54,8 +54,11 @@ class View:
@staticmethod
def view_toggle_buttons(model):
txt = "Hide examples" if model.examples_shown else "Show examples"
return [ h("span.button.toggle", {"on": {"click": msg(ToggleExamples())}}, txt) ]
txt_examples = "Hide examples" if model.examples_shown else "Show examples"
txt_clusters = "Hide clusters" if model.clusters_shown else "Show clusters"
return [h("span.button.toggle", {"on": {"click": msg(ToggleExamples())}}, txt_examples),
h("span.button.toggle", {"on": {"click": msg(ToggleClusters())}}, txt_clusters)]
@staticmethod
@@ -138,13 +141,18 @@ class View:
if not model.examples_shown and not example.is_collocation():
parent_display = "none"
clusters_display = "inherit"
if not model.clusters_shown:
clusters_display = "none"
return h("div.example", {"style": {"display": parent_display}}, [
h("div.example-dot", dot_attr, ""),
h(example_tag, {}, [
h("span.example-text", {"on": {"click": msg(ShowExampleMenu(example))} }, example_content),
h("div.example-translation-list", {}, [
h("div.example-translation", {}, View.view_translations(example.translations, example, model))]),
h("div.example-clusters", {}, show_toggle_cluster_buttons(sense, example))])])
h("div.example-clusters",
{"style": {"display": clusters_display }}, show_toggle_cluster_buttons(sense, example))])])
@staticmethod
def view_translations(translations, parent, model):