From 86d5889861ff7b107312d0b8f67118b035ea5d75 Mon Sep 17 00:00:00 2001 From: Sascha Schulz <sschulz@dh-software.de> Date: Di, 12 Sep 2023 17:26:42 +0200 Subject: [PATCH] Merge branch 'draft' --- index.html | 462 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 461 insertions(+), 1 deletions(-) diff --git a/index.html b/index.html index d31dd79..98cd018 100644 --- a/index.html +++ b/index.html @@ -2604,6 +2604,466 @@ </code> </pre> </section> + <section> + <h3>Strings</h3> + <pre> + <code class="js" data-trim data-line-numbers> + const empty1 = ""; + const empty1 = ''; + + const s1 = 'abc'; + const s2 = "abc"; + + const s3 = 'a"b"c'; + const s4 = "a\"b\"c"; + + const s5 = 'a\'b\'c'; + const s6 = "a'b'c"; + + const s7 = `a'b'"c"`; + </code> + </pre> + </section> + <section> + <h5>Strings zusammenfügen</h5> + <pre> + <code class="js" data-trim data-line-numbers> + const age = 10; + + // Konkatenation + const s = "My age is " + number + "!"; + + // Interpolation + const s = `My age is ${number}!`; + + // => "My age is 10!" + </code> + </pre> + </section> + <section> + <h5>Template Strings</h5> + <pre> + <code class="js" data-trim data-line-numbers> + function sayHello() { + return "Hello"; + } + + let interpolation = `${sayHello()}`; + + // => "Hello" + + interpolation = `5 + 5 = ${5+5}`; + + // => "5 + 5 = 10" + </code> + </pre> + </section> + <section> + lit + <pre> + <code class="js" data-trim data-line-numbers> + return html`<div>hello world!</div>` + </code> + </pre> + </section> + <section> + <pre> + <code class="js" data-trim data-line-numbers> + function myTag() { + console.log(arguments); + + // return 5; + // return true; + return "abc"; + } + + let interpolation = myTag`a ${5} b ${6} c`; + + // => "abc" + </code> + </pre> + <pre> + <code class="bash" data-trim data-line-numbers> + Arguments(3) [Array(3), 5, 6] + 0 : (3) ['a ', ' b ', ' c', raw: Array(3)] + 1 : 5 + 2 : 6 + </code> + </pre> + </section> + <section> + <h5>Aufgabe</h5> + <p>Schreibe ein Tag, welches die Zahlen aus den dynamischen Ausdrücken zusammenrechnet (<code>strings.js</code>)</p> + </section> + <section> + <h5>Lösung</h5> + <pre> + <code class="js" data-trim data-line-numbers> + function add(parts, ...numbers) { + return numbers.reduce((p, c) => p + c, 0); + } + + let sum = add`a ${5} b ${6} c`; + + console.log(sum); + + // => 11 + </code> + </pre> + </section> + <section> + <h5>Rest-Operator</h5> + <pre> + <code class="js" data-trim data-line-numbers> + function add(...numbers) { + return numbers.reduce((p, c) => p + c, 0); + } + + add(1, 2, 3); // => 6 + </code> + </pre> + <pre> + <code class="js" data-trim data-line-numbers> + const o1 = {a: 1, b: 2}; + const o2 = {x: 5, y: 6, ...o1}; + </code> + </pre> + <pre> + <code class="js" data-trim data-line-numbers> + const a1 = [4, 5, 6]; + const a2 = [1, 2, 3, ...a1]; + </code> + </pre> + </section> + <section> + <h3>Relevante Browser-APIs</h3> + </section> + <section> + <h5>window</h5> + <pre> + <code class="js" data-trim data-line-numbers> + window.innerWidth; // innere Auflösung des sichtbaren Fensters + window.innerHeight; + window.outerWidth; // äußere Auflösung des Browserfensters inklusive Adresszeile usw. + window.outerHeight; + + window.addEventListener(); // Events an das äußerste "Dach"-Element hängen + </code> + </pre> + </section> + <section> + <h5>location</h5> + <pre> + <code class="js" data-trim data-line-numbers> + location.href; // aktuelle URL + location.host; // aktuelle Domain, z.B. "www.google.de" + location.protocol; // aktuelles Protokoll, z.B. "https:" + </code> + </pre> + </section> + <section> + <h5>Navigator</h5> + <pre> + <code class="js" data-trim data-line-numbers> + navigator.language; // bevorzugte Browsersprache, z.B. "de" + navigator.userAgent; // z.B. "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) [...]" + navigator + .mediaDevices + .getDisplayMedia(); // Fordere Erlaubis zum Streamen von Anwendungen oder Bildschirmen an + </code> + </pre> + </section> + <section> + <h5>Document</h5> + <pre> + <code class="js" data-trim data-line-numbers> + document.body; // <body>-Element der Seite + document.activeElement; // aktives Element der Seite, welche gerade den Fokus besitzt + document.cookie; // für die aktuelle Seite gesetzte Cookies + document.execCommand("copy"); // Texte in die Zwischenablage zu schreiben + document.createElement("div"); // erzeuge neues DOM-Element mit angegebenen Tag + </code> + </pre> + </section> + <section> + <h5>LocalStorage</h5> + <pre> + <code class="js" data-trim data-line-numbers> + // auf 5MB Daten pro Domain begrenzt + localStorage.getItem(key); // Element holen + localStorage.setItem(key, value); // Element setzen + localStorage.removeItem(key); // Element entfernen + </code> + </pre> + </section> + </section> + <section> + <section> + <h2>CSS</h2> + <img data-src="/assets/images/css-sucks.png"> + </section> + <section> + <h3>Warum CSS?</h3> + <ul> + <li>Erhöhte Zugänglichkeit des Inhalts</li> + <li>Wiederverwendbarkeit</li> + </ul> + </section> + <section> + <h3>Syntax</h3> + <pre> + <code class="css" data-trim data-line-numbers> + selector [, selector2, selector3, ...] { + property1: value; + property2: value; + } + </code> + </pre> + </section> + <section> + <h3>Beispiel</h3> + <pre> + <code class="css" data-trim data-line-numbers> + html, body { + width: 100%; + height: 100%; + margin: 0; + } + </code> + </pre> + </section> + <section> + <h3>Selektoren</h3> + <pre> + <code class="css" data-trim data-line-numbers> + /* Elemente */ + html, body {...} + + /* IDs */ + #my-id {...} + + /* Klassen */ + .my-class {...} + + /* Pseudo-Klassen */ + div:hover {...} + + /* Attribute */ + div[my-attribut="abc"] {...} + + /* Kombinationen */ + div.my-class#my-id {...} + </code> + </pre> + </section> + <section> + <h3>Variablen</h3> + <pre> + <code class="css" data-trim data-line-numbers> + html { + --my-background-color: #abcdef; + } + + html div { + background-color: var(--my-background-color, white); + } + </code> + </pre> + </section> + <section> + <h3>Das <code>display</code>-Attribut</h3> + </section> + <section> + <p>block</p> + <img data-src="/assets/images/css-display-block.svg"> + <ul> + <li>untereinander angeordnet</li> + <li>nehmen sich die volle Breite</li> + <li><code>width</code> und <code>height</code> möglich</li> + </ul> + </section> + <section> + <p>inline</p> + <img data-src="/assets/images/css-display-inline.svg"> + <ul> + <li>Standard bei <code>Custom Elements</code></li> + <li>nur so groß wie der content</li> + <li><code>width</code> und <code>height</code> nicht möglich</li> + <li>nebeneinander angeordnet</li> + </ul> + </section> + <section> + <p>inline-block</p> + <img data-src="/assets/images/css-display-inline-block.svg"> + <ul> + <li>Mischform von <code>block</code> und <code>inline</code></li> + <li>nur so groß wie der content</li> + <li><code>width</code> und <code>height</code> möglich</li> + <li>nebeneinander angeordnet</li> + </ul> + </section> + <section> + <p>none</p> + <img data-src="/assets/images/css-display-none.svg"> + <ul> + <li>unsichtbar</li> + <li>Platz wird nicht länger beansprucht, so als wenn das Element nicht im DOM wäre</li> + </ul> + </section> + <section> + <h3>Das <code>position</code>-Attribut</h3> + </section> + <section> + <p>static</p> + <img data-src="/assets/images/css-position-static.svg"> + <ul> + <li>Standard</li> + <li>Element wird am Ort der Verankerung im HTML dargestellt</li> + </ul> + </section> + <section> + <p>relative</p> + <img data-src="/assets/images/css-position-relative.svg"> + <ul> + <li>Verschiebung zur eigentlichen <code>static</code>-Position, z.B. mittels <code>left: 20px</code></li> + </ul> + </section> + <section> + <p>absolut</p> + <img data-src="/assets/images/css-position-absolute.svg"> + <ul> + <li>relative Verschiebung zum nächsten nicht-<code>static</code>-Parent (sonst <code>window</code>)</li> + </ul> + </section> + <section> + <h3>Aufgabe</h3> + <p>Implementiere folgendes Beispiel-Menü</p> + <iframe data-src="/assets/html/css-menu.html"></iframe> + </section> + <section> + <h3>Lösung</h3> + <pre> + <code class="css" data-trim data-line-numbers> + .menu-item { + display: inline-block; + + position: relative; + } + + .menu-item .children { + display: none; + + position: absolute; + } + + .menu-item:hover .children { + display: block; + } + </code> + </pre> + </section> + <section> + <pre> + <code class="html" data-trim data-line-numbers> + <script type="text/template"> + <div class="menu"> + <div class="menu-item">Eins</div> + <div class="menu-item"> + Hover Me! + <div class="children"> + <div>Item 1</div> + <div>Item 2</div> + </div> + </div> + <div class="menu-item">Drei</div> + </div> + </script> + </code> + </pre> + </section> + <section> + <h3>Viewport</h3> + <pre> + <code class="html" data-trim data-line-numbers> + <!DOCTYPE html> + <html> + <head> + <meta charset="utf-8"></meta> + <meta + name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" + > + </head> + <body> + ... + </body> + </html> + </code> + </pre> + <p>Ein Muss für alle responsiven Seiten</p> + </section> + <section> + <pre> + <code class="bash" data-trim data-line-numbers=""> + npm install -g http-server + cd pfad/zum/projekt + http-server --port 8080 + </code> + </pre> + </section> + <section> + <h3>Einheiten</h3> + <pre> + <code class="css" data-trim data-line-numbers=""> + div { + width: 1px; /* Pixel */ + width: 1pt; /* Points */ + width: 1em; /* Breite des "M" in der Schriftgröße des Elements */ + width: 1rem; /* Breite des "M" in der Schriftgröße des HTML-Elements */ + width: 1vw; /* Prozent der View Width */ + width: 1%; /* Prozent des Elternelements */ + + width: 5fr; /* Fraction (nur im CSS Grid verfügbar) */ + } + </code> + </pre> + </section> + <section> + <h3>Aufgabe</h3> + <p>Größeneinheiten in einer HTML-Datei ausprobieren</p> + </section> + <section> + <h3>CSS Flexbox</h3> + <pre> + <code class="css" data-trim data-line-numbers=""> + .container { + display: flex; /* soll ein flexibler Container sein */ + display: inline-flex; + + flex-direction: column; /* Kinder spaltenweise anordnen */ + flex-direction: row; /* Kinder zeilenweise anordnen */ + + align-items: center; + justify-content: center; + + gap: 20px; /* Abstände zwischen den Achsen */ + } + + .child { + flex-grow: 1; /* Anteiliger Platz, wenn mehr als nötig da ist */ + flex-shrink: 1; /* Anteiliger Platz, wenn weniger als nötig da ist */ + flex-basis: 20px; /* Grundlage zur Berechnung der finalen Größe */ + order: 1; /* Erlaubt die Darstellung in anderer Reihenfolge als durch das HTML vorgegeben */ + } + </code> + </pre> + </section> + <section> + <img data-src="/assets/images/css-flexbox-axes.drawio.svg"> + </section> + <section> + <h3>Aufgabe</h3> + <p>Mit CSS Flexbox rumspielen</p> + </section> </section> </div> </div> @@ -2620,7 +3080,7 @@ hash: true, slideNumber: "c/t", transition: "fade", - + // Learn about plugins: https://revealjs.com/plugins/ plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ] }); -- Gitblit v1.9.3