From d39788c7886173b48399268d25c83874b1681a05 Mon Sep 17 00:00:00 2001 From: robert-ryu7 Date: Sun, 13 Nov 2022 21:49:59 +0100 Subject: [PATCH] Implement TableView component (#151) --- docs/index.html.ejs | 91 ++++++++++++++++++++++++++++++++++++ icon/sunken-panel-border.svg | 10 ++++ style.css | 42 +++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 icon/sunken-panel-border.svg diff --git a/docs/index.html.ejs b/docs/index.html.ejs index 6c1e8f1..2073dbf 100644 --- a/docs/index.html.ejs +++ b/docs/index.html.ejs @@ -41,6 +41,7 @@
  • TreeView
  • +
  • TableView
  • Issues, Contributing, etc.
  • @@ -798,6 +799,96 @@ +
    +

    TableView

    +
    +

    + To render a table view, use a table element. Wrap it with a div element with sunken-panel class to provide proper border and overflow container. +

    +

    + With a bit of extra scripting you can make table view interactive. Give interactive class to + table element to show pointer cursor when hovering over body rows. Table rows can be given + highlighted class to appear selected. +

    + + <%- example(` +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameVersionCompany
    MySQL ODBC 3.51 Driver3.51.11.00MySQL AB
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    SQL Server3.70.06.23Microsoft Corporation
    +
    + + `) %> +
    +
    +

    Issues, Contributing, etc.

    diff --git a/icon/sunken-panel-border.svg b/icon/sunken-panel-border.svg new file mode 100644 index 0000000..1f09c91 --- /dev/null +++ b/icon/sunken-panel-border.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/style.css b/style.css index 86e8e18..f222a15 100644 --- a/style.css +++ b/style.css @@ -99,6 +99,7 @@ input, textarea, select, option, +table, ul.tree-view, .window, .title-bar { @@ -790,3 +791,44 @@ summary:focus { width: 16px; background-image: svg-load("./icon/button-right.svg"); } + +.sunken-panel { + box-sizing: border-box; + border: 2px groove transparent; + border-image: svg-load("./icon/sunken-panel-border.svg") 2; + overflow: auto; + background-color: #fff; +} + +table { + border-collapse: collapse; + position: relative; + text-align: left; + white-space: nowrap; + background-color: #fff; +} + +table > thead > tr > * { + position: sticky; + top: 0; + height: 17px; + box-shadow: var(--border-raised-outer), var(--border-raised-inner); + background: var(--surface); + box-sizing: border-box; + font-weight: normal; + padding: 0 var(--grouped-element-spacing); +} + +table.interactive > tbody > tr { + cursor: pointer; +} + +table > tbody > tr.highlighted { + color: #fff; + background-color: var(--dialog-blue); +} + +table > tbody > tr > * { + padding: 0 var(--grouped-element-spacing); + height: 14px; +} \ No newline at end of file