adds validation for fields.
* renames RoomTooltip to be a generic Tooltip (which it is) * hooks it into Field to show validation results * adds onValidate to Field to let Field instances call an arbitrary validation function Rebased from @ara4n's https://github.com/matrix-org/matrix-react-sdk/pull/2550 by @jryans. Subsequent commits revise and adapt this work.
This commit is contained in:
parent
a5c1d6733f
commit
40f16fa310
15 changed files with 154 additions and 47 deletions
|
@ -141,6 +141,39 @@ limitations under the License.
|
|||
color: $greyed-fg-color;
|
||||
}
|
||||
|
||||
.mx_Field_valid input,
|
||||
.mx_Field_valid select,
|
||||
.mx_Field_valid textarea {
|
||||
border-color: $input-valid-border-color ! important;
|
||||
}
|
||||
|
||||
.mx_Field_valid input + label,
|
||||
.mx_Field_valid select + label,
|
||||
.mx_Field_valid textarea + label {
|
||||
color: $input-valid-border-color ! important;
|
||||
}
|
||||
|
||||
.mx_Field_invalid input,
|
||||
.mx_Field_invalid select,
|
||||
.mx_Field_invalid textarea {
|
||||
border-color: $input-invalid-border-color ! important;
|
||||
}
|
||||
|
||||
.mx_Field_invalid input + label,
|
||||
.mx_Field_invalid select + label,
|
||||
.mx_Field_invalid textarea + label {
|
||||
color: $input-invalid-border-color ! important;
|
||||
}
|
||||
|
||||
.mx_Field_tooltip {
|
||||
margin-top: -12px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.mx_Field_tooltip.mx_Field_valid {
|
||||
animation: mx_fadeout 1s 2s forwards;
|
||||
}
|
||||
|
||||
// Customise other components when placed inside a Field
|
||||
|
||||
.mx_Field .mx_Dropdown_input {
|
||||
|
|
69
res/css/views/elements/_Tooltip.scss
Normal file
69
res/css/views/elements/_Tooltip.scss
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
Copyright 2015, 2016 OpenMarket Ltd
|
||||
Copyright 2019 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
@keyframes mx_fadein {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
@keyframes mx_fadeout {
|
||||
from { opacity: 1; }
|
||||
to { opacity: 0; }
|
||||
}
|
||||
|
||||
.mx_Tooltip_chevron {
|
||||
position: absolute;
|
||||
left: -7px;
|
||||
top: 10px;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 7px solid transparent;
|
||||
border-right: 7px solid $menu-border-color;
|
||||
border-bottom: 7px solid transparent;
|
||||
}
|
||||
|
||||
.mx_Tooltip_chevron:after {
|
||||
content:'';
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 6px solid transparent;
|
||||
border-right: 6px solid $menu-bg-color;
|
||||
border-bottom: 6px solid transparent;
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 1px;
|
||||
}
|
||||
|
||||
.mx_Tooltip {
|
||||
display: none;
|
||||
animation: mx_fadein 0.2s;
|
||||
position: fixed;
|
||||
border: 1px solid $menu-border-color;
|
||||
border-radius: 4px;
|
||||
box-shadow: 4px 4px 12px 0 rgba(118, 131, 156, 0.6);
|
||||
background-color: $menu-bg-color;
|
||||
z-index: 2000;
|
||||
padding: 10px;
|
||||
pointer-events: none;
|
||||
line-height: 14px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: $primary-fg-color;
|
||||
max-width: 200px;
|
||||
word-break: break-word;
|
||||
margin-right: 50px;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue