Skip to content

Commit

Permalink
Merge pull request #10 from dogeorg/fouc-handle
Browse files Browse the repository at this point in the history
Handling FOUC (flash of unstyled content)
  • Loading branch information
blendtwenty authored Feb 22, 2024
2 parents be766dc + 8ccdb4e commit 629808b
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 10 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ add them to your webpage and voilà!

### 1. Cherry Pick (Under development)

Quick and easy.
**Quick and easy**
Within your HTML file, add a doge component and start using it.

```
<script type="module" src="https://fetch.dogecoin.org/qr"></script>
<doge-qr address="D89DhnsgKncmN12RejxudfU8AwXp3946q1" caption="Treat me a coffee?"></doge-qr>
```

**Optionally**, add the initial.css stylesheet to the head of your page to prevent/reduce FOUC (flash of unstyled content).

```
<link rel="stylesheet" href="https://fetch.dogecoin.org/initial.css"
```

---

### 2. Fetch Lib (Coming Soon)
### 2. Fetch Lib (Concept)

Within your HTML file, add configure.js, configure and utilise.

Expand Down
16 changes: 14 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@ rm -rf dist
mkdir -p dist

# Find all JavaScript files within src/components directory
JS_FILES=$(find src/components -type f -name "*.js")
JS_FILES=$(find src/components -type f -name "doge-*.js")
CSS_FILES=$(find src/components -type f -name "*initial.css")

# For each file, compile via rollup, outputting as individual JS modules.
# For each JS file, copy it to the root for convenient
# consumption from fetch.dogecoin.org/<component>.js
for file in $JS_FILES
do
filename=$(basename "$file")
echo "File: $filename"
cp "$file" "dist/$filename"
done

# For each css file, concatinate and create a single file
# for component consumers to include within the <head>
# of their webpage, to reduce flash of unstyled content.
for file in $CSS_FILES
do
echo "File: $file"
cat "$file" >> "dist/initial.css"
echo >> "dist/initial.css" #Adds line
done

# Write CNAME file
echo "fetch.dogecoin.org" > dist/CNAME
echo "fetch.dogecoin.org" > CNAME
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"license": "ISC",
"scripts": {
"dev": "web-dev-server --open example/ --node-resolve --watch",
"test": "web-test-runner \"src/**/*.test.html\" --node-resolve --playwright --browsers firefox",
"test:watch": "web-test-runner src/**/*.test.html --node-resolve --watch",
"test": "web-test-runner \"src/**/test.html\" --node-resolve --playwright --browsers firefox",
"test:watch": "web-test-runner src/**/test.html --node-resolve --watch",
"prepare": "husky"
},
"devDependencies": {
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/components/doge-nav/initial.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doge-nav:not(:defined) {
display: block;
height: 62px;
overflow: hidden;
opacity: 0;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
dogeComponentInit,
resourceBasePath,
LitElement, css, html, classMap
} from "../lib/cherry.js"
} from "../../lib/cherry.js"

export class DogePal extends LitElement {
static styles = css``;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
dogeComponentInit,
resourceBasePath,
LitElement, css, html, classMap
} from "../lib/cherry.js"
} from "../../lib/cherry.js"

export class DogePrice extends LitElement {
static styles = css``;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
dogeComponentInit,
resourceBasePath,
LitElement, css, html, classMap
} from "../lib/cherry.js"
import "../../resources/blocks/[email protected]/qr-code-styling.js";
} from "../../lib/cherry.js"
import "../../../resources/blocks/[email protected]/qr-code-styling.js";

export class DogeQR extends LitElement {
static properties = {
Expand Down
6 changes: 6 additions & 0 deletions src/components/doge-qr/initial.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
doge-qr:not(:defined) {
display: inline-block;
width: 220px;
height: 220px;
opacity: 0;
}
File renamed without changes.

0 comments on commit 629808b

Please sign in to comment.