1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 00:47:00 +02:00

feat: Declare & Use CSS Custom Properties (#3146)

This commit is contained in:
Sami Mazouz
2021-11-04 22:34:18 +01:00
committed by GitHub
parent 26bf5d350b
commit 809df29d29
44 changed files with 502 additions and 380 deletions

View File

@@ -12,7 +12,7 @@
list-style: none;
> li {
border-bottom: 1px solid @control-bg;
border-bottom: 1px solid var(--control-bg);
margin-bottom: 15px;
}
@@ -27,7 +27,7 @@
z-index: 1;
&, a {
color: @muted-color;
color: var(--muted-color);
}
a {
font-style: italic;

View File

@@ -3,12 +3,12 @@
.Composer {
pointer-events: auto;
box-shadow: 0 2px 6px @shadow-color;
box-shadow: 0 2px 6px var(--shadow-color);
&.minimized {
height: 46px;
cursor: pointer;
background: @control-bg;
background: var(--control-bg);
}
}
.Composer-controls {
@@ -39,7 +39,7 @@
h3 {
margin: 0;
line-height: 1.5em;
color: @secondary-color;
color: var(--secondary-color);
&, input, a {
font-size: 14px;
@@ -87,9 +87,9 @@
left: 0;
right: 0;
bottom: 0;
background: fade(@body-bg, 90%);
background: var(--body-bg-faded);
display: none;
border-radius: @border-radius @border-radius 0 0;
border-radius: var(--border-radius) var(--border-radius) 0 0;
&.active {
display: flex;
@@ -110,15 +110,15 @@
bottom: 0;
left: 0;
right: 0;
z-index: @zindex-composer;
background: @body-bg;
z-index: var(--zindex-composer);
background: var(--body-bg);
&:not(.minimized) {
position: fixed;
top: 0;
height: 350px !important;
max-height: 100%;
padding-top: @header-height-phone;
padding-top: var(--header-height-phone);
// Fixes a bug where fixed position doesn't properly work in Safari mobile
// https://github.com/flarum/core/issues/2652
@@ -139,7 +139,7 @@
& .Composer-controls {
position: static;
z-index: @zindex-header + 1;
z-index: calc(~"var(--zindex-header) + 1");
li:not(.App-backControl) {
display: none;
@@ -159,8 +159,8 @@
right: 0;
bottom: 0;
left: 0;
z-index: @zindex-composer - 1;
background-color: @overlay-bg;
z-index: calc(~"var(--zindex-composer) - 1");
background-color: var(--overlay-bg);
opacity: 0.9;
}
.ComposerBody-content {
@@ -176,7 +176,7 @@
> li {
display: block;
border-bottom: 1px solid @control-bg;
border-bottom: 1px solid var(--control-bg);
padding: 10px 15px;
.minimized & {
@@ -185,17 +185,17 @@
}
.normal &:first-child {
margin: -@header-height-phone 50px 0;
margin: calc(~"0px - var(--header-height-phone)") 50px 0;
text-align: center;
position: relative;
z-index: @zindex-header + 1;
z-index: calc(~"var(--zindex-header) + 1");
border: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
h3 {
color: @header-control-color;
color: var(--header-control-color);
}
}
}
@@ -219,22 +219,22 @@
bottom: 0;
left: 0;
right: 0;
z-index: @zindex-composer;
z-index: var(--zindex-composer);
pointer-events: none;
transition: left 0.2s;
}
.Composer {
border-radius: @border-radius @border-radius 0 0;
background: fade(@body-bg, 95%);
border-radius: var(--border-radius) var(--border-radius) 0 0;
background: var(--body-bg-faded);
position: relative;
height: 300px;
transition: background 0.2s, box-shadow 0.2s;
&.active, &.fullScreen {
background: @body-bg;
background: var(--body-bg);
}
&.active:not(.fullScreen) {
box-shadow: 0 0 0 2px @primary-color, 0 2px 6px @shadow-color;
box-shadow: 0 0 0 2px var(--primary-color), 0 2px 6px var(--shadow-color);
}
&.fullScreen {
position: fixed;
@@ -322,6 +322,6 @@
@media @desktop-hd {
.hasPane.panePinned .App-composer {
left: @pane-width;
left: var(--pane-width);
}
}

View File

@@ -14,7 +14,7 @@
}
.DiscussionListItem-content {
position: relative;
color: @muted-color;
color: var(--muted-color);
}
.DiscussionListItem-main {
color: inherit;
@@ -45,13 +45,13 @@
.DiscussionListItem-title {
margin: 0 0 3px;
line-height: 1.3;
color: @heading-color;
color: var(--heading-color);
font-weight: normal;
overflow: hidden;
text-overflow: ellipsis;
.DiscussionList:not(.DiscussionList--searchResults) .read & {
color: mix(@heading-color, @body-bg, 55%);
color: var(--discussion-title-color);
}
.DiscussionList:not(.DiscussionList--searchResults) .unread & {
font-weight: 600;
@@ -61,7 +61,7 @@
background: none;
box-shadow: none;
font-weight: bold;
color: @text-color;
color: var(--text-color);
}
}
.DiscussionListItem-info {
@@ -69,7 +69,7 @@
padding: 0;
margin: 0;
font-size: 11px;
color: @muted-more-color;
color: var(--muted-more-color);
> li {
display: inline;
@@ -110,10 +110,10 @@
}
}
@media (any-hover: none) {
.DiscussionListItem-controls > .Dropdown-toggle {
@media (any-hover: none) {
.DiscussionListItem-controls > .Dropdown-toggle {
display: none;
}
}
}
@media @phone {
@@ -125,7 +125,7 @@
padding-right: 15px + 35px;
&:active {
background: @control-bg;
background: var(--control-bg);
}
}
.DiscussionListItem-author {
@@ -158,14 +158,14 @@
}
.DiscussionListItem-count {
margin-right: -35px;
background: @control-bg;
color: @control-color;
border-radius: @border-radius;
background: var(--control-bg);
color: var(--control-color);
border-radius: var(--border-radius);
font-size: 12px;
padding: 2px 6px;
.unread & {
background: @primary-color;
background: var(--primary-color);
color: #fff;
font-weight: bold;
@@ -185,11 +185,11 @@
padding-right: 25px;
padding-left: 15px;
margin-left: -15px;
border-radius: @border-radius;
border-radius: var(--border-radius);
transition: background 0.2s;
&:hover {
background: mix(@control-bg, @body-bg, 50%);
background: var(--discussion-list-item-bg-hover);
}
&:hover .DiscussionListItem-controls,
.DiscussionListItem-controls.open {
@@ -245,7 +245,7 @@
margin-top: 12px;
margin-right: -70px;
width: 55px;
color: @muted-color;
color: var(--muted-color);
font-size: 14px;
padding-left: 21px;
@@ -257,7 +257,7 @@
margin-top: 3px;
}
.unread & {
color: @heading-color;
color: var(--heading-color);
font-weight: bold;
&:before {

View File

@@ -9,7 +9,7 @@
@media @phone {
.DiscussionPage-nav {
margin: 0 -15px;
border-bottom: 1px solid @control-bg;
border-bottom: 1px solid var(--control-bg);
> ul > li {
margin: 15px;
@@ -69,17 +69,17 @@
@media @tablet-up {
.DiscussionPage-list {
left: -@pane-width - 6px;
left: calc(~"-6px - var(--pane-width)");
position: absolute;
z-index: @zindex-pane;
z-index: var(--zindex-pane);
overflow: auto;
top: @header-height;
height: ~"calc(100vh - @{header-height})";
width: @pane-width;
background: @body-bg;
top: var(--header-height);
height: ~"calc(100vh - var(--header-height))";
width: var(--pane-width);
background: var(--body-bg);
padding-bottom: 40px;
border-top: 1px solid @control-bg;
box-shadow: 0 6px 6px @shadow-color;
border-top: 1px solid var(--control-bg);
box-shadow: 0 6px 6px var(--shadow-color);
transition: left 0.2s;
.affix & {
@@ -96,7 +96,7 @@
border-radius: 0;
&.active {
background: @control-bg;
background: var(--control-bg);
}
}
.DiscussionListItem-controls {
@@ -134,7 +134,7 @@
// When the pane is pinned, move the other page content inwards
.App-content, .App-footer {
.hasPane.panePinned & {
margin-left: @pane-width;
margin-left: var(--pane-width);
.container {
max-width: 100%;

View File

@@ -4,7 +4,7 @@
&-header {
@media @tablet-up {
padding: 12px 15px;
border-bottom: 1px solid @control-bg;
border-bottom: 1px solid var(--control-bg);
display: flex;
justify-content: space-between;
@@ -15,7 +15,7 @@
text-transform: uppercase;
font-weight: bold;
margin: 0;
color: @muted-color;
color: var(--muted-color);
}
}
@@ -29,11 +29,11 @@
// it. In this case we will need to reset the button's styles back to
// normal.
& when (@config-colored-header = true) {
color: @control-color;
color: var(--control-color);
&:hover,
&:focus {
color: @link-color;
color: var(--link-color);
}
}
@@ -48,7 +48,7 @@
// Message displayed when notifications are empty
&-empty {
color: @muted-color;
color: var(--muted-color);
text-align: center;
padding: 50px 0;
font-size: 16px;
@@ -56,7 +56,7 @@
}
.NotificationGroup {
border-top: 1px solid @control-bg;
border-top: 1px solid var(--control-bg);
margin-top: -1px;
&:not(:last-child) {
@@ -65,7 +65,7 @@
&-header {
font-weight: bold;
color: @heading-color !important;
color: var(--heading-color) !important;
padding: 8px 16px;
white-space: nowrap;
overflow: hidden;
@@ -79,13 +79,13 @@
}
&-badges {
@overlap: 13px;
--overlap: 13px;
margin-right: 8px;
padding-right: @overlap;
padding-right: var(--overlap);
.Badge {
margin-right: -@overlap;
margin-right: calc(~"0px - var(--overlap)");
position: relative;
.Badge--size(21px);
}
@@ -100,7 +100,7 @@
.Notification {
padding: 8px 16px;
color: @muted-color !important; // required to override .light-contents applied to header
color: var(--muted-color) !important; // required to override .light-contents applied to header
overflow: hidden;
display: grid;
@@ -118,14 +118,14 @@
.add-keyboard-focus-ring-offset(-1px);
&.unread {
background: @control-bg;
background: var(--control-bg);
}
&:hover,
&:focus,
&:focus-within {
text-decoration: none;
background: @control-bg;
background: var(--control-bg);
.Notification-action {
opacity: 1;
@@ -136,7 +136,7 @@
.Avatar--size(24px);
grid-area: avatar;
}
// Since images don't have baselines, aligning against the baseline won't work.
// Instead we need to do some manual hackery to fix then, otherwise they won't
// be correctly vertically aligned.
@@ -187,11 +187,11 @@
// Needs more specificity to fix hover/focus styles not applying in dropdown
.Notification & when (@config-colored-header = true) {
color: @control-color;
color: var(--control-color);
&:hover,
&:focus {
color: @link-color;
color: var(--link-color);
}
}
@@ -203,7 +203,7 @@
&-excerpt {
grid-area: excerpt;
color: @muted-more-color;
color: var(--muted-more-color);
font-size: 11px;
white-space: nowrap;
text-overflow: ellipsis;

View File

@@ -23,21 +23,21 @@
}
.NotificationsDropdown .Dropdown-toggle.new .Button-icon {
color: @header-color;
color: var(--header-color);
}
.NotificationsDropdown-unread {
position: absolute;
top: 2px;
left: 18px;
background: @header-control-color;
color: @header-bg;
background: var(--header-control-color);
color: var(--header-bg);
font-size: 11px;
font-weight: bold;
padding: 2px 4px 3px;
line-height: 1em;
border-radius: 10px;
box-shadow: 0 0 0 1px @header-bg;
box-shadow: 0 0 0 1px var(--header-bg);
min-width: 16px;
height: 16px;
text-align: center;
@@ -47,6 +47,6 @@
}
.new & {
background: @header-color;
background: var(--header-color);
}
}

View File

@@ -7,7 +7,7 @@
transition: 0.2s box-shadow, top 0.2s, opacity 0.2s;
position: relative;
top: 0;
border-radius: @border-radius;
border-radius: var(--border-radius);
.clearfix();
&.editing {
@@ -18,10 +18,10 @@
.Post-header {
margin-bottom: 15px;
color: @muted-color;
color: var(--muted-color);
&, a {
color: @muted-color;
color: var(--muted-color);
}
> ul {
list-style-type: none;
@@ -44,7 +44,7 @@
display: inline;
}
h3, h3 a {
color: @heading-color;
color: var(--heading-color);
font-weight: bold;
font-size: 14px;
}
@@ -56,7 +56,7 @@
font-size: 12px;
}
& .fa-circle {
color: @online-user-circle-color;
color: var(--online-user-circle-color);
}
}
@@ -64,7 +64,7 @@
position: absolute;
top: -10px;
left: -100px;
z-index: @zindex-dropdown;
z-index: var(--zindex-dropdown);
transition: opacity 0.2s, transform 0.2s;
transform: scale(0.95);
transform-origin: left top;
@@ -99,31 +99,31 @@
margin-bottom: 1em;
}
a {
border-bottom: 1px solid @control-bg;
border-bottom: 1px solid var(--control-bg);
font-weight: 600;
&:hover, &:focus, &:active {
text-decoration: none;
border-color: @link-color;
border-color: var(--link-color);
}
}
blockquote {
font-size: inherit;
border: 0;
background: @control-bg;
color: @control-color;
border-radius: @border-radius;
background: var(--control-bg);
color: var(--control-color);
border-radius: var(--border-radius);
padding: 8px 15px;
border-top: 2px dotted @body-bg;
border-bottom: 2px dotted @body-bg;
border-top: 2px dotted var(--body-bg);
border-bottom: 2px dotted var(--body-bg);
margin: 1em 0;
}
// Inline code
code {
font-family: source-code-pro, Monaco, Consolas, "Courier New", monospace;
padding: 5px;
background: @code-bg;
color: @code-color;
background: var(--code-bg);
color: var(--code-color);
line-height: 1.3;
font-size: 90%;
border-radius: 4px
@@ -132,10 +132,10 @@
pre {
border: 0;
padding: 0;
background: @code-bg;
color: #666;
background: var(--code-bg);
color: var(--code-color);
font-size: 90%;
border-radius: @border-radius;
border-radius: var(--border-radius);
overflow-wrap: normal;
code {
@@ -173,7 +173,7 @@
font-size: 100%;
}
h6 {
color: @muted-more-color;
color: var(--muted-more-color);
}
img, iframe {
max-width: 100%;
@@ -186,12 +186,12 @@
}
.Post--renderFailed {
background-color: @control-danger-bg;
background-color: var(--control-danger-bg);
}
.Post--hidden {
.Post-header, .Post-header a, .PostUser h3, .PostUser h3 a {
color: @muted-more-color;
color: var(--muted-more-color);
}
&:not(.revealContent) {
.Post-header {
@@ -205,7 +205,7 @@
opacity: 0.5;
}
.Post-header .Button--more {
.Button--color(@muted-more-color, fade(@muted-more-color, 30%), 'muted-more');
.Button--color-auto('muted-more');
}
}
.Post--loading {
@@ -217,14 +217,14 @@
.PostMeta .Dropdown-menu {
width: 420px;
padding: 10px;
color: @muted-color;
color: var(--muted-color);
@media @phone {
padding: 15px !important;
}
}
.PostMeta-number {
color: @text-color;
color: var(--text-color);
font-weight: bold;
}
.PostMeta-time, .PostMeta-ip {
@@ -249,7 +249,7 @@
}
.EventPost {
&, a {
color: @muted-color;
color: var(--muted-color);
}
a {
font-weight: bold;
@@ -266,7 +266,7 @@
margin: 0;
}
&, a {
color: @muted-color;
color: var(--muted-color);
}
a {
display: inline-block;
@@ -328,7 +328,7 @@
}
.PostPreview {
color: @muted-color;
color: var(--muted-color);
padding-left: 50px;
line-height: 1.7em;
@@ -342,7 +342,7 @@
.Avatar--size(32px);
}
.username {
color: @text-color;
color: var(--text-color);
font-weight: bold;
margin-right: 5px;
}
@@ -417,8 +417,8 @@
cursor: text;
overflow: hidden;
margin-top: 50px;
border: 2px dashed @control-bg;
color: @muted-color;
border: 2px dashed var(--control-bg);
color: var(--muted-color);
border-radius: 10px;
.Post-header {
@@ -439,7 +439,7 @@
margin-top: -18px;
}
&:hover {
border-color: @control-bg;
border-color: var(--control-bg);
}
}
.LoadingPost .Post-header {

View File

@@ -8,7 +8,7 @@
}
.PostStream-item {
&:not(:last-child) {
border-bottom: 1px solid @control-bg;
border-bottom: 1px solid var(--control-bg);
@media @phone {
margin: 0 -15px;
@@ -28,11 +28,11 @@
.fakeText {
display: inline-block;
vertical-align: middle;
background: @control-bg;
background: var(--control-bg);
height: 12px;
width: 100%;
margin-bottom: 20px;
border-radius: @border-radius;
border-radius: var(--border-radius);
.Post-header & {
height: 16px;
@@ -47,7 +47,7 @@
.PostStream-timeGap {
text-transform: uppercase;
font-weight: bold;
color: @muted-color;
color: var(--muted-color);
padding: 20px 20px 20px @avatar-column-width;
font-size: 12px;

View File

@@ -1,7 +1,7 @@
.Scrubber {
& a {
margin-left: -1px;
color: @muted-color;
color: var(--muted-color);
& .fa {
font-size: 14px;
@@ -9,7 +9,7 @@
}
&:hover, &:focus {
text-decoration: none;
color: @link-color;
color: var(--link-color);
}
}
}
@@ -22,16 +22,16 @@
.user-select(none);
}
.Scrubber-before, .Scrubber-after {
border-left: 1px solid @control-bg;
border-left: 1px solid var(--control-bg);
}
.Scrubber-unread {
position: absolute;
border-left: 1px solid lighten(@muted-color, 10%);
border-left: 1px solid var(--muted-color-light);
width: 100%;
background-image: linear-gradient(to right, @control-bg, fade(@control-bg, 0) 10px, fade(@control-bg, 0));
background-image: linear-gradient(to right, var(--control-bg), transparent 10px, transparent);
display: flex;
align-items: center;
color: @muted-color;
color: var(--muted-color);
text-transform: uppercase;
font-size: 11px;
font-weight: bold;
@@ -49,14 +49,14 @@
.Scrubber-bar {
height: 100%;
width: 5px;
background: @primary-color;
background: var(--primary-color);
border-radius: 4px;
float: left;
margin-left: -2px;
transition: background 0.2s;
.disabled & {
background: @control-bg;
background: var(--control-bg);
}
}
.Scrubber-info {
@@ -71,7 +71,7 @@
}
}
.Scrubber-description {
color: @muted-color;
color: var(--muted-color);
}
@media @phone {

View File

@@ -11,7 +11,7 @@
}
.Slidable-underneath {
display: none;
background: @secondary-color !important;
background: var(--secondary-color) !important;
position: absolute;
right: 0;
top: 0;
@@ -44,10 +44,10 @@
.sliding& {
position: relative;
background: @control-bg;
background: var(--control-bg);
z-index: 2;
border-radius: 2px;
box-shadow: 0 2px 6px @shadow-color;
box-shadow: 0 2px 6px var(--shadow-color);
}
}
}

View File

@@ -13,10 +13,10 @@
}
.UserCard--popover {
width: 500px;
box-shadow: 0 2px 6px @shadow-color;
box-shadow: 0 2px 6px var(--shadow-color);
&, .darkenBackground {
border-radius: @border-radius;
border-radius: var(--border-radius);
}
.container {
width: auto !important;
@@ -64,7 +64,7 @@
.Avatar {
.Avatar--size(96px);
border: 4px solid #fff;
box-shadow: 0 2px 6px @shadow-color;
box-shadow: 0 2px 6px var(--shadow-color);
@media @phone {
.Avatar--size(64px);
@@ -97,7 +97,7 @@
font-size: 14px;
}
&.online .fa-circle {
color: @online-user-circle-color;
color: var(--online-user-circle-color);
}
&.online .icon {
font-size: 12px;