slice-machine icon indicating copy to clipboard operation
slice-machine copied to clipboard

refactor(slice-machine-ui): use `Table` from `@prismicio/editor-ui`

Open angeloashmore opened this issue 1 year ago • 3 comments

Context

DT-2019

The Solution

  • Replace use of Table with @prismicio/editor-ui's Table.
  • Remove the empty space around the "Repeatable" and "Single" document icons.
  • Remove the Table component set.
  • Remove the CustomTypesTablePage Vitest tests. The tests broke as a result of this PR, and we already have Playwright tests to cover the page. It isn't worth our time to fix the Vitest version.

Impact / Dependencies

N/A

Checklist before requesting a review

  • [x] I hereby declare my code ready for review.
  • [ ] If it is a critical feature, I have added tests.
  • [ ] The CI is successful.
  • [ ] If there could backward compatibility issues, it has been discussed and planned.

Preview

image

angeloashmore avatar May 01 '24 20:05 angeloashmore

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
slice-machine ✅ Ready (Inspect) Visit Preview May 21, 2024 1:16am

vercel[bot] avatar May 01 '24 20:05 vercel[bot]

Excellent!

🕵️‍♂️ I've only noticed that the Button's shadow is clipped, but I don't understand why. I don't think this is a blocking issue though.

Screenshot 2024-05-06 at 11 02 10

It is because TableCell has overflow class assigned by default and the outline spans beyond element bounds. Maybe we could provide prop to remove it, bcs in the cell like this you don't need it.

.overflow {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

filip-prismic avatar May 10 '24 07:05 filip-prismic

It is because TableCell has overflow class assigned by default and the outline spans beyond element bounds. Maybe we could provide prop to remove it, bcs in the cell like this you don't need it.

.overflow {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

Exposing a prop that controls the overflow feels like a leaky abstraction. Throwing a different idea out: what if we removed the 16px inline padding and moved it to the first and last cells in a row? That would prevent the overflow clipping.

Unfortunately, it means the first and last column sizes need to increase by 16px, which may have negative consequences:

- <Table columnLayout="28px 1fr 1fr 1fr 40px">
+ <Table columnLayout="44px 1fr 1fr 1fr 56px">

angeloashmore avatar May 21 '24 01:05 angeloashmore

@bapmrl I fixed the issue by increasing the table column by 2px: https://github.com/prismicio/slice-machine/pull/1362/commits/2dc6d5a48fb2c3f8d62697e16d637d6ebaf82f8c

I think it's an okay solution for now. The change is barely visible:

image

angeloashmore avatar May 21 '24 01:05 angeloashmore

what if we removed the 16px inline padding and moved it to the first and last cells in a row? That would prevent the overflow clipping.

@angeloashmore seems like patch for a problem we should not be dealing with. I would rather ask why the overflow is there for all the columns by default in the first place. Seems weird to me :D

But agree this one shouldn't be a blocker for you and 2px size change is a good enough right now.

filip-prismic avatar May 21 '24 16:05 filip-prismic

@filip-prismic I quickly looked at it closer and I agree; it doesn't seem like the overflow styles are needed. It could be something handled by the cell's children instead.

But let's move forward with the 2px fix for now.

angeloashmore avatar May 22 '24 20:05 angeloashmore