{"id":18690076,"url":"https://github.com/ottiker/flow-view","last_synced_at":"2025-11-08T07:30:39.276Z","repository":{"id":26089455,"uuid":"29533473","full_name":"ottiker/flow-view","owner":"ottiker","description":"A HTML renderer for flow.","archived":false,"fork":false,"pushed_at":"2017-10-24T15:35:27.000Z","size":509,"stargazers_count":0,"open_issues_count":7,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-28T02:27:02.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ottiker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-20T14:24:12.000Z","updated_at":"2016-11-11T15:14:34.000Z","dependencies_parsed_at":"2022-08-27T01:03:03.023Z","dependency_job_id":null,"html_url":"https://github.com/ottiker/flow-view","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottiker%2Fflow-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottiker%2Fflow-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottiker%2Fflow-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ottiker%2Fflow-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ottiker","download_url":"https://codeload.github.com/ottiker/flow-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239550283,"owners_count":19657541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T10:46:26.170Z","updated_at":"2025-11-08T07:30:39.236Z","avatar_url":"https://github.com/ottiker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# view\nA HTML renderer for jillix/engine.\n\n#### Config example\n\n```json\n{\n    \"template\": {\n        \"name\": {\n            \"to\": \"#css\",\n            \"css\": [\"/path/file.css\"],\n            \"httpClient\": \"http_client\",\n            \"html\": \"/path/file.html\",\n            \"title\": \"Document title\",\n            \"position:\" \"beforebegin|afterbegin|beforeend|afterend\"\n            \"clear\": false,\n            \"leaveKeys\": true,\n            \"dontEscape\": false,\n            \"events\": {\n                \"listener\": [\n                    {\n                        \"on\": \"event\",\n                        \"sel\": \"#css\",\n                        \"elm\": \"elmName\",\n                        \"dontPrevent\": true\n                    }\n                ]\n            }\n        }\n    },\n    \"states\": {\n        \"stateA\": [\n            {\n                \"sel\": \"#css\",\n                \"element\": \"elmName\",\n                \"states\": [\"stateB\"],\n                \"rm\": [\"className\"],\n                \"add\": [\"className\"],\n                \"toggle\": [\"className\"]\n            }\n        ]\n    }\n}\n```\n# WARNING! The docs below are outdated.\n\n#### HTML data attribute\n\nThe `element` flow option searches for elements that have a `data-element` attribute with that value.\n\n```html\n\u003cdiv data-element=\"myElement\"\u003e\u003c/div\u003e\n```\n\n#### Public mehtods\n\n* `render` (render data to a template)\n* `state` (activate a state)\n\n# Implementing standard configurations\nThis section covers \"how to do\" general configurations.\n\n#### Navbars\n\nThe navbar will be an instance of the view module.\n\nPractical example:\nThe composition file of the navbar `nav_layout`:\n\n```json\n{\n  \"client\": {\n    \"config\": {\n      \"templates\": {\n        \"layout\": {\n          \"to\": \".one-container\",\n          \"html\": \"/nav.html\",\n          \"render\": true\n        }\n      },\n      \"defaultTemplate\": \"layout\",\n      \"states\": {\n        \"resetNav\": [{\n            \"sel\": \".navbar li\",\n            \"rm\": [\"active\"]\n          }],\n        \"nav\": [{\n            \"states\": [\"resetNav\"],\n            \"add\": [\"active\"]\n          }]\n      },\n      \"domEvents\": [{\n          \"on\": \"click\",\n          \"selector\": \"li\",\n          \"flow\": \"itemClick\"\n        }]\n    },\n    \"flow\": [\n      [\n        \"itemClick\",\n        [\":ALTR\", {\"data\": {\"url\": \"{event.target.href}\"}}],\n        \":public_router/route\"\n      ]\n    ],\n    \"markup\": [\n      \"/nav.html\"\n    ]\n  },\n  \"name\": \"nav_layout\",\n  \"module\": \"view\",\n  \"roles\": {\n    \"*\": true\n  }\n}\n```\nThe states are for adding the active class to the active `li`.\nThe 'domEvents' triggers the 'itemClick' event on item click.\nHtml navbar example `nav.html`:\n\n```html\n\u003cul class=\"navbar\"\u003e\n    \u003cli\u003e\u003ca href=\"faq\"\u003eFAQ\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"features\"\u003eFeatures\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"pricing\"\u003ePricing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"signin\"\u003eLogin\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"signup\"\u003eSign up\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n```\n\nTo use the navbar in a view module instance it must be loaded:\n```json\n{\n  \"client\": {\n    \"load\": [\n      \"nav_layout\",\n    ],\n    \"config\": {\n    },\n    \"markup\": [\n    ]\n  },\n  \"roles\": {\n    \"*\": true\n  },\n  \"module\": \"view\",\n  \"name\": \"public_layout\"\n}\n```\n\n#### Footer visibility on certain pages\nThe footer will be a module view instance\n\n```json\n{\n  \"client\": {\n    \"config\": {\n      \"templates\": {\n        \"layout\": {\n          \"to\": \"footer\",\n          \"html\": \"/any_footer.html\",\n          \"render\": true\n        }\n      },\n      \"defaultTemplate\": \"layout\",\n    },\n    \"markup\": [\n      \"/any_footer.html\"\n    ]\n  },\n  \"name\": \"footer_layout\",\n  \"module\": \"view\",\n  \"roles\": {\n    \"*\": true\n  }\n}\n```\nThe main html file which contains and empty footer:\n```html\n\u003cdiv id=\"page-content\"\u003e\n    \u003cdiv class=\"_container hide\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n\u003cfooter\u003e\u003c/footer\u003e\n\n```\nIn the main composition, for ex. `private_layout.json`, `footer_layout` can be loaded and states can be used to control the footer visibility:\n```\n{\n  \"client\": {\n    \"load\": [\n      \"footer_private_layout\"\n    ]\n    ......\n    \"states\": {\n        \"showFooter\": [{\n            \"sel\": \"footer\",\n            \"rm\": [\"hide\"]\n    }],\n        \"hideFooter\": [{\n            \"sel\": \"footer\",\n            \"add\": [\"hide\"]\n        }]\n}\n```\nIn a view module instance composition in which the footer must be shown or hidden, the following flow configuration can be used:\n```json\n    \"flow\": [\n      [\n        \"renderedDOM\",\n        [\":private_layout/state\", \"showFooter\"],\n      ]\n    ]\n```\nor\n```json\n    \"flow\": [\n      [\n        \"renderedDOM\",\n        [\":private_layout/state\", \"hideFooter\"],\n      ]\n    ]\n```\n\n#### Loader for loading pages\nFor page loader implementation the states can be used to control the loader visibility\n\nIn the main html file the loader must be present and `hide` must be the default class for the pages container:\n```html\n\u003cdiv id=\"page-content\"\u003e\n    \u003cdiv class=\"pages-container _container hide\"\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"page-loader\"\u003eLoader\u003c/div\u003e\n\u003c/div\u003e\n```\nIn the main composition, for ex. 'private_layout.json', states can be defined to control the loader visibility:\n```json\n{\n    \"showLoader\": [{\n        \"sel\": \".page-loader\",\n        \"rm\": [\"hide\"]\n    }],\n    \"hideLoader\": [{\n        \"sel\": \".page-loader\",\n        \"add\": [\"hide\"]\n    }],\n    \"showContainer\": [{\n        \"sel\": \"._container\",\n        \"rm\": [\"hide\"]\n    }],\n    \"hideContainer\": [{\n        \"sel\": \"._container\",\n        \"add\": [\"hide\"]\n    }],\n    \"displayLoader\": [{\n        \"states\": [\n            \"showLoader\",\n            \"hideContainer\"\n            ]\n    }],\n    \"displayContainer\": [{\n        \"states\": [\n            \"showContainer\",\n            \"hideLoader\"\n            ]\n    }]\n}\n```\nIn the compositions in which the loader is needed, the flow configuration can be used to manipulate the loader state:\n```json\n\"flow\": [\n    [\n        \"renderedDOM\",\n        [\":private_layout/state\", \"displayContainer\"]\n    ]\n]\n```\nIn special cases (ex. service builder, service file editor) the `renderedDOM` event will not be the right event to be used for manipulating the loader states and thus a custom event will be needed.\n```json\n\"flow\": [\n    [\n        \"renderedGraph\",\n        [\":private_layout/state\", \"displayContainer\"]\n    ]\n]\n```\n#### Pages inside a certain container\nIf a section which contains multiple pages must be added to `container` class, states can be used to show/hide pages\n```html\n\u003cdiv class=\"pages-container container hide\"\u003e\u003c/div\u003e\n```\nA section added to `container` can be similar to the following:\n```html\n\u003cdiv class=\"app-options\"\u003e\n    \u003cdiv class=\"app-dashboard hide\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"app-editor hide\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"app-terminal hide\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\nA view module instance composition file `app_options_layout.json` can be used for the section configuration.\nThe `app_dashboard`, `app_editor`, `app_terminal` events from the flow configuration come from an engine-ruut module instance.\n```json\n\"states\": {\n    \"hide-all\": [{\n        \"sel\": \".app-options \u003e div\",\n        \"add\": [\"hide\"]\n    }],\n    \"app_dashboard\": [{\n        \"sel\": \".app-options \u003e .app-dashboard\",\n        \"rm\": [\"hide\"]\n    }],\n    \"app_editor\": [{\n        \"sel\": \".app-options \u003e .app-editor\",\n        \"rm\": [\"hide\"]\n    }],\n    \"app_terminal\": [{\n        \"sel\": \".app-options \u003e .app-terminal\",\n        \"rm\": [\"hide\"]\n    }]\n    }\n```\n```json\n\"flow\": [\n    [\n        \"renderedDOM\",\n        [\"LOAD\", [\"nav_app_layout\"]]\n    ],\n    [\n        \"app_dashboard\",\n        [\"LOAD\", [\"app_dashboard_layout\"]],\n        [\":state\", \"hide-all\"],\n        [\":state\", \"app_dashboard\"],\n    ],\n    [\n        \"app_editor\",\n        [\"LOAD\", [\"app_editor_layout\"]],\n        [\":state\", \"hide-all\"],\n        [\":state\", \"app_editor\"]\n    ],\n    [\n        \"app_terminal\",\n        [\"LOAD\", [\"app_terminal_layout\"]],\n        [\":state\", \"hide-all\"],\n        [\":state\", \"app_terminal\"],\n    ]\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fottiker%2Fflow-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fottiker%2Fflow-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fottiker%2Fflow-view/lists"}