-
Notifications
You must be signed in to change notification settings - Fork 81
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
[Proposal]: Add dynamic slots for KTable columns #743
Comments
Nice proposal. I'd even go as far as to make |
Regarding |
@BabyElias any thoughts on @AlexVelezLl's proposal before we open a final issue out of it? Please let us know! I am also going to invite the core team for discussion now. |
Alex's proposal seems all good to me, nothing to add from my end. |
When a component evolves to the point where you're passing related data via two or more pathways, I think it's worthwhile to think how you might consolidate them. For instance, the table headers metadata are essentially the props for whatever template will be used to render each column header. I know you're not proposing this specifically for the headers, but rather the table cells. Although, I do think it can apply similarly to the table cells, but that has reliance the table headers (ordering). The main advantage I see is that you could consolidate two pieces of the rendering to make it more plainly evident without as much need for in depth explanation, which you acknowledge will be a challenge. It doesn't matter what order you define the slots as children being passed to a component-- the output of course is determined by how the component uses the slots. In the case of the table, the order of the headers is determine by related data being passed to the |
Thank you @bjester, would you have a moment for a rough pseudo-code example or two that would demonstrate the consolidation you describe? Overall I think what you're describing makes sense, but I don't understand yet how that'd translate into the table interface. Generally, during the first stages of |
I can see many different pathways to achieve the consolidation, which all could look somewhat different. Here are some considerations that come to my mind:
One idea is to take inspiration from the native <table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table> would be rendered as: <table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</tbody>
</table> The above behavior is possible because of the encapsulation of information into each type of element. So with My impression is that the <KTable :rows="rows" :sortable="true">
<KTableHead #head>
<KTableHeader :name="name">Name</KTableHeader>
<KTableHeader :name="age">Age</KTableHeader>
<KTableHeader :name="city" :sortable="false" :colspan="2">City & State</KTableHeader>
</KTableHead>
<KTableBody #body>
<KTableStringCell />
<KTableNumericCell />
<KTableStringCell>
<template #cell="{ content, row }">
{{ content || row.city }} (city)
</template>
</KTableStringCell>
<KTableStringCell :key="state" />
</KTableBody>
</KTable> The above incorporates a number of possibilities that I'm not necessarily proposing, like the idea of |
Thanks for your time putting your thoughts here, @bjester, this is really valuable. I'd like to invite @BabyElias and @AlexVelezLl to have a look and provide your input if you can think of anything. @bjester In the last summary example you provide, I appreciate the way this resembles the native HTML table since it's intuitive way of working with tables. I consider breaking the logic to more components helpful and was something I already thought a bit about too. Particularly because of the future use-cases, where we will need editable cells and also possibly vertical headers. Then we could:
As @BabyElias mentioned in another issue proposal if I recall, with adding new functionality, the current initial configuration objects will be growing larger and larger and this strategy would help with that. I was also reminded of a former proposal by @indirectlylit that seems to have some similar aspects. I am planning to look into it later on as we're closer to this stage of work. One thing to clarify later would how many components we'd want to have exactly, and a discussion around the value of them compared to slots and other alternatives. I am too not yet completely clear on this but pretty sure that breaking it somehow similarly as suggested would help. I am going to open some discussion on Slack soon regarding a roadmap of the next steps focused on Regarding the original @AlexVelezLl's proposal, I'd say it'd be best to leave in the proposal stage at this point and gather feedback like in this discussion, and then make some decisions based on our decisions around the future direction for |
Definetely! Makes sense to me! My initial proposal was based on the current KTable implementation, but didnt know that the base public api of KTable had not been fully decided yet 😅. |
No problem, @AlexVelezLl, it'd be also possible we will have two parallel lines of work, one for the current version, and another focused on another iteration more high-level. Depends on priorities, it's all quite open at this point. In any case, I see much value in writing and discussing these proposals, because it gives us much concrete ideas and things to talk about that will later become well-crafted components :) |
Hi! Coming back to this, from my perspective, I see a lot of value in keeping these components separate as Blaine proposed, because of Blaine's explanation, and because otherwise the I was thinking about how we would handle sorting with this structure, I know there are several ways, using composables externally to these components that the KTable user uses, using composables internally in the subcomponents and communicating them via Of these, in my opinion, the one that leaves more abstraction and ease of use for the KTable user is to use composables with To handle whether we are using local or external sorting, we could consider that if we send a Although I think we can reconsider the use of such specific components as |
On a separate comment, this would introduce a breaking change in the KTable structure. If we decide to go with this change, would it be ok to introduce this new API in KDS v6? Which would be more aligned with a next Kolibri feature flag release. Or would we want to introduce this new API in 0.18 and also wait for this change before wrapping up KDS v5.0.0? @MisRob |
Thank you @AlexVelezLl , I will read your comment. For now just briefly regarding release schedule, I am opening this is a longer-term discussion in preparation for future work that is not scoped yet so there is no need to be worried about the releases at all :) I could imagine that this exchange could serve well as a basis for another gsoc project that'd be about writing the detailed specification and implementing it. Or it'd serve us internally for having some initial direction should we find ourselves in need of it sooner. With a benefit that it can inform decisions around smaller features, for example like this original proposal. It's part of my attempts to have pro-active discussions around KDS APIs, in advance. |
And when the time comes, we will connect and plan around breaking apis together for sure @AlexVelezLl |
Hi again @AlexVelezLl,
Yes, I think ensuring that we handle internally things that don't need to be known externally will help to simplify, and this sounds like a useful pattern.
I appreciate this idea. It would create a simpler interface as we could remove
I too was wondering about this and too am not very opinionated. May be nice to hear from other developers and re-fine when the time comes. |
Product
KDS.
Desired behavior
I would like to be able to customize the contents of certain columns in a table using dynamic slots. For example:
We can pass an id to our headers array:
And for the columns that have that id we can add a slot with that name to have specific content for that column:
So if there is a column that has a dynamic slot, use that slot to render its content, otherwise use the default #cell.
Current behavior
Currently if I wanted custom content for the city column, I have to use the colIndex of that column:
The Value Add
This improves maintainability as if we change the position of the headers, or prepends any column, we wouldnt have to change the template or have to deal with counting which index corresponds to each attribute.
Possible Tradeoffs
We must find an effective way to communicate this in the api docs. Since it can be a bit confusing to have something like a dynamic slot in the slots table in the documentation.
The text was updated successfully, but these errors were encountered: