Merge pull request #1729 from novnc/css_cleanup

Add styling for checkboxes and range-sliders
This commit is contained in:
Samuel Mannehed 2022-12-12 15:44:17 +01:00 committed by GitHub
commit 6a650ade2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 143 additions and 117 deletions

View File

@ -389,31 +389,25 @@ html {
vertical-align: middle; vertical-align: middle;
border:1px solid rgba(255, 255, 255, 0.2); border:1px solid rgba(255, 255, 255, 0.2);
border-radius: 6px; border-radius: 6px;
background: transparent; background-image: unset; /* we don't want the gradiant from input.css */
} }
#noVNC_control_bar .noVNC_button.noVNC_selected { #noVNC_control_bar .noVNC_button.noVNC_selected {
border-color: rgba(0, 0, 0, 0.8); border-color: rgba(0, 0, 0, 0.8);
background: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
} }
#noVNC_control_bar .noVNC_button:disabled { /* Android browsers don't properly update hover state if touch events are
opacity: 0.4; * intercepted, like they are when clicking on the remote screen. */
/* See firefox bug regarding cursor on disabled <input type="image">: :root:not(.noVNC_touch) #noVNC_control_bar .noVNC_button.noVNC_selected:not(:disabled):hover {
https://bugzilla.mozilla.org/show_bug.cgi?id=1798304 */ border-color: rgba(0, 0, 0, 0.4);
cursor: default; background-color: rgba(0, 0, 0, 0.2);
}
:root:not(.noVNC_touch) #noVNC_control_bar .noVNC_button:not(:disabled):hover {
background-color: rgba(255, 255, 255, 0.2);
} }
#noVNC_control_bar .noVNC_button:not(:disabled):active { #noVNC_control_bar .noVNC_button:not(:disabled):active {
padding-top: 5px; padding-top: 5px;
padding-bottom: 3px; padding-bottom: 3px;
} }
/* Android browsers don't properly update hover state if touch events are
* intercepted */
:root:not(.noVNC_touch) #noVNC_control_bar .noVNC_button.noVNC_selected:not(:disabled):hover {
border-color: rgba(0, 0, 0, 0.4);
background: rgba(0, 0, 0, 0.2);
}
:root:not(.noVNC_touch) #noVNC_control_bar .noVNC_button:not(:disabled):hover {
background: rgba(255, 255, 255, 0.2);
}
#noVNC_control_bar .noVNC_button.noVNC_hidden { #noVNC_control_bar .noVNC_button.noVNC_hidden {
display: none !important; display: none !important;
} }

View File

@ -5,25 +5,13 @@
* This file is licensed under the 2-Clause BSD license (see LICENSE.txt). * This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
*/ */
input, select, textarea { /*
* Common for all inputs
*/
input, input::file-selector-button, button, select, textarea {
/* Respect standard font settings */ /* Respect standard font settings */
font: inherit; font: inherit;
}
input:not([type]),
input[type=date],
input[type=datetime-local],
input[type=email],
input[type=month],
input[type=number],
input[type=password],
input[type=search],
input[type=tel],
input[type=text],
input[type=time],
input[type=url],
input[type=week],
textarea {
/* Disable default rendering */ /* Disable default rendering */
appearance: none; appearance: none;
background: none; background: none;
@ -32,71 +20,76 @@ textarea {
border: 1px solid rgb(192, 192, 192); border: 1px solid rgb(192, 192, 192);
border-radius: 5px; border-radius: 5px;
color: black; color: black;
background: linear-gradient(to top, rgb(255, 255, 255) 80%, rgb(240, 240, 240)); background-image: linear-gradient(to top, rgb(255, 255, 255) 80%, rgb(240, 240, 240));
} }
/*
* Buttons
*/
input[type=button], input[type=button],
input[type=color], input[type=color],
input[type=image], input[type=image],
input[type=reset], input[type=reset],
input[type=submit], input[type=submit],
input::file-selector-button,
button, button,
select { select {
/* Disable default rendering */
appearance: none;
background: none;
padding: 5px;
border: 1px solid rgb(192, 192, 192);
border-bottom-width: 2px; border-bottom-width: 2px;
border-radius: 5px;
color: black;
background: linear-gradient(to top, rgb(255, 255, 255), rgb(240, 240, 240));
/* This avoids it jumping around when :active */ /* This avoids it jumping around when :active */
vertical-align: middle; vertical-align: middle;
}
input[type=button],
input[type=color],
input[type=reset],
input[type=submit],
button {
padding-left: 20px; padding-left: 20px;
padding-right: 20px; padding-right: 20px;
} }
/*
* Select dropdowns
*/
select { select {
--select-arrow: calc(100% - 7px) no-repeat url('data:image/svg+xml;utf8, \ --select-arrow: url('data:image/svg+xml;utf8, \
<svg width="8" height="6" version="1.1" viewBox="0 0 8 6" \ <svg width="8" height="6" version="1.1" viewBox="0 0 8 6" \
xmlns="http://www.w3.org/2000/svg"> \ xmlns="http://www.w3.org/2000/svg"> \
<path d="m6.5 1.5 -2.5 3 -2.5 -3 5 0" stroke-width="3" \ <path d="m6.5 1.5 -2.5 3 -2.5 -3 5 0" stroke-width="3" \
stroke="rgb(31,31,31)" fill="none" \ stroke="rgb(31,31,31)" fill="none" \
stroke-linecap="round" stroke-linejoin="round" /> \ stroke-linecap="round" stroke-linejoin="round" /> \
</svg>'); </svg>');
background: var(--select-arrow), background-image: var(--select-arrow),
linear-gradient(to top, rgb(255, 255, 255), rgb(240, 240, 240)); linear-gradient(to top, rgb(255, 255, 255), rgb(240, 240, 240));
background-position: calc(100% - 7px), left top;
background-repeat: no-repeat;
padding-right: calc(2*7px + 8px); padding-right: calc(2*7px + 8px);
padding-left: 7px; padding-left: 7px;
} }
:root:not(.noVNC_touch) select:hover:not(:disabled) { select:active {
background: var(--select-arrow), /* Rotated arrow */
linear-gradient(to top, rgb(255, 255, 255), rgb(250, 250, 250)); --select-arrow: url('data:image/svg+xml;utf8, \
<svg width="8" height="6" version="1.1" viewBox="0 0 8 6" \
xmlns="http://www.w3.org/2000/svg" transform="rotate(180)" > \
<path d="m6.5 1.5 -2.5 3 -2.5 -3 5 0" stroke-width="3" \
stroke="rgb(31,31,31)" fill="none" \
stroke-linecap="round" stroke-linejoin="round" /> \
</svg>');
} }
option { option {
color: black; color: black;
background: white; background: white;
} }
/*
* Checkboxes
*/
input[type=checkbox] { input[type=checkbox] {
position: relative; position: relative;
appearance: none; background-color: white;
background-image: unset;
border: 1px solid dimgrey; border: 1px solid dimgrey;
border-radius: 3px; border-radius: 3px;
width: 0.8em; width: 13px;
height: 0.8em; height: 13px;
margin-right: 6px;
vertical-align: bottom; vertical-align: bottom;
transition: 0.2s background-color linear;
} }
input[type=checkbox]:checked { input[type=checkbox]:checked {
background-color: rgb(110, 132, 163); background-color: rgb(110, 132, 163);
@ -114,10 +107,30 @@ input[type=checkbox]:checked::after {
transform: rotate(40deg); transform: rotate(40deg);
} }
/*
* Radiobuttons
*/
input[type=radio] {
border-radius: 50%;
border: 1px solid dimgrey;
width: 12px;
height: 12px;
padding: 0;
margin-right: 6px;
transition: 0.2s border linear;
}
input[type=radio]:checked {
border: 6px solid rgb(110, 132, 163);
}
/*
* Range sliders
*/
input[type=range] { input[type=range] {
appearance: none; border: unset;
border-radius: 3px; border-radius: 3px;
height: 20px; height: 20px;
padding: 0;
background: transparent; background: transparent;
} }
/* -webkit-slider.. & -moz-range.. cant be in selector lists: /* -webkit-slider.. & -moz-range.. cant be in selector lists:
@ -151,78 +164,97 @@ input[type=range]::-moz-range-thumb {
margin-top: -7px; margin-top: -7px;
} }
input:not([type]):focus-visible, /*
input[type=button]:focus-visible, * File choosers
input[type=color]:focus-visible, */
input[type=image]:focus-visible, input[type=file] {
input[type=date]:focus-visible, background-image: none;
input[type=datetime-local]:focus-visible, border: none;
input[type=email]:focus-visible, }
input[type=month]:focus-visible, input::file-selector-button {
input[type=number]:focus-visible, margin-right: 6px;
input[type=password]:focus-visible,
input[type=reset]:focus-visible,
input[type=search]:focus-visible,
input[type=submit]:focus-visible,
input[type=tel]:focus-visible,
input[type=text]:focus-visible,
input[type=time]:focus-visible,
input[type=url]:focus-visible,
input[type=week]:focus-visible,
input[type=checkbox]:focus-visible,
input[type=range]:focus-visible,
button:focus-visible,
select:focus-visible,
textarea:focus-visible {
outline: 2px solid rgb(74, 144, 217);
outline-offset: 1px;
} }
input:not([type]):disabled, /*
input[type=button]:disabled, * Hover
input[type=color]:disabled, */
input[type=image]:disabled, :root:not(.noVNC_touch) input[type=button]:hover,
input[type=date]:disabled, :root:not(.noVNC_touch) input[type=color]:hover,
input[type=datetime-local]:disabled, :root:not(.noVNC_touch) input[type=image]:hover,
input[type=email]:disabled, :root:not(.noVNC_touch) input[type=reset]:hover,
input[type=month]:disabled, :root:not(.noVNC_touch) input[type=submit]:hover,
input[type=number]:disabled, :root:not(.noVNC_touch) input::file-selector-button:hover,
input[type=password]:disabled, :root:not(.noVNC_touch) button:hover {
input[type=reset]:disabled, background-image: linear-gradient(to top, rgb(255, 255, 255), rgb(250, 250, 250));
input[type=search]:disabled,
input[type=submit]:disabled,
input[type=tel]:disabled,
input[type=text]:disabled,
input[type=time]:disabled,
input[type=url]:disabled,
input[type=week]:disabled,
button:disabled,
select:disabled,
textarea:disabled {
color: rgb(128, 128, 128);
background: rgb(240, 240, 240);
} }
input[type=checkbox]:disabled, :root:not(.noVNC_touch) select:hover {
input[type=range]:disabled { background-image: var(--select-arrow),
opacity: 0.4; linear-gradient(to top, rgb(255, 255, 255), rgb(250, 250, 250));
background-position: calc(100% - 7px), left top;
background-repeat: no-repeat;
} }
/*
* Active (clicked)
*/
input[type=button]:active, input[type=button]:active,
input[type=color]:active, input[type=color]:active,
input[type=image]:active, input[type=image]:active,
input[type=reset]:active, input[type=reset]:active,
input[type=submit]:active, input[type=submit]:active,
input::file-selector-button:active,
button:active, button:active,
select:active { select:active {
border-bottom-width: 1px; border-bottom-width: 1px;
margin-top: 1px; margin-top: 1px;
} }
:root:not(.noVNC_touch) input[type=button]:hover:not(:disabled), /*
:root:not(.noVNC_touch) input[type=color]:hover:not(:disabled), * Focus (tab)
:root:not(.noVNC_touch) input[type=image]:hover:not(:disabled), */
:root:not(.noVNC_touch) input[type=reset]:hover:not(:disabled), input:focus-visible,
:root:not(.noVNC_touch) input[type=submit]:hover:not(:disabled), input:focus-visible::file-selector-button,
:root:not(.noVNC_touch) button:hover:not(:disabled) { button:focus-visible,
background: linear-gradient(to top, rgb(255, 255, 255), rgb(250, 250, 250)); select:focus-visible,
textarea:focus-visible {
outline: 2px solid rgb(74, 144, 217);
outline-offset: 1px;
}
input[type=file]:focus-visible {
outline: none; /* We outline the button instead of the entire element */
}
/*
* Disabled
*/
input:disabled,
input:disabled::file-selector-button,
button:disabled,
select:disabled,
textarea:disabled {
opacity: 0.4;
}
:root:not(.noVNC_touch) input[type=button]:disabled,
:root:not(.noVNC_touch) input[type=color]:disabled,
:root:not(.noVNC_touch) input[type=image]:disabled,
:root:not(.noVNC_touch) input[type=reset]:disabled,
:root:not(.noVNC_touch) input[type=submit]:disabled,
:root:not(.noVNC_touch) input:disabled::file-selector-button,
:root:not(.noVNC_touch) button:disabled,
:root:not(.noVNC_touch) select:disabled {
background-image: linear-gradient(to top, rgb(255, 255, 255), rgb(240, 240, 240));
border-bottom-width: 2px;
margin-top: 0;
}
input[type=file]:disabled {
background-image: none;
}
:root:not(.noVNC_touch) select:disabled {
background-image: var(--select-arrow),
linear-gradient(to top, rgb(255, 255, 255), rgb(240, 240, 240));
}
input[type=image]:disabled {
/* See Firefox bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1798304 */
cursor: default;
} }