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

feat(table): auto resize actions column #381

Merged
merged 5 commits into from
Nov 14, 2023
Merged

Conversation

brc-dd
Copy link
Member

@brc-dd brc-dd commented Nov 13, 2023

closes #377


Also adjusted the code to always left align the action cell items. It was looking weird when some of the icons are hidden:

Before:

image

After:

image

Not sure though which is more desirable.


Close #382 if merging this. show is the recommended way if you want to hide some icons and use auto resize at the same time. This PR won't work when actions.cell is a function.

@brc-dd brc-dd requested a review from kiaking November 13, 2023 11:16
@brc-dd brc-dd self-assigned this Nov 13, 2023
Copy link

netlify bot commented Nov 13, 2023

Deploy Preview for sefirot-story ready!

Name Link
🔨 Latest commit b4a25ee
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-story/deploys/65523f0b384a9a00089b614b
😎 Deploy Preview https://deploy-preview-381--sefirot-story.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 13, 2023

Deploy Preview for sefirot-docs ready!

Name Link
🔨 Latest commit b4a25ee
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-docs/deploys/65523f0bb53d8e0008195287
😎 Deploy Preview https://deploy-preview-381--sefirot-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Nov 13, 2023

Codecov Report

Attention: 44 lines in your changes are missing coverage. Please review.

Comparison is base (164ea02) 79.74% compared to head (b4a25ee) 79.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #381      +/-   ##
==========================================
- Coverage   79.74%   79.50%   -0.24%     
==========================================
  Files         152      153       +1     
  Lines       12187    12259      +72     
  Branches      516      522       +6     
==========================================
+ Hits         9718     9746      +28     
- Misses       2469     2513      +44     
Files Coverage Δ
lib/components/STableCellActions.vue 100.00% <100.00%> (ø)
lib/support/Text.ts 36.00% <36.00%> (ø)
lib/components/STable.vue 74.54% <40.42%> (-2.90%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brc-dd brc-dd changed the title fix(table): don't center align action cell items feat(table): auto resize actions column Nov 13, 2023
@brc-dd brc-dd marked this pull request as draft November 13, 2023 13:57
@brc-dd brc-dd marked this pull request as ready for review November 13, 2023 14:18
@brc-dd brc-dd force-pushed the fix/actions-alignment branch from ef6b21f to 8a4ea96 Compare November 13, 2023 14:21
@brc-dd brc-dd force-pushed the fix/actions-alignment branch from ba264be to 3a35465 Compare November 13, 2023 14:23
@kiaking
Copy link
Member

kiaking commented Nov 14, 2023

Nicely done!

Also adjusted the code to always left align the action cell items. It was looking weird when some of the icons are hidden:

Yup, this is desirable I say. It should align left 👍

This PR won't work when actions.cell is a function.

Yeah we are so close. Confirmed that It does work with cell being function, unless user use the cell argument to do something... (passing in value and record arg here would be tough).

But I guess this limitation makes sense. It too complicated to tweak the cell type just for this.

One use case I have in mind is something I commented on #832, where we might wanna have different array rather than hiding action via show prop.

But I think for that case, we can do so by making columns reactive instead of making cell a function 👍

const isAdmin = ref(false)

useTable({
  columns: computed(() => ({
    actions: {
      type: 'actions',
      actions: getActions()
    }
  }))
})

function getActions() {
  const actions = []
  
  actions.push({ icon: 'edit', onClick: () => {} })

  if (isAdmin.value) {
    actions.push({ icon 'delete', onClick: () => {} })
  }

  return actions
}

@brc-dd
Copy link
Member Author

brc-dd commented Nov 14, 2023

Yeah let's merge this and close #382 for now. If we need something complex, we probably can just specify the CSS variable.

@kiaking
Copy link
Member

kiaking commented Nov 14, 2023

Sounds good 👍

@kiaking kiaking merged commit c37b97c into main Nov 14, 2023
7 of 9 checks passed
@kiaking kiaking deleted the fix/actions-alignment branch November 14, 2023 03:27
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 this pull request may close these issues.

[Table] Set actions column/cell width automatically
2 participants