Skip to content

Commit

Permalink
fix(global): revamp demo site to include document section examples
Browse files Browse the repository at this point in the history
  • Loading branch information
waldronmatt committed Mar 26, 2023
1 parent c4d8706 commit f6817b0
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 36 deletions.
54 changes: 50 additions & 4 deletions src/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,57 @@
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<header>
<h1>Webpack Template</h1>
<nav>
<ul class="nav">
<li>
<a
href="/"
title="home"
>Home</a
>
</li>
<li>
<a
href="/"
title="blog"
>Blog</a
>
</li>
<li>
<a
href="/"
title="contact"
>Contact</a
>
</li>
</ul>
</nav>
</header>
<main>
<h1>404 - Page Not Found</h1>
<footer>
<p>© Copyright <span id="copyright"></span></p>
</footer>
<h2>404 - Page Not Found</h2>
</main>
<footer>
<small>© <span id="footer-copyright"></span> Webpack Template</small>
<nav>
<ul class="nav">
<li>
<a
href="/"
title="sitemap"
>Sitemap</a
>
</li>
<li>
<a
href="/"
title="legal"
>Legal</a
>
</li>
</ul>
</nav>
</footer>
</body>
</html>
114 changes: 109 additions & 5 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,116 @@
}
</script>
<body>
<header>
<h1>Webpack Template</h1>
<nav>
<ul class="nav">
<li>
<a
href="/"
title="home"
>Home</a
>
</li>
<li>
<a
href="/"
title="blog"
>Blog</a
>
</li>
<li>
<a
href="/"
title="contact"
>Contact</a
>
</li>
</ul>
</nav>
</header>
<main>
<h1>Welcome to Webpack Template!</h1>
<footer>
<p>© Copyright <span id="copyright"></span></p>
</footer>
<div id="root"></div>
<h2>Lorem ipsum dolor</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean at
pulvinar ligula. Praesent eget elit venenatis, elementum sapien id,
aliquam lorem. Suspendisse auctor eu justo eu pellentesque. Donec
gravida quam eu leo congue venenatis. Sed consectetur nunc justo, et
mattis arcu interdum id. Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Donec a mi id massa cursus vehicula.
</p>
<h2>Nunc laoreet aliquet</h2>
<p>
Nunc laoreet aliquet orci, a sollicitudin neque convallis non.
Pellentesque ac nulla eget orci ornare fermentum ut in arcu. In nisl
velit, pretium quis pulvinar et, porta sit amet neque. Fusce sagittis
dui purus, nec pharetra risus egestas vitae. Suspendisse semper nisl sed
euismod scelerisque. Praesent dapibus commodo ligula, id varius diam
vulputate id. Sed pharetra egestas erat quis sodales. Aenean ut faucibus
neque, imperdiet semper leo. Nullam pharetra elit vel pellentesque
rutrum. Donec pulvinar leo vel iaculis sodales. Phasellus vel rhoncus
nibh. Donec convallis nec ipsum vitae mattis. Nullam at urna laoreet,
vulputate enim et, aliquet massa. Vestibulum in porttitor nunc.
</p>
<h2>Nullam fermentum magna</h2>
<p>
Nullam fermentum magna ut lacus egestas aliquam. Aliquam accumsan tellus
tellus, ornare maximus dui suscipit sed. Suspendisse potenti. Cras vel
interdum risus. Sed rutrum a odio ut rutrum. Suspendisse potenti.
Maecenas venenatis laoreet ante in cursus. Etiam malesuada volutpat
euismod.
</p>
<h2>Vivamus et luctus</h2>
<p>
Vivamus et luctus sem, vel aliquam ipsum. Donec elementum iaculis augue
nec tempus. Integer massa quam, euismod nec lectus sed, luctus gravida
sapien. Duis dignissim tempor orci, a accumsan est consectetur at.
Suspendisse potenti. Aenean imperdiet lectus in nibh mollis, sed
facilisis eros semper. Aliquam eu odio turpis. Aliquam efficitur finibus
tortor, id ornare dolor commodo posuere. Aenean vulputate sed felis
vitae euismod. Phasellus pellentesque at felis vitae vestibulum. Nunc
ultrices enim leo, ut pharetra mauris lobortis et. Ut at luctus velit,
non fermentum leo.
</p>
<h2>Phasellus fringilla diam</h2>
<p>
Phasellus fringilla diam eget dui venenatis ullamcorper. Phasellus lorem
magna, vulputate sed nibh id, pellentesque venenatis orci. Maecenas
rhoncus, urna eget pellentesque venenatis, nibh felis convallis est, nec
euismod odio magna in est. Sed dignissim metus ac consectetur luctus.
Nulla id bibendum neque. Etiam imperdiet auctor diam at ultricies.
Praesent condimentum justo urna, eget facilisis nisi elementum non.
Morbi sed nisi convallis, sagittis magna at, facilisis purus. Class
aptent taciti sociosqu ad litora torquent per conubia nostra, per
inceptos himenaeos. Aliquam rutrum, turpis a bibendum aliquam, sapien
tellus tincidunt nulla, eget interdum risus arcu sed tellus. Quisque in
libero malesuada, pellentesque lectus vitae, consectetur mauris. Cras
diam mi, condimentum sit amet imperdiet eu, accumsan quis libero.
Vestibulum sed pulvinar augue. Nunc rutrum purus a erat fermentum, ac
blandit lorem sagittis. Quisque vitae suscipit velit. Nunc non dolor
iaculis, ullamcorper odio ultrices, blandit ante.
</p>
</main>
<footer>
<small>© <span id="footer-copyright"></span> Webpack Template</small>
<nav>
<ul class="nav">
<li>
<a
href="/"
title="sitemap"
>Sitemap</a
>
</li>
<li>
<a
href="/"
title="legal"
>Legal</a
>
</li>
</ul>
</nav>
</footer>
</body>
</html>
63 changes: 58 additions & 5 deletions src/scss/base/_base.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,63 @@
body {
font-family: Tajawal, Arial, Helvetica, sans-serif;
margin: 2rem;
margin: 1rem;
}

img {
// https://web.dev/optimize-cls/#modern-best-practice
aspect-ratio: attr(width) / attr(height);
margin-top: 1rem;
header,
footer {
align-items: center;
/* stylelint-disable plugin/no-unsupported-browser-features */
column-gap: 2rem;
display: flex;
flex-wrap: wrap;
row-gap: 1rem;
}

header {
border-bottom: 2px solid #d3d3d3;
padding-bottom: 1rem;

h1 {
flex-grow: 1;
margin: 0;
}
}

nav {
ul {
align-items: center;
display: flex;
gap: 2rem;
justify-content: flex-end;
}
}

a,
button {
padding: 0.5rem;

&:focus {
border: 2px solid #00f;
}
}

main {
h2 {
font-size: larger;
font-weight: bold;
margin: 1rem 0;
}

:last-child {
margin-bottom: 1rem;
}
}

footer {
border-top: 2px solid #d3d3d3;
padding-top: 1rem;

small {
flex-grow: 1;
}
}
2 changes: 0 additions & 2 deletions src/scss/index.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@charset 'UTF-8';

/* Vendors */
@import 'vendors/reset', 'vendors/sanitize';

/* Base styles */
@import 'base/base', 'base/fonts';
5 changes: 5 additions & 0 deletions src/ts/footer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
document
?.querySelector('#footer-copyright')
?.append(
document.createTextNode(new Date().getFullYear() as unknown as string)
);
12 changes: 12 additions & 0 deletions src/ts/header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import '@/scss/index.scss';
// @PERFORMANCE-COMMENT
// tells webpack to map generated webp to jpg
import webpackLogo from '@/images/icon-square-small.jpg?as=webp';

const logo = document.createElement('img');
const header = document.querySelector('header');
header?.prepend(logo);
logo.src = webpackLogo;
logo.alt = 'Webpack Logo';
logo.height = 50;
logo.width = 50;
22 changes: 2 additions & 20 deletions src/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
/* global document */
// eslint-disable-next-line import/no-unresolved
import '@/scss/index.scss';

// Test webp generation from jpg source image
import webpackLogo from '@/images/icon-square-small.jpg?as=webp';

document
.querySelector('#copyright')
?.appendChild(document.createTextNode(new Date().getFullYear().toString()));

const logo = document.createElement('img');
logo.src = webpackLogo;
logo.alt = 'Webpack Logo';
logo.height = 200;
logo.width = 200;

const app = document.querySelector('#root');
app?.append(logo);
import './header';
import './footer';

// jest testing
export const sum = (...a: number[]) =>
a.reduce((accumulator, value) => accumulator + value, 0);
console.log(sum(1, 2, 3));

0 comments on commit f6817b0

Please sign in to comment.