Skip to content

Shared React component library #76

Closed
@olizilla

Description

@olizilla

We want to reuse our UI componets across at least ipfs-webui, ipfs-desktop, ipfs-share-files. We want to define the patterns we have to creating our presentational components, in terms of component styling, and overrides, and i18n and bundling locale dictionaries when the componet is used in an app.

We believe we want a shared component library. A dev experience of

import { CidInfo, LoadingIndicator } from ipfs-gui

would be nice, epecially if it could automagically sort out adding the additional i18n keys to the bundle.

Prior art:

Puzzle pieces:

Next steps:

Starting from the gui-team principles... take a look at https://github.com/ipfs-shipyard/ipld-explorer-components

  • update storybook to the fancy new one.
  • add the circle ci build process to it. Have it publish the storybook in PR. Comment out the dnslink update step, until we decide on a domain for it.
  • Pull some components from ipfs-webui into ipld-explorer-components (will be renamed later) and import them from webui
  • Define the pattern for exporting re-usable components that use tachyons for styling, but allow the use site to overide the style of the containing element. This is probably just
export const Thing = ({className, children, ...props})  => {
  return <div className={`bg-gray charcoal ${className}` ...props>{children}</div>
}

to start with, but it has the problem that if ma4 is the default, and the caller tries to apply ma2 as an override it will not work as the class will end up with both in its class list, and then its down to document order in the css file as to which one wins, in this example, the default ma4 occurs after ma2 so it does not apply. I think we can figure out a neat solution to that tho.

  • Define the component api for i18n. Right now we export components that expect a t function and call that with i18n key names that they need. Alternatives are to create props for each label that appears in the component, and then write a container that maps those props to i18n keys. This could be neat if we use the path/to/the/Component.fooLabel as the key. In general you want to make it easy to have sensible defaults and possible to override them when the compent is used in a different setting. It's worth highlighting that really atomic components like <Button> should not have any awareness of i18n, as their text will change with every use case, but something like a <DeleteButtonWithConfirmation/> might benefit from sharing good default explanation text, that would need localising.

Metadata

Metadata

Labels

topic/design-visualVisual design ONLY, not part of a larger UX effort

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions