-
Notifications
You must be signed in to change notification settings - Fork 25
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
is it possible to have a super-sugar API? #120
Comments
I'm thinking from the perspective of someone dropping us into an app. Say I have an app where users are already logged into something, and I just want to add a drop target for uploads. For instance, this seems to be about the minimal amount of code to add right now. I am thinking something 1/2 between here and " |
The code for the I separated the uploader and upload listing components so you didn't have to include all the code to build a UnixFS DAG when all you wanted to do was list items (we have this arrangement currently in the NFT.Storage site). They also both have reactive state that I wanted to keep separated. It's also concievable that you might want multiple listings of items, for example from different spaces. The auth provider is likely to be used by the w3access keyring on it's own without the upload related providers so needs to be separate. It also needs to be separate to allow it to provide context to multiple other providers and components in the tree without introducing dependencies between them. Should be trivial to do a monolith though: import React, { useContext } from 'react'
import { AuthContext } from '@w3ui/react-keyring'
import { UploaderContext } from '@w3ui/react-uploader'
import { UploadsListContext } from '@w3ui/react-uploads-list'
export function MonolithicProvider ({ children }) {
return (
<AuthProvider>
<UploaderProvider>
<UploadsListProvider>
{children}
</UploadsListProvider>
</UploaderProvider>
</AuthProvider>
)
}
export function useMonolithic () {
const authCtx = useContext(AuthContext)
const uploaderCtx = useContext(UploaderContext)
const listCtx = useContext(UploadsListContext)
return [{ ...authCtx[0], ...uploaderCtx[0], ...listCtx[0] }, { ...authCtx[1], ...uploaderCtx[1], ...listCtx[1] }]
} |
Yep agree with all this! I think it should also be pretty trivial to expose standalone/convenience versions of these components that don't require a separate import { UploadsListProvider, UploadsList } from '@w3ui/react-uploads-list'
export function StandaloneUploadsList () {
return (
<AuthProvider>
<UploadsListProvider>
<UploadsList/>
</UploadsListProvider>
</AuthProvider>
)
} and/or import { UploadsListProvider, UploadsList } from '@w3ui/react-uploads-list'
export function SpaceAgentUploadsList ({ space, agent }) {
return (
<UploadsListProvider>
<UploadsList space={space} agent={agent} />
</UploadsListProvider>
)
} I think the specific shape of these examples isn't quite right, but they demonstrate a) hiding the provider inside a standalone component for the case where a user just wants to drop a single upload list (or an uploader) into an app and b) parameterizing an upload list with a The second example suggests another question - what kind of user/developer experience do we want to provide for people who just want to display a particular uploads list on their website? I suspect that rather than parameterizing a component with import { UploadsListContext } from '@w3ui/react-uploads-list'
export function UCANUploadsList ({ ucan }) {
return (
<UploadsListProvider>
<UploadsList ucan={ucan} />
</UploadsListProvider>
)
} Which would let the end user/developer do something like: import { UCANUploadsList } from '@w3ui/react-uploads-list'
function MyApp () {
return (
<div>
<h1>check out my kewl filez</h1>
<UCANUploadsList ucan="paste-a-ucan-here" />
</div>
)
} We could display a UCAN appropriate to paste into the
Does this all make sense? Am I missing anything? |
One of the things I like about the withIdentity style is that our complete thing can be done in one file. Discussed with Travis that this not an either/or, but rather a few ways to use the composability. So I'm imagining two main super-sugar options:
|
ok I threw together an initial prototype of an there are definitely some design issues to be worked through here - making a component this complex that gives the developer maximum control over presentation is tricky - but I think it's promising. will add a bit more tomorrow in line with your comments above @jchris - I should be able to throw together a draft version of the functions and components you're talking about pretty quickly now |
The question I didn’t address in my comment is whether the login flow is embedded in those upload and upload list components, or if it’s required for you to somehow bridge login and those components state yourself. I think it is worth having a distinct |
Yep agreed. Here's a rough sketch of what I'm thinking:
This is certainly a lot of options and will require a bit of complexity and careful design to do well, but if we pull it off it provides a clean path for developers at any level of experience to start using our components and elegantly evolve their usage over time. A developer who starts with "Drop-in" components will be able to look at the source for them and easily transition to Customizable or Headless components as their needs evolve. This is becoming a wall of text so I'll stop now - perhaps a good idea to start a design doc in this repo and maybe some issues to start tracking each of these separately? Particularly interested in your thoughts @jchris and @alanshaw as I think you two have thought about this the most so far! |
oo - we should definitely throw "custom css properties" in the ring for this one - see this comment and demo from @cmunns - I think this is probably the right way to implement the "customizable ui" components from 1.iii above: |
@travis @jchris Here are two examples of theme/look using only css custom properties. right now that list is namespaced to the uploader here, but I imagine some would be global and some would be component specific
|
The all-in-one component, for super simple login and upload, is probably ready for us to think about how it looks on the w3ui website. I think it is not just a 4th component, but rather an umbrella. So maybe it goes over the top (excuse my sketch skills). We should open a new ticket to track the website homepage style update. Wanted to get everyone thinking about it in the context first. |
Yep agreed - I've been imagining we'd have a series of components like this, probably each in their own package, that use combinations of the lower level components to do common things - this serves the dual purpose of providing concrete examples of how to use the lower level components AND giving developers a super easy "drop a single component into your page" way to get started with In this context, I wonder how we'd present this - maybe each of the 4 "levels" gets its own section on the website - one just highlighting the hooks/no-UI components for each framework, one for the Headless components, one for the "customizable" components and another that shows off all of the different example/drop-in components we introduce over time... would this be too much content for the homepage of the w3ui site? |
At some point the detail fades into supporting evidence, not headline news. The headline is probably:
These are in tension because headless / framework specific are part of bullet two, but the first bullet is for people who don't even want to think about that stuff. As far as how we roll these out, are there any circumstances where someone uses our uploader but not our keyring? I'm kinda guessing not. So then we want the easiest version of each of our components to include keyring. |
We should start to think about how to carve out the heavy lift part of the all-in-one component, because maybe we should have that for after w3console ships. Heavy lift is stuff that is beyond writing the code for the all-in-one (we should probably keep doing that.) Stuff like:
This is distinct from the w3console effort, so we should make sure to cross-pollinate as w3console is a huge w3ui user, and should reflect the same w3ui brand look-and-feel as the default theme of the w3ui all-in-one components. |
At the "headless" level there will definitely be some folks who won't want to use markup or styling we provide, however customizable it is - at this level of abstraction I still think it's a good idea to just provide the building blocks and let people put them together however they want. At the "customizable" and "drop-in" component levels I think you're right - we should probably just fold the keyring and uploader together so people don't need to worry about how to fit them together. I could see people using the "uploads list" without a keyring - @mikeal and @Gozala riffed a bit at the end of my demo on Friday about this and I think the idea was that we could pass the component the CID of a UCAN invocation that would return the list of uploads. Would definitely need to dig a bit deeper (and, tbh, understand UCAN invocations a bit better) to fully execute on this but it sounds like it's a use case worth considering. |
🙏 Can we close this in favor of the other issues for creating HeadlessUI and CustomUI? |
A couple of places in the app code that smell like they could be tucked in:
Also here:
I think the fix would be to have a monolithic upload component that includes login automatically, and has an easy way to enable lists with custom markup. Also we need to include the
Authenticator
so no one has to write it.I like the
withIdentity
style of wrapping ContentPage, maybe we can make a monolithicwithUploader
?The text was updated successfully, but these errors were encountered: