Coder Social home page Coder Social logo

Component API consistency about brand HOT 4 CLOSED

primer avatar primer commented on May 2, 2024
Component API consistency

from brand.

Comments (4)

rezrah avatar rezrah commented on May 2, 2024 1

👋 @stefankp - thanks for bringing this up.

We'll need to discuss this in detail at our next maintainer sync to find the right solution going forward, but in the meantime here are my immediate thoughts..

<Component heading="..." />

We will occasionally use this prop based API where we want - or sometimes need - to restrict the appearance and implementation of the prop through an abstraction. While I agree it's not composable API like we offer elsewhere, the tradeoff here is that it's faster to implement and render while achieving our intended guardrails.

<Component>
  <Heading>...</Heading>
</Component>

<Component>
  <Component.Heading>...</Component.Heading>
</Component>

Definitely agree the differences aren't immediately clear 😅. The context here, is that namespaced versions do a lot more under the hood than non-namespaced equivalents. It's also meant to indicate that the entire API for Heading is available to you on the former. Component.Heading however, could have an entirely different API and is not necessarily equivalent to Heading. We always try to go with the former first, but when there's too many defaults required, we end up namespacing.

This API suggests to me that I could pass in more than one component (or other), but actually only the first one is accepted.

This either should be documented or fixed so that we batch the rendering of multiple Text child types. I think this is an easy one to fix, we can take this away.

Hero

Just an FYI that the Hero component will be refactored eventually... here a related issue.

from brand.

stefankp avatar stefankp commented on May 2, 2024 1

@rezrah I think we should prefer the composable APIs when possible. Exception could be when a component only has required inputs with no optional customization. Looking forward to the Hero refactor 👌

from brand.

rezrah avatar rezrah commented on May 2, 2024 1

Closing this issue as..

  • A revised hero has now shipped with a composable API
  • We'll be writing up the ADR in contributor documentation in Q1
  • Nuances around filtering of children on certain components will be captured and explained in their respective documentation.
  • We already have established precedent for writing composable component API's, which is being used in all net new components.

from brand.

rezrah avatar rezrah commented on May 2, 2024

Next steps:

  • Await feedback from @stefankp et al
  • Document API conventions and rationales in an ADR

from brand.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.