structure adjustment

This commit is contained in:
2023-04-18 17:23:09 +08:00
parent af78bf0381
commit 22dbcf8db2
25 changed files with 519 additions and 138 deletions

51
lib/ui/css/checkbox.scss Normal file
View File

@ -0,0 +1,51 @@
@import './functions/checkbox.scss';
.checkbox-image {
>input[type="checkbox"] {
display: none;
&:checked {
&~.checked {
display: inline;
}
&~.unchecked {
display: none;
}
}
}
>.checked {
display: none;
}
>.unchecked {
display: inline;
}
}
.checkbox-wrapper {
display: inline-flex;
align-items: center;
padding: 0 8px;
height: 36px;
@include check-box();
.check-box-inner {
flex: 0 0 auto;
&+* {
flex: 1 1 auto;
font-weight: 400;
font-size: var(--font-size);
padding-left: 8px;
padding-right: 6px;
align-self: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
color: var(--color);
}
}
}

29
lib/ui/css/common.scss Normal file
View File

@ -0,0 +1,29 @@
.ui-text,
.ui-input {
font-size: var(--font-size);
font-family: var(--font-family);
border: 1px solid var(--box-color);
border-radius: var(--border-radius);
transition: border-color .2s;
&:focus,
&:focus-visible {
outline: none;
}
&:focus,
&:hover {
border-color: var(--focus-color);
}
&:disabled {
border-color: var(--disabled-box-color);
color: var(--disabled-color);
background-color: var(--disabled-bg-color);
}
}
.ui-input {
text-indent: var(--text-indent);
line-height: var(--line-height);
}

271
lib/ui/css/dropdown.scss Normal file
View File

@ -0,0 +1,271 @@
@import './functions/func.scss';
$headerHeight: 26px;
$caretWidth: 26px;
$dropItemHeight: 30px;
$scrollBarSize: 4px;
$searchBarHeight: 36px;
$searchInputHeight: 26px;
$searchIconSize: 13px;
$listMaxHeight: 210px;
.drop-wrapper {
display: inline-block;
border: none;
border-radius: unset;
user-select: none;
position: relative;
>.drop-header {
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
background-color: var(--bg-color);
display: flex;
height: $headerHeight;
transition: border-color .2s;
&:focus,
&:hover {
border-color: var(--focus-color);
// box-shadow: 0 0 3px 1px rgba(0, 0, 0, .2);
}
&:focus,
&:focus-visible {
outline: none;
}
/*>.drop-select-container {
flex: 1 1 auto;
overflow-x: auto;
white-space: nowrap;
display: flex;
flex-direction: row;
@include scrollbar();
&::-webkit-scrollbar {
height: $scrollBarSize;
}
&::-webkit-scrollbar-thumb {
border-radius: var(--border-radius);
}
>span {
display: inline-block;
margin: 2px;
padding: 0 2px;
border: 1px solid lightgray;
height: 20px;
line-height: 20px;
background-color: white;
font-size: $tinySize;
border-radius: var(--border-radius);
cursor: pointer;
position: relative;
>svg {
display: none;
width: 8px;
height: 20px;
fill: white;
vertical-align: top;
}
&:hover {
border-color: #1890ff;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
background-color: #1890ff;
color: white;
>svg {
display: inline-block;
margin-left: 3px;
padding: 0 2px;
}
}
}
>label {
flex: 1 1 auto;
min-width: 40px;
cursor: pointer;
outline: none;
line-height: $headerHeight;
padding: 0 4px;
font-weight: 400;
font-size: var(--font-smaller-size);
color: var(--color);
}
}*/
>.drop-text {
flex: 1 1 auto;
cursor: pointer;
font-size: var(--font-size);
// line-height: $headerHeight;
padding: 0 6px;
overflow: hidden;
text-overflow: ellipsis;
border: none;
outline: none;
white-space: nowrap;
}
>input.drop-text {
cursor: initial;
&::placeholder {
font-size: var(--font-smaller-size);
font-style: italic;
}
}
>.drop-caret {
flex: 0 0 auto;
width: $caretWidth;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
&::after {
display: block;
content: '';
border-top: 4px solid;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
height: 0;
width: 0;
}
}
&.disabled {
border-color: var(--disabled-bg-color);
color: var(--disabled-color);
&:focus {
border-color: var(--disabled-bg-color);
// box-shadow: none;
}
>.drop-text,
>.drop-caret {
cursor: default;
}
}
}
>.drop-box {
position: absolute;
visibility: hidden;
opacity: 0;
transform: scaleY(0);
transform-origin: top;
background-color: var(--bg-color);
top: calc($headerHeight + 2px);
z-index: 2;
transition: transform 120ms ease, opacity 120ms ease, visibility 120ms ease;
width: calc(100% + 2px);
box-sizing: border-box;
/*border: 1px solid var(--border-color);
border-top-width: 0;*/
box-shadow: 0 3px 6px -4px rgba(0, 0, 0, .12), 0 6px 16px 0 rgba(0, 0, 0, .08), 0 9px 28px 8px rgba(0, 0, 0, .05);
left: -1px;
&.slide-up {
/*border-top-width: 1px;
border-bottom-width: 0;*/
transform-origin: bottom;
top: unset;
bottom: calc($headerHeight + 2px);
}
&.active {
visibility: visible;
opacity: 1;
transform: scaleY(1);
}
>.drop-search {
box-sizing: border-box;
height: $searchBarHeight;
line-height: $searchBarHeight;
padding: 0 8px;
position: relative;
display: flex;
align-items: center;
>input[type="text"] {
box-sizing: border-box;
width: 100%;
height: $searchInputHeight;
outline: none;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 0 6px 0 22px;
color: var(--color);
transition: border-color .2s;
&:hover,
&:focus {
border-color: var(--focus-color);
}
// &:focus {
// box-shadow: 0 0 3px 1px rgba(0, 0, 0, .2);
// }
&::placeholder {
font-style: italic;
}
}
>svg {
position: absolute;
left: 14px;
width: $searchIconSize;
height: 100%;
cursor: text;
}
}
>.drop-list {
margin: 0;
padding: 0;
list-style: none;
max-height: $listMaxHeight;
overflow-y: auto;
font-size: var(--font-size);
@include scrollbar();
&.filtered>li:first-child {
background-color: var(--hover-bg-color);
}
>li {
// display: flex;
// align-items: center;
line-height: $dropItemHeight;
height: $dropItemHeight;
padding: 0 10px;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:hover,
&.selected {
background-color: var(--hover-bg-color);
}
>.checkbox-wrapper {
height: $dropItemHeight;
display: flex;
}
}
}
}
}

View File

@ -0,0 +1,68 @@
@mixin check-box() {
.check-box-inner {
position: relative;
display: inline-block;
padding: 0;
width: 14px;
height: 14px;
background-color: #fff;
border: 1px solid var(--box-color);
user-select: none;
border-radius: 2px;
transition: all .2s;
cursor: pointer;
>svg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
fill: #fff;
transform: scale(0);
opacity: 0;
transition: all .08s cubic-bezier(.78, .14, .15, .86);
}
}
&.radiobox-wrapper {
.check-box-inner {
box-sizing: border-box;
border-radius: 8px;
width: 16px;
height: 16px;
}
}
>input[type="checkbox"],
>input[type="radio"] {
display: none;
&:checked+.check-box-inner {
border-color: var(--link-color);
background-color: var(--link-color);
>svg {
transform: scale(1);
opacity: 1;
}
}
&:disabled {
&+.check-box-inner {
border-color: var(--disabled-box-color);
cursor: default;
}
&:checked+.check-box-inner {
border-color: var(--disabled-box-color);
background-color: var(--disabled-box-color);
}
&~span {
color: var(--disabled-box-color);
cursor: default;
}
}
}
}

View File

@ -0,0 +1,18 @@
@mixin inset($top, $right, $bottom, $left) {
top: $top;
right: $right;
bottom: $bottom;
left: $left;
}
@mixin scrollbar() {
&::-webkit-scrollbar {
width: 8px;
height: 8px;
}
&::-webkit-scrollbar-thumb {
background-color: rgba(168, 168, 168, 0.9);
border-radius: 4px;
}
}

378
lib/ui/css/grid.scss Normal file
View File

@ -0,0 +1,378 @@
@import './functions/func.scss';
.grid {
position: relative;
box-sizing: border-box;
display: flex;
flex-direction: column;
overflow: visible;
& {
--hover-bg-color: lightyellow;
--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;
--row-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: 6px 4px 6px 8px;
}
&:focus,
&:focus-visible {
outline: none;
}
&,
input[type="text"],
textarea,
.drop-wrapper>.drop-header>.drop-text,
.drop-wrapper>.drop-box>.drop-list {
font-size: var(--font-size);
font-family: var(--font-family);
}
>.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(--row-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"],
>textarea {
border: none;
box-sizing: border-box;
width: 100%;
padding: 0;
&:focus,
&:focus-visible {
outline: none;
}
&:disabled {
color: var(--text-disabled-color);
}
}
>input[type="text"] {
height: var(--row-height);
text-indent: var(--text-indent);
}
>textarea {
resize: none;
line-height: var(--line-height);
display: block;
padding: var(--spacing-cell);
white-space: nowrap;
@include scrollbar();
}
.checkbox-wrapper {
display: flex;
justify-content: center;
.check-box-inner {
&,
>svg {
transition: none;
}
}
}
.drop-wrapper {
height: var(--row-height);
width: 100%;
display: flex;
flex-direction: column;
>.drop-header {
border: none;
height: 100%;
>.drop-text {
padding: var(--spacing-cell);
}
}
>.drop-box {
top: calc(var(--row-height) + 2px);
&.slide-up {
top: unset;
bottom: calc(var(--row-height) + 2px);
}
}
}
.col-icon {
display: flex;
cursor: pointer;
justify-content: center;
align-items: center;
position: relative;
>svg {
width: 16px;
height: 16px;
fill: var(--primary-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;
}
}
}
}

297
lib/ui/css/popup.scss Normal file
View File

@ -0,0 +1,297 @@
@import './functions/func.scss';
$headerLineHeight: 24px;
$buttonHeight: 28px;
.popup-mask {
position: fixed;
@include inset(0, 0, 0, 0);
background-color: rgba(0 0 0 /20%);
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
z-index: 200;
transition: opacity .12s ease;
& {
--corner-radius: 6px;
--loading-size: 20px;
--loading-border-radius: 10px;
}
&.popup-active .popup-container {
transform: scale(1.1);
}
&.popup-transparent {
right: unset;
bottom: unset;
}
.popup-container {
min-width: 400px;
max-width: 800px;
background-color: var(--bg-color);
border-radius: var(--corner-radius);
box-shadow: 0 2px 8px rgba(0 0 0 /11%);
transition: opacity .12s ease, transform .12s ease;
position: absolute;
display: flex;
flex-direction: column;
.popup-header {
flex: 0 0 auto;
padding: 10px 12px 6px;
border-radius: var(--corner-radius) var(--corner-radius) 0 0;
line-height: $headerLineHeight;
user-select: none;
background-color: var(--title-bg-color);
color: var(--title-color);
display: flex;
align-items: center;
>div {
flex: 1 1 auto;
font-size: 1rem;
}
>.popup-header-title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
>svg {
flex: 0 0 auto;
width: $headerLineHeight;
height: $headerLineHeight;
fill: var(--title-color);
padding: 4px;
cursor: pointer;
box-sizing: border-box;
transition: opacity .12s ease;
&:hover {
opacity: .8;
}
}
}
.popup-body {
margin: 6px 10px;
flex: 1 1 auto;
line-height: $headerLineHeight;
position: relative;
min-height: 100px;
>.popup-loading {
position: absolute;
@include inset(0, 0, -46px, 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;
}
}
}
>.message-wrapper {
display: flex;
margin: 10px;
>svg {
width: 40px;
height: 40px;
&+span {
padding-left: 16px;
}
}
}
.setting-wrapper {
--line-height: 28px;
>.setting-item {
display: flex;
align-items: center;
line-height: var(--line-height);
margin: 4px 0;
>.setting-label {
flex: 0 0 auto;
width: 120px;
text-align: right;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding-right: 10px;
&.setting-required::after {
content: '*';
color: var(--red-color);
font-weight: bold;
}
&+* {
flex: 1 1 auto;
margin-right: 10px;
box-sizing: border-box;
height: var(--line-height);
line-height: var(--line-height);
}
&+input[type="text"],
&+input[type="email"],
&+input[type="tel"],
&+textarea {
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
text-indent: var(--text-indent);
transition: border-color .12s ease;
&:hover {
border-color: var(--focus-color);
}
&:focus,
&:focus-visible {
outline: none;
}
}
&+.drop-wrapper>.drop-header>.drop-text {
font-size: 12px;
}
&+.checkbox-wrapper {
padding: 0;
}
}
}
}
}
.popup-footer {
flex: 0 0 auto;
display: flex;
align-items: center;
justify-content: flex-end;
padding: 4px 10px 16px 2px;
.popup-button {
margin-left: 12px;
border: none;
height: $buttonHeight;
line-height: $buttonHeight;
color: var(--title-color);
border-radius: var(--corner-radius);
padding: 0 16px;
box-sizing: border-box;
min-width: 70px;
text-align: center;
cursor: pointer;
user-select: none;
background-color: var(--title-bg-color);
transition: opacity .12s ease;
&:hover {
opacity: .8;
}
&:focus,
&:focus-visible {
outline: none;
}
}
}
.popup-border {
position: absolute;
&.popup-border-left,
&.popup-border-right {
width: 6px;
height: 100%;
top: 0;
cursor: ew-resize;
}
&.popup-border-top,
&.popup-border-bottom {
width: 100%;
height: 6px;
left: 0;
cursor: ns-resize;
}
&.popup-border-top-left,
&.popup-border-top-right,
&.popup-border-bottom-right,
&.popup-border-bottom-left {
width: 8px;
height: 8px;
}
&.popup-border-top-left,
&.popup-border-bottom-right {
cursor: nwse-resize;
}
&.popup-border-top-right,
&.popup-border-bottom-left {
cursor: nesw-resize;
}
&.popup-border-left,
&.popup-border-top-left,
&.popup-border-bottom-left {
left: -4px;
}
&.popup-border-right,
&.popup-border-top-right,
&.popup-border-bottom-right {
right: -4px;
}
&.popup-border-top,
&.popup-border-top-left,
&.popup-border-top-right {
top: -4px;
}
&.popup-border-bottom,
&.popup-border-bottom-right,
&.popup-border-bottom-left {
bottom: -4px;
}
}
&.popup-collapse {
min-height: 40px;
min-width: 160px;
.popup-body,
.popup-footer,
.popup-border {
display: none;
}
}
}
}

51
lib/ui/css/tooltip.scss Normal file
View File

@ -0,0 +1,51 @@
.tooltip-color {
background-color: #fff;
color: #323130;
border-color: rgba(204, 204, 204, .8);
outline: none;
}
.tooltip-wrapper {
position: absolute;
word-wrap: break-word;
height: auto;
text-align: left;
z-index: 250;
min-width: 45px;
max-width: 480px;
min-height: 32px;
border-radius: 2px;
box-shadow: 0 3.2px 7.2px 0 rgba(0, 0, 0, .13), 0 0.6px 1.8px 0 rgba(0, 0, 0, .11);
transition: visibility 0s linear 120ms, opacity 120ms ease;
>.tooltip-pointer {
box-sizing: border-box;
box-shadow: 0 5px 15px 2px rgba(0, 0, 0, .3);
border: 1px solid #fff;
z-index: -1;
width: 16px;
height: 16px;
position: absolute;
left: calc(50% - 8px);
bottom: -8px;
transform: rotate(-45deg);
transform-origin: center;
}
>.tooltip-curtain {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
}
>.tooltip-content {
font-size: var(--font-smaller-size);
line-height: 1rem;
white-space: normal;
overflow: hidden;
margin: 8px;
height: calc(100% - 16px);
user-select: none;
}
}

View File

@ -0,0 +1,38 @@
// animation
@keyframes loading-spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
:root {
--color: #201f1e;
--red-color: red;
--bg-color: #fff;
--title-color: #fff;
--title-bg-color: rgb(68, 114, 196);
--border-color: #d9d9d9;
--focus-color: #666;
--disabled-bg-color: #e9e9e9;
--disabled-color: #aaa;
--box-color: #999898;
--disabled-box-color: #d9d9d9;
--hover-bg-color: #eee;
--link-color: #1890ff;
--primary-color: rgb(123, 28, 33);
--loading-bg-color: hsla(0, 0%, 100%, .4);
--loading-fore-color: rgba(0, 0, 0, .2);
--border-radius: 2px;
--text-indent: 4px;
--line-height: 24px;
--font-size: .8125rem; // 13px
--font-smaller-size: .75rem; // 12px
--font-larger-size: .875rem; // 14px
--font-family: "Franklin Gothic Book", "San Francisco", "Segoe UI", "Open Sans", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei UI", sans-serif;
}