From dd934e29b2ecd548573928d88562b536f8f7189e Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 12 Mar 2022 15:11:12 +0100 Subject: Added table --- src/_objects.scss | 1 + src/objects/_table.scss | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ tpl/index.pug | 31 +++++++++++++++ tpl/objects/table.pug | 23 +++++++++++ 4 files changed, 159 insertions(+) create mode 100644 src/objects/_table.scss create mode 100644 tpl/objects/table.pug diff --git a/src/_objects.scss b/src/_objects.scss index ce91f5b..7f77968 100644 --- a/src/_objects.scss +++ b/src/_objects.scss @@ -17,3 +17,4 @@ @use 'objects/dialog'; @use 'objects/lightbox'; @use 'objects/list-group'; +@use 'objects/table'; diff --git a/src/objects/_table.scss b/src/objects/_table.scss new file mode 100644 index 0000000..e50e2fd --- /dev/null +++ b/src/objects/_table.scss @@ -0,0 +1,104 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; +@use '../mixins' as mx; + +@include iro.props-namespace('table') { + @include iro.props-store(( + --dims: ( + --pad-x: fn.global-dim(--size --200), + --pad-y: fn.global-dim(--size --125), + --rounding: 3px, + ), + ), 'dims'); + + @include iro.props-store(( + --colors: ( + --bg: fn.global-color(--bg-hi2), + --border: fn.global-color(--obj), + --hover: fn.global-color(--bg), + --press: fn.global-color(--obj-hi), + --heading: fn.global-color(--fg-hi), + ) + ), 'colors'); + + @include iro.bem-object(iro.props-namespace()) { + border-spacing: 0; + border-collapse: separate; + + @include iro.bem-elem('head-cell') { + @include mx.set-font(--standard, ( + --line-height: null, + --size: fn.global-dim(--font-size --50), + --weight: 500, + --transform: uppercase, + --spacing: .5px + )); + + padding: fn.dim(--pad-y) fn.dim(--pad-x); + color: fn.color(--heading); + text-align: left; + } + + @include iro.bem-elem('cell') { + padding: fn.dim(--pad-y) fn.dim(--pad-x); + border-width: 1px 0 0 0; + border-style: solid; + border-color: fn.color(--border); + background-color: fn.color(--bg); + + &:first-child { + border-left-width: 1px; + } + + &:last-child { + border-right-width: 1px; + } + } + + @include iro.bem-elem('row') { + &:first-child { + @include iro.bem-elem('cell') { + &:first-child { + border-top-left-radius: fn.dim(--rounding); + } + + &:last-child { + border-top-right-radius: fn.dim(--rounding); + } + } + } + + &:last-child { + @include iro.bem-elem('cell') { + border-bottom-width: 1px; + + &:first-child { + border-bottom-left-radius: fn.dim(--rounding); + } + + &:last-child { + border-bottom-right-radius: fn.dim(--rounding); + } + } + } + + @include iro.bem-next-twin-elem { + @include iro.bem-elem('cell') { + border-top: 1px solid fn.color(--border); + } + } + + &:hover { + @include iro.bem-elem('cell') { + background-color: fn.color(--hover); + } + } + + &:active { + @include iro.bem-elem('cell') { + background-color: fn.color(--press); + } + } + } + } +} diff --git a/tpl/index.pug b/tpl/index.pug index e1a6445..162a041 100644 --- a/tpl/index.pug +++ b/tpl/index.pug @@ -22,6 +22,7 @@ include objects/backdrop.pug include objects/dialog.pug include objects/lightbox.pug include objects/list-group.pug +include objects/table.pug mixin box +container(padX=true padY=true inPage=true) @@ -596,4 +597,34 @@ html +list-group-item(action=true)= 'Third item' +list-group-item(action=true)= 'Fourth item' + //----------------------------------------- + + +h1-heading('xl')= 'Table' + +rule('medium') + + +box + +table + +table-head + +table-row + +table-head-cell= 'Title' + +table-head-cell= 'Title' + +table-head-cell= 'Title' + +table-body + +table-row + +table-cell= 'Row 1,1' + +table-cell= 'Row 1,2' + +table-cell= 'Row 1,3' + +table-row + +table-cell= 'Row 2,1' + +table-cell= 'Row 2,2' + +table-cell= 'Row 2,3' + +table-row + +table-cell= 'Row 3,1' + +table-cell= 'Row 3,2' + +table-cell= 'Row 3,3' + +table-row + +table-cell= 'Row 4,1' + +table-cell= 'Row 4,2' + +table-cell= 'Row 4,3' + diff --git a/tpl/objects/table.pug b/tpl/objects/table.pug new file mode 100644 index 0000000..9fb2a06 --- /dev/null +++ b/tpl/objects/table.pug @@ -0,0 +1,23 @@ +mixin table + table.o-table + block + +mixin table-head + thead.o-table__head + block + +mixin table-head-cell + th.o-table__head-cell + block + +mixin table-body + tbody.o-table__body + block + +mixin table-row + tr.o-table__row + block + +mixin table-cell + td.o-table__cell + block -- cgit v1.2.3-54-g00ecf