WIP: Prepare presentation

This commit is contained in:
Nils Norman Haukås 2020-11-22 19:53:30 +01:00
parent 4f7a65256c
commit 44ba5669b0
11 changed files with 311 additions and 197 deletions

6
.prettierrc.json Normal file
View file

@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}

23
components/appNav.js Normal file
View file

@ -0,0 +1,23 @@
import Link from 'next/link'
export default function AppNav() {
const links = {
'/': 'Start',
'/overblikk': 'Overblikk',
'/web-components-in-react': 'Web komponenter i React',
'/react-in-web-components': 'React komponenter i Web komponenter',
}
return (
<nav>
<ol>
{Object.entries(links).map(([url, title]) => (
<li key={url}>
<Link href={url}>
<a>{title}</a>
</Link>
</li>
))}
</ol>
</nav>
)
}

24
components/counter.js Normal file
View file

@ -0,0 +1,24 @@
import { useState } from 'react'
export default function Counter() {
const [count, setCount] = useState(0)
return (
<div className="counter">
<button onClick={() => setCount((prevState) => prevState + 1)}>+</button>
<button onClick={() => setCount((prevState) => prevState - 1)}>-</button>
<div>Current count: {count}</div>
<style jsx>{`
.counter {
display: flex;
align-items: center;
}
.counter > * {
margin: var(--spacing-small);
}
button {
border: 1px solid var(--chill-blue);
}
`}</style>
</div>
)
}

View file

@ -8,8 +8,12 @@
"start": "next start"
},
"dependencies": {
"@webcomponents/webcomponentsjs": "^2.5.0",
"next": "10.0.2",
"react": "17.0.1",
"react-dom": "17.0.1"
},
"devDependencies": {
"prettier": "^2.2.0"
}
}

View file

@ -1,7 +1,54 @@
import '../styles/globals.css'
import AppNav from '../components/appNav'
function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
return (
<>
<main>
<AppNav />
<Component {...pageProps} />
</main>
<style jsx>{`
main {
padding: var(--spacing);
}
`}</style>
<style global jsx>
{`
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue,
sans-serif;
}
* {
box-sizing: border-box;
}
a:visited {
color: blue;
}
li {
margin: 12px 0;
}
:root {
--moz-green: #7d835f;
--chill-blue: #638a89;
--brown-light: #93733a;
--brown: #8d6e3f;
--graynish: #7c7b66;
--spacing: 24px;
--spacing-small: 12px;
}
`}
</style>
</>
)
}
export default MyApp

View file

@ -1,65 +1,29 @@
import Head from 'next/head'
import styles from '../styles/Home.module.css'
export default function Home() {
const pageTitle =
'Intro til web komponenter i React komponenter: Korleis og kvifor?'
return (
<div className={styles.container}>
<>
<Head>
<title>Create Next App</title>
<link rel="icon" href="/favicon.ico" />
<title>{pageTitle}</title>
</Head>
<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>
<p className={styles.description}>
Get started by editing{' '}
<code className={styles.code}>pages/index.js</code>
</p>
<div className={styles.grid}>
<a href="https://nextjs.org/docs" className={styles.card}>
<h3>Documentation &rarr;</h3>
<p>Find in-depth information about Next.js features and API.</p>
</a>
<a href="https://nextjs.org/learn" className={styles.card}>
<h3>Learn &rarr;</h3>
<p>Learn about Next.js in an interactive course with quizzes!</p>
</a>
<a
href="https://github.com/vercel/next.js/tree/master/examples"
className={styles.card}
>
<h3>Examples &rarr;</h3>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>
<a
href="https://vercel.com/import?filter=next.js&utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
>
<h3>Deploy &rarr;</h3>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>
<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{' '}
<img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} />
</a>
</footer>
</div>
<h1>{pageTitle}</h1>
<p>
Om du saumfarer React dokumentasjonen lengje nok finn du til slutt ei
side som snakker om korleis React komponenter kan samhandle med web
komponenter. Men kvifor er det ønskeleg? Om du lurer det er dette
rette staden å vere! I dette foredraget vil eg gi ein intro til web
komponenter i kontekst av React, og snakke om når dei passer inn, når
dei kjem til kort og korleis framtida til denne teknologien ser ut.
</p>
<p>
Nils Norman Haukås er interaksjonsdesigner av utdanning og utvikler av
praksis. Til dagleg jobber han som teknolog ved Netlife Bergen og er
ekstra nøgd om han kan slette meir kode enn det han skriv. fritida
blogger han om teknologi og samfunn <a href="nilsnh.no">nilsnh.no</a>
.
</p>
</>
)
}

134
pages/overblikk.js Normal file
View file

@ -0,0 +1,134 @@
import Head from 'next/head'
export default function Overview() {
const pageTitle = 'Overblikk'
return (
<>
<Head>
<title>{pageTitle}</title>
</Head>
<h1>{pageTitle}</h1>
<p>
(Vanilje) web komponenter består av eit sett med nettleser-API som lar
oss definere gjenbrukbare, isolerte elementer.
</p>
<h2>Kvifor?</h2>
<ul>
<li>
Rammeverk lar oss lage gjenbrukbare komponenter effektivt vis. Men
denne effektiviteten kjem i byte mot ekstra kode som alle brukere
laste ned. Og dersom me finner å blande rammeverk i samme
applikasjon får brukerane enda meir å laste ned.
<ul>
<li>
react 17.0.1 (
<a href="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js">
4.95kb gzip
</a>
)
</li>
<li>
react-dom 17.0.1 (
<a href="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js">
34.74kb gzip
</a>
)
</li>
<li>
vue.js 2.6.12 (
<a href="https://cdn.jsdelivr.net/npm/vue@2.6.12">33.18kb gzip</a>
)
</li>
<li>
preact.js 10.5.7 (
<a href="https://unpkg.com/preact@10.5.7/dist/preact.min.js?module">
4.76kb gzip
</a>
)
</li>
<li>
angular 11.0.2 (
<a href="https://cdnjs.cloudflare.com/ajax/libs/angular/11.0.2/core.umd.min.js">
70.41kb gzip
</a>
)
</li>
</ul>
</li>
<li>
Me bruker mykje tid å lage gjenbrukbare komponenter som er låst til
visse økosystem.
</li>
</ul>
<h2>Kvifor ikkje?</h2>
<ul>
<li>
Ingen server-side rendering støtte (enda). Se:{' '}
<a href="https://web.dev/declarative-shadow-dom/">
Deklarativ SkyggeDOM
</a>
</li>
</ul>
<h2>Ressurser</h2>
<ul>
<li>
<a href="https://reactjs.org/docs/web-components.html">
ReactJS docs: Web components
</a>
</li>
<li>
<a href="https://lea.verou.me/2020/09/the-failed-promise-of-web-components/">
The failed promise of Web Components - Lea Verou
</a>
<ul>
<li>
Korleis avsporet denne teknologien, og kva kan me gjere for å
den tilbake skinner?
</li>
</ul>
</li>
<li>
<a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components">
MDN Web docs: Web components
</a>
</li>
<li>
<a href="https://www.youtube.com/watch?v=zZ1YMJydqR0">
Web Components: It's about Time | Erin Zimmer
</a>
</li>
</ul>
<h2>Relevante prosjekter</h2>
<ul>
<li>
<a href="https://www.webcomponents.org/">webcomponents.org</a>
</li>
<li>
<a href="https://www.polymer-project.org/">Polymer project</a>
<ul>
<li>Lansert i 2015.</li>
<li>
2018: Annonserte eit skifte mot lit-html (
<a href="https://en.wikipedia.org/wiki/Polymer_(library)">
source
</a>
).
</li>
</ul>
</li>
<li>
<a href="https://open-ui.org/">Open UI</a>
<ul>
<li>
Forsøk å standardisere navngivning tvers av rammeverk.
</li>
</ul>
</li>
</ul>
</>
)
}

View file

@ -0,0 +1,40 @@
import Head from 'next/head'
import Counter from '../components/counter'
export default function WCInReact() {
const pageTitle = 'Web komponenter i React'
return (
<>
<Head>
<title>{pageTitle}</title>
</Head>
<h1>{pageTitle}</h1>
<p>La oss sjå nokre web komponenter.</p>
<Example title="React teller">
<Counter />
</Example>
<Example title="Web komponent teller">
<wc-counter />
</Example>
</>
)
}
function Example({ title, children }) {
return (
<section>
<h2>{title}</h2>
{children}
<style jsx>{`
h2 {
margin: 0;
}
section {
border: 3px solid var(--moz-green);
padding: var(--spacing-small);
margin-bottom: var(--spacing);
}
`}</style>
</section>
)
}

View file

@ -1,122 +0,0 @@
.container {
min-height: 100vh;
padding: 0 0.5rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.main {
padding: 5rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.footer {
width: 100%;
height: 100px;
border-top: 1px solid #eaeaea;
display: flex;
justify-content: center;
align-items: center;
}
.footer img {
margin-left: 0.5rem;
}
.footer a {
display: flex;
justify-content: center;
align-items: center;
}
.title a {
color: #0070f3;
text-decoration: none;
}
.title a:hover,
.title a:focus,
.title a:active {
text-decoration: underline;
}
.title {
margin: 0;
line-height: 1.15;
font-size: 4rem;
}
.title,
.description {
text-align: center;
}
.description {
line-height: 1.5;
font-size: 1.5rem;
}
.code {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}
.grid {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 800px;
margin-top: 3rem;
}
.card {
margin: 1rem;
flex-basis: 45%;
padding: 1.5rem;
text-align: left;
color: inherit;
text-decoration: none;
border: 1px solid #eaeaea;
border-radius: 10px;
transition: color 0.15s ease, border-color 0.15s ease;
}
.card:hover,
.card:focus,
.card:active {
color: #0070f3;
border-color: #0070f3;
}
.card h3 {
margin: 0 0 1rem 0;
font-size: 1.5rem;
}
.card p {
margin: 0;
font-size: 1.25rem;
line-height: 1.5;
}
.logo {
height: 1em;
}
@media (max-width: 600px) {
.grid {
width: 100%;
flex-direction: column;
}
}

View file

@ -1,16 +0,0 @@
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
a {
color: inherit;
text-decoration: none;
}
* {
box-sizing: border-box;
}

View file

@ -291,6 +291,11 @@
"@webassemblyjs/wast-parser" "1.9.0"
"@xtuc/long" "4.2.2"
"@webcomponents/webcomponentsjs@^2.5.0":
version "2.5.0"
resolved "https://registry.npmjs.org/@webcomponents/webcomponentsjs/-/webcomponentsjs-2.5.0.tgz#61b27785a6ad5bfd68fa018201fe418b118cb38d"
integrity sha512-C0l51MWQZ9kLzcxOZtniOMohpIFdCLZum7/TEHv3XWFc1Fvt5HCpbSX84x8ltka/JuNKcuiDnxXFkiB2gaePcg==
"@xtuc/ieee754@^1.2.0":
version "1.2.0"
resolved "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790"
@ -2870,6 +2875,11 @@ prebuild-install@^5.3.5:
tunnel-agent "^0.6.0"
which-pm-runs "^1.0.0"
prettier@^2.2.0:
version "2.2.0"
resolved "https://registry.npmjs.org/prettier/-/prettier-2.2.0.tgz#8a03c7777883b29b37fb2c4348c66a78e980418b"
integrity sha512-yYerpkvseM4iKD/BXLYUkQV5aKt4tQPqaGW6EsZjzyu0r7sVZZNPJW4Y8MyKmicp6t42XUPcBVA+H6sB3gqndw==
process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"