1
0
Fork 0

[react] feat: Added docs for components/Account

This commit is contained in:
joostdecock 2025-05-09 17:46:51 +02:00
parent f5a089f884
commit 6d9cbf55c2
37 changed files with 665 additions and 277 deletions

View file

@ -25,7 +25,10 @@ const types = {
}
/**
* Component for the account/bookmarks page
* A component to manage the user's bookmarks
*
* @component
* @returns {JSX.Element}
*/
export const Bookmarks = () => {
// Hooks & Context
@ -178,7 +181,7 @@ export const Bookmarks = () => {
* @param {object} props - All the React props
* @param {function} onCreated - An optional method to call when the bookmark is created
*/
export const NewBookmark = ({ onCreated = false }) => {
const NewBookmark = ({ onCreated = false }) => {
// Hooks
const { setLoadingStatus } = useContext(LoadingStatusContext)
const { clearModal } = useContext(ModalContext)
@ -242,13 +245,15 @@ export const NewBookmark = ({ onCreated = false }) => {
)
}
/*
* A component to add a bookmark from wherever
/**
* Component to add a bookmark to the user's account
*
* @params {object} props - All React props
* @params {string} props.href - The bookmark href
* @params {string} props.title - The bookmark title
* @params {string} props.type - The bookmark type
* @component
* @param {object} props - All component props
* @param {string} props.slug - The bookmark slug/href
* @param {string} props.title - The bookmark title
* @param {string} props.type - The bookmark type, one of design, pattern, set, cset, doc, or custom
* @returns {JSX.Element}
*/
export const BookmarkButton = ({ slug, type, title }) => {
const { setModal } = useContext(ModalContext)
@ -274,19 +279,22 @@ export const BookmarkButton = ({ slug, type, title }) => {
/*
* A component to create a bookmark, preloaded with props
*
* @params {object} props - All React props
* @params {string} props.href - The bookmark href
* @params {string} props.title - The bookmark title
* @params {string} props.type - The bookmark type
*
* @component
* @param {object} props - All component props
* @param {string} props.href - The bookmark href
* @param {string} props.title - The bookmark title
* @param {string} props.type - The bookmark type
* @returns {JSX.Element}
*/
export const CreateBookmark = ({ type, title, slug }) => {
const CreateBookmark = ({ type, title, slug }) => {
const backend = useBackend()
const [name, setName] = useState(title)
const { setLoadingStatus } = useContext(LoadingStatusContext)
const { setModal } = useContext(ModalContext)
const url = `/${slug}`
const url = slug.toLowerCase().slice(0,4) === 'http'
? slug
: `/${slug}`
const bookmark = async (evt) => {
evt.stopPropagation()