discourse/app/assets/stylesheets/common/base/discourse.scss

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

806 lines
14 KiB
SCSS
Raw Normal View History

// Common
// global styles that apply to the Discourse application specifically
// BEWARE: changing these styles implies they take effect anywhere they are seen
// throughout the Discourse application
2023-11-29 03:10:41 +08:00
:root {
--d-input-bg-color: var(--secondary);
--d-input-text-color: var(--primary);
--d-input-border: 1px solid var(--primary-400);
--d-input-bg-color--disabled: var(--primary-low);
--d-input-text-color--disabled: var(--primary);
--d-input-border--disabled: 1px solid var(--primary-low);
}
// Animation Keyframes
@keyframes ping {
0% {
transform: scale(0.6);
box-shadow: 0 0 0 0 rgba(var(--success-rgb), 0.7);
}
70% {
transform: scale(1);
box-shadow: 0 0 0 10px rgba(var(--success-rgb), 0);
}
100% {
transform: scale(0.95);
box-shadow: 0 0 0 0 rgba(var(--success-rgb), 0);
}
}
@keyframes rotate-forever {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
2015-07-20 15:47:53 +08:00
}
@keyframes background-fade-highlight {
0% {
background-color: var(--tertiary-low);
}
100% {
background-color: transparent;
}
2014-05-20 11:55:46 +08:00
}
// placeholder
@keyframes placeHolderShimmer {
0% {
background-position: -1000px 0;
}
100% {
background-position: 1100px 0;
}
}
@media (prefers-reduced-motion: no-preference) {
.placeholder-animation {
animation-duration: 4s;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: placeHolderShimmer;
animation-timing-function: linear;
background: var(--primary-very-low);
background: linear-gradient(
to right,
var(--primary-very-low) 10%,
var(--primary-low) 18%,
var(--primary-very-low) 33%
);
}
}
// Base Elements
html {
height: 100%;
}
body {
background-attachment: fixed;
background-size: cover;
min-height: 100%;
box-sizing: border-box;
@include clearfix;
2014-05-20 11:55:46 +08:00
}
2018-01-19 15:12:30 +08:00
// setting a static limit on big and small prevents nesting abuse
big {
font-size: var(--font-up-5);
}
small {
font-size: var(--font-down-2);
}
2014-05-20 11:55:46 +08:00
blockquote {
@include post-aside;
2015-05-19 17:40:19 +08:00
clear: both;
2014-05-20 11:55:46 +08:00
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: var(--heading-font-family);
margin-top: 0;
margin-bottom: 0.5rem;
}
a.cancel {
margin-left: 1.25em;
line-height: normal;
color: var(--primary-high);
transition: color 250ms;
&:hover {
color: var(--danger);
}
}
ul.breadcrumb {
margin: 0 10px 0 10px;
}
2014-05-26 14:17:25 +08:00
a.no-href {
cursor: pointer;
}
img.avatar {
border-radius: 50%;
}
// don't wrap relative dates; we want Jul 26, '15, not: Jul
// 26,
// '15
span.relative-date {
white-space: nowrap;
}
legend {
color: var(--primary-high);
font-weight: bold;
}
label {
display: flex;
margin-bottom: 5px;
2018-09-19 23:48:48 +08:00
align-items: flex-start;
color: var(--primary-high);
&:not(.checkbox-label) {
font-weight: bold;
}
> .d-icon {
align-self: center;
margin-right: 4px;
}
a {
// flex removes whitespace characters between text nodes and elements
// so we need to add it back
margin: 0 0.25em;
}
2017-08-19 00:36:21 +08:00
}
input {
&[type="radio"],
&[type="checkbox"] {
2018-10-03 00:04:37 +08:00
margin-top: 0.17em;
margin-right: 0.43em;
margin-left: 0.1em;
line-height: var(--line-height-small);
cursor: pointer;
flex-shrink: 0; // Adding for safety, Safari will shrink checkboxes
}
&[type="submit"],
&[type="reset"],
&[type="button"],
&[type="radio"],
&[type="checkbox"] {
width: auto;
}
&.invalid {
background-color: var(--danger-low);
}
.radio &[type="radio"],
.checkbox &[type="checkbox"] {
float: left;
margin-left: -18px;
}
}
input {
&[type="text"],
&[type="password"],
&[type="datetime"],
&[type="datetime-local"],
&[type="date"],
&[type="month"],
&[type="time"],
&[type="week"],
&[type="number"],
&[type="email"],
&[type="url"],
&[type="search"],
&[type="tel"],
&[type="color"] {
@include appearance-none;
@include form-item-sizing;
display: inline-block;
margin-bottom: 9px;
2023-11-29 03:10:41 +08:00
color: var(--d-input-text-color);
background-color: var(--d-input-bg-color);
border: var(--d-input-border);
border-radius: var(--d-input-border-radius);
&:focus {
@include default-focus;
}
}
&[type="time"] {
max-width: 140px;
}
}
input[type="search"] {
&::-webkit-search-cancel-button,
&::-webkit-search-decoration {
-webkit-appearance: none;
appearance: none;
}
}
// Fixes Safari height inconsistency
::-webkit-datetime-edit {
display: inline;
}
// Fixes Webkit inconsistencies (Safari/Chrome)
::-webkit-datetime-edit-fields-wrapper,
::-webkit-datetime-edit-text,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-year-field {
padding-top: 0;
padding-bottom: 0;
}
2018-10-05 03:47:14 +08:00
::placeholder {
text-overflow: ellipsis;
2018-10-05 03:47:14 +08:00
}
textarea {
padding: $vpad $hpad;
box-sizing: border-box;
height: auto;
background-color: var(--secondary);
border: 1px solid var(--primary-400);
border-radius: 0;
&:focus {
@include default-focus;
}
}
select {
border: 1px solid var(--primary-low);
2017-08-19 00:36:21 +08:00
}
2015-03-28 02:42:27 +08:00
table {
th {
font-weight: normal;
color: var(--primary-medium);
text-align: left;
padding: 0.5em;
}
}
2023-11-29 03:10:41 +08:00
input,
select,
textarea {
color: var(--d-input-text-color);
2023-11-29 03:10:41 +08:00
caret-color: currentColor;
&[disabled],
&[readonly] {
cursor: not-allowed;
color: var(--d-input-text-color--disabled);
2023-11-29 03:10:41 +08:00
background-color: var(--d-input-bg-color--disabled);
border: var(--d-input-border--disabled);
}
&:focus:required:invalid {
color: var(--danger);
border-color: var(--danger);
outline: 1px solid var(--danger);
}
}
// Common Classes
.sortable {
white-space: nowrap;
.discourse-no-touch & {
&:hover,
&:focus {
background-color: var(--primary-low);
}
}
.d-icon {
margin-left: 0.25em;
}
@include unselectable;
cursor: pointer;
}
.radio,
.checkbox {
min-height: 18px;
padding-left: 18px;
.controls > &:first-child {
padding-top: 5px;
}
&.inline {
display: inline-block;
padding-top: 5px;
margin-bottom: 0;
vertical-align: middle;
}
2017-08-19 00:36:21 +08:00
}
.radio.inline .radio.inline,
.checkbox.inline .checkbox.inline {
margin-left: 10px;
}
.container {
@extend .clearfix;
}
.wrap {
--d-wrap-padding-h: 10px;
max-width: var(--d-max-width);
margin-right: auto;
margin-left: auto;
padding: 0 var(--d-wrap-padding-h);
.contents {
position: relative;
}
}
.boxed {
&.white {
background-color: var(--secondary);
}
2017-08-19 00:36:21 +08:00
}
.full-width {
margin-left: 12px;
}
2017-08-19 00:36:21 +08:00
.clear-transitions {
transition: none !important;
2017-08-19 00:36:21 +08:00
}
2017-08-19 00:36:21 +08:00
.tip {
display: inline-block;
&.good {
color: var(--success);
}
2017-08-19 00:36:21 +08:00
&.bad {
color: var(--danger);
}
2017-08-19 00:36:21 +08:00
}
2017-08-19 00:36:21 +08:00
.avatar-wrapper {
background-color: var(--secondary);
2017-08-19 00:36:21 +08:00
display: inline-block;
border-radius: 50%;
}
.unread-high-priority-notifications {
color: var(--secondary);
background: var(--success);
&.badge-notification[href] {
color: var(--secondary);
}
2014-07-26 01:33:38 +08:00
}
2014-08-22 22:45:51 +08:00
2020-12-18 23:03:51 +08:00
.d-header .header-dropdown-toggle .do-not-disturb-background {
position: absolute;
2022-05-27 17:15:14 +08:00
left: 0;
2020-12-18 23:03:51 +08:00
bottom: -1px;
}
.do-not-disturb-background {
display: flex;
align-items: center;
justify-content: center;
width: 1.25em;
background-color: var(--secondary);
2020-12-18 23:03:51 +08:00
border-radius: 50%;
height: 1.25em;
.d-icon.d-icon-discourse-dnd {
color: var(--header_primary-medium) !important;
font-size: 1em;
height: 1em;
width: 1em;
2020-12-18 23:03:51 +08:00
}
}
2022-05-27 17:15:14 +08:00
.d-header .header-dropdown-toggle .user-status-background {
position: absolute;
right: -3px;
bottom: -1px;
z-index: 1002;
}
.user-status-background {
display: flex;
align-items: center;
justify-content: center;
width: 1.25em;
height: 1.25em;
background-color: var(--secondary);
2022-05-27 17:15:14 +08:00
border-radius: 50%;
.emoji {
width: 14px;
height: 14px;
display: block;
}
}
.user-menu .quick-access-panel li.user-status .relative-date {
text-align: left;
font-size: var(--font-down-3);
padding-top: 0.45em;
margin-left: 0.75em;
color: var(--primary-medium);
}
.user-menu .quick-access-panel li.do-not-disturb {
2020-12-18 23:03:51 +08:00
display: flex;
flex: 0 0 100%;
flex-wrap: wrap;
align-items: center;
background: var(--secondary);
2020-12-18 23:03:51 +08:00
.do-not-disturb-inner-container {
display: flex;
width: 100%;
2020-12-18 23:03:51 +08:00
align-items: center;
.do-not-disturb-label {
display: flex;
align-items: center;
2020-12-18 23:03:51 +08:00
}
.relative-date {
2020-12-18 23:03:51 +08:00
text-align: left;
font-size: var(--font-down-3);
padding-top: 3px;
margin-left: 0.75em;
2020-12-18 23:03:51 +08:00
color: var(--primary-medium);
}
.d-icon-toggle-off,
.d-icon-toggle-on {
padding-top: 0;
}
.d-icon-toggle-on {
color: var(--tertiary);
2020-12-18 23:03:51 +08:00
}
}
}
.do-not-disturb-modal {
.do-not-disturb-choice {
display: grid;
grid-template-columns: 2em 1fr auto;
grid-template-rows: auto auto;
align-items: center;
cursor: pointer;
padding: 0.5em 0;
&:hover {
background-color: var(--tertiary-low);
}
label {
margin-bottom: 0;
}
}
}
2014-08-22 22:45:51 +08:00
.fade {
opacity: 0;
transition: opacity 0.15s linear;
2014-11-06 09:13:51 +08:00
&.in {
opacity: 1;
2014-11-06 09:13:51 +08:00
}
}
2014-11-14 03:15:36 +08:00
.inline-spinner {
display: inline-block;
margin: 0;
}
.spinner {
margin: 20px auto 20px auto;
position: relative;
-webkit-animation: rotate-forever 1s infinite linear;
animation: rotate-forever 1s infinite linear;
height: 30px;
width: 30px;
border: 4px solid var(--primary-low-mid);
border-right-color: transparent;
border-radius: 50%;
2014-11-14 03:15:36 +08:00
&.small {
width: 10px;
height: 10px;
margin: 0;
display: inline-block;
}
2014-11-06 09:13:51 +08:00
}
2016-02-07 06:22:46 +08:00
2016-06-07 02:18:15 +08:00
.content-list {
h3 {
color: var(--primary-medium);
font-size: var(--font-up-1);
2016-06-07 02:18:15 +08:00
padding-left: 5px;
margin-bottom: 10px;
}
ul {
list-style: none;
margin: 0;
li {
border-bottom: 1px solid var(--primary-low);
2016-06-07 02:18:15 +08:00
&:first-of-type {
border-top: 1px solid var(--primary-low);
2016-06-07 02:18:15 +08:00
}
a {
display: block;
padding: 10px;
color: var(--primary);
&:hover {
background-color: var(--primary-low);
color: var(--primary);
}
&.active {
font-weight: bold;
color: var(--primary);
background: var(--d-selected);
}
2016-06-07 02:18:15 +08:00
}
}
}
}
.form-vertical {
input,
textarea,
select {
display: inline-block;
margin-bottom: 0;
2018-10-02 22:42:49 +08:00
flex: 0 0 auto;
max-width: 100%;
}
2022-12-14 00:13:48 +08:00
.control-label:not(.checkbox-label) {
font-family: var(--heading-font-family);
font-weight: bold;
font-size: var(--font-up-2);
line-height: var(--line-height-large);
}
.control-group,
.controls {
margin-left: 0;
label {
font-weight: normal;
}
}
2016-02-07 06:22:46 +08:00
}
// Special elements
#main-outlet-wrapper {
box-sizing: border-box;
width: 100%;
display: grid;
grid-template-areas: "sidebar content";
grid-template-columns: 0 minmax(0, 1fr); // 0 column width needs to be set for CSS transitions
gap: 0;
#main-outlet {
grid-area: content;
}
}
#main-outlet {
padding-top: 1.5em;
}
#main {
img.avatar {
&.header {
width: 45px;
height: 45px;
}
&.medium {
width: 32px;
height: 32px;
}
&.small {
width: 25px;
height: 25px;
}
&.tiny {
width: 20px;
height: 20px;
}
}
.user-list {
.user {
padding-bottom: 5px;
}
}
}
#loading-message {
position: absolute;
font-size: var(--font-up-5);
text-align: center;
top: 120px;
left: 500px;
color: var(--primary);
}
#footer {
.container {
height: 50px;
.contents {
padding-top: 10px;
a[href] {
color: var(--secondary);
}
}
}
}
.inline {
display: inline;
}
.pref-email {
.row {
border-bottom: 1px solid #ddd;
margin: 5px 0px;
padding-bottom: 5px;
&:last-child {
border-bottom: 0;
}
}
.email-first {
font-size: 1.1em;
}
.email-second {
color: var(--primary-medium);
.primary {
color: var(--success);
font-weight: bold;
}
.unconfirmed {
font-style: italic;
}
}
.email-dropdown {
float: right;
.btn,
.btn:hover {
background: transparent;
.d-icon {
color: var(--primary-high);
}
}
}
.dropdown-menu {
width: 120px;
& .icon {
margin-top: auto;
}
}
}
.topic-statuses {
// avoid adding margin/padding on this parent; sometimes it appears as an empty container
float: left;
.topic-status {
margin: 0;
display: inline-flex;
color: var(--primary-medium);
margin-right: 0.2em;
.d-icon {
height: 0.74em;
width: 0.75em;
}
}
.topic-status-warning .d-icon-envelope {
color: var(--danger);
}
}
.broken-theme-alert-banner {
font-size: var(--base-font-size);
font-weight: bold;
padding: 5px 0;
background: var(--danger);
text-align: center;
z-index: z("max");
color: var(--secondary);
a {
color: var(--secondary);
text-decoration: underline;
}
.theme-error-suffix {
font-weight: normal;
}
}
.controls {
.grouped-control {
display: flex;
flex-direction: column;
.grouped-control-label {
padding: 0.25em 0;
}
.grouped-control-field {
flex: 1 0 auto;
display: flex;
padding-bottom: 0.25em;
label {
margin: 0;
}
}
}
}
a#skip-link {
padding: 0.25em 0.5em;
position: fixed;
top: -50px;
left: 1em;
color: var(--secondary);
background: var(--tertiary);
transition: top 0.3s ease-out;
z-index: z("header") + 1;
&:focus {
top: 0px;
transition: top 0.15s ease-in;
}
}
UX: improve touch, swipe, panning performance on mobile menus (#23775) PERF: improve touch, swipe, panning performance on mobile menus --- * stop event propagation on swipe events: other touch events were stealing a huge amount of time here. Stop event propagation when handling pan events. * animate with [web animations api](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API) * prefer translate3d to hint for gpu rendering. * query document for elements only on start move event, not on subsequent move events * remove unused calculations for directioned velocity and distance: all swipe/pan elements function in x/y direction only. * re-implement scroll locking behavior. re-implemented scroll lock behavior --- With stop event propagation, we need to re-implement scroll locking on menu swipes. Previously, this was using onTouchMove which was costly. We may now use styling with overflow-y:hidden to lock scroll behavior. overflow:hidden on html/body elements is now supported by iOS as of 2022 https://bugs.webkit.org/show_bug.cgi?id=153852 https://bugs.webkit.org/show_bug.cgi?id=220908 UX: improve swipe --- Some improvements to get gestures and swipes feeling a little more polished. This focuses on end gesture, and how we transfer it to a css animation to complete a menu open/close action. Multitouch: events may pan, scroll, and zoom - especially on iOS safari. Cancelling the swipe event allows for a more pleasant zooming experience. * ease-out on menus opening, linear on close * calculate animation duration for opening and closing, attempt to better transfer user swipe velocity to css animation. * more timely close/open and cleanup from calculated animation timing. * add animation to closing menus on cloak tap * correctly animate menus with ease-in and ease-out * add swipe cancel event on multitouch event DEV --- * lean on promises js animations api gives us promises to listen to. Update test waiters to use waitForPromise from @ember/test-waiters instead of reigster/unregister. * convert swipe mixin to its own class. Convert swipe callbacks to custom events on the element. Move shared functions for max animation time and close logic to new shared class. swipe-events lib uses custom events to trigger callbacks, rather than assuming implemented hard coded function from the mixin's base class. Custom events are triggered from the bound element as swipestart, swipeend, swipe Add shared convenience functions for swipe events so they can be more easily shared. A client receives an initial swipe event and can check some state to see if it wants to handle the swipe event and if it doesn't, calling `event.preventDefault();` will prevent `swipe` and `swipeend` events from firing until another distinct swipestart event is fired. Swipe events will auto-cancel on multitouch. The scroll lock has also exposed as its own utility class.
2023-10-17 02:27:00 +08:00
.scroll-lock {
overflow: hidden !important;
margin-right: var(--scroll-gap, 0);
}