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

docs: split atom creators in multiple files #2083

Merged
merged 4 commits into from
Aug 29, 2023

Conversation

gerzonc
Copy link
Contributor

@gerzonc gerzonc commented Aug 20, 2023

Related Issues or Discussions

Closes #2082

Summary

Atom creators file in docs is too big so I just split it in a file per atom creator.

Check List

  • yarn run prettier for formatting code and docs

@vercel
Copy link

vercel bot commented Aug 20, 2023

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

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2023 0:41am

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 20, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c2785d1:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration

@gerzonc
Copy link
Contributor Author

gerzonc commented Aug 20, 2023

@dai-shi the other way I thought of doing it is that we can keep it as it was (just atom-creators.mdx) and import all the creators as components, e.g.

---
title: Atom creators
nav: 8.02
keywords: creators
---

<AtomWithToggle />

I did it with separate file straight up first, but let me know which one you prefer since I already had both solutions in mind 🙈

@dai-shi
Copy link
Member

dai-shi commented Aug 20, 2023

I think multiple files are better for search.

Maybe we should consider about the sidebar labels.
image

@sandren Do you have any idea?

@dai-shi dai-shi requested a review from sandren August 20, 2023 23:51
```js
import { atomWithToggleAndStorage } from 'XXX'

// will have an initial value set to false & get stored in localStorage under the key "isActive"
Copy link
Collaborator

Choose a reason for hiding this comment

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

set to false? I don't see the initial value on your code

Copy link
Member

Choose a reason for hiding this comment

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

I think L19 should be initialValue = false,.

prevVal: Value
) => void

export function atomWithListeners<Value>(initialValue: Value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think useCurrentStore (non-exist API) and store.sub(aAtom) would be better

Copy link
Member

Choose a reason for hiding this comment

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

This recipe is written for v1 API, I guess. useStore exists, btw.

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

This PR is to split markdown files. We should probably open a new PR for improving the contents.

prevVal: Value
) => void

export function atomWithListeners<Value>(initialValue: Value) {
Copy link
Member

Choose a reason for hiding this comment

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

This recipe is written for v1 API, I guess. useStore exists, btw.

```js
import { atomWithToggleAndStorage } from 'XXX'

// will have an initial value set to false & get stored in localStorage under the key "isActive"
Copy link
Member

Choose a reason for hiding this comment

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

I think L19 should be initialValue = false,.

@gerzonc
Copy link
Contributor Author

gerzonc commented Aug 27, 2023

This PR is to split markdown files. We should probably open a new PR for improving the contents.

I can do both if you don't mind. I'm still waiting for approval of current changes so I can open a new PR in order to update the docs

@sandren
Copy link
Collaborator

sandren commented Aug 27, 2023

@sandren Do you have any idea?

Yes, let's change the frontmatter title of each of the new docs to reflect the recipe function name instead. For example, atomWithToggle instead of Atom creator with toggle. Once that is done, we can merge. Thanks, @gerzonc! 🙂

@gerzonc
Copy link
Contributor Author

gerzonc commented Aug 28, 2023

@sandren Do you have any idea?

Yes, let's change the frontmatter title of each of the new docs to reflect the recipe function name instead. For example, atomWithToggle instead of Atom creator with toggle. Once that is done, we can merge. Thanks, @gerzonc! 🙂

Is ready now!

@sandren sandren merged commit 58dec50 into pmndrs:main Aug 29, 2023
@sandren
Copy link
Collaborator

sandren commented Aug 29, 2023

Is ready now!

Merged. Thank you so much! 🙂

}
```

## atomWithRefresh
Copy link
Member

Choose a reason for hiding this comment

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

@gerzonc It seems like this section is lost. Can you double check please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True OMG 🥺 I'll add it right away!

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.

Split atom creators recipe in docs into multiple markdown files
4 participants