Loading css/style.css 0 → 100644 +108 −0 Original line number Diff line number Diff line .RevisionGraph-open-btn { background: none; border: 1px solid black; border-radius: 10px; cursor: pointer; height: 50px; margin-bottom: 25px; padding: 10px; width: 135px; } .RevisionGraph-legend { display: none; padding: 20px; border: 1px solid black; border-radius: 10px; margin-bottom: 25px; margin-left: 0; max-width: 100%; position: relative; } .RevisionGraph-legend-item { align-items: center; display: flex; gap: 10px; } .RevisionGraph-tag { height: 31px; position: relative; width: 91px; } .RevisionGraph-tag:after { background: black; border-bottom-right-radius: 8px; border-top-right-radius: 8px; color: white; content: 'current'; height: 31px; left: 15px; line-height: 31px; position: absolute; text-align: center; width: 75px; } .RevisionGraph-tag:before { content: ""; right: 100%; position: absolute; width: 0; height: 0; left: 1px; border-top: 15px solid transparent; border-right: 15px solid black; border-bottom: 16px solid transparent; } .RevisionGraph-draft { border: 1px solid; padding: 5px; border-radius: 10px; } .RevisionGraph-revision { background: black; height: 27px; width: 27px; position: relative; color: white; text-align: center; line-height: 27px; border-radius: 50%; font-size: 10pt; } .RevisionGraph-revision:before { position: absolute; content: ''; width: 10px; background: black; height: 47px; top: -10px; left: 8px; z-index: -1; } .RevisionGraph-close-btn { color: gray; position: absolute; top: 0; right: 0; margin: 10px; height: 20px; width: 20px; text-align: center; line-height: 20px; transition: 300ms ease; cursor: pointer; border: 1px solid transparent; } .RevisionGraph-close-btn:hover { border-color: gray; border-radius: 50%; } js/revision_graph.js +12 −0 Original line number Diff line number Diff line const legendOpenBtn = document.querySelector('.RevisionGraph-open-btn'); const legend = document.querySelector('.RevisionGraph-legend'); const legendClose = document.querySelector('.RevisionGraph-close-btn'); legendOpenBtn.onclick = () => { legendOpenBtn.style.display = 'none'; legend.style.display = 'block'; } legendClose.onclick = () => { legend.style.display = 'none'; legendOpenBtn.style.display = 'block'; } var myTemplateConfig = { colors: ['#00c58e', '#0096db', '#ff6f40'], commit: { Loading revision_graph.libraries.yml +3 −0 Original line number Diff line number Diff line Loading @@ -11,5 +11,8 @@ revision_graph: version: 1.x dependencies: - revision_graph/gitgraph css: theme: css/style.css: {} js: js/revision_graph.js: {} revision_graph.module +14 −0 Original line number Diff line number Diff line Loading @@ -28,3 +28,17 @@ function revision_graph_entity_insert(EntityInterface $entity) { ->initGraph($entity); } } /** * Implements hook_theme(). */ function revision_graph_theme($existing, $type, $theme, $path) { return [ 'revision_graph' => [ 'variables' => [ 'commits' => NULL, 'initialBranch' => NULL, ], ], ]; } src/Controller/RevisionGraphNodeController.php +3 −4 Original line number Diff line number Diff line Loading @@ -61,10 +61,9 @@ class RevisionGraphNodeController extends NodeController { $commits = $this->revisionOverviewAsFakeCommits($node); return [ '#markup' => '<!-- DOM element in which we\'ll mount our graph --> <div id="graph-container">', '#theme' => 'revision_graph', '#attached' => [ 'library' => ['revision_graph/revision_graph'], 'library' => 'revision_graph/revision_graph', 'drupalSettings' => [ 'revision_graph' => [ 'commits' => $commits, Loading Loading @@ -137,7 +136,7 @@ class RevisionGraphNodeController extends NodeController { 'author' => '', 'subject' => '', 'style' => ['dot' => ['font' => '8pt courier']], 'branch' => isset($graph_data[$vid]) ? $graph_data[$vid] : RevisionGraphStorage::UNTRACKED_BANCH_NAME, 'branch' => $graph_data[$vid] ?? RevisionGraphStorage::UNTRACKED_BANCH_NAME, 'spawn_branches' => $branches_to_be_spawned, 'name' => $vid, 'dotText' => $vid, Loading Loading
css/style.css 0 → 100644 +108 −0 Original line number Diff line number Diff line .RevisionGraph-open-btn { background: none; border: 1px solid black; border-radius: 10px; cursor: pointer; height: 50px; margin-bottom: 25px; padding: 10px; width: 135px; } .RevisionGraph-legend { display: none; padding: 20px; border: 1px solid black; border-radius: 10px; margin-bottom: 25px; margin-left: 0; max-width: 100%; position: relative; } .RevisionGraph-legend-item { align-items: center; display: flex; gap: 10px; } .RevisionGraph-tag { height: 31px; position: relative; width: 91px; } .RevisionGraph-tag:after { background: black; border-bottom-right-radius: 8px; border-top-right-radius: 8px; color: white; content: 'current'; height: 31px; left: 15px; line-height: 31px; position: absolute; text-align: center; width: 75px; } .RevisionGraph-tag:before { content: ""; right: 100%; position: absolute; width: 0; height: 0; left: 1px; border-top: 15px solid transparent; border-right: 15px solid black; border-bottom: 16px solid transparent; } .RevisionGraph-draft { border: 1px solid; padding: 5px; border-radius: 10px; } .RevisionGraph-revision { background: black; height: 27px; width: 27px; position: relative; color: white; text-align: center; line-height: 27px; border-radius: 50%; font-size: 10pt; } .RevisionGraph-revision:before { position: absolute; content: ''; width: 10px; background: black; height: 47px; top: -10px; left: 8px; z-index: -1; } .RevisionGraph-close-btn { color: gray; position: absolute; top: 0; right: 0; margin: 10px; height: 20px; width: 20px; text-align: center; line-height: 20px; transition: 300ms ease; cursor: pointer; border: 1px solid transparent; } .RevisionGraph-close-btn:hover { border-color: gray; border-radius: 50%; }
js/revision_graph.js +12 −0 Original line number Diff line number Diff line const legendOpenBtn = document.querySelector('.RevisionGraph-open-btn'); const legend = document.querySelector('.RevisionGraph-legend'); const legendClose = document.querySelector('.RevisionGraph-close-btn'); legendOpenBtn.onclick = () => { legendOpenBtn.style.display = 'none'; legend.style.display = 'block'; } legendClose.onclick = () => { legend.style.display = 'none'; legendOpenBtn.style.display = 'block'; } var myTemplateConfig = { colors: ['#00c58e', '#0096db', '#ff6f40'], commit: { Loading
revision_graph.libraries.yml +3 −0 Original line number Diff line number Diff line Loading @@ -11,5 +11,8 @@ revision_graph: version: 1.x dependencies: - revision_graph/gitgraph css: theme: css/style.css: {} js: js/revision_graph.js: {}
revision_graph.module +14 −0 Original line number Diff line number Diff line Loading @@ -28,3 +28,17 @@ function revision_graph_entity_insert(EntityInterface $entity) { ->initGraph($entity); } } /** * Implements hook_theme(). */ function revision_graph_theme($existing, $type, $theme, $path) { return [ 'revision_graph' => [ 'variables' => [ 'commits' => NULL, 'initialBranch' => NULL, ], ], ]; }
src/Controller/RevisionGraphNodeController.php +3 −4 Original line number Diff line number Diff line Loading @@ -61,10 +61,9 @@ class RevisionGraphNodeController extends NodeController { $commits = $this->revisionOverviewAsFakeCommits($node); return [ '#markup' => '<!-- DOM element in which we\'ll mount our graph --> <div id="graph-container">', '#theme' => 'revision_graph', '#attached' => [ 'library' => ['revision_graph/revision_graph'], 'library' => 'revision_graph/revision_graph', 'drupalSettings' => [ 'revision_graph' => [ 'commits' => $commits, Loading Loading @@ -137,7 +136,7 @@ class RevisionGraphNodeController extends NodeController { 'author' => '', 'subject' => '', 'style' => ['dot' => ['font' => '8pt courier']], 'branch' => isset($graph_data[$vid]) ? $graph_data[$vid] : RevisionGraphStorage::UNTRACKED_BANCH_NAME, 'branch' => $graph_data[$vid] ?? RevisionGraphStorage::UNTRACKED_BANCH_NAME, 'spawn_branches' => $branches_to_be_spawned, 'name' => $vid, 'dotText' => $vid, Loading