Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Table Refactor #520

Merged
merged 38 commits into from
Nov 14, 2022
Merged

Table Refactor #520

merged 38 commits into from
Nov 14, 2022

Conversation

endigo9740
Copy link
Contributor

Submitting an early draft. Fixes #217

@endigo9740 endigo9740 linked an issue Nov 9, 2022 that may be closed by this pull request
10 tasks
@vercel
Copy link

vercel bot commented Nov 9, 2022

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

Name Status Preview Updated
skeleton-ui ✅ Ready (Inspect) Visit Preview Nov 14, 2022 at 7:09PM (UTC)

@endigo9740 endigo9740 marked this pull request as draft November 9, 2022 23:39
@endigo9740 endigo9740 mentioned this pull request Nov 9, 2022
10 tasks
<!-- Arrows -->
<div class="paginator-arrows space-x-2">
<button class="btn-icon {buttons}" on:click={onPrev} disabled={offset === 0}>&larr;</button>
<button class="btn-icon {buttons}" on:click={onNext} disabled={(offset + 1) * limit >= size}>&rarr;</button>
<button class="btn-icon {buttons}" on:click={onPrev} disabled={settings.offset === 0}>&larr;</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need aria labels

Copy link
Contributor Author

@endigo9740 endigo9740 Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To represent what the action is, given the unicode? That opens us up to i18n issues, so perhaps we just make those straight labels like Dialog buttons?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they need to be screenreader accessible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll handle this as part of the updates here:
#465

// Cell Formatters ---

/** Wrap object key value with HTML tags. */
export function tableCellFormatter(object: any[], key: string, openTag: string, closeTag: string): any[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about this. You're opening yourself up to injections. I would prefer to see a solution based around document.createElement(tagName). I know that you're using this to also pass in classes, but it would be relatively trivial to pass global attributes as an optional argument. Change the type to unknown and remove the return cast to any[] and I can have a look at the typing later

Copy link
Contributor Author

@endigo9740 endigo9740 Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've modified as follows:

  • Now access tagName and classes as params
  • Create a new entity using createElement(tagName)
  • Appends the key value using .innerHTML
  • Uses setAttribute(classes) to append optional classes
  • Updates the object value using .outerHTML, which returns as a string.

I think this will be better?

Copy link
Contributor Author

@endigo9740 endigo9740 Nov 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually on second thought, this is not a good change to make. Svelte can't do anything with the document/DOM until the Mount event. This means all the table setup would have to occur during onMount which is slow as molasses.

This was just a bonus feature, so I think for now I'll just disable it until we can think this through a bit more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about the onMount, hadn't considered that.

@endigo9740
Copy link
Contributor Author

@ryceg I've knocked out all but the two items above. Just awaiting feedback on what's left.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data Table refactor and cleanup
3 participants