Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfixes #445

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
284 changes: 142 additions & 142 deletions src/lib/components/Feedback.svelte
Original file line number Diff line number Diff line change
@@ -1,152 +1,152 @@
<script lang="ts">
import { page } from '$app/stores';
import { page } from '$app/stores';

export let date: string;
let showFeedback = false;
let feedbackType = '';
let email = '';
let comment = '';
let error: string | undefined;
let submitted = false;
let submitting = false;
export let date: string | undefined = undefined;
let showFeedback = false;
let feedbackType = '';
let email = '';
let comment = '';
let error: string | undefined;
let submitted = false;
let submitting = false;

async function handleSubmit() {
submitting = true;
error = undefined;
const response = await fetch('https://growth.appwrite.io/v1/feedback/docs', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email,
type: feedbackType,
route: $page.route.id,
comment
})
});
submitting = false;
if (response.status >= 400) {
error = response.status >= 500 ? 'Server Error.' : 'Error submitting form.';
return;
}
comment = email = '';
submitted = true;
}
async function handleSubmit() {
submitting = true;
error = undefined;
const response = await fetch('https://growth.appwrite.io/v1/feedback/docs', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email,
type: feedbackType,
route: $page.route.id,
comment
})
});
submitting = false;
if (response.status >= 400) {
error = response.status >= 500 ? 'Server Error.' : 'Error submitting form.';
return;
}
comment = email = '';
submitted = true;
}

function reset() {
comment = email = '';
feedbackType = '';
submitted = false;
error = undefined;
}
function reset() {
comment = email = '';
feedbackType = '';
submitted = false;
error = undefined;
}

$: if (!showFeedback) {
reset();
}
$: if (!showFeedback) {
reset();
}
</script>

<section class="aw-content-footer">
<header class="aw-content-footer-header u-width-full-line">
<div
class="u-flex u-gap-32 u-main-space-between u-cross-center u-width-full-line"
style="flex-wrap: wrap-reverse;"
>
<div class="u-flex u-gap-16 u-cross-center">
<h5 class="aw-main-body-600 aw-u-color-text-primary">Was this page helpful?</h5>
<div class="u-flex u-gap-8">
<button
class="aw-radio-button"
aria-label="helpful"
on:click={() => {
showFeedback = feedbackType === 'positive' ? false : true;
feedbackType = 'positive';
}}
>
<span class="icon-thumb-up" />
</button>
<button
class="aw-radio-button"
aria-label="unhelpful"
on:click={() => {
showFeedback = feedbackType === 'negative' ? false : true;
feedbackType = 'negative';
}}
>
<!-- TODO: fix the icon name on pink -->
<span class="icon-thumb-dowm" />
</button>
</div>
</div>
<div class="aw-content-footer-header-end">
<ul class="aw-metadata aw-caption-400">
{#if date}
<li>Last updated on {new Date(date)?.toLocaleDateString()}</li>
{/if}
<li>
<a
href="https://github.com/appwrite/website"
target="_blank"
rel="noopener noreferrer"
class="aw-link u-flex u-gap-4 u-cross-baseline"
>
<span class="icon-pencil-alt u-contents" aria-hidden="true" />
<span>Update on GitHub</span>
</a>
</li>
</ul>
</div>
</div>
</header>
{#if showFeedback}
<form
on:submit|preventDefault={handleSubmit}
class="aw-card is-normal"
style="--card-padding:1rem"
>
<div class="u-flex-vertical u-gap-8">
<label for="message">
<span class="aw-u-color-text-primary">
What did you {feedbackType === 'negative' ? 'dislike' : 'like'}? (optional)
</span>
</label>
<textarea
class="aw-input-text"
id="message"
placeholder="Write your message"
bind:value={comment}
/>
<label for="message" class="u-margin-block-start-8">
<span class="aw-u-color-text-primary">Email</span>
</label>
<input
class="aw-input-text"
placeholder="Enter your email"
type="email"
name="email"
required
bind:value={email}
/>
</div>
{#if submitted}
<p class="aw-u-color-text-primary u-margin-block-start-16">
Your message has been sent successfully. We appreciate your feedback.
</p>
{/if}
{#if error}
<p class="aw-u-color-text-primary u-margin-block-start-16">
There was an error submitting your feedback. Please try again later.
</p>
{/if}
<header class="aw-content-footer-header u-width-full-line">
<div
class="u-flex u-gap-32 u-main-space-between u-cross-center u-width-full-line"
style="flex-wrap: wrap-reverse;"
>
<div class="u-flex u-gap-16 u-cross-center">
<h5 class="aw-main-body-600 aw-u-color-text-primary">Was this page helpful?</h5>
<div class="u-flex u-gap-8">
<button
class="aw-radio-button"
aria-label="helpful"
on:click={() => {
showFeedback = feedbackType === 'positive' ? false : true;
feedbackType = 'positive';
}}
>
<span class="icon-thumb-up" />
</button>
<button
class="aw-radio-button"
aria-label="unhelpful"
on:click={() => {
showFeedback = feedbackType === 'negative' ? false : true;
feedbackType = 'negative';
}}
>
<!-- TODO: fix the icon name on pink -->
<span class="icon-thumb-dowm" />
</button>
</div>
</div>
<div class="aw-content-footer-header-end">
<ul class="aw-metadata aw-caption-400">
{#if date}
<li>Last updated on {new Date(date)?.toLocaleDateString()}</li>
{/if}
<li>
<a
href="https://github.com/appwrite/website"
target="_blank"
rel="noopener noreferrer"
class="aw-link u-flex u-gap-4 u-cross-baseline"
>
<span class="icon-pencil-alt u-contents" aria-hidden="true" />
<span>Update on GitHub</span>
</a>
</li>
</ul>
</div>
</div>
</header>
{#if showFeedback}
<form
on:submit|preventDefault={handleSubmit}
class="aw-card is-normal"
style="--card-padding:1rem"
>
<div class="u-flex-vertical u-gap-8">
<label for="message">
<span class="aw-u-color-text-primary">
What did you {feedbackType === 'negative' ? 'dislike' : 'like'}? (optional)
</span>
</label>
<textarea
class="aw-input-text"
id="message"
placeholder="Write your message"
bind:value={comment}
/>
<label for="message" class="u-margin-block-start-8">
<span class="aw-u-color-text-primary">Email</span>
</label>
<input
class="aw-input-text"
placeholder="Enter your email"
type="email"
name="email"
required
bind:value={email}
/>
</div>
{#if submitted}
<p class="aw-u-color-text-primary u-margin-block-start-16">
Your message has been sent successfully. We appreciate your feedback.
</p>
{/if}
{#if error}
<p class="aw-u-color-text-primary u-margin-block-start-16">
There was an error submitting your feedback. Please try again later.
</p>
{/if}

<div class="u-flex u-main-end u-margin-block-start-16 u-gap-8">
<button class="aw-button is-text" on:click={() => (showFeedback = false)}>
<span>Cancel</span>
</button>
<button type="submit" class="aw-button" disabled={submitting || !email}>
<span>Submit</span>
</button>
</div>
</form>
{/if}
<div class="u-flex u-main-end u-margin-block-start-16 u-gap-8">
<button class="aw-button is-text" on:click={() => (showFeedback = false)}>
<span>Cancel</span>
</button>
<button type="submit" class="aw-button" disabled={submitting || !email}>
<span>Submit</span>
</button>
</div>
</form>
{/if}
</section>
2 changes: 1 addition & 1 deletion src/lib/components/Tooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { FloatingConfig } from '@melt-ui/svelte/internal/actions';
import { fly, type FlyParams } from 'svelte/transition';

export let placement: FloatingConfig['placement'] = 'top';
export let placement: NonNullable<FloatingConfig>['placement'] = 'top';
export let disabled = false;
export let closeOnPointerDown = false;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/layouts/DocsArticle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
export let title: string;
export let toc: Array<TocItem>;
export let back: string | undefined = undefined;
export let date: string;
export let date: string | undefined = undefined;
</script>

<main class="u-contents" id="main">
Expand Down
5 changes: 0 additions & 5 deletions src/lib/utils/image.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/lib/utils/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { AuthorData } from '$markdoc/layouts/Author.svelte';
import type { PostsData } from '$markdoc/layouts/Post.svelte';
import type { AuthorData, PostsData } from "$routes/blog/content";

export const DEFAULT_HOST = 'https://website-appwrite.vercel.app';
export const DEFAULT_DESCRIPTION = 'Appwrite is an open-source platform for building applications at any scale, using your preferred programming languages and tools.';
Expand Down
2 changes: 1 addition & 1 deletion src/markdoc/layouts/Article.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
export let back: string | undefined = undefined;
export let difficulty: string | undefined = undefined;
export let readtime: string | undefined = undefined;
export let date: string;
export let date: string | undefined = undefined;

setContext<LayoutContext>('headings', writable({}));

Expand Down
14 changes: 6 additions & 8 deletions src/routes/blog/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<script lang="ts">
import type { AuthorData } from '$markdoc/layouts/Author.svelte';
import type { CategoryData } from '$markdoc/layouts/Category.svelte';
import type { PostsData } from '$markdoc/layouts/Post.svelte';
import { setContext } from 'svelte';
import { setContext } from 'svelte';
import type { AuthorData, CategoryData, PostsData } from './content.js';

export let data;
setContext<PostsData[]>('posts', data.posts);
setContext<AuthorData[]>('authors', data.authors);
setContext<CategoryData[]>('categories', data.categories);
export let data;
setContext<PostsData[]>('posts', data.posts);
setContext<AuthorData[]>('authors', data.authors);
setContext<CategoryData[]>('categories', data.categories);
</script>

<slot />
4 changes: 2 additions & 2 deletions src/routes/blog/+page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { base } from '$app/paths';
import type { AuthorData } from '$markdoc/layouts/Author.svelte';
import type { PostsData } from '$markdoc/layouts/Post.svelte';
import type { AuthorData, PostsData } from './content';


export function load() {
const postsGlob = import.meta.glob('./post/**/*.markdoc', {
Expand Down
Loading