From c93127861912c35e335d2b790a4e8bccf2a2f287 Mon Sep 17 00:00:00 2001 From: Markelle Kelly Date: Thu, 9 Aug 2018 15:52:07 -0700 Subject: [PATCH] Added show/hide cell functionality --- src/generators.tsx | 37 +++++++++++++++++++++++++++++++++++++ static/eyeball_hidden.svg | 3 +++ static/eyeball_hover.svg | 3 +++ static/eyeball_view.svg | 3 +++ style/index.css | 9 +++++++++ 5 files changed, 55 insertions(+) create mode 100644 static/eyeball_hidden.svg create mode 100644 static/eyeball_hover.svg create mode 100644 static/eyeball_view.svg diff --git a/src/generators.tsx b/src/generators.tsx index 4963ed0..246aff9 100644 --- a/src/generators.tsx +++ b/src/generators.tsx @@ -153,6 +153,11 @@ function notebookItemRenderer( 6: '10' }; let jsx; + const hideOnClick = (cell?: Cell) => { + if (cell) { + cell.inputHidden = !cell.inputHidden; + } + }; if (item.type === 'markdown' || item.type === 'header') { const paddingLeft = 24; const collapseOnClick = (cellRef?: Cell) => { @@ -221,6 +226,14 @@ function notebookItemRenderer(
{item.hasChild && twistButton} {jsx} +
+ { + hideOnClick(item.cellRef); + }} + /> +
); } @@ -271,6 +284,14 @@ function notebookItemRenderer(
{item.hasChild && twistButton} {jsx} +
+ { + hideOnClick(item.cellRef); + }} + /> +
); } @@ -284,6 +305,14 @@ function notebookItemRenderer( +
+ { + hideOnClick(item.cellRef); + }} + /> +
); } else if (item.type === 'raw' && options.showRaw) { @@ -292,6 +321,14 @@ function notebookItemRenderer( +
+ { + hideOnClick(item.cellRef); + }} + /> +
); } else { diff --git a/static/eyeball_hidden.svg b/static/eyeball_hidden.svg new file mode 100644 index 0000000..e28ffdb --- /dev/null +++ b/static/eyeball_hidden.svg @@ -0,0 +1,3 @@ + + + diff --git a/static/eyeball_hover.svg b/static/eyeball_hover.svg new file mode 100644 index 0000000..e084fc6 --- /dev/null +++ b/static/eyeball_hover.svg @@ -0,0 +1,3 @@ + + + diff --git a/static/eyeball_view.svg b/static/eyeball_view.svg new file mode 100644 index 0000000..297fae9 --- /dev/null +++ b/static/eyeball_view.svg @@ -0,0 +1,3 @@ + + + diff --git a/style/index.css b/style/index.css index 36a1ca2..3b3c2c5 100644 --- a/style/index.css +++ b/style/index.css @@ -222,6 +222,7 @@ TOTAL SIZE REMAINS AT 24PX INCLUDING MARGINS AND PADDING */ display: inline-flex; position: relative; align-items: center; + width: 100%; } .toc-collapse-button { @@ -232,6 +233,7 @@ TOTAL SIZE REMAINS AT 24PX INCLUDING MARGINS AND PADDING */ } .header-cell { + width: 100%; overflow-x: hidden; overflow-y: hidden; } @@ -248,3 +250,10 @@ TOTAL SIZE REMAINS AT 24PX INCLUDING MARGINS AND PADDING */ opacity: 0; overflow: hidden; } + +.eyeball-icon { + float: right; + padding: 0px; + margin: 0px; + padding-left: 7px; +}