Refactor styling code

This commit is contained in:
panr 2020-06-20 00:07:59 +02:00
parent 409741f42c
commit 149fb37220
13 changed files with 44 additions and 136 deletions

View File

@ -16,11 +16,7 @@
} }
&:not(:last-of-type) { &:not(:last-of-type) {
border-bottom: 1px solid var(--light-border-color); border-bottom: 1px solid var(--border-color);
.dark-theme & {
border-color: var(--dark-border-color);
}
} }
} }
@ -32,11 +28,7 @@
} }
&:not(:last-of-type) { &:not(:last-of-type) {
border-bottom: 1px solid var(--light-border-color); border-bottom: 1px solid var(--border-color);
.dark-theme & {
border-color: var(--dark-border-color);
}
} }
&-header { &-header {
@ -65,11 +57,7 @@
padding: 20px 0; padding: 20px 0;
&:not(:last-of-type) { &:not(:last-of-type) {
border-bottom: 1px solid var(--light-border-color); border-bottom: 1px solid var(--border-color);
.dark-theme & {
border-color: var(--dark-border-color);
}
} }
&-title { &-title {

View File

@ -13,7 +13,7 @@ a.button {
justify-content: center; justify-content: center;
padding: 8px 18px; padding: 8px 18px;
margin-bottom: 5px; margin-bottom: 5px;
background: var(--light-background-secondary); background: var(--background-secondary);
text-decoration: none; text-decoration: none;
text-align: center; text-align: center;
font-weight: 500; font-weight: 500;
@ -23,24 +23,14 @@ a.button {
cursor: pointer; cursor: pointer;
outline: none; outline: none;
.dark-theme & {
background: var(--dark-background-secondary);
color: inherit;
}
/* variants */ /* variants */
&.outline { &.outline {
background: transparent; background: transparent;
border-color: var(--light-background-secondary); border-color: var(--background-secondary);
box-shadow: none; box-shadow: none;
padding: 8px 18px; padding: 8px 18px;
.dark-theme & {
border-color: var(--dark-background-secondary);
color: inherit;
}
:hover { :hover {
transform: none; transform: none;
box-shadow: none; box-shadow: none;
@ -82,10 +72,6 @@ a.read-more:active {
padding: 0; padding: 0;
margin: 20px 0; margin: 20px 0;
font-weight: bold; font-weight: bold;
.dark-theme & {
background: none;
}
} }
.code-toolbar { .code-toolbar {
@ -98,7 +84,7 @@ a.read-more:active {
justify-content: center; justify-content: center;
padding: 3px 8px; padding: 3px 8px;
margin-bottom: 5px; margin-bottom: 5px;
background: var(--light-background-secondary); background: var(--background-secondary);
text-decoration: none; text-decoration: none;
text-align: center; text-align: center;
font-size: 13px; font-size: 13px;
@ -108,10 +94,5 @@ a.read-more:active {
appearance: none; appearance: none;
cursor: pointer; cursor: pointer;
outline: none; outline: none;
.dark-theme & {
background: var(--dark-background-secondary);
color: inherit;
}
} }
} }

View File

@ -38,7 +38,7 @@
position: relative; position: relative;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
background: hsla(0, 0%, 10%, 10%); background: var(--background-secondary);
padding: 10px; padding: 10px;
border-top-left-radius: 10px; border-top-left-radius: 10px;
border-top-right-radius: 10px; border-top-right-radius: 10px;
@ -46,15 +46,11 @@
min-height: 30px; min-height: 30px;
margin: 0; margin: 0;
cursor: pointer; cursor: pointer;
.dark-theme & {
background: hsla(0, 0%, 10%, 40%);
}
} }
&__title { &__title {
flex: 1; flex: 1;
color: var(--accent); color: var(--color);
padding: 3px 10px; padding: 3px 10px;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
@ -62,19 +58,15 @@
} }
&__language { &__language {
background: hsl(0, 0%, 100%); background: var(--background);
color: var(--accent); color: var(--color);
border-radius: 10px; border-radius: 10px;
text-transform: uppercase; text-transform: uppercase;
padding: 3px 10px; padding: 3px 10px;
.dark-theme & {
background: hsla(0, 0%, 100%, 10%);
}
} }
&__toggle { &__toggle {
color: var(--accent); color: var(--color);
font-size: 16px; font-size: 16px;
padding: 3px 10px; padding: 3px 10px;

View File

@ -1,11 +1,7 @@
.footer { .footer {
padding: 40px 20px; padding: 40px 20px;
flex-grow: 0; flex-grow: 0;
color: var(--light-color-secondary); color: var(--color-secondary);
.dark-theme & {
color: var(--dark-color-secondary);
}
&__inner { &__inner {
display: flex; display: flex;
@ -53,4 +49,3 @@
} }
} }
} }

View File

@ -1,15 +1,11 @@
.header { .header {
background: var(--light-header); background: var(--header);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: relative; position: relative;
padding: 20px; padding: 20px;
.dark-theme & {
background: var(--dark-header);
}
&__right { &__right {
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@ -15,8 +15,8 @@ body {
font-size: 1rem; font-size: 1rem;
font-weight: 600; font-weight: 600;
line-height: 1.54; line-height: 1.54;
background-color: var(--light-background); background-color: var(--background);
color: var(--light-color); color: var(--color);
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
@ -25,11 +25,6 @@ body {
@media (--phone) { @media (--phone) {
font-size: 1rem; font-size: 1rem;
} }
&.dark-theme {
background-color: var(--dark-background);
color: var(--dark-color);
}
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
@ -131,16 +126,12 @@ figure {
code { code {
font-family: Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace; font-family: Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;
background: var(--light-background-secondary); background: var(--background-secondary);
padding: 1px 6px; padding: 1px 6px;
margin: 0 2px; margin: 0 2px;
border-radius: 5px; border-radius: 5px;
font-size: .9rem; font-size: .9rem;
font-weight: normal; font-weight: normal;
.dark-theme & {
background: var(--dark-background-secondary);
}
} }
pre { pre {
@ -161,10 +152,6 @@ pre {
margin: 0; margin: 0;
padding: 0; padding: 0;
font-size: .9rem; font-size: .9rem;
.dark-theme & {
color: inherit;
}
} }
} }
@ -210,11 +197,7 @@ table, th, td {
} }
th { th {
background: var(--light-background-secondary); background: var(--background-secondary);
.dark-theme & {
background: var(--dark-background-secondary);
}
} }
ul, ol { ul, ol {
@ -253,12 +236,8 @@ ol ol {
hr { hr {
width: 100%; width: 100%;
border: none; border: none;
background: var(--light-border-color); background: var(--border-color);
height: 1px; height: 1px;
.dark-theme & {
background: var(--dark-border-color);
}
} }
.hidden { .hidden {

View File

@ -1,21 +1,17 @@
@define-mixin menu { @define-mixin menu {
position: absolute; position: absolute;
background: var(--light-header); background: var(--header);
box-shadow: var(--shadow); box-shadow: var(--shadow);
margin: 0; margin: 0;
padding: 5px; padding: 5px;
list-style: none; list-style: none;
border-radius: 5px; border-radius: 5px;
z-index: 99; z-index: 99;
.dark-theme & {
background: var(--dark-background-secondary);
}
} }
.menu { .menu {
--shadow-color: rgba(0, 0, 0, .12); --color: rgba(0, 0, 0, .12);
--shadow: 0 8px 20px var(--shadow-color); --shadow: 0 8px 20px var(--color);
border-right: 1px solid; border-right: 1px solid;
margin-right: 18px; margin-right: 18px;
@ -118,10 +114,6 @@
background: rgba(0, 0, 0, 0.05); background: rgba(0, 0, 0, 0.05);
border-radius: 3px; border-radius: 3px;
cursor: pointer; cursor: pointer;
.dark-theme & {
background: rgba(0, 0, 0, 0.15);
}
} }
} }
} }

View File

@ -11,18 +11,13 @@
text-align: center; text-align: center;
margin: 0 auto; margin: 0 auto;
padding: 5px 10px; padding: 5px 10px;
background: var(--light-background); background: var(--background);
color: var(--light-color-secondary); color: var(--color-secondary);
font-size: .8rem; font-size: .8rem;
text-transform: uppercase; text-transform: uppercase;
text-decoration: none; text-decoration: none;
letter-spacing: .1em; letter-spacing: .1em;
z-index: 1; z-index: 1;
.dark-theme & {
background: var(--dark-background);
color: var(--dark-color-secondary);
}
} }
hr { hr {
@ -52,7 +47,7 @@
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
background: var(--light-background-secondary); background: var(--background-secondary);
font-size: 1rem; font-size: 1rem;
font-weight: 600; font-weight: 600;
border-radius: 8px; border-radius: 8px;
@ -61,10 +56,6 @@
cursor: pointer; cursor: pointer;
appearance: none; appearance: none;
.dark-theme & {
background: var(--dark-background-secondary);
}
+ .button { + .button {
margin-left: 10px; margin-left: 10px;
} }

View File

@ -10,11 +10,7 @@
} }
&:not(:last-of-type) { &:not(:last-of-type) {
border-bottom: 1px solid var(--light-border-color); border-bottom: 1px solid var(--border-color);
.dark-theme & {
border-color: var(--dark-border-color);
}
} }
&-meta { &-meta {

View File

@ -19,16 +19,12 @@
margin-bottom: 15px; margin-bottom: 15px;
&-count { &-count {
background: var(--light-background-secondary); background: var(--background-secondary);
font-size: 12px; font-size: 12px;
margin-left: 5px; margin-left: 5px;
padding: 2px 10px; padding: 2px 10px;
border-radius: 5px; border-radius: 5px;
text-decoration: none; text-decoration: none;
.dark-theme & {
background: var(--dark-background-secondary);
}
} }
} }
} }

View File

@ -1,25 +1,27 @@
:root { :root {
/* light theme color */ /* light theme color */
--light-background: #fff; --background: #fff;
--light-background-secondary: #eaeaea; --background-secondary: #eaeaea;
--light-header: #fafafa; --header: #fafafa;
--light-color: #222; --color: #222;
--light-color-secondary: #999; --color-secondary: #999;
--light-border-color: #dcdcdc; --border-color: #dcdcdc;
/* dark theme colors */
--dark-background: #292a2d;
--dark-background-secondary: #3b3d42;
--dark-header: #252627;
--dark-color: #a9a9b3;
--dark-color-secondary: #73747b;
--dark-border-color: #4a4b50;
/* variables for js, must be the same as these in @custom-media queries */ /* variables for js, must be the same as these in @custom-media queries */
--phoneWidth: (max-width: 684px); --phoneWidth: (max-width: 684px);
--tabletWidth: (max-width: 900px); --tabletWidth: (max-width: 900px);
} }
body.dark-theme {
/* dark theme colors */
--background: #292a2d;
--background-secondary: #3b3d42;
--header: #252627;
--color: #a9a9b3;
--color-secondary: #73747b;
--border-color: #4a4b50;
}
@custom-media --phone (width < 684px); @custom-media --phone (width < 684px);
@custom-media --tablet (width < 900px); @custom-media --tablet (width < 900px);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long