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

Feat nuxt tutorial #355

Merged
merged 9 commits into from
Jan 18, 2024
Merged

Feat nuxt tutorial #355

merged 9 commits into from
Jan 18, 2024

Conversation

gewenyu99
Copy link
Contributor

What does this PR do?

Add Nuxt tutorial by @evelinabe

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Copy link

render bot commented Nov 17, 2023

Copy link

vercel bot commented Nov 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2024 8:18pm

src/routes/docs/tutorials/nuxt/step-2/+page.markdoc Outdated Show resolved Hide resolved
src/routes/docs/tutorials/nuxt/step-2/+page.markdoc Outdated Show resolved Hide resolved
src/routes/docs/tutorials/nuxt/step-2/+page.markdoc Outdated Show resolved Hide resolved
src/routes/docs/tutorials/nuxt/step-4/+page.markdoc Outdated Show resolved Hide resolved
src/routes/docs/tutorials/nuxt/step-4/+page.markdoc Outdated Show resolved Hide resolved
<!-- Email and logout button if logged in user -->
<div
class="main-header-end u-margin-inline-end-16"
v-if="user.isLoggedIn.value === true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC you don't need .value in templates. Weird, I know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

import { database } from "~/appwrite";
import { ref } from "vue";

const ideasDatabaseId = import.meta.env.VITE_IDEAS_DATABASE_ID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ideas prefix is unnecessary, we can infer it's the ideas database from the file name, or by the env variable name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


// Fetch the 10 most recent ideas from the database
// Add the list to the current reference object
const init = async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is misleading, since this is used more than once. Refetch or invalidate would be better names. Also, this can be called immediately when the composable is created, and probably doesn't need to be an exposed method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<input
type="text"
placeholder="Title"
v-model="addIdeaData.title.value"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formdata could be used to avoid creating refs and binding them. Especially as nothing else is being done with these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 89 to 91
Next, add the component to the page `pages/index.vue` by auto-importing it in the `<template>`tag.
In doing that, we need to take a moment to think about how we want to display the form to the users.
Since it should only be shown to logged in user, we need to wrap it in a `<section>`that renders conditionally when the `isLoggedIn` reference in the `useUserSession` is true.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some spaces are missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link

render bot commented Jan 10, 2024

src/routes/docs/tutorials/nuxt/step-2/+page.markdoc Outdated Show resolved Hide resolved

<template>
<div>
<h1>Hello, idea tracker!</h1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add pink classes to make it look pwetty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

src/routes/docs/tutorials/nuxt/step-4/+page.markdoc Outdated Show resolved Hide resolved
await account.deleteSession("current"); // Delete Appwrite user session
current.value = null; // Clear current ref
navigateTo("/");
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to check if the user is logged in when initialising the composable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

src/routes/docs/tutorials/nuxt/step-4/+page.markdoc Outdated Show resolved Hide resolved
src/routes/docs/tutorials/nuxt/step-7/+page.markdoc Outdated Show resolved Hide resolved
const ideas = useIdeas();
const user = useUserSession();

console.log(ideas.current.value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 172 to 174
onMounted(() => {
ideas.fetch();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done inside useIdeas

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 186 to 188
<!-- Section with form component for logged in users -->
<!-- Section with paragraph for not logged in users -->

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with ...skipped code.

---

# Test your project {% #test-project %}
Run your project with `npm run dev -- --open --port 3000` and open [http:https://localhost:3000](http:https://localhost:3000) in your browser.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In another one of the steps, we mentioned using npm run dev directly, instead of specifying a port.

IMO, we should not try and change the port, no reason to. Port 3000 is a React convention, most projects use something else, and it's fine :)

@appwrite appwrite deleted a comment from TGlide Jan 12, 2024
Copy link

render bot commented Jan 12, 2024

@TGlide
Copy link
Contributor

TGlide commented Jan 17, 2024

@gewenyu99 why does this have an android tutorial in it as well?

@gewenyu99
Copy link
Contributor Author

@gewenyu99 why does this have an android tutorial in it as well?

I merged the Android tutorial reviewed separately here. There are some shared photo assets.

@gewenyu99
Copy link
Contributor Author

@TGlide #190

src/routes/docs/tutorials/nuxt/step-2/+page.markdoc Outdated Show resolved Hide resolved

Next, head over to the `pages`directory.
This is where we will keep the content that will render on our pages in the web application.
Each file you put in here will automatically become a route.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be unclear as to what that means.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/routes/docs/tutorials/nuxt/step-4/+page.markdoc Outdated Show resolved Hide resolved
The response from these interactions will be stored as references to get more information about the user in our app.

In your `composable` directory, create the file `useUserSession.js` and add the following code.
Then you can call the `useUserSession()` function in the pages and components to use the functionality.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include this line after the code snippet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

});

return {
current,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current is a weird name, maybe call it user?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's fine, since you're doing user.current.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's the idea

In step 5 we will add a login button that will redirect us to this page.

We will define functions to handle form submissions and show either a signup
or a login form, which renders one form or the other depending on `isSignUp`'s state.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isSignUp has not yet been defined, isn't it confusing?

# Authentication forms {% #auth-forms %}

In the previous step, we defined a `AuthForm` to handle signup and login.
Let's build this form now.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, shouldn't we maybe create it before the page? Either is fine by me, just a suggestion.

src/routes/docs/tutorials/nuxt/step-5/+page.markdoc Outdated Show resolved Hide resolved

<template>
<div class="u-max-width-650" style="margin: 0 auto;">
... Some skipped code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use HTML commments

</div>
</template>

.. Skipped script section and styling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@gewenyu99 gewenyu99 merged commit 1d43024 into main Jan 18, 2024
1 check passed
@TorstenDittmann TorstenDittmann deleted the feat-nuxt-tutorial branch January 22, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants