ui-lib/css/grid.scss

372 lines
11 KiB
SCSS

@keyframes loading-spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
.grid {
position: relative;
box-sizing: border-box;
display: flex;
flex-direction: column;
overflow-x: hidden;
& {
--hover-bg-color: lightyellow;
--link-fore-color: #1890ff;
--link-disabled-color: #d9d9d9;
--header-border-color: #adaba9;
--header-bg-color: #fafafa;
--header-fore-color: #000;
--cell-border-color: #f0f0f0;
--cell-fore-color: #333;
--dark-border-color: #666;
--split-border-color: #b3b3b3;
--dragger-bg-color: #fff;
--dragger-cursor-color: #333;
--row-bg-color: #fff;
--row-active-bg-color: #fafafa;
--row-selected-bg-color: #e6f2fb;
--text-disabled-color: gray;
--loading-bg-color: hsla(0, 0%, 100%, .4);
--loading-fore-color: rgba(0, 0, 0, .2);
--font-size: .8125rem;
--line-height: 36px;
--header-line-height: 26px;
--text-indent: 8px;
--loading-size: 40px;
--loading-border-radius: 20px;
--arrow-size: 4px;
--split-width: 8px;
--dragger-size: 20px;
--dragger-opacity: .6;
--dragger-cursor-size: 4px;
--dragger-cursor-pos: -4px;
--dragger-cursor-opacity: .3;
--header-padding: 4px 12px 4px 8px;
--spacing-s: 4px;
--spacing-cell: 0 4px 0 8px;
}
&:focus,
&:focus-visible {
outline: none;
}
&,
input[type="text"],
.dropdown-wrapper>.dropdown-header>.dropdown-text,
.dropdown-wrapper>.dropdown-box>.dropdown-list {
font-size: var(--font-size);
}
>.grid-sizer {
position: absolute;
white-space: nowrap;
font-weight: bold;
visibility: hidden;
}
>.grid-header {
width: 100%;
min-width: 100%;
margin: 0;
border-bottom: 1px solid var(--header-border-color);
background-color: var(--header-bg-color);
color: var(--header-fore-color);
user-select: none;
border-collapse: collapse;
border-spacing: 0;
table-layout: fixed;
position: relative;
tr {
position: relative;
>th {
padding: 0;
margin: 0;
word-wrap: break-word;
white-space: normal;
position: relative;
>div {
line-height: var(--header-line-height);
min-height: var(--line-height);
display: flex;
align-items: center;
padding: var(--header-padding);
box-sizing: border-box;
// overflow-x: hidden;
>span {
overflow: hidden;
}
}
>.arrow {
width: 0;
height: 0;
top: 50%;
margin-top: calc(0px - var(--arrow-size) / 2);
right: calc(var(--arrow-size) / 2);
position: absolute;
&.asc {
border-bottom: var(--arrow-size) solid var(--dark-border-color);
}
&.desc {
border-top: var(--arrow-size) solid var(--dark-border-color);
}
&.asc,
&.desc {
border-left: var(--arrow-size) solid transparent;
border-right: var(--arrow-size) solid transparent;
}
}
>.spliter {
position: absolute;
height: 100%;
top: 0;
right: calc(0px - var(--split-width) /2);
width: var(--split-width);
cursor: ew-resize;
z-index: 1;
&::after {
content: '';
height: 100%;
width: 1px;
display: block;
margin: 0 auto;
transition: background-color .12s ease;
}
&:hover::after {
background-color: var(--split-border-color);
}
}
>.dragger {
position: absolute;
left: 0;
top: 0;
min-width: var(--dragger-size);
height: 100%;
background-color: var(--dragger-bg-color);
opacity: var(--dragger-opacity);
display: none;
}
>.dragger-cursor {
position: absolute;
top: 0;
height: 100%;
border: 1px solid var(--dragger-cursor-color);
box-sizing: border-box;
margin-left: 0;
opacity: var(--dragger-cursor-opacity);
display: none;
transition: left .12s ease;
&::before {
top: -1px;
border-top: var(--dragger-cursor-size) solid;
}
&::after {
bottom: -1px;
border-bottom: var(--dragger-cursor-size) solid;
}
&::before,
&::after {
content: '';
position: absolute;
left: var(--dragger-cursor-pos);
border-left: var(--dragger-cursor-size) solid transparent;
border-right: var(--dragger-cursor-size) solid transparent;
}
}
}
}
}
>.grid-body {
flex: 1 1 auto;
overflow: auto;
color: var(--cell-fore-color);
@include scrollbar();
.grid-body-content {
position: absolute;
min-width: 100%;
table-layout: fixed;
border-collapse: collapse;
border-spacing: 0;
>.grid-row {
line-height: var(--line-height);
white-space: nowrap;
background-color: var(--row-bg-color);
border-bottom: 1px solid var(--cell-border-color);
box-sizing: border-box;
&:hover {
background-color: var(--row-active-bg-color);
}
&.selected {
background-color: var(--row-selected-bg-color);
}
>td {
padding: 0;
>span {
padding: var(--spacing-cell);
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: pre;
}
>input[type="text"] {
border: none;
box-sizing: border-box;
height: calc(var(--line-height) + 2px);
width: 100%;
text-indent: var(--text-indent);
padding: 0;
&:focus,
&:focus-visible {
outline: none;
}
&:disabled {
color: var(--text-disabled-color);
}
}
.checkbox-wrapper .check-box-inner {
&,
>svg {
transition: none;
}
}
.dropdown-wrapper {
height: calc(var(--line-height) + 2px);
width: 100%;
display: flex;
flex-direction: column;
>.dropdown-header {
border: none;
height: 100%;
>.dropdown-text {
padding: var(--spacing-cell);
}
}
>.dropdown-box {
top: calc(var(--line-height) + 2px);
&.slide-up {
top: unset;
bottom: calc(var(--line-height) + 2px);
}
}
}
.icon {
display: flex;
cursor: pointer;
height: var(--line-height);
justify-content: center;
align-items: center;
position: relative;
>svg {
width: 16px;
height: 16px;
fill: var(--link-fore-color);
transition: opacity .12s ease;
}
&:hover>svg {
opacity: .4;
}
&.disabled {
cursor: unset;
>svg {
fill: var(--header-border-color);
opacity: unset;
}
}
}
}
}
}
.grid-hover-holder {
box-sizing: border-box;
position: absolute;
line-height: var(--line-height);
padding: var(--spacing-cell);
background-color: var(--hover-bg-color);
white-space: pre;
display: flex;
align-items: center;
visibility: hidden;
opacity: 0;
transition: visibility 0s linear .12s, opacity .12s ease;
&.active {
visibility: visible;
opacity: 1;
}
}
}
>.grid-loading {
position: absolute;
@include inset(0, 0, 0, 0);
visibility: hidden;
opacity: 0;
transition: visibility 0s linear .12s, opacity .12s ease;
background-color: var(--loading-bg-color);
display: flex;
justify-content: center;
align-items: center;
z-index: 1;
>div {
background-color: var(--loading-fore-color);
border-radius: var(--loading-border-radius);
>svg {
width: var(--loading-size);
height: var(--loading-size);
padding: 20px;
animation: loading-spinner 1.2s infinite linear;
}
}
}
}