Skip to content

Commit ceaafe9

Browse files
authored
Merge pull request #209 from swup/feat/demos-on-glitch
feat: demos on Glitch
2 parents 0712900 + e5dcef4 commit ceaafe9

File tree

6 files changed

+73
-75
lines changed

6 files changed

+73
-75
lines changed

lib/markdown-it-code-enhancements.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,24 @@ function renderCodeBlockWithLanguage(code, language) {
1919
</div>`;
2020
}
2121

22-
function renderReplFrame(code) {
22+
function renderGlitchFrame(code) {
2323
const isSrc = (line) => line.startsWith('https://');
2424
const lines = code.trim().split(/\r?\n/);
2525
const srcLine = lines.find(isSrc);
2626
if (!srcLine) {
2727
return renderCodeBlockRaw(code);
2828
}
2929
const src = srcLine.trim();
30-
const replSlug = (src.match(/^https:\/\/([\w-]+?)(-temp)?\.replit\.app/i) || [])[1] || '';
31-
const linkSlug = replSlug.replace(/(?:^|-)\w/g, (m) => m.toUpperCase().replace('-', ' ')).replace(/ /g, '-').replace('-A-', '-a-');
32-
const link = `https://replit.com/@philippdaun/${linkSlug}`;
30+
const linkSlug = (src.match(/^https:\/\/([\w-]+?)\.glitch\.me/i) || [])[1] || '';
31+
const link = `https://glitch.com/edit/#!/${linkSlug}`;
3332
const description = lines.filter((line) => !isSrc(line)).join(' ').trim();
3433
return /*html*/ `
35-
<div class="repl" data-src="${src}" data-title="${encode(description)}">
36-
<div class="repl__frame">
34+
<div class="glitch" data-src="${src}" data-title="${encode(description)}">
35+
<div class="glitch__frame">
3736
<iframe src="${src}" loading="lazy" title="${encode(description)}" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>
38-
<p class="repl__link">
39-
<a href="${link}" target="_blank">
40-
<img src="https://replit.com/badge?theme=dark&variant=small&caption=Try%20with%20Replit" alt="Try this demo with Replit">
37+
<p class="glitch__link">
38+
<a href="${link}" class="glitch__pill" target="_blank">
39+
Edit on Glitch
4140
</a>
4241
</p>
4342
</div>
@@ -51,8 +50,8 @@ function renderCodeBlock(originalRule) {
5150
const info = tokens[idx].info;
5251
const language = synonyms[info] || info || 'unknown';
5352

54-
if (language === 'repl') {
55-
return renderReplFrame(content);
53+
if (language === 'glitch') {
54+
return renderGlitchFrame(content);
5655
}
5756

5857
let code = originalRule(...args);

src/_assets/scss/inc/demos.scss

+31-34
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
.repl {
2-
--repl-scale: 0.8;
1+
.glitch {
2+
--glitch-scale: 0.8;
33
position: relative;
44
}
55

6-
.repl__frame {
6+
.glitch__frame {
77
position: relative;
88
width: 100%;
99
min-width: 300px;
10-
height: calc((500px + 6vh) * var(--repl-scale));
11-
// max-height: 500px;
10+
height: calc((500px + 6vh) * var(--glitch-scale));
1211
position: relative;
1312
resize: both;
1413
border: 1px solid var(--color-transparent-1);
@@ -21,53 +20,51 @@
2120
left: 0;
2221
width: 100%;
2322
height: 100%;
24-
width: calc(100% / var(--repl-scale));
25-
height: calc(100% / var(--repl-scale));
23+
width: calc(100% / var(--glitch-scale));
24+
height: calc(100% / var(--glitch-scale));
2625
background: transparent;
27-
transform: scale(var(--repl-scale));
26+
transform: scale(var(--glitch-scale));
2827
transform-origin: 0 0;
2928
}
3029
}
3130

3231
@include bp(s) {
33-
.repl {
34-
--repl-scale: 0.667;
32+
.glitch {
33+
--glitch-scale: 0.667;
3534
}
36-
.repl__frame {
35+
.glitch__frame {
3736
width: 80%;
3837
}
3938
}
4039

41-
.repl__link {
40+
.glitch__link {
4241
position: absolute;
43-
bottom: 0.2rem;
42+
bottom: 0.4rem;
4443
right: 0.4rem;
4544
@include bp(s) {
46-
bottom: 0.5rem;
47-
right: 0.7rem;
45+
bottom: 0.6rem;
46+
right: 0.6rem;
4847
}
4948
margin: 0;
50-
a {
51-
background: none !important;
52-
}
5349
}
5450

55-
img[src*='https://replit.com/badge']
56-
{
51+
.glitch__pill {
5752
display: inline-block;
58-
margin-inline: 0.3em;
59-
transition: opacity 150ms;
60-
a & {
61-
opacity: 0.7;
62-
}
63-
a:hover & {
64-
opacity: 1;
65-
}
66-
filter: drop-shadow(0 0 1px var(--color-transparent-2))
67-
drop-shadow(0 0 5px hsl(var(--shadow-color) / var(--shadow-strength-dark)));
53+
line-height: 1;
54+
white-space: nowrap;
55+
padding: 0.5em 0.8em;
56+
background: black;
57+
color: white;
58+
font-size: 0.7rem;
59+
border-radius: 0.5em;
60+
border: 1px solid rgb(255 255 255 / 0.2);
61+
--shadow-color: 239 80% 90%;
62+
box-shadow: var(--shadow-4);
63+
vertical-align: middle;
6864
}
69-
70-
.page_body > p > img[src*='https://replit.com/badge']
71-
{
72-
transform: translateY(0.3em);
65+
.glitch__pill--dummy {
66+
position: relative;
67+
top: -0.1em;
68+
margin-inline: 0.2rem;
69+
pointer-events: none;
7370
}

src/_assets/scss/inc/props.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
--font-mono: Dank Mono, Operator Mono, Inconsolata, Fira Mono, ui-monospace, SF Mono, Monaco,
77
Droid Sans Mono, Source Code Pro, monospace;
88

9-
--font-size-fluid-0-B: clamp(.8rem, 1.5vw, .8rem);
9+
--font-size-fluid-0-B: clamp(0.8rem, 1.5vw, 0.8rem);
1010
--font-size-fluid-0: clamp(1rem, 2vw, 1.15rem);
1111
--font-size-fluid-1: clamp(1.15rem, 3vw, 1.35rem);
1212
--font-size-fluid-2: clamp(1.35rem, 4vw, 1.7rem);

src/_assets/scss/inc/showcase.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
border: 1px solid var(--color-transparent-1);
1515
border-radius: var(--radius-1);
1616
overflow: hidden;
17-
padding-bottom: .8rem;
17+
padding-bottom: 0.8rem;
1818
a {
1919
position: relative;
2020
z-index: 2;
@@ -35,7 +35,7 @@ header.showcase_header {
3535
display: flex;
3636
justify-content: space-between;
3737
align-items: baseline;
38-
padding: .8rem 1rem 0;
38+
padding: 0.8rem 1rem 0;
3939
border-top: 1px solid var(--color-transparent-1);
4040
svg {
4141
position: relative;
@@ -58,7 +58,7 @@ ul.showcase_credits {
5858
list-style: none;
5959
padding: 0;
6060
margin: 0;
61-
margin-top: .25em;
61+
margin-top: 0.25em;
6262
padding: 0 1rem;
6363
display: flex;
6464
flex-wrap: wrap;

src/docs/getting-started/demos.md

+27-25
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,52 @@ Looking for a demo of swup animations in action? You are in fact looking at one!
1515
with swup and CSS-only animations. See below for more isolated examples showcasing swup's
1616
features and options.
1717

18-
Click the <img src="https://replit.com/badge?theme=dark&variant=small&caption=Try%20with%20Replit"> button
18+
Click the <span class="glitch__pill glitch__pill--dummy">Edit on Glitch</span> button
1919
of each demo to see the code and fork it for experimenting yourself.
2020

2121
## Basic animation
2222

2323
Default swup installation with two containers and a fade animation between pages.
2424

25-
```repl
26-
https://swup-demo-basic-temp.replit.app
25+
```glitch
26+
https://swup-demo-basic.glitch.me
2727
Swup Demo: Basic
2828
```
2929

3030
## Slide animation
3131

3232
Slide pages into view horizontally.
3333

34-
```repl
35-
https://swup-demo-slide-temp.replit.app
34+
```glitch
35+
https://swup-demo-slide.glitch.me
3636
Swup Demo: Slide
3737
```
3838

3939
## Overlay animation
4040

4141
Cover content while loading the new page.
4242

43-
```repl
44-
https://swup-demo-overlay-temp.replit.app
43+
```glitch
44+
https://swup-demo-overlay.glitch.me
4545
Swup Demo: Overlay
4646
```
4747

4848
## Multiple animations
4949

5050
Use swup's animation classes for other elements than the main content containers.
5151

52-
```repl
53-
https://swup-demo-multiple-temp.replit.app
52+
```glitch
53+
https://swup-demo-multiple.glitch.me
5454
Swup Demo: Mulitple animations
5555
```
5656

5757
## Slideshow animation
5858

59-
Animate between pages as a horizontal slideshow.
60-
Uses the [Parallel Plugin](/plugins/parallel-plugin/) to show both pages at the same time.
59+
Animate between pages as a horizontal slideshow. Uses the [Parallel Plugin](/plugins/parallel-plugin/) to show both pages at the same time
60+
and the [Preload Plugin](/plugins/preload-plugin/) to preload the slides.
6161

62-
```repl
63-
https://swup-demo-slideshow-temp.replit.app
62+
```glitch
63+
https://swup-demo-slideshow.glitch.me
6464
Swup Demo: Slideshow
6565
```
6666

@@ -69,8 +69,8 @@ Swup Demo: Slideshow
6969
Reveal the next page using masks and gradients.
7070
Uses the [Parallel Plugin](/plugins/parallel-plugin/) to show both pages at the same time.
7171

72-
```repl
73-
https://swup-demo-reveal-temp.replit.app
72+
```glitch
73+
https://swup-demo-reveal.glitch.me
7474
Swup Demo: Reveal
7575
```
7676

@@ -79,41 +79,43 @@ Swup Demo: Reveal
7979
Load sub-pages as modals.
8080
Uses the [Fragment Plugin](/plugins/fragment-plugin/) to dynamically select containers based on route.
8181

82-
```repl
83-
https://swup-demo-modal-overlay-temp.replit.app/
82+
```glitch
83+
https://swup-demo-fragment-modal.glitch.me
84+
Swup Fragment Demo: Modal
8485
```
8586

8687
## Fragment support: list
8788

8889
Uses the [Fragment Plugin](/plugins/fragment-plugin/) to replace only the items of a list when applying filters.
8990

90-
```repl
91-
https://swup-demo-filter-a-list-temp.replit.app/
91+
```glitch
92+
https://swup-demo-fragment-list.glitch.me
93+
Swup Fragment Demo: List
9294
```
9395

9496
## Animated forms
9597

9698
Animate form submissions using the [Forms Plugin](/plugins/forms-plugin/).
9799

98-
```repl
99-
https://swup-demo-forms-temp.replit.app
100+
```glitch
101+
https://swup-demo-forms.glitch.me
100102
Swup Demo: Animated forms
101103
```
102104

103105
## Inline forms
104106

105107
Submit simple forms in place without full page loads using the [Forms Plugin](/plugins/forms-plugin/).
106108

107-
```repl
108-
https://swup-demo-inline-forms-temp.replit.app
109+
```glitch
110+
https://swup-demo-inline-forms.glitch.me
109111
Swup Demo: Inline forms
110112
```
111113

112114
## Infinite scroll cache
113115

114116
Persist items loaded with infinite scroll between page visits.
115117

116-
```repl
117-
https://swup-demo-infinite-scroll-cache-temp.replit.app
118+
```glitch
119+
https://swup-demo-infinite-scroll-cache.glitch.me
118120
Swup Demo: Infinite Scroll Cache
119121
```

src/showcase/showcase.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"tags": ["showcase"]
2+
"tags": ["showcase"]
33
}

0 commit comments

Comments
 (0)