So delete comment is a destructive thing. We wanted to have a different, scarier style. Let's move on. On the right side of the issue, you'll see all of these options. Let's start with labels. The difference here is that it has a circle, the label color. Seems smart. But when we talk about assignees, assignees has, doesn't have labels, it has avatar. So seems smart enough. So we have, it could be a label color, or it could be an avatar. Right, and the ActionList component knows how to render both of these. Seems okay. But then you have other things like milestones, which has this icon, you have projects, which has this icon. Maybe we just need to know if it's a label or avatar or an icon. And that probably just works, doesn't it? For an icon use case, maybe we just import an icon from our icon library and pass it on, so milestones know how to render an icon. But what happens if you give it an avatar or an icon port? So this is one of those things where if the API pushes you in a certain direction it should be the direction that you want. You don't want people to make these decisions, to fall into these traps because they're not trying to break the API, they're just trying to create the selection feature. So coming from that realize there should only be one prefix, there should only be one visual be an avatar, it could be a label, it could be the selection icon and you import that and you pass that as a prefix element. So in this case you only get one, you get an avatar, but of course if you get a prefix element then you also need to pass it a prop. So you get something like maybe prefix props where I have to pass the avatar URL. And if you think about it, this is like if you have an element and props, this is a component so we might as well just call it a component. So this is a prefix which accepts any component that you want and it tries to put it here. Now definitely more flexible, definitely more in sync with what we need it to do, but the trade off here is that you could put any component that you want. So this opens up the API more than just three allowed config to put whatever you want, but if you want an icon, then you can. You can import the icon and put the check icon is what I wanted.
So delete comment is a destructive thing. We wanted to have a different, scarier style. Could be as simple as adding a variant. So everything is variant default or variant subtle. And this one is variant danger, seems like. Seems to fit well. Let's move on.
Now, on the right side of the issue, you'll see all of these options. You have labels, you have assignees, you have reviewers. Let's start with labels. So if you look at labels, it kind of is similar. It's an action list with options that you can click. The difference here is that it has a circle, the label color. So to begin with, I'd say let's just put all the items here. There's a text. There's an unselect. And there's a label color. Because I only have text here, I need something to qualify that there should be a circle. I'm putting this special smart key here, which is called label color. And if you pass it a hex value, it knows that it has to render a color, render a circle with that color. And it takes care of what should be the margin, what should be the gap between the color and the text. Seems smart. And you know, so you do it with all of them, and realistically, if this is being used in a product, it will look something like this. You would loop through repo.labels, or like a config of labels, and pull the label color out of it. Seems smart. Okay.
But when we talk about assignees, assignees has, doesn't have labels, it has avatar. So do we just do repo.collaborators, map through them, and then you have text and onSelect, which is the same. But instead of label color, it becomes avatar, and it knows it has to render a circle, how much gap should there be, and you just pass the user.avatar.url. So seems smart enough. So we have, it could be a label color, or it could be an avatar. Right, and the ActionList component knows how to render both of these. Seems okay. But then you have other things like milestones, which has this icon, you have projects, which has this icon. In fact, if I show you all of these samples, there's a bunch of these. Some of them have icons, some of them don't. Some of them have this indentation, but overall, it looks like most of these are either avatars or their icons. Some of the colored icons, but they're still icons. So maybe we just need to know if it's a label or avatar or an icon. And that probably just works, doesn't it? For an icon use case, maybe we just import an icon from our icon library and pass it on, so milestones know how to render an icon. But what happens if you give it an avatar or an icon port? I'm not saying people are actively trying to do this, they're trying to break something, but it's more like if they're trying to achieve something else, like a selection and they want to put a checkmark, does this feel like a feasible solution? So you import the check icon and you want to show checkmark next to the person it's assigned to and you will end up with something like this in this case where there's not enough space for both of them so they just kind of shift everything and then you're thinking about how do I create that margin, how do I get more space, maybe I can overwrite some margin with CSS and this API looks like that is a valid direction even though we don't want you to do that with the component so this is one of those things where if the API pushes you in a certain direction it should be the direction that you want. You don't want people to make these decisions, to fall into these traps because they're not trying to break the API, they're just trying to create the selection feature. So coming from that realize there should only be one prefix, there should only be one visual be an avatar, it could be a label, it could be the selection icon and you import that and you pass that as a prefix element. So in this case you only get one, you get an avatar, but of course if you get a prefix element then you also need to pass it a prop. So you get something like maybe prefix props where I have to pass the avatar URL. And if you think about it, this is like if you have an element and props, this is a component so we might as well just call it a component. So this is a prefix which accepts any component that you want and it tries to put it here. Now definitely more flexible, definitely more in sync with what we need it to do, but the trade off here is that you could put any component that you want. So this opens up the API more than just three allowed config to put whatever you want, but if you want an icon, then you can. You can import the icon and put the check icon is what I wanted.
Comments