npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cozy-sharing

v13.2.0

Published

Provides sharing login for React applications.

Downloads

2,874

Readme

Test 'n play

Open the playgrounds in cozy-libs and run yarn start

How to use the lib

In your app, you have to :

  • import the Provider: import SharingProvider, { ShareButton, ShareModal } from 'cozy-sharing'
  • import the stylesheet.css: import 'cozy-sharing/dist/stylesheet.css'

Using the built-in components

Some of the exposed components are fully featured components, ready to render. They need a SharingProvider above them in the render tree and the imported stylesheet for their styles.

import { ShareModal } from 'cozy-sharing'

const ToggleModal = () => {
  const [isModalDisplayed, setIsModalDisplayed] = useState(false)

  return (
    <div>
      <Button onClick={() => setIsModalDisplayed(true)}>Open modal</Button>
      {isModalDisplayed && <ShareModal document={doc} />}
    </div>
  )
}

Other components accept a render prop as children that receive some information from the sharing context.

import { SharedDocument } from 'cozy-sharing'

const MyComp = () => {
  return (
    <SharedDocument docId='123'>
      {({ isShared, link }) => (
        {isShared ? link : 'Not shared yet'}
      )}
    </SharedDocument>
  )
}

Usage with hooks

cozy-sharing can now be used with hooks as well:

import { SharingContext } from 'cozy-sharing'

const MyComp = () => {
  const { share } = useContext(SharingContext)

  return <Button onClick={() => share(document, recipients, sharingType, description)}>Share</Button>
}

Share and send mail in development

Cozy apps let users share documents from cozy to cozy.

Meet Alice and Bob. Alice wants to share a folder with Bob. Alice clicks on the share button and fills in the email input with Bob's email address. Bob receives an email with a « Accept the sharing » button. Bob clicks on that button and is redirected to Alice's cozy to enter his own cozy url to link both cozys. Bob sees Alice's shared folder in his own cozy.

🤔 But how could we do this scenario on development environment?

With the docker image

If you develop with the cozy-app-dev docker image, MailHog is running inside it to catch emails.

If cozy-stack has to send an email, MailHog catches it and exposes it on its web interface on http://cozy.tools:8025/.

With the binary cozy-stack

If you develop with the cozy-stack CLI, you have to run MailHog on your computer and tell cozy-stack serve where to find the mail server with some options:

./cozy-stack serve --appdir drive:../cozy-drive/build,settings:../cozy-settings/build --mail-disable-tls --mail-port 1025

This commands assumes you git clone cozy-drive and cozy-settings in the same folder than you git clone cozy-stack.

Then simply run mailhog and open http://cozy.tools:8025/.

Retrieve sent emails

With MailHog, every email sent by cozy-stack is caught. That means the email address does not have to be a real one, ie. bob@cozy, [email protected] are perfectly fine. It could be a real one, but the email will not reach the real recipient's inbox, say [email protected].