First couple of slides

This commit is contained in:
Lewis Dale 2023-09-29 19:33:03 +01:00
commit 2fc934e324
20 changed files with 4819 additions and 0 deletions

23
.eleventy.js Normal file
View File

@ -0,0 +1,23 @@
const PostCSSPlugin = require("eleventy-plugin-postcss");
const markdown = require("./config/plugins/markdown");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = function (config) {
config.addPlugin(PostCSSPlugin);
config.addPlugin(syntaxHighlight);
config.addPlugin(markdown);
return {
passthroughFileCopy: true,
dataTemplateEngine: false,
markdownTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dir: {
input: "src",
includes: "_includes",
data: "_data",
output: "_site"
}
};
}

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.DS_Store
_site
node_modules

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v18.18.0

9
.postcssrc.json Normal file
View File

@ -0,0 +1,9 @@
{
"plugins": {
"postcss-import-ext-glob": {},
"postcss-import": {},
"postcss-nested": {},
"autoprefixer": {},
"cssnano": { "preset": "default" }
}
}

1858
config/plugins/icons.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
const path = require("path");
const markdownIt = require('markdown-it');
const markdownItPrism = require('markdown-it-prism');
const markdownItClass = require('@toycode/markdown-it-class');
const markdownItLinkAttributes = require('markdown-it-link-attributes');
const markdownItEmoji = require('markdown-it-emoji');
const markdownItFootnote = require('markdown-it-footnote');
const markdownitMark = require('markdown-it-mark');
const markdownitAbbr = require('markdown-it-abbr');
const icons = require('./icons.json');
const { slugifyString } = require('../utils');
const markdownLib = markdownIt({
html: true,
breaks: true,
linkify: true,
typographer: true
})
.disable('code')
.use(markdownItPrism, {
defaultLanguage: 'plaintext'
})
.use(markdownItClass, {
ol: 'list',
ul: 'list'
})
.use(markdownItLinkAttributes, [
{
// match external links
matcher(href) {
return href.match(/^https?:\/\//);
},
attrs: {
target: '_blank',
rel: 'noreferrer noopener'
}
}
])
.use(markdownItEmoji, { defs: icons })
.use(markdownItFootnote)
.use(markdownitMark)
.use(markdownitAbbr);
markdownLib.renderer.rules.emoji = function(token, idx) {
return `<span class="fa-li"><i class="fa-solid fa-${token[idx].markup}"></i></span>`;
};
module.exports = function(eleventyConfig) {
eleventyConfig.setLibrary('md', markdownLib);
};

14
config/utils.js Normal file
View File

@ -0,0 +1,14 @@
const slugify = require('slugify');
/** Converts string to a slug form. */
const slugifyString = str => {
return slugify(str, {
replacement: '-',
remove: /[#,&,+()$~%.'":*?<>{}]/g,
lower: true
});
};
module.exports = {
slugifyString
}

29
package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "css-components",
"version": "1.0.0",
"main": "index.js",
"author": "Lewis Dale <lewis@ihd.software>",
"license": "MIT",
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@toycode/markdown-it-class": "^1.2.4",
"autoprefixer": "^10.4.16",
"cssnano": "^6.0.1",
"eleventy-plugin-postcss": "^1.0.4",
"markdown-it": "^13.0.2",
"markdown-it-abbr": "^1.0.4",
"markdown-it-anchor": "^8.6.7",
"markdown-it-emoji": "^2.0.2",
"markdown-it-footnote": "^3.0.3",
"markdown-it-link-attributes": "^4.0.1",
"markdown-it-mark": "^3.0.1",
"markdown-it-prism": "^2.3.0",
"postcss-import": "^15.1.0",
"postcss-import-ext-glob": "^2.1.1",
"postcss-nested": "^6.0.1"
},
"scripts": {
"serve": "eleventy --serve"
}
}

13
src/_includes/base.njk Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>eleventy-plugin-postcss</title>
<link rel="stylesheet" href="./styles/styles.css">
</head>
<body>
{{ content | safe }}
</body>

11
src/index.html Normal file
View File

@ -0,0 +1,11 @@
---
title: Home
layout: base.njk
---
<main>
{% for slide in collections.slides %}
<section class="slide {{ slide.data.type }}">
{{ slide.content | safe }}
</section>
{% endfor %}
</main>

7
src/slides/01-intro.md Normal file
View File

@ -0,0 +1,7 @@
---
type: title
---
# Browsers do it better
Replacing Javascript with HTML & CSS

5
src/slides/02-what.md Normal file
View File

@ -0,0 +1,5 @@
## What do you mean?
* When we create a custom component, often we have to tell the browser how it should treat it
* But often browsers already give us the tools to do that natively
* Reaching for CSS and HTML first can make our components faster, more reusable, and more accessible

158
src/slides/03-example-1.md Normal file
View File

@ -0,0 +1,158 @@
## Example: toggles
<div class="grid">
```typescript
import React, { Component } from 'react';
import uniqueId from 'lodash/uniqueId';
import Icon from 'components/Icon';
import styled from 'styled-components';
import theme from 'theme';
const TRANSITION_SPEED = '0.25s';
export const StyledContainer = styled.div`
[type='checkbox'] {
display: none;
& + label {
cursor: pointer;
display: block;
width: 56px;
height: 26px;
color: ${theme.colours.gray700};
background-color: ${theme.colours.gray700};
border-radius: 18px;
position: relative;
padding: 2px;
transition: color ${TRANSITION_SPEED}, background-color ${TRANSITION_SPEED};
&:hover {
color: ${theme.colours.gray800};
background-color: ${theme.colours.gray800};
}
}
&:checked + label {
color: ${theme.colours.confirmation500};
background-color: ${theme.colours.confirmation500};
&:hover {
color: ${theme.colours.confirmation600};
background-color: ${theme.colours.confirmation600};
}
}
}
[disabled] + label {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none;
}
`;
export const StyledIconContainer = styled.div`
display: inline-block;
width: 24px;
height: 24px;
position: absolute;
right: 33px;
top: 50%;
transform: translateY(-50%);
border-radius: 50%;
background-color: white;
transition: right ${TRANSITION_SPEED};
&.active {
right: 3px;
}
`;
export const StyledIcon = styled.div`
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
`;
type Props = {
active: boolean;
disabled?: boolean;
onActivate: () => void;
onDeactivate: () => void;
className?: string;
};
type State = {
active: boolean;
};
export default class Toggle extends Component<Props, State> {
static defaultProps = {
active: false,
disabled: false,
onActivate: () => {},
onDeactivate: () => {},
};
id = uniqueId('toggle-');
state = {
active: this.props.active,
};
componentDidUpdate(prevProps: Readonly<Props>, prevState: Readonly<State>) {
if (prevState.active !== this.state.active) {
return;
}
const { active } = this.props;
if (prevProps.active !== active && this.state.active !== active) {
this.setState({ active });
}
}
toggle = () => {
const newActive = !this.state.active;
newActive ? this.props.onActivate() : this.props.onDeactivate();
this.setState({ active: newActive });
};
render() {
const { disabled, className } = this.props;
const { active } = this.state;
return (
<StyledContainer className={className}>
<input
id={this.id}
type="checkbox"
checked={active}
disabled={disabled}
readOnly={true}
onChange={this.toggle}
onClick={(e) => e.stopPropagation()}
aria-label="toggle"
/>
<label htmlFor={this.id}>
<StyledIconContainer className={active ? 'active' : undefined}>
<StyledIcon>{active ? <Icon icon="tick" size={14} /> : <Icon icon="close" size={18} />}</StyledIcon>
</StyledIconContainer>
</label>
</StyledContainer>
);
}
}
```
<div>
* 139 lines of code (+ the Icons, theme, 3 libraries required)
* Manual state management
* Have to import all of this everywhere we use it
* No meaningful labels possible!
* No keyboard navigation
</div>
</div>

View File

@ -0,0 +1,65 @@
## Example 1: Fixing the toggle
<div class="grid">
```html
<style>
input[type="checkbox"][data-role="toggle"] {
appearance: none;
background: lightgray;
border: 1px solid gray;
width: 50px;
height: 20px;
border-radius: 20px;
position: relative;
cursor: pointer;
&::before {
content: " ";
width: 14px;
aspect-ratio: 1;
background: gray;
position: absolute;
left: 2px;
top: 1px;
border-radius: 20px;
border: 1px solid transparent;
transition:
left .2s ease-in-out,
right .2s ease-in-out;
}
&:checked {
background: lightgreen;
&::before {
border-color: gray;
background-color: white;
left: calc(100% - 18px);
}
}
}
</style>
<input
type="checkbox"
data-type="toggle"
name="activated"
/>
```
<div>
<input
type="checkbox"
data-role="toggle"
name="activated"
/>
* 42 lines of code
* Uses regular HTML markup - 0 javascript needed
* Fully accessible
* Labels work
* Can be used anywhere - all you need is the stylesheet
</div>
</div>

View File

@ -0,0 +1,6 @@
{
"tags": [
"slides"
],
"permalink": false
}

1
src/styles/prism.min.css vendored Normal file
View File

@ -0,0 +1 @@
code[class*=language-],pre[class*=language-]{word-wrap:normal;background:0 0;color:#fff;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;-webkit-hyphens:none;hyphens:none;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;text-align:left;text-shadow:0 -.1em .2em #000;white-space:pre;word-break:normal;word-spacing:normal}:not(pre)>code[class*=language-],pre[class*=language-]{background:#141414}pre[class*=language-]{border:.3em solid #545454;border-radius:.5em;box-shadow:inset 1px 1px .5em #000;margin:.5em 0;overflow:auto;padding:1em}pre[class*=language-]::-moz-selection{background:#27292a}pre[class*=language-]::selection{background:#27292a}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{background:hsla(0,0%,93%,.15);text-shadow:none}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{background:hsla(0,0%,93%,.15);text-shadow:none}:not(pre)>code[class*=language-]{border:.13em solid #545454;border-radius:.3em;box-shadow:inset 1px 1px .3em -.1em #000;padding:.15em .2em .05em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#777}.token.namespace,.token.punctuation{opacity:.7}.token.boolean,.token.deleted,.token.number,.token.tag{color:#ce6849}.token.builtin,.token.constant,.token.keyword,.token.property,.token.selector,.token.symbol{color:#f9ed99}.language-css .token.string,.style .token.string,.token.attr-name,.token.attr-value,.token.char,.token.entity,.token.inserted,.token.operator,.token.string,.token.url,.token.variable{color:#909e6a}.token.atrule{color:#7385a5}.token.important,.token.regex{color:#e8c062}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.language-markup .token.attr-name,.language-markup .token.punctuation,.language-markup .token.tag{color:#ac885c}.token{position:relative;z-index:1}.line-highlight.line-highlight{background:hsla(0,0%,33%,.25);background:linear-gradient(90deg,hsla(0,0%,33%,.1) 70%,hsla(0,0%,33%,0));border-bottom:1px dashed #545454;border-top:1px dashed #545454;margin-top:.75em;z-index:0}.line-highlight.line-highlight:before,.line-highlight.line-highlight[data-end]:after{background-color:#8693a6;color:#f4f1ef}

310
src/styles/props.css Normal file
View File

@ -0,0 +1,310 @@
/* VARIABLES GENERATED WITH TAILWIND CONFIG ON 9/27/2023.
Tokens location: ./tailwind.config.js */
:root {
--color-inherit: inherit;
--color-current: currentColor;
--color-transparent: transparent;
--color-black: #000;
--color-white: #fff;
--color-slate-50: #f8fafc;
--color-slate-100: #f1f5f9;
--color-slate-200: #e2e8f0;
--color-slate-300: #cbd5e1;
--color-slate-400: #94a3b8;
--color-slate-500: #64748b;
--color-slate-600: #475569;
--color-slate-700: #334155;
--color-slate-800: #1e293b;
--color-slate-900: #0f172a;
--color-gray-50: #f9fafb;
--color-gray-100: #f3f4f6;
--color-gray-200: #e5e7eb;
--color-gray-300: #d1d5db;
--color-gray-400: #9ca3af;
--color-gray-500: #6b7280;
--color-gray-600: #4b5563;
--color-gray-700: #374151;
--color-gray-800: #1f2937;
--color-gray-900: #111827;
--color-zinc-50: #fafafa;
--color-zinc-100: #f4f4f5;
--color-zinc-200: #e4e4e7;
--color-zinc-300: #d4d4d8;
--color-zinc-400: #a1a1aa;
--color-zinc-500: #71717a;
--color-zinc-600: #52525b;
--color-zinc-700: #3f3f46;
--color-zinc-800: #27272a;
--color-zinc-900: #18181b;
--color-neutral-50: #fafafa;
--color-neutral-100: #f5f5f5;
--color-neutral-200: #e5e5e5;
--color-neutral-300: #d4d4d4;
--color-neutral-400: #a3a3a3;
--color-neutral-500: #737373;
--color-neutral-600: #525252;
--color-neutral-700: #404040;
--color-neutral-800: #262626;
--color-neutral-900: #171717;
--color-stone-50: #fafaf9;
--color-stone-100: #f5f5f4;
--color-stone-200: #e7e5e4;
--color-stone-300: #d6d3d1;
--color-stone-400: #a8a29e;
--color-stone-500: #78716c;
--color-stone-600: #57534e;
--color-stone-700: #44403c;
--color-stone-800: #292524;
--color-stone-900: #1c1917;
--color-red-50: #fef2f2;
--color-red-100: #fee2e2;
--color-red-200: #fecaca;
--color-red-300: #fca5a5;
--color-red-400: #f87171;
--color-red-500: #ef4444;
--color-red-600: #dc2626;
--color-red-700: #b91c1c;
--color-red-800: #991b1b;
--color-red-900: #7f1d1d;
--color-orange-50: #fff7ed;
--color-orange-100: #ffedd5;
--color-orange-200: #fed7aa;
--color-orange-300: #fdba74;
--color-orange-400: #fb923c;
--color-orange-500: #f97316;
--color-orange-600: #ea580c;
--color-orange-700: #c2410c;
--color-orange-800: #9a3412;
--color-orange-900: #7c2d12;
--color-amber-50: #fffbeb;
--color-amber-100: #fef3c7;
--color-amber-200: #fde68a;
--color-amber-300: #fcd34d;
--color-amber-400: #fbbf24;
--color-amber-500: #f59e0b;
--color-amber-600: #d97706;
--color-amber-700: #b45309;
--color-amber-800: #92400e;
--color-amber-900: #78350f;
--color-yellow-50: #fefce8;
--color-yellow-100: #fef9c3;
--color-yellow-200: #fef08a;
--color-yellow-300: #fde047;
--color-yellow-400: #facc15;
--color-yellow-500: #eab308;
--color-yellow-600: #ca8a04;
--color-yellow-700: #a16207;
--color-yellow-800: #854d0e;
--color-yellow-900: #713f12;
--color-lime-50: #f7fee7;
--color-lime-100: #ecfccb;
--color-lime-200: #d9f99d;
--color-lime-300: #bef264;
--color-lime-400: #a3e635;
--color-lime-500: #84cc16;
--color-lime-600: #65a30d;
--color-lime-700: #4d7c0f;
--color-lime-800: #3f6212;
--color-lime-900: #365314;
--color-green-50: #f0fdf4;
--color-green-100: #dcfce7;
--color-green-200: #bbf7d0;
--color-green-300: #86efac;
--color-green-400: #4ade80;
--color-green-500: #22c55e;
--color-green-600: #16a34a;
--color-green-700: #15803d;
--color-green-800: #166534;
--color-green-900: #14532d;
--color-emerald-50: #ecfdf5;
--color-emerald-100: #d1fae5;
--color-emerald-200: #a7f3d0;
--color-emerald-300: #6ee7b7;
--color-emerald-400: #34d399;
--color-emerald-500: #10b981;
--color-emerald-600: #059669;
--color-emerald-700: #047857;
--color-emerald-800: #065f46;
--color-emerald-900: #064e3b;
--color-teal-50: #f0fdfa;
--color-teal-100: #ccfbf1;
--color-teal-200: #99f6e4;
--color-teal-300: #5eead4;
--color-teal-400: #2dd4bf;
--color-teal-500: #14b8a6;
--color-teal-600: #0d9488;
--color-teal-700: #0f766e;
--color-teal-800: #115e59;
--color-teal-900: #134e4a;
--color-cyan-50: #ecfeff;
--color-cyan-100: #cffafe;
--color-cyan-200: #a5f3fc;
--color-cyan-300: #67e8f9;
--color-cyan-400: #22d3ee;
--color-cyan-500: #06b6d4;
--color-cyan-600: #0891b2;
--color-cyan-700: #0e7490;
--color-cyan-800: #155e75;
--color-cyan-900: #164e63;
--color-sky-50: #f0f9ff;
--color-sky-100: #e0f2fe;
--color-sky-200: #bae6fd;
--color-sky-300: #7dd3fc;
--color-sky-400: #38bdf8;
--color-sky-500: #0ea5e9;
--color-sky-600: #0284c7;
--color-sky-700: #0369a1;
--color-sky-800: #075985;
--color-sky-900: #0c4a6e;
--color-blue-50: #eff6ff;
--color-blue-100: #dbeafe;
--color-blue-200: #bfdbfe;
--color-blue-300: #93c5fd;
--color-blue-400: #60a5fa;
--color-blue-500: #3b82f6;
--color-blue-600: #2563eb;
--color-blue-700: #1d4ed8;
--color-blue-800: #1e40af;
--color-blue-900: #1e3a8a;
--color-indigo-50: #eef2ff;
--color-indigo-100: #e0e7ff;
--color-indigo-200: #c7d2fe;
--color-indigo-300: #a5b4fc;
--color-indigo-400: #818cf8;
--color-indigo-500: #6366f1;
--color-indigo-600: #4f46e5;
--color-indigo-700: #4338ca;
--color-indigo-800: #3730a3;
--color-indigo-900: #312e81;
--color-violet-50: #f5f3ff;
--color-violet-100: #ede9fe;
--color-violet-200: #ddd6fe;
--color-violet-300: #c4b5fd;
--color-violet-400: #a78bfa;
--color-violet-500: #8b5cf6;
--color-violet-600: #7c3aed;
--color-violet-700: #6d28d9;
--color-violet-800: #5b21b6;
--color-violet-900: #4c1d95;
--color-purple-50: #faf5ff;
--color-purple-100: #f3e8ff;
--color-purple-200: #e9d5ff;
--color-purple-300: #d8b4fe;
--color-purple-400: #c084fc;
--color-purple-500: #a855f7;
--color-purple-600: #9333ea;
--color-purple-700: #7e22ce;
--color-purple-800: #6b21a8;
--color-purple-900: #581c87;
--color-fuchsia-50: #fdf4ff;
--color-fuchsia-100: #fae8ff;
--color-fuchsia-200: #f5d0fe;
--color-fuchsia-300: #f0abfc;
--color-fuchsia-400: #e879f9;
--color-fuchsia-500: #d946ef;
--color-fuchsia-600: #c026d3;
--color-fuchsia-700: #a21caf;
--color-fuchsia-800: #86198f;
--color-fuchsia-900: #701a75;
--color-pink-50: #fdf2f8;
--color-pink-100: #fce7f3;
--color-pink-200: #fbcfe8;
--color-pink-300: #f9a8d4;
--color-pink-400: #f472b6;
--color-pink-500: #ec4899;
--color-pink-600: #db2777;
--color-pink-700: #be185d;
--color-pink-800: #9d174d;
--color-pink-900: #831843;
--color-rose-50: #fff1f2;
--color-rose-100: #ffe4e6;
--color-rose-200: #fecdd3;
--color-rose-300: #fda4af;
--color-rose-400: #fb7185;
--color-rose-500: #f43f5e;
--color-rose-600: #e11d48;
--color-rose-700: #be123c;
--color-rose-800: #9f1239;
--color-rose-900: #881337;
--color-lightBlue-50: #f0f9ff;
--color-lightBlue-100: #e0f2fe;
--color-lightBlue-200: #bae6fd;
--color-lightBlue-300: #7dd3fc;
--color-lightBlue-400: #38bdf8;
--color-lightBlue-500: #0ea5e9;
--color-lightBlue-600: #0284c7;
--color-lightBlue-700: #0369a1;
--color-lightBlue-800: #075985;
--color-lightBlue-900: #0c4a6e;
--color-warmGray-50: #fafaf9;
--color-warmGray-100: #f5f5f4;
--color-warmGray-200: #e7e5e4;
--color-warmGray-300: #d6d3d1;
--color-warmGray-400: #a8a29e;
--color-warmGray-500: #78716c;
--color-warmGray-600: #57534e;
--color-warmGray-700: #44403c;
--color-warmGray-800: #292524;
--color-warmGray-900: #1c1917;
--color-trueGray-50: #fafafa;
--color-trueGray-100: #f5f5f5;
--color-trueGray-200: #e5e5e5;
--color-trueGray-300: #d4d4d4;
--color-trueGray-400: #a3a3a3;
--color-trueGray-500: #737373;
--color-trueGray-600: #525252;
--color-trueGray-700: #404040;
--color-trueGray-800: #262626;
--color-trueGray-900: #171717;
--color-coolGray-50: #f9fafb;
--color-coolGray-100: #f3f4f6;
--color-coolGray-200: #e5e7eb;
--color-coolGray-300: #d1d5db;
--color-coolGray-400: #9ca3af;
--color-coolGray-500: #6b7280;
--color-coolGray-600: #4b5563;
--color-coolGray-700: #374151;
--color-coolGray-800: #1f2937;
--color-coolGray-900: #111827;
--color-blueGray-50: #f8fafc;
--color-blueGray-100: #f1f5f9;
--color-blueGray-200: #e2e8f0;
--color-blueGray-300: #cbd5e1;
--color-blueGray-400: #94a3b8;
--color-blueGray-500: #64748b;
--color-blueGray-600: #475569;
--color-blueGray-700: #334155;
--color-blueGray-800: #1e293b;
--color-blueGray-900: #0f172a;
--space-size-4xs: clamp(0.125rem, calc(0.12rem + 0.03vw), 0.21rem);
--space-size-3xs: clamp(0.25rem, calc(0.24rem + 0.06vw), 0.31rem);
--space-size-2xs: clamp(0.5rem, calc(0.48rem + 0.13vw), 0.63rem);
--space-size-xs: clamp(0.75rem, calc(0.71rem + 0.19vw), 0.94rem);
--space-size-s: clamp(1rem, calc(0.95rem + 0.25vw), 1.25rem);
--space-size-m: clamp(1.5rem, calc(1.43rem + 0.38vw), 1.88rem);
--space-size-l: clamp(2rem, calc(1.9rem + 0.5vw), 2.5rem);
--space-size-xl: clamp(3rem, calc(2.85rem + 0.75vw), 3.75rem);
--space-size-2xl: clamp(4rem, calc(3.8rem + 1vw), 5rem);
--space-size-3xl: clamp(6rem, calc(5.7rem + 1.5vw), 7.5rem);
--text-size-2xs: clamp(0.56rem, calc(0.72rem + -0.14vw), 0.69rem);
--text-size-xs: clamp(0.83rem, calc(0.83rem + 0vw), 0.83rem);
--text-size-s: clamp(1rem, calc(0.95rem + 0.25vw), 1.25rem);
--text-size-m: clamp(1.2rem, calc(1.07rem + 0.68vw), 1.88rem);
--text-size-l: clamp(1.44rem, calc(1.17rem + 1.37vw), 2.81rem);
--text-size-xl: clamp(1.73rem, calc(1.23rem + 2.49vw), 4.22rem);
--text-size-2xl: clamp(2.07rem, calc(1.22rem + 4.25vw), 6.33rem);
--text-size-3xl: clamp(2.49rem, calc(1.09rem + 7vw), 9.49rem);
--font-family-sans: ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
"Noto Color Emoji";
--font-family-mono: "Space Grotesk", ui-monospace, SFMono-Regular, Menlo,
Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--screen-sm: 640px;
--screen-md: 768px;
--screen-lg: 1024px;
--screen-xl: 1280px;
--screen-2xl: 1536px;
--screen-3xl: 1920px;
}

79
src/styles/reset.css Normal file
View File

@ -0,0 +1,79 @@
/* Modern reset: https://piccalil.li/blog/a-modern-css-reset/ */
/* Box sizing rules */
*,
*::before,
*::after {
box-sizing: border-box;
}
/* Remove default margin */
body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
margin: 0;
}
/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
[role='list']
{
list-style: none;
padding: 0;
margin: 0;
}
/* Set core root defaults */
html:focus-within {
scroll-behavior: smooth;
}
/* Set core body defaults */
body {
min-height: 100vh;
min-height: 100dvh; /* safari-specific */
text-rendering: optimizeSpeed;
line-height: 1.75;
}
/* A elements that don't have a class get default styles */
a:not([class]) {
text-decoration-skip-ink: auto;
}
/* Make images easier to work with */
img,
picture {
max-width: 100%;
display: block;
}
/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
font: inherit;
}
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
html:focus-within {
scroll-behavior: auto;
}
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}

135
src/styles/styles.css Normal file
View File

@ -0,0 +1,135 @@
@import "reset.css";
@import "props.css";
@import "prism.min.css";
body {
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;
overflow: hidden;
}
main {
background-color: var(--color-slate-700);
color: var(--color-neutral-200);
display: flex;
scroll-snap-type: x mandatory;
overflow-x: auto;
height: 100vh;
height: 100dvh;
width: 100vw;
}
.slide {
scroll-snap-align: start;
position: relative;
border-bottom: 1px solid black;
height: 100%;
flex: 1 0 100%;
font-size: var(--text-size-m);
&.title {
display: flex;
flex-direction: column;
gap: var(--space-size-sm);
align-items: center;
justify-content: center;
}
h1 {
font-size: var(--text-size-2xl);
}
h2 {
font-size: var(--text-size-xl);
border-bottom: 2px solid var(--color-neutral-200);
padding-inline: var(--space-size-xs);
}
h1, h2, h3, h4 {
a {
text-decoration: none;
}
}
a {
color: white;
}
ul {
max-width: 60ch;
display: flex;
flex-direction: column;
gap: var(--space-size-m);
}
pre[class*=language-] {
max-width: 60ch;
max-height: 80vh;
max-height: 80dvh;
font-size: var(--text-size-s);
}
pre, code {
word-wrap:
}
input[type="checkbox"][data-role="toggle"] {
appearance: none;
background: lightgray;
border: 1px solid gray;
width: 55px;
height: 25px;
border-radius: 20px;
position: relative;
cursor: pointer;
&::before {
content: " ";
width: 20px;
aspect-ratio: 1;
background: gray;
position: absolute;
left: 2px;
top: 1px;
border-radius: 20px;
border: 1px solid transparent;
transition: left .2s ease-in-out, right .2s ease-in-out;
}
&:checked {
background: var(--color-green-500);
&::before {
border-color: gray;
background-color: white;
left: calc(100% - 22px);
}
}
}
.grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: space-around;
gap: var(--space-size-m);
padding: var(--space-size-s);
> :not(:first-child) {
flex-shrink: 1;
display: flex;
flex-direction: column;
align-items: center;
padding: var(--space-size-s);
}
> :first-child {
min-width: 40ch;
flex-basis: 60%;
flex-grow: 1;
}
}
}

2040
yarn.lock Normal file

File diff suppressed because it is too large Load Diff