-
Notifications
You must be signed in to change notification settings - Fork 55
The content property is not consistently implemented in all Stadust components #522
Comments
Exactly, it should solve that issue as well. |
Couple of additional thoughts. As this proposal would add additional dom element in the component, we must be sure that we are okay with it for all components. It seems kind a strange for the component that contains just the content in their structure. For example, let's take the Text component. Previously the rendered html was the following: <span class="ui-text">This text is light.</span> After the changes, we have additional span rendered: <span class="ui-text" dir="auto">
<span class="ui-slot">This text is light.</span>
</span> If we decide that we won't do this for some components however, we will stind end up with the previous problem. Any suggestions would be appreciated. |
I think for some components (like That's because it's pretty obvious (or should be) for the user that the |
Apart from the issue with the component containing only the content property, here is an overview for all other components regarding the content property: Components not containing the content property:
Components with custom content property
Other problems found
Question
|
<wrapper = li>
<ElementType = a>
<Icon />
content
</ElementType>
</wrapper> If we refactor |
I would say the MenuItem is not the only component that needs this, as @Bugaa92 has mention there are other components that want the content to be just a string. But still, we should be very careful with this, because if the content is string, then we are not providing any way for it to be targeted and styled by the user, moreover we are not allowing the async rendering of the content (currently provided by the renderContent method, or the refactored approach, by using the shorthand as a function).If we are okay with this, we should document this clearly and make it consistent throughout all components. Other components containing only the content property in the root
|
Yes, this is a tough issue. Here is more conversation and design on the same topic: Standardize content prop: Semantic-Org/Semantic-UI-React#1364 Standardize shorthand prop names for primary content: Semantic-Org/Semantic-UI-React#391 The conclusion in those issues was to leave the inconsistency we have in favor of more correct markup. After our offline discussions here at Stardust, we still think the same thing. |
Here's another summary and comparison of the content prop: REMOVE? content is only aliasing children Shorthand usages: This API would be more confusing to users. Also, if the component changes its markup, it has to break its API typings. Let's stick with content for now and only change typings 👍 |
@miroslavstastny I believe you had a closing comment on this topic after we discussed the above (see my last comment). Can you post here and close this issue? |
|
Bug Report
Steps
The content property is not consistent across all Stardust components. This can lead to confusion or incorrect usage of the Components when the content slot is in question.
Expected Result
I would expect that the content property should be used consistently in all Stardust components. As far as I remember, we decided to make the content property shorthand for the Slot component, and use it everywhere across our components. This would allow us to use the content as an actual shorthand slot inside each component.
On top of this, we are not even using consistent propTypes and interfaces for the content property. If we decide to go with the shorthand, then it can simple be defined as
customPropTypes.itemShorthand
in the propTypes andShorthandValue
in the props' interface.Actual Result
Not all components support it. Actually only few components are following this convention. Let's take a look into two examples of a Component that supports it (Button) and of Component that do not support this (Divider):
Button component
Example code:
Result:
Divider component
Example code:
Result:
Error thrown
Version
0.12.0
Proposal
Let's try to make the content property to be shorthand for the Slot component in all Stardust components. If we see that this is not possible for some of the components, I would suggest we document it explicitly in the docs site, so that it won't create confusion to the users.
The text was updated successfully, but these errors were encountered: