Skip to content
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

[Table] Add STableCellPills component #178

Closed
ryo-gk opened this issue Dec 19, 2022 · 2 comments · Fixed by #179
Closed

[Table] Add STableCellPills component #178

ryo-gk opened this issue Dec 19, 2022 · 2 comments · Fixed by #179
Assignees

Comments

@ryo-gk
Copy link
Member

ryo-gk commented Dec 19, 2022

We need a STableCellPills component that accepts string[] as value, and show them as pills.
This is because the STableCellPill which we already have can't show multiple pills.

Design image is below. ("Topic type" column)
image

The usage is like below.

const table = useTable({
  ...
  columns: {
    tags: {
      label: 'Tags',
      cell: {
        type: 'pills',
        pills(items, record) {
          return items.map((item) => {
            return {
              label: item,
              color: item === 'info' ? 'info' : 'mute'
            }
          })
        }
      },
  },
  records: [
    { ... , tags: ['Info', 'News'], ... },
    { ... , tags: ['Info'], ... },
  ],
  ...
})
  ...
})

Or, might be simpler to allow STableCellPill to accept also string[]?

@kiaking
Copy link
Member

kiaking commented Dec 20, 2022

Or, might be simpler to allow STableCellPill to accept also string[]?

Yeah, it might 🤔 But however, I think we should make it accept an array of items and return pill objects so that we can have different colors depending on each value. This makes the API consistent with other type of cells.

So... maybe we should have a different API because the structure could be very different.

const table = useTable({
  ...
  columns: {
    tags: {
      label: 'Tags',
      cell: {
        type: 'pills',
        pills(items, record) {
          return items.map((item) => {
            return {
              label: item,
              color: item === 'info' ? 'info' : 'mute'
            }
          })
        }
      },
  },
  records: [
    { ... , tags: ['Info', 'News'], ... },
    { ... , tags: ['Info'], ... },
  ],
  ...
})

@ryo-gk
Copy link
Member Author

ryo-gk commented Dec 21, 2022

So... maybe we should have a different API because the structure could be very different.

I see, it looks good the API you suggested!

@brc-dd brc-dd self-assigned this Dec 22, 2022
kiaking added a commit that referenced this issue Dec 23, 2022
fix #177
close #178

Co-authored-by: Kia Ishii <kia.king.08@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants