From 4b2a8a5d877c653d52103a0bf8472b43ebed3a2d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 21 Mar 2021 22:49:39 +0100 Subject: [PATCH] layout tweaks --- gatsby/sources.js | 6 +- src/components/Layout.module.css | 24 ++++ src/components/atoms/Breakout.module.css | 11 -- src/components/atoms/Container.module.css | 11 -- src/components/atoms/Exif.module.css | 1 + src/components/atoms/Image.tsx | 12 +- .../molecules/RelatedPosts.module.css | 4 - .../molecules/Search/SearchResults.module.css | 2 +- .../templates/Post/Actions.module.css | 4 +- .../templates/Post/PrevNext.module.css | 1 - .../templates/Post/index.module.css | 4 +- src/global/_alerts.css | 46 ++++++ src/global/_mixins.scss | 134 ------------------ src/global/_variables.css | 4 +- src/global/global.css | 11 +- src/pages/index.module.css | 4 +- 16 files changed, 99 insertions(+), 180 deletions(-) delete mode 100644 src/components/atoms/Breakout.module.css delete mode 100644 src/components/atoms/Container.module.css create mode 100644 src/global/_alerts.css delete mode 100644 src/global/_mixins.scss diff --git a/gatsby/sources.js b/gatsby/sources.js index 1bf19082..3c6cf3a7 100644 --- a/gatsby/sources.js +++ b/gatsby/sources.js @@ -44,10 +44,10 @@ module.exports = [ url: 'https://api.github.com/graphql', headers: { Authorization: `bearer ${process.env.GATSBY_GITHUB_TOKEN}` - }, + } // Additional options to pass to node-fetch - fetchOptions: {}, - refetchInterval: 300 // 5 min. + // fetchOptions: {}, + // refetchInterval: 300 // 5 min. } } ] diff --git a/src/components/Layout.module.css b/src/components/Layout.module.css index e1bdcd00..dd3fa493 100644 --- a/src/components/Layout.module.css +++ b/src/components/Layout.module.css @@ -49,3 +49,27 @@ min-height: 500px; } } + +.container { + width: 100%; + max-width: var(--maxWidthContent); + margin-left: auto; + margin-right: auto; +} + +.wide { + composes: container; + max-width: none; +} + +.breakout { + margin-left: calc(-50vw + 50%); + margin-right: calc(-50vw + 50%); +} + +@media (min-width: 1000px) { + .breakout { + margin-left: -8rem; + margin-right: -8rem; + } +} diff --git a/src/components/atoms/Breakout.module.css b/src/components/atoms/Breakout.module.css deleted file mode 100644 index cb410172..00000000 --- a/src/components/atoms/Breakout.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.breakout { - margin-left: calc(-50vw + 50%); - margin-right: calc(-50vw + 50%); -} - -@media (min-width: 70rem) { - .breakout { - margin-left: -6rem; - margin-right: -6rem; - } -} diff --git a/src/components/atoms/Container.module.css b/src/components/atoms/Container.module.css deleted file mode 100644 index e57427ef..00000000 --- a/src/components/atoms/Container.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.container { - width: 100%; - max-width: var(--maxWidthContent); - margin-left: auto; - margin-right: auto; -} - -.wide { - composes: container; - max-width: none; -} diff --git a/src/components/atoms/Exif.module.css b/src/components/atoms/Exif.module.css index 0511445d..28e5330b 100644 --- a/src/components/atoms/Exif.module.css +++ b/src/components/atoms/Exif.module.css @@ -48,6 +48,7 @@ } .map { + composes: breakout from '../Layout.module.css'; composes: frame from './Image.module.css'; height: 180px; margin-top: calc(var(--spacer) * 2); diff --git a/src/components/atoms/Image.tsx b/src/components/atoms/Image.tsx index 26c931ef..8b45c05e 100644 --- a/src/components/atoms/Image.tsx +++ b/src/components/atoms/Image.tsx @@ -25,7 +25,7 @@ export const imageSizeDefault = graphql` original { src } - gatsbyImageData(layout: CONSTRAINED, width: 950, quality: 85) + gatsbyImageData(layout: CONSTRAINED, width: 1040, quality: 85) } ` @@ -34,7 +34,7 @@ export const imageSizeThumb = graphql` original { src } - gatsbyImageData(layout: CONSTRAINED, width: 420, height: 140, quality: 85) + gatsbyImageData(layout: CONSTRAINED, width: 480, height: 140, quality: 85) } ` @@ -43,6 +43,12 @@ export const photoSizeThumb = graphql` original { src } - gatsbyImageData(layout: CONSTRAINED, width: 300, height: 300, quality: 85) + gatsbyImageData( + layout: CONSTRAINED + width: 316 + height: 316 + quality: 85 + transformOptions: { cropFocus: CENTER } + ) } ` diff --git a/src/components/molecules/RelatedPosts.module.css b/src/components/molecules/RelatedPosts.module.css index f8cca035..535a705e 100644 --- a/src/components/molecules/RelatedPosts.module.css +++ b/src/components/molecules/RelatedPosts.module.css @@ -1,7 +1,3 @@ -.relatedPosts { - composes: container from '../atoms/Container.module.css'; -} - .title { font-size: var(--font-size-h3); margin-bottom: var(--spacer); diff --git a/src/components/molecules/Search/SearchResults.module.css b/src/components/molecules/Search/SearchResults.module.css index 7a253efa..615cd81d 100644 --- a/src/components/molecules/Search/SearchResults.module.css +++ b/src/components/molecules/Search/SearchResults.module.css @@ -13,7 +13,7 @@ } .results { - composes: container from '../../atoms/Container.module.css'; + composes: container from '../../Layout.module.css'; padding: var(--spacer) calc(var(--spacer) / 2); margin-bottom: 0; display: flex; diff --git a/src/components/templates/Post/Actions.module.css b/src/components/templates/Post/Actions.module.css index 9073dde4..539c0dee 100644 --- a/src/components/templates/Post/Actions.module.css +++ b/src/components/templates/Post/Actions.module.css @@ -1,9 +1,9 @@ .actions { + composes: breakout from '../../Layout.module.css'; margin-top: calc(var(--spacer) * 2); margin-bottom: calc(var(--spacer) * 2); background: var(--box-background-color); - padding-top: var(--spacer); - padding-bottom: var(--spacer); + padding: var(--spacer); border-radius: var(--border-radius); display: grid; } diff --git a/src/components/templates/Post/PrevNext.module.css b/src/components/templates/Post/PrevNext.module.css index 5ccc51b1..ac36e5f5 100644 --- a/src/components/templates/Post/PrevNext.module.css +++ b/src/components/templates/Post/PrevNext.module.css @@ -1,5 +1,4 @@ .prevnext { - composes: container from '../../atoms/Container.module.css'; margin-top: calc(var(--spacer) * 2); padding-top: calc(var(--spacer) * 2); display: grid; diff --git a/src/components/templates/Post/index.module.css b/src/components/templates/Post/index.module.css index 12b1db05..9d30a85f 100644 --- a/src/components/templates/Post/index.module.css +++ b/src/components/templates/Post/index.module.css @@ -1,5 +1,5 @@ .hentry { - composes: container from '../../atoms/Container.module.css'; + composes: container from '../../Layout.module.css'; width: 100%; padding-bottom: var(--spacer); } @@ -13,5 +13,5 @@ } .image { - composes: breakout from '../../atoms/Breakout.module.css'; + composes: breakout from '../../Layout.module.css'; } diff --git a/src/global/_alerts.css b/src/global/_alerts.css new file mode 100644 index 00000000..b037c3a8 --- /dev/null +++ b/src/global/_alerts.css @@ -0,0 +1,46 @@ +.alert { + padding: calc(var(spacer) / 2); + margin-top: var(--spacer); + margin-bottom: var(--spacer); + border-radius: var(--border-radius); + border: var(--stroke-width) solid transparent; + box-shadow: var(--box-shadow); +} + +@media (min-width: 40rem) { + .alert { + padding: var(--spacer); + } +} + +.alert > p:last-child, +.alert > ul:last-child { + margin-bottom: 0; +} + +.alert-info { + color: #826527; + background: var(--alert-info); +} + +.dark .alert-info { + color: var(--alert-info); + background: rgba(248, 241, 227, 0.2); +} + +/* .dark & { + color: darken($alert-info, 40%); + background: darken($alert-info, 85%); + border-color: darken($alert-info, 90%); + } */ + +.alert-success { + /* color: darken($alert-success, 60%); */ + background: var(--alert-success); +} + +.alert-danger, +.alert-error { + /* color: darken($alert-error, 60%); */ + background: var(--alert-error); +} diff --git a/src/global/_mixins.scss b/src/global/_mixins.scss deleted file mode 100644 index 5f562946..00000000 --- a/src/global/_mixins.scss +++ /dev/null @@ -1,134 +0,0 @@ -@import 'variables'; - -// CSS image replacement -///////////////////////////////////// - -@mixin hide-text() { - font: 0/0 a; // stylelint-disable font-family-no-missing-generic-family-keyword - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} - -// Text overflow -///////////////////////////////////// - -@mixin ellipsis() { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; -} - -// Layout breakout -///////////////////////////////////// - -@mixin breakoutviewport() { - margin-left: calc(-50vw + 50%); - margin-right: calc(-50vw + 50%); - - @media (min-width: $screen-md) { - @include breakoutviewport--base(); - } -} - -@mixin breakoutviewport--base() { - margin-left: -($spacer * 4); - margin-right: -($spacer * 4); -} - -@mixin breakoutviewport--full() { - margin-left: calc(-50vw + 50%); - margin-right: calc(-50vw + 50%); -} - -// Button sizing -///////////////////////////////////// - -@mixin button-size( - $padding-vertical, - $padding-horizontal, - $font-size, - $line-height, - $border-radius -) { - padding: $padding-vertical $padding-horizontal; - font-size: $font-size; - line-height: $line-height; - border-radius: $border-radius; -} - -// Form control sizing -///////////////////////////////////// - -@mixin input-size( - $padding-vertical, - $padding-horizontal, - $font-size, - $line-height, - $border-radius -) { - padding: $padding-vertical $padding-horizontal; - font-size: $font-size; - line-height: $line-height; - border-radius: $border-radius; - - &input[type='search'] { - background-size: $font-size; - background-position: $padding-vertical center; - padding-left: ($padding-vertical * 4); - } - - &select { - line-height: $input-height; - } - - &textarea, - &select[multiple] { - height: auto; - } -} - -// Placeholder text -///////////////////////////////////// - -@mixin placeholder($color: $input-color-placeholder) { - &::-moz-placeholder { - color: $color; - opacity: 1; // Override Firefox's unusual default opacity; See https//github.com/twbs/bootstrap/pull/11526 - } - - &::-webkit-input-placeholder { - color: $color; - } - - &:-ms-input-placeholder { - color: $color; - } -} - -// Image frame style -///////////////////////////////////// - -@mixin media-frame() { - @include transition(); - - border-top: 2px solid transparent; - border-bottom: 2px solid transparent; - border-radius: $border-radius; - box-shadow: 0 3px 5px rgba($brand-grey, 0.2), - 0 5px 16px rgba($brand-grey, 0.2); - - @media (min-width: $screen-sm) { - border: 2px solid transparent; - } - - :global(.dark) & { - box-shadow: 0 3px 5px rgba(darken($brand-main, 20%), 0.25), - 0 5px 16px rgba(darken($brand-main, 20%), 0.25); - } - - img { - border-radius: $border-radius; - } -} diff --git a/src/global/_variables.css b/src/global/_variables.css index e8b27d62..8086a3d4 100644 --- a/src/global/_variables.css +++ b/src/global/_variables.css @@ -14,7 +14,7 @@ --brand-grey-light: #7f97a1; --brand-grey-dimmed: #c3d8e0; - --alert-info: #f7f1e4; + --alert-info: rgb(248, 241, 227); --alert-success: #dff0d8; --alert-error: #f2dede; @@ -115,7 +115,7 @@ /* Misc. ///////////////////////////////////// */ - --maxWidthContent: 44rem; + --maxWidthContent: 42rem; --maxWidthContainer: 60rem; --easing: cubic-bezier(0.75, 0, 0.08, 1); } diff --git a/src/global/global.css b/src/global/global.css index b6328b43..ea876c99 100644 --- a/src/global/global.css +++ b/src/global/global.css @@ -120,7 +120,7 @@ h6 { line-height: var(--line-height-headings); color: var(--color-headings); font-weight: var(--font-weight-headings); - margin: 0 0 calc(var(--spacer) / var(--line-height)); + margin: var(--spacer) 0; letter-spacing: -0.01em; transition: color 0.2s ease-out; } @@ -197,6 +197,10 @@ ol { li { position: relative; + margin-bottom: calc(var(--spacer) / 2); +} + +ul ul li { margin-bottom: calc(var(--spacer) / 8); } @@ -209,7 +213,7 @@ li::before { } li p { - margin-bottom: 0; + margin-bottom: calc(var(--spacer) / 4); } ul li::before { @@ -341,8 +345,7 @@ td { @import '_buttons'; @import '_code.css'; @import '_toast.css'; - -/* @import '_alerts'; */ +@import '_alerts.css'; .medium-zoom-overlay { background-color: var(--body-background-color) !important; diff --git a/src/pages/index.module.css b/src/pages/index.module.css index 65ed9653..f20a8267 100644 --- a/src/pages/index.module.css +++ b/src/pages/index.module.css @@ -1,5 +1,5 @@ .section { - composes: wide from '../components/atoms/Container.module.css'; + composes: wide from '../components/Layout.module.css'; } .section:not(:first-child) { @@ -41,6 +41,6 @@ @media (min-width: 40rem) { .photos { gap: calc(var(--spacer) * 1.5); - grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); + grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }