Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Styling intro screen and adding demo images.

Jake Archibald568b9e9459d0
diff --git a/src/assets/favicon.ico b/src/assets/favicon.ico
index a96e45b2..a3a6c2d7 100644
Binary files a/src/assets/favicon.ico and b/src/assets/favicon.ico differ
diff --git a/src/assets/icon-large.png b/src/assets/icon-large.png
new file mode 100644
index 00000000..e394516e
Binary files /dev/null and b/src/assets/icon-large.png differ
diff --git a/src/assets/icon-small.png b/src/assets/icon-small.png
new file mode 100644
index 00000000..709b1829
Binary files /dev/null and b/src/assets/icon-small.png differ
diff --git a/src/assets/icon.png b/src/assets/icon.png
deleted file mode 100644
index 8371feaa..00000000
Binary files a/src/assets/icon.png and /dev/null differ
diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx
index ce990fe9..92d5868b 100644
--- a/src/components/App/index.tsx
+++ b/src/components/App/index.tsx
@@ -43,7 +43,7 @@ import Intro from '../intro';
type Orientation = 'horizontal' | 'vertical';
export interface SourceImage {
- file: File;
+ file: File | Fileish;
data: ImageData;
vectorImage?: HTMLImageElement;
}
@@ -259,7 +259,7 @@ export default class App extends Component<Props, State> {
}
@bind
- async updateFile(file: File) {
+ async updateFile(file: File | Fileish) {
this.setState({ loading: true });
try {
let data: ImageData;
@@ -268,7 +268,7 @@ export default class App extends Component<Props, State> {
// Special-case SVG. We need to avoid createImageBitmap because of
// https://bugs.chromium.org/p/chromium/issues/detail?id=606319.
// Also, we cache the HTMLImageElement so we can perform vector resizing later.
- if (file.type === 'image/svg+xml') {
+ if (file.type.startsWith('image/svg+xml')) {
vectorImage = await processSvg(file);
data = drawableToImageData(vectorImage);
} else {
@@ -368,6 +368,7 @@ export default class App extends Component<Props, State> {
this.setState({ images });
}
+ @bind
showError (error: string) {
if (!this.snackbar) throw Error('Snackbar missing');
this.snackbar.showSnackbar({ message: error });
@@ -410,7 +411,7 @@ export default class App extends Component<Props, State> {
))}
</div>
:
- <Intro onFile={this.updateFile} />
+ <Intro onFile={this.updateFile} onError={this.showError} />
}
{anyLoading && <span style={{ position: 'fixed', top: 0, left: 0 }}>Loading...</span>}
<snack-bar ref={linkRef(this, 'snackbar')} />
diff --git a/src/components/App/style.scss b/src/components/App/style.scss
index e9e8db3d..0cbb89f8 100644
--- a/src/components/App/style.scss
+++ b/src/components/App/style.scss
@@ -10,7 +10,6 @@ Note: These styles are temporary. They will be replaced before going live.
height: 100%;
overflow: hidden;
contain: strict;
- display: flex;
}
:global {
@@ -59,6 +58,7 @@ Note: These styles are temporary. They will be replaced before going live.
display: flex;
justify-content: flex-end;
width: 100%;
+ height: 100%;
&.horizontal {
justify-content: space-between;
diff --git a/src/components/Output/style.scss b/src/components/Output/style.scss
index 511d0f0f..dacb10bf 100644
--- a/src/components/Output/style.scss
+++ b/src/components/Output/style.scss
@@ -14,7 +14,6 @@ Note: These styles are temporary. They will be replaced before going live.
.output {
@extend %fill;
- background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none"><path fill="rgba(0,0,0,0.05)" d="M0 0h10v10H0zM10 10h10v10H10z"/></svg>') center repeat;
&:before {
content: '';
diff --git a/src/components/custom-els/LoadingSpinner/index.ts b/src/components/custom-els/LoadingSpinner/index.ts
new file mode 100644
index 00000000..843b1b65
--- /dev/null
+++ b/src/components/custom-els/LoadingSpinner/index.ts
@@ -0,0 +1,62 @@
+import * as styles from './styles.css';
+
+/**
+ * A simple spinner. This custom element has no JS API. Just put it in the document, and it'll
+ * spin. You can configure the following using CSS custom properties:
+ *
+ * --size: Size of the spinner element (it's always square). Default: 28px.
+ * --color: Color of the spinner. Default: #4285f4.
+ * --stroke-width: Width of the stroke of the spinner. Default: 3px.
+ * --delay: Once the spinner enters the DOM, how long until it shows. This prevents the spinner
+ * appearing on the screen for short operations. Default: 300ms.
+ */
+export default class LoadingSpinner extends HTMLElement {
+ private _delayTimeout: number = 0;
+
+ constructor() {
+ super();
+
+ // Ideally we'd use shadow DOM here, but we're targeting browsers without shadow DOM support.
+ // You can't set attributes/content in a custom element constructor, so I'm waiting a microtask.
+ Promise.resolve().then(() => {
+ this.style.display = 'none';
+ this.innerHTML = '' +
+ `<div class="${styles.spinnerContainer}">` +
+ `<div class="${styles.spinnerLayer}">` +
+ `<div class="${styles.spinnerCircleClipper} ${styles.spinnerLeft}">` +
+ `<div class="${styles.spinnerCircle}"></div>` +
+ '</div>' +
+ `<div class="${styles.spinnerGapPatch}">` +
+ `<div class="${styles.spinnerCircle}"></div>` +
+ '</div>' +
+ `<div class="${styles.spinnerCircleClipper} ${styles.spinnerRight}">` +
+ `<div class="${styles.spinnerCircle}"></div>` +
+ '</div>' +
+ '</div>' +
+ '</div>';
+ });
+ }
+
+ disconnectedCallback() {
+ this.style.display = 'none';
+ clearTimeout(this._delayTimeout);
+ }
+
+ connectedCallback() {
+ const delayStr = getComputedStyle(this).getPropertyValue('--delay').trim();
+ let delayNum = parseFloat(delayStr);
+
+ // If seconds…
+ if (/\ds$/.test(delayStr)) {
+ // Convert to ms.
+ delayNum *= 1000;
+ }
+
+ this._delayTimeout = self.setTimeout(
+ () => { this.style.display = ''; },
+ delayNum,
+ );
+ }
+}
+
+customElements.define('loading-spinner', LoadingSpinner);
diff --git a/src/components/custom-els/LoadingSpinner/missing-types.d.ts b/src/components/custom-els/LoadingSpinner/missing-types.d.ts
new file mode 100644
index 00000000..b9f29dc3
--- /dev/null
+++ b/src/components/custom-els/LoadingSpinner/missing-types.d.ts
@@ -0,0 +1,7 @@
+interface LoadingSpinner extends JSX.HTMLAttributes {}
+
+declare namespace JSX {
+ interface IntrinsicElements {
+ 'loading-spinner': LoadingSpinner;
+ }
+}
diff --git a/src/components/custom-els/LoadingSpinner/styles.css b/src/components/custom-els/LoadingSpinner/styles.css
new file mode 100644
index 00000000..63c7856d
--- /dev/null
+++ b/src/components/custom-els/LoadingSpinner/styles.css
@@ -0,0 +1,124 @@
+@keyframes spinner-left-spin {
+ from { transform: rotate(130deg); }
+ 50% { transform: rotate(-5deg); }
+ to { transform: rotate(130deg); }
+}
+
+@keyframes spinner-right-spin {
+ from { transform: rotate(-130deg); }
+ 50% { transform: rotate(5deg); }
+ to { transform: rotate(-130deg); }
+}
+
+@keyframes spinner-fade-out {
+ to { opacity: 0; }
+}
+
+@keyframes spinner-container-rotate {
+ to { transform: rotate(360deg) }
+}
+
+@keyframes spinner-fill-unfill-rotate {
+ 12.5% { transform: rotate(135deg); } /* 0.5 * ARCSIZE */
+ 25% { transform: rotate(270deg); } /* 1 * ARCSIZE */
+ 37.5% { transform: rotate(405deg); } /* 1.5 * ARCSIZE */
+ 50% { transform: rotate(540deg); } /* 2 * ARCSIZE */
+ 62.5% { transform: rotate(675deg); } /* 2.5 * ARCSIZE */
+ 75% { transform: rotate(810deg); } /* 3 * ARCSIZE */
+ 87.5% { transform: rotate(945deg); } /* 3.5 * ARCSIZE */
+ to { transform: rotate(1080deg); } /* 4 * ARCSIZE */
+}
+
+loading-spinner {
+ --size: 28px;
+ --color: #4285f4;
+ --stroke-width: 3px;
+ --delay: 300ms;
+
+ pointer-events: none;
+ display: inline-block;
+ position: relative;
+ width: var(--size);
+ height: var(--size);
+ border-color: var(--color);
+}
+
+loading-spinner .spinner-circle {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ box-sizing: border-box;
+ height: 100%;
+ width: 200%;
+ border-width: var(--stroke-width);
+ border-style: solid;
+ border-color: inherit;
+ border-bottom-color: transparent !important;
+ border-radius: 50%;
+}
+
+/*
+ Patch the gap that appear between the two adjacent div.circle-clipper while the
+ spinner is rotating (appears on Chrome 38, Safari 7.1, and IE 11).
+*/
+loading-spinner .spinner-gap-patch {
+ position: absolute;
+ box-sizing: border-box;
+ top: 0;
+ left: 45%;
+ width: 10%;
+ height: 100%;
+ overflow: hidden;
+ border-color: inherit;
+}
+
+loading-spinner .spinner-gap-patch .spinner-circle {
+ width: 1000%;
+ left: -450%;
+}
+
+loading-spinner .spinner-circle-clipper {
+ display: inline-block;
+ position: relative;
+ width: 50%;
+ height: 100%;
+ overflow: hidden;
+ border-color: inherit;
+}
+
+loading-spinner .spinner-left .spinner-circle {
+ border-right-color: transparent !important;
+ transform: rotate(129deg);
+ animation: spinner-left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
+}
+
+loading-spinner .spinner-right .spinner-circle {
+ left: -100%;
+ border-left-color: transparent !important;
+ transform: rotate(-129deg);
+ animation: spinner-right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
+}
+
+loading-spinner.spinner-fadeout {
+ animation: spinner-fade-out 400ms cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
+}
+
+loading-spinner .spinner-container {
+ width: 100%;
+ height: 100%;
+ border-color: inherit;
+
+ /* duration: 360 * ARCTIME / (ARCSTARTROT + (360-ARCSIZE)) */
+ animation: spinner-container-rotate 1568ms linear infinite;
+}
+
+loading-spinner .spinner-layer {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ border-color: inherit;
+ /* durations: 4 * ARCTIME */
+ animation: spinner-fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
+}
diff --git a/src/components/intro/imgs/demos/artwork-icon.jpg b/src/components/intro/imgs/demos/artwork-icon.jpg
new file mode 100644
index 00000000..79d05f02
Binary files /dev/null and b/src/components/intro/imgs/demos/artwork-icon.jpg differ
diff --git a/src/components/intro/imgs/demos/artwork.jpg b/src/components/intro/imgs/demos/artwork.jpg
new file mode 100644
index 00000000..8da9183b
Binary files /dev/null and b/src/components/intro/imgs/demos/artwork.jpg differ
diff --git a/src/components/intro/imgs/demos/device-screen-icon.jpg b/src/components/intro/imgs/demos/device-screen-icon.jpg
new file mode 100644
index 00000000..5f140f0f
Binary files /dev/null and b/src/components/intro/imgs/demos/device-screen-icon.jpg differ
diff --git a/src/components/intro/imgs/demos/device-screen.png b/src/components/intro/imgs/demos/device-screen.png
new file mode 100644
index 00000000..b4c237c5
Binary files /dev/null and b/src/components/intro/imgs/demos/device-screen.png differ
diff --git a/src/components/intro/imgs/demos/large-photo-icon.jpg b/src/components/intro/imgs/demos/large-photo-icon.jpg
new file mode 100644
index 00000000..f418b268
Binary files /dev/null and b/src/components/intro/imgs/demos/large-photo-icon.jpg differ
diff --git a/src/components/intro/imgs/demos/large-photo.jpg b/src/components/intro/imgs/demos/large-photo.jpg
new file mode 100644
index 00000000..6f77519b
Binary files /dev/null and b/src/components/intro/imgs/demos/large-photo.jpg differ
diff --git a/src/components/intro/imgs/demos/logo-icon.png b/src/components/intro/imgs/demos/logo-icon.png
new file mode 100644
index 00000000..44ff9216
Binary files /dev/null and b/src/components/intro/imgs/demos/logo-icon.png differ
diff --git a/src/components/intro/imgs/logo.svg b/src/components/intro/imgs/logo.svg
new file mode 100644
index 00000000..a989475d
--- /dev/null
+++ b/src/components/intro/imgs/logo.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 414 414"><circle cx="207" cy="207" r="203.5" fill="#40403f" stroke="#4a494a" stroke-miterlimit="10" stroke-width="7"/><path d="M69.9 122l-6-7.8 11.8-7.3a41.8 41.8 0 0 0-5.8 15.1zm52.1 91.3l-2.8.2c-1.9.2-5.1-.6-7.3.1l1.4 7.1 9.6-2.9a35.8 35.8 0 0 0-.9-4.5zm-3.5 65.1l-1.8 2.2-.4 5.4 1.8-.5a64.5 64.5 0 0 1 8.4-2.1l.6-11.2a29.5 29.5 0 0 0-8.6 6.2zM315.4 81.3a268.6 268.6 0 0 0-94.3-17.7c-40.6 0-79.5 10-116.8 27.9a66.2 66.2 0 0 1 15.8 3.8c7.8-3.4 15.5-6.3 23.3-8.9a247.1 247.1 0 0 1 77.7-12.8A256.8 256.8 0 0 1 301.6 87c-19.6 42-31.5 80-36.3 115.9a255.8 255.8 0 0 0-1.2 60.4 228.7 228.7 0 0 0 11.4 50.4c-34 19.8-66.7 29.4-99.7 29.4a174.2 174.2 0 0 1-55.5-9.3 33.4 33.4 0 0 1-12.1 2.4l-.9 3.5a185.7 185.7 0 0 0 68.5 13.4c38.9 0 76.2-12.9 112-35.1-28.9-73-14-151.5 27.6-236.7zM97.9 158.4c-1.9-3.9-3.9-7.7-6-11.5-.7 1.2-1.5 4-2.9 5.1l3.7 7.1a43.4 43.4 0 0 1 5.2-.7z" fill="#e17926"/><path d="M270.2 203.5c5-36.7 17.5-75.9 38.3-119.4a263.4 263.4 0 0 0-87.4-15.5c-35.9 0-72.2 8.2-108.2 24.5a64.2 64.2 0 0 1 29.6 16.6l1.4 1.5a12.6 12.6 0 0 1 3.3 4.7 12.7 12.7 0 0 1-.4 6.7 30.3 30.3 0 0 1-14.6 17.9c-8.2 4.4-17.5 3.5-26.4 1.6-2.5-.5-5.2-1-7.8-.4s-4.6 2.6-6.1 5.1c2.1 3.8 4.1 7.6 6 11.5a114.4 114.4 0 0 1 11.8-.4c10.1-.1 20.2-.8 30.2.8a56.9 56.9 0 0 1 13.5 3.4 14.7 14.7 0 0 1 4.7 2.7h.1a16 16 0 0 1 3.5 5.7c6.5 17.8-6.8 33.5-22.8 39.2a70 70 0 0 1-19.7 3.7 8.5 8.5 0 0 1-2.2-.1l1.1 5.8c3.7-1.1 7.4-2.2 11.2-3.1a126.7 126.7 0 0 1 16.3-3.1c4.2-.4 10.8-1.9 14.2 1.3 1.8 1.6 2.8 4 3.8 6.3a128.1 128.1 0 0 1 4.7 12.2 24.2 24.2 0 0 1 1.2 10.3c-.9 5.8-5.3 10.6-10.3 13.8-9.3 6-20.1 9.3-29.9 14.1a59.6 59.6 0 0 0-7.4 4.3l-.5 9.2a87.2 87.2 0 0 1 36.3-1.5 18 18 0 0 1 6.4 2.2c3.6 2.2 5.4 6.5 5.4 10.7s-1.7 8.2-3.8 11.8a50.1 50.1 0 0 1-25.9 20.5c-5.1 1.8-10.4 2.5-15.4 4.2a100.2 100.2 0 0 1-11 3.4 3.1 3.1 0 0 1-.2.8 182.4 182.4 0 0 0 62.6 11.5c35.1 0 69.7-10.5 105.8-32.2a227.4 227.4 0 0 1-11.4-112.3z" fill="#f78f20"/><path d="M206.8 168.3c7.4-1.2 14.8-11.1 17-22.9s-5.1-21.6-16.4-20.6-18 12.4-16.3 24.3 8.3 20.3 15.7 19.2z" fill="#fdcda0"/><path d="M246 233.2c-20.9-13.4-30.4-36.2-46.7-59.1-15.5 28-21.7 56.9-41.2 79.1 32.3 1.6 61-7.7 87.9-20z" fill="#e17827"/><path d="M220.6 272.7c-26.7-24.5-36.9-61.6-76.5-83.3 6 34.1 6.9 63.9-14.8 88.9 33.8 8.1 63.7 3.9 91.3-5.6z" fill="#c86228"/><path d="M253.3 244c-40.4 17.8-82.8 29-129.6 21.2 7.6-44.3 1.1-86.8-29.1-125.5 51.5-23.9 109.6-38.6 177.2-27.3C250.5 159.3 241 203 253.3 244z" fill="none" stroke="#e17827" stroke-miterlimit="10" stroke-width="4"/><path d="M151 116.7a4.1 4.1 0 0 0-.5-1.9l-.4-.5c-1-.8-2.5-.9-3.7-1.3l-1.7-.7-.6-.6a64.6 64.6 0 0 0-38.1-19 27.4 27.4 0 0 0-10.3.3c-14.9 3.8-26.8 23.5-24.8 38.3 1.3 9.5 8.2 15.2 15.4 20.7a4.7 4.7 0 0 0 2 1c2.3.3 3.4-4 4.4-5.4s3-4.4 6.1-5a19.3 19.3 0 0 1 7.9.6c8.8 2.1 18.1 3.1 26.4-1.1a26.6 26.6 0 0 0 6.8-4.7 4.2 4.2 0 0 0 1.4-.9 36.2 36.2 0 0 0 4.2-3.6l2.1-2.1a15.4 15.4 0 0 0 3.1-7.7 27.5 27.5 0 0 0 .3-6.4z" fill="#c96328" opacity=".5"/><path d="M143.1 110.7a64.4 64.4 0 0 0-38-19 26 26 0 0 0-10.4.3c-14.8 3.7-26.8 23.5-24.8 38.3 1.4 9.5 8.2 15.2 15.4 20.6a4.9 4.9 0 0 0 2 1.1c2.3.3 3.4-4 4.4-5.5s3.1-4.3 6.2-4.9a18.7 18.7 0 0 1 7.8.6c8.8 2.1 18.1 3.1 26.5-1.1a30.1 30.1 0 0 0 14.9-17.4 11.8 11.8 0 0 0 .5-6.7 12.4 12.4 0 0 0-3.1-4.8z" fill="#f7ddc4"/><path d="M132.2 141.1l2.8-1.6c-8.6-1.3-12.2-.1-14-.7s-9.4-.2-12-.9-6.1-.5-8.3-1a51.4 51.4 0 0 0-9.8-1.4c-5.1-.5-9.4-2.5-12.3-.3s-4 2.6-5.6 3.6c3 4.8 7.6 8.5 12.3 12.1a4.9 4.9 0 0 0 2 1.1c2.3.3 3.4-4 4.4-5.5s3.1-4.3 6.2-4.9a18.7 18.7 0 0 1 7.8.6c8.8 2.1 18.1 3.1 26.5-1.1z" fill="#eaceb1"/><path d="M147.6 117a12.4 12.4 0 0 0-3.1-4.8l-1.4-1.5a64.4 64.4 0 0 0-38-19 26 26 0 0 0-10.4.3s-13.2 6.8-12.2 21.9c1.3 19 5.1 18.9 15.4 27.7a18.7 18.7 0 0 1 7.8.6c8.8 2.1 18.1 3.1 26.5-1.1a30.1 30.1 0 0 0 14.9-17.4 11.8 11.8 0 0 0 .5-6.7z" fill="#f8e9db" opacity=".3"/><path d="M149.5 114.8l-.4-.5c-1-.8-2.5-.9-3.7-1.3l-4.7-1.8c-2.7-.8-5.5-1.5-8.2-2.4-6.5-1.7-14.1-3.4-20.3.2a12.3 12.3 0 0 0-6.2 8.4 10.2 10.2 0 0 0 2.8 8.8c2.5 2.4 6.4 3.7 9.7 4.9a71.8 71.8 0 0 0 19.3 5.3 5.4 5.4 0 0 0 2.2 0 3.8 3.8 0 0 0 1.3-.9 29.7 29.7 0 0 0 5.3-4.7 15.4 15.4 0 0 0 3.1-7.7 27.5 27.5 0 0 0 .3-6.4 3.8 3.8 0 0 0-.5-1.9z" fill="#34b9eb"/><path d="M106.3 116.2l-.3 1.2a10.2 10.2 0 0 0 2.8 8.8c2.5 2.4 6.4 3.7 9.7 4.9a71.8 71.8 0 0 0 19.3 5.3 5.4 5.4 0 0 0 2.2 0 3.8 3.8 0 0 0 1.3-.9 29.7 29.7 0 0 0 5.3-4.7 14.4 14.4 0 0 0 1.9-3.1z" fill="#fff" opacity=".3" style="mix-blend-mode:overlay"/><path d="M89 149c-1.6 0-1.6-.3-4.2-.7s-1.7-.2-2.8-.1h-.2l3.5 2.7 1.1.8 1.2.3a2.5 2.5 0 0 0 1.5-.8l1-1.4.3-.7z" fill="#ddc1a8"/><path d="M207.2 195.8a16 16 0 0 1 1-2.3c5.7-13.4 15.5-24.4 25.4-34.9s19.5-19.1 32.8-22.4a68 68 0 0 1 27.7.4c5.5 1 11.7 1.4 16.8 4s8.9 8 12 12.7a417 417 0 0 1 24.9 44.2c4.7 9.3 10.1 18.7 10.1 29.3a72 72 0 0 1-3.4 19.6c-5.1 17.1-12.5 33.8-19.9 49.9s-16.3 30.5-30.8 40c-21.2 14-48.1 11.4-71.9 8-4-.6-37.8-3.9-38.1-7.1-.2-1.6 10.7-5.2 12.2-5.9a91 91 0 0 0 36.4-28.2 39.8 39.8 0 0 0 6.8-15.8c1.5-8.4 4.1-16.6 8.8-23.7s11.1-12.1 11.1-21.2c0-3.2-.7-6.3-.4-9.5s1.8-6.5 4.8-7.6 4-.5 5-2.1a4 4 0 0 0 .6-2.2 58.4 58.4 0 0 1 8.9-23 67 67 0 0 1-34.8 26.9c-8.8 3.5-18.5 5.8-27.8 4s-18.2-8.5-20.1-17.8a27 27 0 0 1 1.9-15.3z" fill="#c96328" opacity=".5"/><path d="M347.5 196.5c-4.8-9.6-9.8-19.1-15.1-28.4l-2.6-4.4-1.1-1.8-2-3.3a8.6 8.6 0 0 1-1-1.6l-3.1-4.7c-3.2-4.7-6.8-10-12.1-12.7s-11.2-3-16.7-4a68 68 0 0 0-27.7-.4c-13.4 3.3-23.7 12.7-32.9 22.4s-19.6 21.5-25.4 34.9l-.9 2.3c-1.9 4.9-3 10.2-1.9 15.3 1.8 9.3 10.7 16.1 20.1 17.9l1.7.2H237a68.1 68.1 0 0 0 15.9-4.3 67.3 67.3 0 0 0 34.8-26.9 86.4 86.4 0 0 0-5.8 11.3 44.8 44.8 0 0 0-3.1 11.7 5.1 5.1 0 0 1-.6 2.2c-1 1.6-3.3 1.5-5 2.1a3.8 3.8 0 0 0-1.5.9 217.1 217.1 0 0 0 15.5 93.5 249.7 249.7 0 0 1-51.1 25.2c22.7 3.1 47.5 4.5 67.4-8.5 14.5-9.6 23.7-24.7 30.8-40.1s14.8-32.8 19.8-49.9a68.3 68.3 0 0 0 3.4-19.6c.1-10.6-5.4-20-10-29.3z" fill="#f7ddc4"/><path d="M272.5 255.8l-.1-.8a1.9 1.9 0 0 0 .1.8zm-.7-12.8l-.1-5.7.1 5.7zm1.6-18.9c1.8-.6 4.1-.5 5.1-2a6 6 0 0 0 .6-2.2 44.5 44.5 0 0 1 3.1-11.8 85.5 85.5 0 0 1 5.7-11.3 52.7 52.7 0 0 1-15.1 16.4l-.9 11.8zm-1.4 25.1l.4 5.5-.4-5.5zm-.2-6.2l.2 5.8-.2-5.8zm.1-17.8c-.2 3.9-.2 7.8-.2 11.7 0-3.9 0-7.8.2-11.7z" fill="#ddc1a8"/><path d="M271.8 234.5a12.1 12.1 0 0 0-.1 1.9v1.6l.1 4.2v1.6l.2 4.3.1 1.5.3 4.5a4.9 4.9 0 0 0 .1 1.2l.5 5.5v.2c.4 3.8.9 7.7 1.6 11.5a5.9 5.9 0 0 0 .2 1.3l.7 4.2a16.2 16.2 0 0 1 .4 1.9l.8 3.7.4 2.1.8 3.4.6 2.2.9 3.4.6 2.2 1 3.3a18.7 18.7 0 0 0 .7 2.2l1.1 3.4a17.2 17.2 0 0 0 .7 2.1 52 52 0 0 0 1.3 3.6l.6 1.8 2.1 5.4-5.9 3.7-.5.3-5.7 3.3-.7.4-5.6 3-.8.5-5.6 2.8-.9.5-5.6 2.7-.8.3-5.7 2.6-.8.3-5.8 2.3-.5.2-6.2 2.3c22.7 3.1 47.5 4.5 67.4-8.6a65.9 65.9 0 0 0 15.9-14.8 139.2 139.2 0 0 0-47.9-86zm47.3-65.8c5.8-10.3 4.7-8.6 1.3-19.6-2.7-3.8-5.8-7.4-9.9-9.5s-11.2-3-16.7-4c-3.4-.6-6.7-1.1-10.1-1.4 12.5 11 15.8 21.9 15.9 31.2s-7.9 24.2-11.9 31.6-20 39.9 3.1 10.4c7.2-9.1 15.7-14.5 20.9-23.5s.9-3.5 7.4-15.2z" fill="#eaceb1"/><path d="M293.6 142c-2.4-2.4-6.5-7.1-10-7.9a51.9 51.9 0 0 0-16.2 1.1c-13.3 3.3-23.7 12.7-32.8 22.4s-19.7 21.5-25.4 34.9a16 16 0 0 0-1 2.3c-1.9 4.9-3 10.2-1.9 15.3 1.8 8.9 9.9 15.4 18.7 17.5 13.9.1 35.1-7.3 51-23.6 22.6-23.1 29.8-50.1 17.6-62z" fill="#f8e9db" opacity=".3"/><path d="M232.5 178.7a16.6 16.6 0 0 0-4.9 3c-4.1 3-7.7 6.6-11.4 9.9s-9.4 6.5-10.8 11.9a14.6 14.6 0 0 0 .6 8.5c1.5 4.8 4.2 9.4 8.4 12.2 7.7 5.1 16.1.7 22.5-4.4s13.1-8.8 16.4-15.7-1.3-13.2-5-17.9-8.9-9.2-14.9-7.8z" fill="#9f87bf"/><path d="M249.3 187.5l-39.5 32.2a19.7 19.7 0 0 0 4.6 4.5c7.7 5.1 16.1.7 22.5-4.4s13.1-8.8 16.4-15.7c2.6-5.4-.6-11.9-4-16.6z" fill="#fff" opacity=".1"/><path d="M165.2 180.8a16.2 16.2 0 0 0 .1-2.2 24.3 24.3 0 0 0-1.3-8.9 5.3 5.3 0 0 0-2.8-3.4 2.8 2.8 0 0 0-1.3-.3 15.1 15.1 0 0 0-4.6-2.7 68.5 68.5 0 0 0-13.5-3.4c-10-1.6-20.1-.8-30.2-.8s-19.3 0-27.7 5-12.9 14.6-14.6 23.4-.2 17.2 4.7 24a29.6 29.6 0 0 0 34.1 9.3 6.1 6.1 0 0 0 2.2-1.3c.8-.9 1-2.2 1.6-3.3 1.5-2.9 6.5-1.4 9.1-1.5a77.1 77.1 0 0 0 19.7-3.7c8.9-3.2 17-9.5 21.3-17.5a3.1 3.1 0 0 0 1.6-1.4 8.5 8.5 0 0 0 .6-1.7 45.2 45.2 0 0 0 .8-6.3 18.3 18.3 0 0 0 .2-3.3z" fill="#c96328" opacity=".5"/><path d="M158.1 165.1h-.1a16.9 16.9 0 0 0-4.7-2.7 68.5 68.5 0 0 0-13.5-3.4c-10-1.6-20.1-.8-30.2-.8s-19.3 0-27.7 5-12.9 14.5-14.6 23.3-.2 17.2 4.7 24a29.7 29.7 0 0 0 34.1 9.3 6.1 6.1 0 0 0 2.2-1.3c.8-.9 1-2.2 1.6-3.3 1.5-2.9 6.5-1.4 9.1-1.5a77.1 77.1 0 0 0 19.7-3.7c16.1-5.8 29.4-21.5 22.9-39.2a15.2 15.2 0 0 0-3.5-5.7z" fill="#f7ddc4"/><path d="M115 226.6c2.6-.8-.5-7.5-2.8-11.9a1.4 1.4 0 0 0-1.3-.6c2.1-1.3 6-.3 8.1-.4a77.1 77.1 0 0 0 19.7-3.7 41.7 41.7 0 0 0 18.2-12.8c-14.4-1.6-20.9 12-42.4 9.7-9.4-1-17.5 1.3-25.7 1.5s-14.9-3.8-17.5 1l.7 1.1c4.3 6 11.2 9.7 18.5 10.9h.3a25.6 25.6 0 0 0 4.7.4c5.9.9 11.6 3.2 17.4 4.6a3.8 3.8 0 0 0 2.1.2z" fill="#eaceb1"/><path d="M90.2 221.4h-.1c7.9-.3 15.3 3.2 22.8 5a3.8 3.8 0 0 0 2.1.2c2.6-.8-.5-7.5-2.8-11.9a1.3 1.3 0 0 0-2.2-.1c-3.2 4.4-17.7 6.6-19.8 6.8z" fill="#ddc1a8"/><path d="M158.1 165.1h-.1a16.9 16.9 0 0 0-4.7-2.7 68.5 68.5 0 0 0-13.5-3.4c-10-1.6-20.1-.8-30.2-.8s-24 4.9-25.4 21.5c-2.5 30.8 44.5 31.4 56.8 28.9a27.7 27.7 0 0 0 20.6-37.7 15.2 15.2 0 0 0-3.5-5.8z" fill="#f8e9db" opacity=".3"/><path d="M119 180.8a12.7 12.7 0 0 1 3.1-8.4c3-3.4 6.8-4.1 11.1-4.8l6.5-.9c5.9-.7 11.9-1.5 18-1.7a7.2 7.2 0 0 1 2.5.3 5.3 5.3 0 0 1 2.8 3.4 24.3 24.3 0 0 1 1.3 8.9 58.9 58.9 0 0 1-1.1 11.8 8.5 8.5 0 0 1-.6 1.7c-1.1 1.9-3.8 2.1-5.7 2.4a115.4 115.4 0 0 1-23.5.5 21.5 21.5 0 0 1-6.7-1.3 12.4 12.4 0 0 1-7.7-11.9z" fill="#5d509e"/><path d="M119.1 182.4a12.4 12.4 0 0 0 7.6 10.3 21.5 21.5 0 0 0 6.7 1.3 115.4 115.4 0 0 0 23.5-.5c1.9-.3 4.6-.5 5.7-2.4a8.5 8.5 0 0 0 .6-1.7 61 61 0 0 0 1.1-11.3z" fill="#fff" opacity=".3" style="mix-blend-mode:overlay"/><path d="M177.8 234.6a24.9 24.9 0 0 0-3.5-11.6c-1.5-2.3-2.3-4.8-5.1-5.2a19.9 19.9 0 0 0-5 .7 9.7 9.7 0 0 0-1.9-2.6c-3.2-3.2-9.9-2-14.1-1.7a130.1 130.1 0 0 0-16.4 2.6 217.7 217.7 0 0 0-31.7 9.4c-9 3.5-18.8 6.8-25.5 14.1-2.5 2.8-6.8 8-7.6 11.7-2.7 12.1.7 27.1 12.6 33.3 7.1 3.7 15.7 3.2 23.7 2.1 4.2-.6 8.5-1.4 11.7-4.1 1.5-1.4 2.7-3.1 4.1-4.5 3-3.2 7-5.3 11-7.1 10-4.5 20.9-7.5 30.3-13.2 5.1-3.1 9.6-7.7 10.7-13.5a8.5 8.5 0 0 0 .3-2.3l2.7-1.3a8.4 8.4 0 0 0 3.2-2.7 6.4 6.4 0 0 0 .5-4.1z" fill="#c96328" opacity=".5"/><path d="M66 250.9c.9-3.7 5.1-8.9 7.6-11.6 6.7-7.3 16.5-10.6 25.6-14.1a216.5 216.5 0 0 1 31.6-9.4 114.2 114.2 0 0 1 16.4-2.6c4.2-.3 10.9-1.6 14.2 1.7a18.3 18.3 0 0 1 3.6 6.4 106.8 106.8 0 0 1 4.3 12.4 24 24 0 0 1 .9 10.3c-1.1 5.8-5.7 10.4-10.7 13.4-9.5 5.7-20.4 8.7-30.4 13.3-4 1.8-7.9 3.9-10.9 7-1.5 1.5-2.6 3.2-4.2 4.5a21.7 21.7 0 0 1-11.6 4.1c-8 1.2-16.6 1.7-23.8-2.1-11.8-6.2-15.3-21.1-12.6-33.3z" fill="#f7ddc4"/><path d="M111.7 282.9c3.2-1.4 5.9-5.2 8-7.8a1.6 1.6 0 0 1 .8-.6.8.8 0 0 1 .8.3c2.4 1.5-3.6 6.3-3.1 9.2a6.3 6.3 0 0 1-.2 2.7c-.4.9-1.9.5-2.8.6-7 1.1-4-2.5-10.8-1.3 2.9-1.4 4.7-1.9 7.3-3.1zm46.9-31.9c-3.1.4-41.4 15.3-46.8 17.1s-14.2 5.4-23.1 5.4-11 .6-13.4 3.6l-2.5 2.8a20.9 20.9 0 0 0 5.8 4.3c7.2 3.8 15.8 3.3 23.8 2.1 4.1-.5 8.4-1.4 11.6-4.1 1.6-1.3 2.7-3 4.2-4.5 3-3.1 6.9-5.2 10.9-7 10-4.6 20.9-7.6 30.4-13.3a24.9 24.9 0 0 0 7.8-7z" fill="#eaceb1"/><path d="M169.3 233.7a106.8 106.8 0 0 0-4.3-12.4 18.3 18.3 0 0 0-3.6-6.4c-3.3-3.3-10-2-14.2-1.7a114.2 114.2 0 0 0-16.4 2.6 208.6 208.6 0 0 0-24.6 6.9c-15.7 10-20.6 21.9-17 32.2C93.7 268 114 271 136 265.8c8-3.2 16-3.9 23.5-8.4 5-3 9.6-7.6 10.7-13.4a24 24 0 0 0-.9-10.3z" fill="#f8e9db" opacity=".3"/><path d="M132.9 227.8c2.9-3.7 8.6-5.6 12.9-6.8s10.2-2 15.3-3.1c1.8-.4 5.3-1.4 7.2-1.1s3.5 2.9 5.1 5.2 3.1 7.6 3.5 11.6a7.4 7.4 0 0 1-.6 4.1 8.4 8.4 0 0 1-3.2 2.7 58.2 58.2 0 0 1-8.1 3.5 118.4 118.4 0 0 1-13.3 3.6c-5.2 1.2-11.5 2.9-16.1-.8a12.5 12.5 0 0 1-4.1-7c-.8-3.4-1-8.1.9-11.2z" fill="#41439a"/><path d="M176 228.1l-44.3 12.5a12 12 0 0 0 3.9 6.1c4.6 3.7 10.9 2 16.1.8a118.4 118.4 0 0 0 13.3-3.6 58.2 58.2 0 0 0 8.1-3.5 8.4 8.4 0 0 0 3.2-2.7 7.4 7.4 0 0 0 .6-4.1 52.5 52.5 0 0 0-.9-5.5z" fill="#fff" opacity=".4" style="mix-blend-mode:overlay"/><path d="M174.7 294.9c-.8-3.2-2.2-6.9-5.7-7.8a6.4 6.4 0 0 0-2-.3l-1.4-1.1a20.2 20.2 0 0 0-6.4-2.2 85.6 85.6 0 0 0-39.6 2.4c-11.1 3.3-30.9 10.3-32.1 23.8a22.7 22.7 0 0 0 4.1 14.7c3.8 5.9 10.3 11.9 17.7 12.2 5.8.2 11.1-2 16.4-3.8s10.4-2.3 15.4-4.2a51 51 0 0 0 24.6-18.3l.8-.2a13.8 13.8 0 0 0 6.7-3.4 9.2 9.2 0 0 0 1.5-2.5c1.3-3 .8-6.3 0-9.3z" fill="#c96328" opacity=".5"/><path d="M164.6 284.7a20.2 20.2 0 0 0-6.4-2.2 85.6 85.6 0 0 0-39.6 2.4c-11.1 3.3-30.9 10.3-32.1 23.8a22.7 22.7 0 0 0 4.1 14.7c3.8 5.9 10.3 11.9 17.7 12.2 5.8.2 11.1-2 16.4-3.8s10.4-2.3 15.4-4.2a50.2 50.2 0 0 0 26-20.4 22.9 22.9 0 0 0 3.8-11.8c.1-4.1-1.8-8.5-5.3-10.7z" fill="#f7ddc4"/><path d="M144.4 319.9c-9 3-16.7 3.9-24.8 6.2s-16.5-6.4-21.4 5.6a18.4 18.4 0 0 0 10.1 3.9c5.8.2 11.1-2 16.4-3.8s10.4-2.3 15.4-4.2c9-3.3 17.3-8.7 23.1-16.3-7.3 3.5-14.3 7.1-18.8 8.6z" fill="#eaceb1"/><path d="M164.6 284.7a20.2 20.2 0 0 0-6.4-2.2 86.7 86.7 0 0 0-38.9 2.1c-8.6 7.6-12.9 16.4-10.6 24.2 3.4 11.6 16 23 41.2 14.1a46.8 46.8 0 0 0 16.2-15.7 22.9 22.9 0 0 0 3.8-11.8c.1-4.1-1.8-8.5-5.3-10.7z" fill="#f8e9db" opacity=".3"/><path d="M132.6 303.9c1.8 4.7 6.9 7.4 11.6 8.1a31.6 31.6 0 0 0 9.7-.3c3.9-.7 7.8-1.6 11.6-2.6a13.4 13.4 0 0 0 6.7-3.4 9.2 9.2 0 0 0 1.5-2.5c1.3-3 .8-6.3 0-9.3s-2.2-6.9-5.7-7.8a12.8 12.8 0 0 0-5.5 0c-5.3.8-10.4 2.7-15.7 3.7-3.2.7-6.5 1.3-9.3 3s-5.3 4.5-5.5 7.7a9.7 9.7 0 0 0 .6 3.4z" fill="#005c9f"/><path d="M132.9 304.7c2.1 4.2 6.8 6.7 11.3 7.3a31.6 31.6 0 0 0 9.7-.3c3.9-.7 7.8-1.6 11.6-2.6a13.4 13.4 0 0 0 6.7-3.4 9.2 9.2 0 0 0 1.5-2.5 12.8 12.8 0 0 0 .3-8z" fill="#fff" opacity=".3" style="mix-blend-mode:overlay"/></svg>
diff --git a/src/components/intro/index.tsx b/src/components/intro/index.tsx
index 5d46ff75..b239a306 100644
--- a/src/components/intro/index.tsx
+++ b/src/components/intro/index.tsx
@@ -1,26 +1,134 @@
import { h, Component } from 'preact';
+
+import { bind, linkRef, Fileish } from '../../lib/util';
+import '../custom-els/LoadingSpinner';
+
+import logo from './imgs/logo.svg';
+import largePhoto from './imgs/demos/large-photo.jpg';
+import artwork from './imgs/demos/artwork.jpg';
+import deviceScreen from './imgs/demos/device-screen.png';
+import largePhotoIcon from './imgs/demos/large-photo-icon.jpg';
+import artworkIcon from './imgs/demos/artwork-icon.jpg';
+import deviceScreenIcon from './imgs/demos/device-screen-icon.jpg';
+import logoIcon from './imgs/demos/logo-icon.png';
import * as style from './style.scss';
-import { bind } from '../../lib/util';
+
+const demos = [
+ {
+ description: 'Large photo (2.8mb)',
+ filename: 'photo.jpg',
+ url: largePhoto,
+ iconUrl: largePhotoIcon,
+ },
+ {
+ description: 'Artwork (2.9mb)',
+ filename: 'art.jpg',
+ url: artwork,
+ iconUrl: artworkIcon,
+ },
+ {
+ description: 'Device screen (1.6mb)',
+ filename: 'pixel3.png',
+ url: deviceScreen,
+ iconUrl: deviceScreenIcon,
+ },
+ {
+ description: 'SVG icon (13k)',
+ filename: 'squoosh.svg',
+ url: logo,
+ iconUrl: logoIcon,
+ },
+];
interface Props {
- onFile: (file: File) => void;
+ onFile: (file: File | Fileish) => void;
+ onError: (error: string) => void;
+}
+interface State {
+ fetchingDemoIndex?: number;
}
-interface State {}
export default class Intro extends Component<Props, State> {
+ state: State = {};
+ private fileInput?: HTMLInputElement;
+
@bind
- onFileChange(event: Event): void {
+ private onFileChange(event: Event): void {
const fileInput = event.target as HTMLInputElement;
const file = fileInput.files && fileInput.files[0];
if (!file) return;
this.props.onFile(file);
}
- render({ }: Props, { }: State) {
+ @bind
+ private onButtonClick() {
+ this.fileInput!.click();
+ }
+
+ @bind
+ private async onDemoClick(index: number, event: Event) {
+ try {
+ this.setState({ fetchingDemoIndex: index });
+ const demo = demos[index];
+ const blob = await fetch(demo.url).then(r => r.blob());
+
+ // Firefox doesn't like content types like 'image/png; charset=UTF-8', which Webpack's dev
+ // server returns. https://bugzilla.mozilla.org/show_bug.cgi?id=1497925.
+ const type = /[^;]*/.exec(blob.type)![0];
+ const file = new Fileish([blob], demo.filename, { type });
+ this.props.onFile(file);
+ } catch (err) {
+ this.setState({ fetchingDemoIndex: undefined });
+ this.props.onError("Couldn't fetch demo image");
+ }
+ }
+
+ render({ }: Props, { fetchingDemoIndex }: State) {
return (
- <div class={style.welcome}>
- <h1>Drop, paste or select an image</h1>
- <input type="file" onChange={this.onFileChange} />
+ <div class={style.intro}>
+ <div>
+ <div class={style.logoSizer}>
+ <div class={style.logoContainer}>
+ <img src={logo} class={style.logo} alt="Squoosh" />
+ </div>
+ </div>
+ <p class={style.openImageGuide}>
+ Drag &amp; drop or{' '}
+ <button class={style.selectButton} onClick={this.onButtonClick}>select an image</button>
+ <input
+ class={style.hide}
+ ref={linkRef(this, 'fileInput')}
+ type="file"
+ onChange={this.onFileChange}
+ />
+ </p>
+ <p>Or try one of these:</p>
+ <ul class={style.demos}>
+ {demos.map((demo, i) =>
+ <li key={demo.url} class={style.demoItem}>
+ <button class={style.demoButton} onClick={this.onDemoClick.bind(this, i)}>
+ <div class={style.demo}>
+ <div class={style.demoImgContainer}>
+ <div class={style.demoImgAspect}>
+ <img class={style.demoIcon} src={demo.iconUrl} alt=""/>
+ {fetchingDemoIndex === i &&
+ <div class={style.demoLoading}>
+ <loading-spinner class={style.demoLoadingSpinner}/>
+ </div>
+ }
+ </div>
+ </div>
+ <div class={style.demoDescription}>{demo.description}</div>
+ </div>
+ </button>
+ </li>,
+ )}
+ </ul>
+ </div>
+ <ul class={style.relatedLinks}>
+ <li><a href="https://github.com/GoogleChromeLabs/squoosh/">View the code</a></li>
+ <li><a href="https://github.com/GoogleChromeLabs/squoosh/issues">Report a bug</a></li>
+ </ul>
</div>
);
}
diff --git a/src/components/intro/style.scss b/src/components/intro/style.scss
index 3fa37a8c..1ab4d88a 100644
--- a/src/components/intro/style.scss
+++ b/src/components/intro/style.scss
@@ -1,22 +1,191 @@
-.welcome {
- margin: auto;
+@font-face {
+ font-family: 'intro-text';
+ font-style: normal;
+ font-weight: 300;
+ // This only contains the chars for "Drag & drop or"
+ src: url('data:font/woff2;base64,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') format('woff2');
+}
+
+@font-face {
+ font-family: 'intro-text';
+ font-style: normal;
+ font-weight: 500;
+ // Only contains the chars for "select an image"
+ src: url('data:font/woff2;base64,d09GMgABAAAAAAXMAA4AAAAACwQAAAV5AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhYbg1IcMAZgAGwRCAqJUId/CxoAATYCJAMwBCAFgnAHIBskCcjEh6dNff8Ou/9Tj9VZGnUhJeqFzWGiVVOkxkTthr9f6kWkRdsBbkIj3YuLaloFZWr7aBg22z7IOoWqBWCW5cZU3GBrh0n+dAcBYAUlzYHAzWTYchqKXEyAT0zOLIS1qqm+B8q2ur4OhEMy0PHHUH8KklaSr8T0mp/EU7kRvXlI1E09HXA1qLN8Djxa0AsSDOg3cJARb9mtQJoSK3gvEn372/gcAigg/gOnbsT/MYv491GTReW4rJC5LA+h5FFclF6QQgoZ5Kx7GbsuGeytUgFClkOomY2Gdake3m9HegkHieAx/a0hBTALsy4jvpxBcnFXUnjC+2ZS5zHnDeEaJVwi+ZWqzOm4Uvgy4k6kGv4kFDVkfjk1gkVRRkk2zlo42PBbRJmG30cClJQjak7BnfQqHza4ITKftQZ/ZMUaEiyy1+mYCh4clKhDA5rQglZ0oG9jw+qiNvT+SfxIXCeuFdeIq8VV4gpxyRaGOl0JiChiCocfc7e93DwZIPvWgPiZJLcJugxyjW7UQyl4TJk6dWqYU7Cn0WQiWnNJCdGeprqjW63fpVS3mKy4YGZ6I3ya4nbIVgM1mwkpNEBzixlNxfPmH7owvdE4973OM9quvk11dwvnzDUy/Zn5S5Ywpn/PeqXBQI2m4lna05CRtsI6+GIENjS9K4jWRHUGYA2ozdZm2Smmf0DI3aqpeNbsJfxe7YdFmcZAn5gXLCFa2/Umqiu017APFhMZ0rfQp4sJX0ZrJ+n9UtAljr5VYWb6oj1MrpvX3qe6u8WRJg0bj7aPkDOa7m+E0Oa9Y8eY/gbRbr+efH7hcO49bMd28fbDVHcUmm3XkozQGKjeBHSJ4TQnI879LIFmF2v/BJuEQlffJPfE9oKayS/PsPE44fvM4MsBESxbuEEV39d5pw6oW4vD6S1WQC3UpSbHNbK0Jikl0bphSs+0CGW8Ew4Kzw7zarmcVz873JHTFhKYay18R8vY0ozPiHPAGyROAqlW5fLj5+HbWBn9TpgekKsOy8N+4dlFfL9i/Nk3+gY1bwzZUAvLVNiFpvqHRenetSoVrgn2obGtPsltEVxEeHJAQFhyBIcHT9rDvTJm06e0TLgase2gd2RffGJNg0o1zrdRyi9s1bYE5bi85cK+o/nUwvBR5+jweEBaSMoCub29fEFISmib9Dn5yl5kVFpoGrPQSmZhafQ7WimttNCH7Cktohb6kFpoEfIsdDF7SgvZTbaY3mKFyLXQh+wpzWE3mUNQQkWnR+lgiW9Afkunej49Nz3sYlI8XFTRdkNhUR5d6h4oOpJc8OjcItMXVqoHW2fSW6ycWuiM8NDYoICouLAZ9BYrwwmhycvKlt4Q8hUlCV5nZ7vOm2ut2rizcFpuWpSrT3K1Z3xinbuHnXBTyGAljV/XzHZaNGu6y7vLDziMpIyUdOBBRXXlxznUQiOoheZsZk9njG8er1mNmz2eOCQ3x9BbLP+Zxt+VrbEz9aWxmimRvyl4/sumyoM/nw+LNzV4/uP0/9T/P5f08cvhl38USAS/xTYs2fL/VNFF0vd+SVsRB/khPwW4SCi5SHhx8fDgVPAiAqIJRQL/EuK5bsRzNnAiezD1i7u2VyHHAKRU+E2YUaA5DUsE2ZfbApAmsJcxjBwmQ2Xk4Y2BqZJ+oxSzsNEogz1O3/xkBMKEBHSiC8PoQStaoEIflPCHL/wQBCUKoUITlMhHP+olt5ojykUPOrEQTWgY+f449KMPKnSiB72jGrLQhEZO24925LtbkG5DndTkD2/4um+NQBEyUIJsRBxX24tcDGmbWtGJjq05jhzTaMgCcR+6EA4f+KAXDay5u6RsL7xJsm3w3mzvFvggB8nI/AYBdVnxNvx/2wA=') format('woff2');
+}
+
+@keyframes fade-in {
+ from { opacity: 0 }
+}
+
+.intro {
+ composes: abs-fill from '../../lib/util.scss';
+ display: grid;
+ grid-template-rows: 1fr min-content;
+ align-items: center;
+ background: rgba(255, 255, 255, 0.25);
text-align: center;
+ font-size: 2rem;
+ -webkit-overflow-scrolling: touch;
+ overflow: auto;
+ padding: 20px 0 0;
+}
+
+.logo-container {
+ position: relative;
+ padding-top: 100%;
+}
+
+.logo-sizer {
+ width: 90%;
+ max-width: 480px;
+ margin: 0 auto;
+}
+
+.logo {
+ composes: abs-fill from '../../lib/util.scss';
+}
+
+.open-image-guide {
+ font: 300 11vw intro-text;
+ margin-bottom: 0;
+
+ @media (min-width: 460px) {
+ font-size: 50.6px;
+ padding: 0 40px;
+ }
+}
+
+.select-button {
+ composes: unbutton from '../../lib/util.scss';
+ font-weight: 500;
+ color: #5D509E;
+
+ &:hover,
+ &:focus {
+ text-decoration: underline;
+ }
+}
+
+.hide {
+ display: none;
+}
+
+.demos {
+ display: block;
+ padding: 0;
+ border-top: 1px solid #e8e8e8;
+ margin: 0 auto;
+
+ @media (min-width: 400px) {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ }
+
+ @media (min-width: 580px) {
+ border-top: none;
+ width: 523px;
+ }
+
+ @media (min-width: 900px) {
+ display: grid;
+ grid-template-columns: 1fr 1fr 1fr 1fr;
+ width: 773px;
+ }
+}
+
+.demo-item {
+ background: #fff;
+ display: flex;
+ border-bottom: 1px solid #e8e8e8;
+
+ @media (min-width: 580px) {
+ border: 1px solid #e8e8e8;
+ border-radius: 4px;
+ margin: 3px;
+ }
+}
+
+.demo-button {
+ composes: unbutton from '../../lib/util.scss';
+ flex: 1;
+
+ &:hover,
+ &:focus {
+ background: #f5f5f5;
+ }
+}
+
+.demo {
+ display: flex;
+ align-items: center;
+ padding: 7px;
+ font-size: 1.3rem;
+}
+
+.demo-img-container {
+ overflow: hidden;
+ display: block;
+ width: 47px;
+ background: #ccc;
+ border-radius: 3px;
+ flex: 0 0 auto;
+}
+
+.demo-img-aspect {
+ position: relative;
+ padding-top: 100%;
+
+}
+
+.demo-icon {
+ composes: abs-fill from '../../lib/util.scss';
+}
+
+.demo-description {
+ display: flex;
+ align-items: center;
+ justify-content: flex-start;
+ text-align: left;
+ flex: 1;
+ padding: 0 10px;
+}
+
+.demo-loading {
+ composes: abs-fill from '../../lib/util.scss';
+ background: rgba(0, 0, 0, 0.6);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ animation: fade-in 300ms ease-in-out;
+}
+
+.demo-loading-spinner {
+ --color: #fff;
+}
+
+.related-links {
+ display: flex;
+ padding: 0;
+ justify-content: center;
+ font-size: 1.3rem;
+
+ & li {
+ display: block;
+ border-left: 1px solid #000;
+ padding: 0 0.6em;
+
+ &:first-child {
+ border-left: none;
+ }
+ }
+
+ & a:link {
+ color: #5D509E;
+ text-decoration: none;
- h1 {
- font-weight: inherit;
- font-size: 150%;
- text-align: center;
- }
-
- input {
- display: inline-block;
- width: 16em;
- padding: 10px;
- margin: 0 auto;
- -webkit-appearance: none;
- border: 1px solid var(--button-fg);
- background: rgba(var(--button-fg-color), 0.1);
- border-radius: 3px;
- cursor: pointer;
+ &:hover {
+ text-decoration: underline;
+ }
}
}
diff --git a/src/lib/util.scss b/src/lib/util.scss
new file mode 100644
index 00000000..f5b3241d
--- /dev/null
+++ b/src/lib/util.scss
@@ -0,0 +1,21 @@
+.abs-fill {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ box-sizing: border-box;
+}
+
+.unbutton {
+ cursor: pointer;
+ background: none;
+ border: none;
+ font: inherit;
+ padding: 0;
+ margin: 0;
+
+ &:focus {
+ outline: none;
+ }
+}
diff --git a/src/missing-types.d.ts b/src/missing-types.d.ts
index ac8e3b63..b553e665 100644
--- a/src/missing-types.d.ts
+++ b/src/missing-types.d.ts
@@ -1,22 +1,24 @@
-// PRs to fix this:
-// https://github.com/developit/preact/pull/1101
-// https://github.com/developit/preact/pull/1102
-declare namespace JSX {
- type PointerEventHandler = EventHandler<PointerEvent>;
-
- interface DOMAttributes {
- onTouchStartCapture?: TouchEventHandler;
- onTouchEndCapture?: TouchEventHandler;
- onTouchMoveCapture?: TouchEventHandler;
+interface CanvasRenderingContext2D {
+ filter: string;
+}
- onPointerDownCapture?: PointerEventHandler;
+// Handling file-loader imports:
+declare module '*.png' {
+ const content: string;
+ export default content;
+}
- onMouseDownCapture?: MouseEventHandler;
+declare module '*.jpg' {
+ const content: string;
+ export default content;
+}
- onWheelCapture?: WheelEventHandler;
- }
+declare module '*.gif' {
+ const content: string;
+ export default content;
}
-interface CanvasRenderingContext2D {
- filter: string;
+declare module '*.svg' {
+ const content: string;
+ export default content;
}
diff --git a/src/style/index.scss b/src/style/index.scss
index 1f0053f0..a22b7362 100644
--- a/src/style/index.scss
+++ b/src/style/index.scss
@@ -13,6 +13,8 @@ html, body {
overflow: hidden;
overscroll-behavior: none;
contain: strict;
+ background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2"><path d="M1 2V0h1v1H0v1z" fill-opacity=".025"/></svg>');
+ background-size: 20px 20px;
}
:root {
diff --git a/webpack.config.js b/webpack.config.js
index 9833151e..0e2017bb 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -156,6 +156,10 @@ module.exports = function (_, env) {
// See https://github.com/webpack/webpack/issues/6725
type: 'javascript/auto',
loader: 'file-loader'
+ },
+ {
+ test: /\.(png|svg|jpg|gif)$/,
+ loader: 'file-loader'
}
]
},