Dynamic square layout for content-and-preview slides.

This commit is contained in:
Christian Kremitzl 2019-04-27 19:19:33 +02:00
parent 9a0fdc202a
commit 460c9b1a8b
3 changed files with 171 additions and 228 deletions

View File

@ -1,12 +1,30 @@
/* basic layout */ @charset "UTF-8";
/* tame reveal.js */
@import url("https://free.bboxtype.com/embedfonts/?family=FiraSans:300,600"); @import url("https://free.bboxtype.com/embedfonts/?family=FiraSans:300,600");
section {
min-height: 100vh;
width: 100vw;
padding: 0 !important; }
/* config */
:root {
--secondary: #c8ceda; }
/* basic layout */
:root {
--square: 100vw; }
@media screen and (min-aspect-ratio: 1 / 1) {
:root {
--square: 50vw; } }
@media screen and (min-aspect-ratio: 2 / 1) {
:root {
--square: 100vh; } }
body { body {
background: red; font-size: calc(0.035 * var(--square)); }
font-size: 1vw;
/* transition: background 1s ease; */ }
body .layout-content-and-preview { body .layout-content-and-preview {
display: grid; display: grid;
grid-template-rows: 100vw auto; grid-template-rows: var(--square) auto;
grid-template-columns: auto; grid-template-columns: auto;
grid-template-areas: "content" "preview"; grid-template-areas: "content" "preview";
min-height: 100vh; min-height: 100vh;
@ -22,46 +40,31 @@ body {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
/* padding: 4vw; */ } background: var(--secondary); }
body .layout-content-and-preview .layout-preview img { body .layout-content-and-preview .layout-preview img {
opacity: .5;
width: auto; width: auto;
height: auto; height: auto;
max-width: 100%; max-width: 90%;
max-height: 100%; max-height: 90%;
box-shadow: 0.2em 0.2em 0.5em 0 rgba(0, 0, 0, 0.3); } box-shadow: 0.2em 0.2em 0.5em 0 rgba(0, 0, 0, 0.3); }
/*
@media screen and (min-aspect-ratio: 1/2) {
$base-unit: 0.5vh;
body {
background: orange;
.layout-content-and-preview {
grid-template-rows: 50vh auto;
grid-template-columns: auto 50vh auto;
grid-template-areas:
" . content . "
"preview preview preview";
}
}
}
*/
@media screen and (min-aspect-ratio: 1 / 1) { @media screen and (min-aspect-ratio: 1 / 1) {
body { body {
background: yellow; } font-size: calc(0.035 * var(--square)); }
body .layout-content-and-preview { body .layout-content-and-preview {
grid-template-rows: auto 50vw auto; grid-template-rows: auto var(--square) auto;
grid-template-columns: 50vw auto; grid-template-columns: var(--square) auto;
grid-template-areas: " . preview" "content preview" " . preview"; } } grid-template-areas: " . preview" "content preview" " . preview"; } }
@media screen and (min-aspect-ratio: 2 / 1) { @media screen and (min-aspect-ratio: 2 / 1) {
body { body {
background: lime; } font-size: calc(0.035 * var(--square)); }
body .layout-content-and-preview { body .layout-content-and-preview {
grid-template-rows: 100vh; grid-template-rows: var(--square);
grid-template-columns: 100vh auto; grid-template-columns: var(--square) auto;
grid-template-areas: "content preview"; } } grid-template-areas: "content preview"; } }
/* content layout */
@font-face { @font-face {
font-family: 'Fira Code'; font-family: 'Fira Code';
src: url("../../lib/font/fira-code/FiraCode-Regular.otf"); src: url("../../lib/font/fira-code/FiraCode-Regular.otf");
@ -77,68 +80,49 @@ body {
margin: 0; margin: 0;
line-height: 1.2em; } line-height: 1.2em; }
section { .layout-content-and-preview {
min-height: 100vh; --margin: 0.1; }
width: 100vw; .layout-content-and-preview .layout-content {
padding: 0 !important; }
.layout-side-by-side {
min-width: 100vw;
max-width: 100vw;
min-height: 100vh;
max-height: 100vh;
overflow: hidden;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 12fr;
background: linear-gradient(to right, white 0%, white calc(50% - 4px), #c8ceda calc(50% - 4px), #c8ceda calc(50% + 4px), #ffffff calc(50% + 4px), #ffffff 100%); }
.layout-side-by-side .layout-title {
grid-column-end: span 2;
padding: 3.5vw calc(50% + 4vw) 0.5vw 4vw;
line-height: 1.15em; }
.layout-side-by-side .layout-content-left {
overflow: auto; overflow: auto;
padding: 4vw; } padding: calc(var(--margin) * var(--square)); }
.layout-side-by-side .layout-content-left *:first-child { .layout-content-and-preview .layout-content *:first-child {
margin-top: 0; } margin-top: 0; }
.layout-side-by-side .layout-content-right { .layout-content-and-preview .layout-content .layout-title {
display: flex; padding: calc(0.3 * var(--margin) * var(--square)) 0;
align-items: flex-start; line-height: 1.15em; }
justify-content: center; .layout-content-and-preview .layout-content .layout-title h2 {
padding: 4vw; }
.layout-side-by-side .layout-content-right img {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
box-shadow: 0.2em 0.2em 0.5em 0 rgba(0, 0, 0, 0.3); }
.layout-side-by-side h2 {
margin: 0; } margin: 0; }
.layout-side-by-side ul { .layout-content-and-preview .layout-content ul {
list-style-type: disc; list-style-type: none;
padding-left: 0; } padding-left: 0;
.layout-side-by-side ul ul { position: relative; }
padding-left: 2vw; } .layout-content-and-preview .layout-content ul li::before {
.layout-side-by-side pre { content: '▪';
margin-left: -4vw; color: var(--secondary);
padding-left: 4vw; position: absolute;
left: calc(-0.33 * var(--margin) * var(--square)); }
.layout-content-and-preview .layout-content ul ul {
margin-left: calc(0.33 * var(--margin) * var(--square)); }
.layout-content-and-preview .layout-content pre {
margin-left: calc(-1 * var(--margin) * var(--square));
padding-left: calc(var(--margin) * var(--square));
line-height: 1.2em; line-height: 1.2em;
position: relative; position: relative;
overflow: hidden; } overflow: hidden; }
.layout-side-by-side pre::before { .layout-content-and-preview .layout-content pre::before {
content: attr(data-sourcefile); content: attr(data-sourcefile);
position: absolute; position: absolute;
top: .3em;
left: calc(1.5vw - 100%);
width: 100%;
text-align: right; text-align: right;
transform: rotate(-90deg); color: var(--secondary);
transform-origin: 100% 50%; top: .85em;
color: #cccccc; } width: 100%;
.layout-side-by-side code { left: calc(-1 * var(--square) + 1.2 * var(--margin) * var(--square));
transform-origin: top right;
transform: rotate(-90deg); }
.layout-content-and-preview code {
font-size: 0.9em; font-size: 0.9em;
font-family: 'Fira Code'; } font-family: 'Fira Code'; }
.layout-side-by-side code.hljs { .layout-content-and-preview code.hljs {
padding: .3em 0; } padding: .3em 0; }
.layout.layout-chapter-heading { .layout.layout-chapter-heading {

View File

@ -1,15 +1,31 @@
/* tame reveal.js */
section {
min-height: 100vh;
width: 100vw;
padding: 0 !important;
}
/* config */
:root {
--secondary: #c8ceda;
}
/* basic layout */ /* basic layout */
:root {
--square: 100vw;
@media screen and (min-aspect-ratio: 1/1) {
--square: 50vw;
}
@media screen and (min-aspect-ratio: 2/1) {
--square: 100vh;
}
}
$base-unit: 1vw;
body { body {
background: red; font-size: calc(0.035 * var(--square));
font-size: $base-unit;
/* transition: background 1s ease; */
.layout-content-and-preview { .layout-content-and-preview {
display: grid; display: grid;
grid-template-rows: 100vw auto; grid-template-rows: var(--square) auto;
grid-template-columns: auto; grid-template-columns: auto;
grid-template-areas: grid-template-areas:
"content" "content"
@ -28,40 +44,23 @@ body {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
/* padding: 4vw; */ background: var(--secondary);
img { img {
opacity: .5;
width: auto; width: auto;
height: auto; height: auto;
max-width: 100%; max-width: 90%;
max-height: 100%; max-height: 90%;
box-shadow: .2em .2em .5em 0 rgba(0, 0, 0, .3); box-shadow: .2em .2em .5em 0 rgba(0, 0, 0, .3);
} }
} }
} }
} }
/*
@media screen and (min-aspect-ratio: 1/2) {
$base-unit: 0.5vh;
body {
background: orange;
.layout-content-and-preview {
grid-template-rows: 50vh auto;
grid-template-columns: auto 50vh auto;
grid-template-areas:
" . content . "
"preview preview preview";
}
}
}
*/
@media screen and (min-aspect-ratio: 1/1) { @media screen and (min-aspect-ratio: 1/1) {
$base-unit: 0.5vw;
body { body {
background: yellow; font-size: calc(0.035 * var(--square));
.layout-content-and-preview { .layout-content-and-preview {
grid-template-rows: auto 50vw auto; grid-template-rows: auto var(--square) auto;
grid-template-columns: 50vw auto; grid-template-columns: var(--square) auto;
grid-template-areas: grid-template-areas:
" . preview" " . preview"
"content preview" "content preview"
@ -70,20 +69,18 @@ body {
} }
} }
@media screen and (min-aspect-ratio: 2/1) { @media screen and (min-aspect-ratio: 2/1) {
$base-unit: 1vh;
body { body {
background: lime; font-size: calc(0.035 * var(--square));
.layout-content-and-preview { .layout-content-and-preview {
grid-template-rows: 100vh; grid-template-rows: var(--square);
grid-template-columns: 100vh auto; grid-template-columns: var(--square) auto;
grid-template-areas: grid-template-areas:
"content preview"; "content preview";
} }
} }
} }
/* content layout */
@import url('https://free.bboxtype.com/embedfonts/?family=FiraSans:300,600'); @import url('https://free.bboxtype.com/embedfonts/?family=FiraSans:300,600');
@font-face { @font-face {
@ -96,102 +93,63 @@ body {
src: url('../../lib/font/fira-code/FiraCode-Bold.otf'); src: url('../../lib/font/fira-code/FiraCode-Bold.otf');
font-weight: 700; font-weight: 700;
} }
body { body {
font-family: 'Fira Sans'; font-family: 'Fira Sans';
margin: 0; margin: 0;
line-height: 1.2em; line-height: 1.2em;
// font-size: 1.7vw;
} }
@media screen and (screen-orientation: landscape) { .layout-content-and-preview {
body { --margin: 0.1;
// font-size: 3.5vh;
}
}
section { .layout-content {
min-height: 100vh;
width: 100vw;
padding: 0 !important;
}
.layout-side-by-side {
$backgroundColor: #c8ceda;
$stripHalfWidth: 4px;
min-width: 100vw;
max-width: 100vw;
min-height: 100vh;
max-height: 100vh;
overflow: hidden;
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 12fr;
// background: linear-gradient(to right, $backgroundColor 0%, $backgroundColor 50%, #ffffff 50%, #ffffff 100%);
background: linear-gradient(to right, white 0%, white calc(50% - #{$stripHalfWidth}), $backgroundColor calc(50% - #{$stripHalfWidth}), $backgroundColor calc(50% + #{$stripHalfWidth}), #ffffff calc(50% + #{$stripHalfWidth}), #ffffff 100%);
.layout-title {
grid-column-end: span 2;
padding: 3.5vw calc(50% + 4vw) 0.5vw 4vw;
line-height: 1.15em;
}
.layout-content-left {
overflow: auto; overflow: auto;
padding: 4vw; padding: calc(var(--margin) * var(--square));
*:first-child { *:first-child {
margin-top: 0 margin-top: 0;
}
} }
.layout-content-right { .layout-title {
display: flex; padding: calc(0.3 * var(--margin) * var(--square)) 0;
align-items: flex-start; line-height: 1.15em;
justify-content: center;
padding: 4vw;
img {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
box-shadow: .2em .2em .5em 0 rgba(0, 0, 0, .3);
}
}
h2 { h2 {
margin: 0; margin: 0;
} }
}
ul { ul {
list-style-type: disc; list-style-type: none;
padding-left: 0; padding-left: 0;
position: relative;
li::before {
content: '';
color: var(--secondary);
position: absolute;
left: calc(-0.33 * var(--margin) * var(--square));
}
ul { ul {
padding-left: 2vw; margin-left: calc(0.33 * var(--margin) * var(--square));
} }
} }
pre { pre {
margin-left: -4vw; margin-left: calc(-1 * var(--margin) * var(--square));
padding-left: 4vw; padding-left: calc(var(--margin) * var(--square));
line-height: 1.2em; line-height: 1.2em;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
&::before { &::before {
content: attr(data-sourcefile); content: attr(data-sourcefile);
position: absolute; position: absolute;
top: .3em;
left: calc(1.5vw - 100%);
width: 100%;
text-align: right; text-align: right;
color: var(--secondary);
top: .85em;
width: 100%;
left: calc(-1 * var(--square) + 1.2 * var(--margin) * var(--square));
transform-origin: top right;
transform: rotate(-90deg); transform: rotate(-90deg);
transform-origin: 100% 50%;
color: #cccccc;
}
} }
code { code {
@ -202,6 +160,7 @@ section {
code.hljs { code.hljs {
padding: .3em 0; padding: .3em 0;
} }
}
} }
.layout.layout-chapter-heading { .layout.layout-chapter-heading {

View File

@ -21,7 +21,7 @@ Ein größeres LaTeX-Projekt anlegen und dabei ...
<li>enthält Grundgerüst, Titelei, etc. </li> <li>enthält Grundgerüst, Titelei, etc. </li>
<li>bindet einzelne Kapitel ein mit <li>bindet einzelne Kapitel ein mit
<ul> <ul>
<li><code>\input{filename.tex}</code> ODER</li> <li><code>\input{filename.tex}</code> oder</li>
<li><code>\include{filename}</code></li> <li><code>\include{filename}</code></li>
</ul> </ul>
</li> </li>