Skip to content

Commit c76e82b

Browse files
authored
Move Testimonial to separate content type and add carousel (#83)
* Move Testimonial to separate content type and add carousel * Fix check * Rebuild * Finish carousel * Testing new option * Add guide * Fix observer * Remove unused css * Remove unused icons * Fix some css * Remove unused import * Fix transitions * Guide fixed height from bottom * Fix button transforms * Don't show 2 testimonials at once * Remove unncessary state var * Simply hasnext and hasprev logic * Make some changes to styles and create dialog component * Fix build * Fix button positions * Re-center guide * Simplify CSS a lot * Unused import * Reposition a few things * Make carousel prev/next buttons place better * Add new icons with iconify * Fix icon fills * Remove unused export * Simplify testimonial and dialog * Remove unncessary section color * Bump padding on nonprofits page testimonial * Close Dialog on outside click and make carousel more blue * Reorder styles
1 parent 990b0b6 commit c76e82b

File tree

14 files changed

+434
-93
lines changed

14 files changed

+434
-93
lines changed

src/lib/components/Dialog.svelte

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<script lang="ts">
2+
let dialog: HTMLDialogElement;
3+
4+
export function close() {
5+
dialog.close();
6+
}
7+
8+
export function open() {
9+
dialog.showModal();
10+
}
11+
</script>
12+
13+
<!-- svelte-ignore a11y-click-events-have-key-events -->
14+
<dialog bind:this={dialog} on:click={close}>
15+
<div class="content" on:click|stopPropagation>
16+
<button class="close" on:click={close}>✕</button>
17+
<slot />
18+
</div>
19+
</dialog>
20+
21+
<style>
22+
dialog {
23+
width: 70ch;
24+
max-width: 95vw;
25+
max-height: 85vh;
26+
font-size: 1rem;
27+
border: 1px solid black;
28+
border-radius: 10px;
29+
padding: 0;
30+
opacity: 0;
31+
transform: translateY(10%);
32+
overscroll-behavior: contain;
33+
box-sizing: border-box;
34+
}
35+
36+
dialog[open] {
37+
animation: fade-in 0.4s both;
38+
}
39+
40+
@media (prefers-reduced-motion: no-preference) {
41+
dialog[open] {
42+
animation: slide-in 0.4s both, fade-in 0.4s both;
43+
}
44+
}
45+
46+
@keyframes slide-in {
47+
to {
48+
transform: translateY(0);
49+
}
50+
}
51+
52+
dialog::backdrop {
53+
background-color: rgba(0, 0, 0, 0.75);
54+
opacity: 0;
55+
animation: fade-in 0.4s both;
56+
}
57+
58+
@keyframes fade-in {
59+
to {
60+
opacity: 1;
61+
}
62+
}
63+
64+
.content {
65+
padding: 2em;
66+
padding-top: 4em;
67+
}
68+
69+
.content > .close {
70+
position: absolute;
71+
top: 0.5em;
72+
right: 0.5em;
73+
font-size: 1.5em;
74+
width: 2em;
75+
appearance: none;
76+
cursor: pointer;
77+
background-color: white;
78+
border-radius: 50%;
79+
border: none;
80+
aspect-ratio: 1;
81+
}
82+
83+
.content > .close:hover {
84+
background-color: var(--gray-lighter);
85+
}
86+
</style>

src/lib/components/Icon.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import searchFill from "@iconify-icons/bx/search";
88
import transfer_altFill from "@iconify-icons/bx/transfer-alt";
99
import unlinkFill from "@iconify-icons/bx/unlink";
10+
import left_arrow_altFill from "@iconify-icons/bx/left-arrow-alt";
11+
import right_arrow_altFill from "@iconify-icons/bx/right-arrow-alt";
1012
import badge_dollarFill from "@iconify-icons/bxs/badge-dollar";
1113
import bookFill from "@iconify-icons/bxs/book";
1214
import bulbFill from "@iconify-icons/bxs/bulb";
@@ -62,6 +64,8 @@
6264
tree: { name: "tree", fill: treeFill },
6365
vector: { name: "vector", fill: vectorFill },
6466
volunteering: { name: "home-heart", fill: home_heartFill },
67+
"left-arrow": { name: "left-arrow-alt", fill: left_arrow_altFill },
68+
"right-arrow": { name: "right-arrow-alt", fill: right_arrow_altFill },
6569
} as const;
6670
6771
for (const { name, fill } of Object.values(iconMap)) {

src/lib/components/Testimonial.svelte

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<script lang="ts">
22
import { setImageHeight } from "$lib/utils/schema";
3-
import Button from "./Button.svelte";
3+
import Dialog from "./Dialog.svelte";
44
import Row from "./Row.svelte";
55
66
// title, content, and route (for button)
77
export let quote: string;
88
export let imageSrc: string | undefined = undefined;
99
export let name: string;
1010
export let desc: string;
11-
export let meetTheTeam = false;
11+
12+
let dialog: Dialog;
13+
14+
$: firstParagraph = quote.slice(0, quote.indexOf("</p>")) + "</p>";
15+
$: needsReadMore = quote.length > firstParagraph.length;
16+
$: text = firstParagraph.replace(/<\/?p>/gi, "");
1217
</script>
1318

1419
<div class="wrap">
@@ -17,29 +22,46 @@
1722
<Row>
1823
<div class="left">
1924
<figure>
20-
<blockquote>{quote}</blockquote>
25+
<blockquote>
26+
{@html text}{needsReadMore ? ".." : ""}
27+
28+
{#if needsReadMore}
29+
<button class="readmore" on:click={dialog.open}>
30+
Read more
31+
</button>
32+
{/if}
33+
</blockquote>
2134
<figcaption>
2235
{name}<br />
2336
<span class="desc">{desc}</span>
2437
</figcaption>
2538
</figure>
26-
{#if meetTheTeam}
27-
<Button type="primary" href="/about/team">Meet The Team</Button>
28-
{/if}
2939
</div>
3040
<div class="right">
3141
<img src={setImageHeight(imageSrc, 400)} alt={name} />
3242
</div>
3343
</Row>
3444
{:else}
3545
<figure class="center">
36-
<blockquote>{quote}</blockquote>
46+
<blockquote>
47+
{@html text}
48+
49+
{#if needsReadMore}
50+
<button class="readmore" on:click={dialog.open}>Read more</button>
51+
{/if}
52+
</blockquote>
3753
<figcaption>
3854
{name}<br />
3955
<span class="desc">{desc}</span>
4056
</figcaption>
4157
</figure>
4258
{/if}
59+
60+
<Dialog bind:this={dialog}>
61+
{@html quote}
62+
63+
<button class="readmore" on:click={dialog.close}>Read less</button>
64+
</Dialog>
4365
</div>
4466
</div>
4567

@@ -49,7 +71,7 @@
4971
display: flex;
5072
justify-content: center;
5173
align-items: center;
52-
padding: 80px 0;
74+
padding-block: 30px;
5375
}
5476
5577
.testimonial {
@@ -103,6 +125,7 @@
103125
flex: auto !important;
104126
max-width: 12rem;
105127
overflow: hidden;
128+
align-self: flex-start;
106129
}
107130
108131
.right > img {
@@ -112,6 +135,17 @@
112135
border-radius: 50%;
113136
}
114137
138+
.readmore {
139+
cursor: pointer;
140+
color: var(--blue-light);
141+
padding: 0;
142+
font-size: 1rem;
143+
background-color: transparent;
144+
appearance: none;
145+
border: none;
146+
margin-left: auto;
147+
}
148+
115149
@media screen and (max-width: 900px) {
116150
.right {
117151
display: none;
@@ -126,7 +160,8 @@
126160
}
127161
128162
.wrap {
129-
padding: 40px 0;
163+
padding-block: 0;
164+
padding-bottom: 10px;
130165
}
131166
}
132167
</style>

0 commit comments

Comments
 (0)