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

Initial Implementation Of KTable Component #727

Merged
merged 104 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
2f527c3
Initialisating KTable Component
BabyElias May 30, 2024
523168e
Initialised KTable (fixed linting)
BabyElias May 30, 2024
9109552
Fixed linting errors
BabyElias May 30, 2024
5b13c64
fixed failing tests
BabyElias May 30, 2024
ba89898
Merge pull request #647 from BabyElias/gsoc-table
MisRob May 31, 2024
60caa84
Added sorting functionality
BabyElias Jun 3, 2024
b85a6d3
organised file structure
BabyElias Jun 3, 2024
2784a07
added ktable to playground
BabyElias Jun 3, 2024
058e4c8
fixed linting errors
BabyElias Jun 3, 2024
b8db731
fixed linting errors
BabyElias Jun 3, 2024
bce8877
fixing linting errors, again
BabyElias Jun 3, 2024
491fe19
Merge pull request #649 from BabyElias/gsoc-table
MisRob Jun 5, 2024
f464d27
added scoped slots and sorting composable
BabyElias Jun 9, 2024
de583df
removed unnecessary validator
BabyElias Jun 9, 2024
2209b03
Merge branch 'learningequality:gsoc-table' into gsoc-table
BabyElias Jun 9, 2024
6f78cd7
Merge pull request #654 from BabyElias/gsoc-table
MisRob Jun 11, 2024
583999a
added changesort event handler and tests
BabyElias Jun 13, 2024
f843b55
Merge pull request #655 from BabyElias/gsoc-table
MisRob Jun 14, 2024
31f0f61
Added date sorting
BabyElias Jun 17, 2024
23a4c65
Merge branch 'learningequality:gsoc-table' into gsoc-table
BabyElias Jun 17, 2024
37beb3f
Fixed screen reader loading states
BabyElias Jun 18, 2024
218205b
Merge pull request #657 from BabyElias/gsoc-table
MisRob Jun 18, 2024
b8b752e
enhanced keyboard nav
BabyElias Jun 21, 2024
e897a71
Merge branch 'learningequality:gsoc-table' into gsoc-table
BabyElias Jul 9, 2024
091e7f2
fixed firefox accessibility issues
BabyElias Jul 11, 2024
11f0604
Merge pull request #669 from BabyElias/gsoc-table
MisRob Jul 12, 2024
e871bf2
Added scroll and custom widths
BabyElias Jul 16, 2024
a1393d1
Merge branch 'learningequality:gsoc-table' into gsoc-table
BabyElias Jul 16, 2024
48e969c
fixed conflicts
BabyElias Jul 16, 2024
96ede77
Added sticky panes
BabyElias Jul 18, 2024
d5b2b5c
added hover effect
BabyElias Jul 22, 2024
83b29fb
Added sortColumn icon
BabyElias Jul 26, 2024
f118cd9
added header highlight feature
BabyElias Jul 27, 2024
fb8bf2b
fixed focus state
BabyElias Aug 1, 2024
05576d1
partial theming
BabyElias Aug 2, 2024
2b0ca06
highlight-header theming and updated examples for clarity
BabyElias Aug 2, 2024
778c512
fixed outline and enhanced tab key navigation
BabyElias Aug 3, 2024
b7f5847
completed theming
BabyElias Aug 5, 2024
0613a21
fixed theming, removed unnecessary code
BabyElias Aug 5, 2024
9c4d02b
Merge pull request #682 from BabyElias/gsoc-table
MisRob Aug 6, 2024
b150305
added more tests
BabyElias Aug 8, 2024
67e1928
Merge branch 'learningequality:gsoc-table' into gsoc-table
BabyElias Aug 11, 2024
90d8c24
Merge branch 'gsoc-table-develop' into gsoc-table
BabyElias Aug 11, 2024
fe1736c
Merge pull request #3 from BabyElias/gsoc-table
BabyElias Aug 11, 2024
b413eae
added composable testing and documentation
BabyElias Aug 11, 2024
b6c4ee1
linting errors
BabyElias Aug 11, 2024
01a0179
documentation updates
BabyElias Aug 13, 2024
8d1c272
added sorted header color
BabyElias Aug 13, 2024
f27f9ae
updated documentation
BabyElias Aug 13, 2024
2e45abe
Updated documentation and examples
BabyElias Aug 14, 2024
5084f30
Merge branch 'develop' into gsoc-table-develop
BabyElias Aug 14, 2024
6e69cc0
tab key navigation fix
BabyElias Aug 15, 2024
dabdf0d
fixed scroll into view for sticky headers
BabyElias Aug 15, 2024
fefcad1
Merge branch 'develop' into gsoc-table-develop
BabyElias Aug 15, 2024
21cc84d
code refactor
BabyElias Aug 16, 2024
350a13a
set tab to default
BabyElias Aug 16, 2024
fb60111
trial
BabyElias Aug 16, 2024
ea166d4
final navigation changes
BabyElias Aug 16, 2024
39657cf
allow default tab behaviour post table navigation
BabyElias Aug 18, 2024
6bae55c
Update docs/pages/ktable.vue
BabyElias Aug 20, 2024
aaa46f3
Update docs/pages/ktable.vue
BabyElias Aug 20, 2024
a2af97c
Update docs/pages/ktable.vue
BabyElias Aug 20, 2024
c374f59
Update docs/pages/ktable.vue
BabyElias Aug 20, 2024
b0b8a93
added data-focus="true"
BabyElias Aug 21, 2024
4e1c3b9
added docstring comments
BabyElias Aug 21, 2024
cb0d3ae
reorganised file structure
BabyElias Aug 21, 2024
109c7d3
updated test suite
BabyElias Aug 21, 2024
b66421f
updated comment
BabyElias Aug 21, 2024
4d59b0f
Merge branch 'develop' into gsoc-table-develop
BabyElias Aug 21, 2024
25487db
added comments
BabyElias Aug 21, 2024
71bd3ab
Merge branch 'gsoc-table-develop' of https://github.com/BabyElias/kol…
BabyElias Aug 21, 2024
f960a47
updated rtl
BabyElias Aug 21, 2024
c8140b0
Merge branch 'develop' into gsoc-table-develop
BabyElias Aug 21, 2024
3d3803a
updated documentation
BabyElias Aug 22, 2024
8854e84
code refactor
BabyElias Aug 23, 2024
ab9c4e3
Merge branch 'develop' into gsoc-table-develop
BabyElias Aug 23, 2024
1215d91
minor change
BabyElias Aug 23, 2024
e43678c
replaced queryselector with refs
BabyElias Aug 25, 2024
0b1b1dc
updated queryselector with refs
BabyElias Aug 25, 2024
e014237
Added height prop to the table
BabyElias Aug 25, 2024
5be11a5
added visuallyhidden class
BabyElias Aug 27, 2024
90558b5
updated height
BabyElias Aug 28, 2024
186ea35
Merge branch 'gsoc-table-develop' into main
BabyElias Aug 28, 2024
da2ec92
Merge pull request #4 from BabyElias/main
BabyElias Aug 28, 2024
34479c3
added emptymessage and updated documentation
BabyElias Aug 28, 2024
1208c1a
updated API specs
BabyElias Aug 29, 2024
8071b67
updated documentation
BabyElias Aug 29, 2024
5d49e23
Merge branch 'learningequality:develop' into main
BabyElias Aug 30, 2024
74e2230
Merge branch 'learningequality:develop' into main
BabyElias Aug 31, 2024
1c04d92
fixed failing test
BabyElias Aug 31, 2024
9fe5d2a
updated datatype of 'content'
BabyElias Aug 31, 2024
7764ef4
added dataLoading prop
BabyElias Sep 1, 2024
feeb34a
added refs to highlightHeader
BabyElias Sep 1, 2024
8119361
added more computed properties
BabyElias Sep 1, 2024
9a69cef
Merge branch 'learningequality:develop' into main
BabyElias Sep 5, 2024
4089e06
Merge pull request #5 from BabyElias/main
BabyElias Sep 5, 2024
a766e78
updated API and other changes
BabyElias Sep 5, 2024
0565bcd
changelog changes
BabyElias Sep 5, 2024
f39cd22
changelog changes
BabyElias Sep 5, 2024
eb923d2
Added header align same as content alignment
BabyElias Sep 5, 2024
34dcfbc
Cleaned up playground page
BabyElias Sep 5, 2024
90bd023
fixed linting errors
BabyElias Sep 5, 2024
d41aef2
changelog.md reverted
BabyElias Sep 7, 2024
7acfa97
passed textAlign to KTableGridItem
BabyElias Sep 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions custom-icons/sortColumn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 153 additions & 0 deletions docs/pages/ktable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<template>

<DocsPageTemplate apiDocs>
<DocsPageSection title="Overview" anchor="#overview">
<p>
The <code>KTable</code> component is an accessible and customizable table component designed to handle a variety of data presentation needs. The component is suitable for both simple and complex data tables. It offers:
<ul>
<li>Offers built-in sorting by default</li>
<li>Integrates with already sorted data</li>
<li>Keyboard navigation</li>
<li>Dynamic column resizing</li>
<li>Sticky headers</li>
</ul>
</p>
</DocsPageSection>
<DocsPageSection title="Usage" anchor="#usage">
<!--Non-Sortable Table-->
<h3>Table without sorting functionality</h3>
<p>
This is an example to show how <code>KTable</code> can be used without any sorting functionality, as a simple table. Use of slots is optional.
</p>
<!-- eslint-disable -->
<DocsShowCode language="html">
<KTable
:headers="headers"
:rows="rows"
caption="Non Sortable Table"
>

<template #header="{ header, colIndex }">
<span>{ header.label } (Backend)</span>
</template>
<template #cell="{ content, rowIndex, colIndex }">
<span v-if="colIndex === 2">{ content } (City)</span>
MisRob marked this conversation as resolved.
Show resolved Hide resolved
<span v-else>{ content }</span>
</template>
</KTable>

</DocsShowCode>

<DocsShowCode language="javascript">
data() {
return {
headers: [
{ label: 'Name', dataType: 'string' },
{ label: 'Age', dataType: 'number' },
{ label: 'City', dataType: 'string' },
],
rows: [
['John Doe', 28, 'New York'],
['Jane Smith', 34, 'Los Angeles'],
['Samuel Green', 22, 'Chicago'],
['Alice Johnson', 30, 'Houston'],
['Michael Brown', 45, 'Phoenix'],
['Emily Davis', 27, 'Philadelphia'],
]
};
},
</DocsShowCode>

<DocsShow block>
<KTable
:headers="headers"
:rows="rows"
caption="Non-sortable table"
>
<template #header="{ header, colIndex }">
<span>{{ header.label }} (Backend)</span>
</template>
<template #cell="{ content, rowIndex, colIndex }">
<span v-if="colIndex === 2">{{ content }} (City)</span>
<span v-else>{{ content }}</span>
</template>
</KTable>
</DocsShow>

<!-- Frontend Sorting Example-->
<h3>Table with Default Sorting</h3>
<p>
The <code>KTable</code> can be used with default sorting functionality, allowing you to sort data on the client side without the need for server requests. There are 4 permissible data types - <code>string</code>,<code>number</code>,<code>date</code> and <code>undefined</code>. Columns declared with <code>undefined</code> data type are not sortable. This example demonstrates a table with default sorting enabled.
</p>

<DocsShowCode language="html">
<KTable
:headers="headers"
:rows="rows"
caption="Table with built-in sorting"
sortable
/>

</DocsShowCode>

<DocsShowCode language="javascript">
data() {
return {
headers: [
{ label: 'Name', dataType: 'string' },
{ label: 'Age', dataType: 'number' },
{ label: 'City', dataType: 'string' },
],
rows: [
['John Doe', 28, 'New York'],
['Jane Smith', 34, 'Los Angeles'],
['Samuel Green', 22, 'Chicago'],
['Alice Johnson', 30, 'Houston'],
['Michael Brown', 45, 'Phoenix'],
['Emily Davis', 27, 'Philadelphia'],
]
};
},
</DocsShowCode>
<DocsShow block>
<KTable
:headers="headers"
:rows="rows"
caption="Local Sorting Table"
sortable
/>
<!-- eslint-enable -->
</DocsShow>

</DocsPageSection>


</DocsPageTemplate>

</template>


<script>

export default {
name: 'DocsKTable',
data() {
return {
headers: [
{ label: 'Name', dataType: 'string' },
{ label: 'Age', dataType: 'number' },
{ label: 'City', dataType: 'string' },
],
rows: [
['John Doe', 28, 'New York'],
['Jane Smith', 34, 'Los Angeles'],
['Samuel Green', 22, 'Chicago'],
['Alice Johnson', 30, 'Houston'],
['Michael Brown', 45, 'Phoenix'],
['Emily Davis', 27, 'Philadelphia'],
],
};
},
};

</script>
1 change: 1 addition & 0 deletions docs/rstIconReplacements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
.. |skillsResource| replace:: :raw-html:`<span class="design-system-icon"><svg role="presentation" focusable="false" width="24" height="24" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 28.75V35h6.25l18.433-18.45-6.25-6.25L5 28.75zm32.683 1.85L30.6 37.684l-8.667-8.667 2.95-2.95 1.667 1.667 4.117-4.134 2.366 2.367-2.433 2.367L32.367 30l2.366-2.333 2.95 2.933zM11.017 18.05l-8.7-8.65L9.4 2.317l2.933 2.95L8.217 9.4 10 11.167l4.1-4.133L16.467 9.4 14.1 11.75l1.667 1.667-4.75 4.633zm23.5-6.383c.65-.65.65-1.667 0-2.35l-3.9-3.833c-.617-.65-1.7-.65-2.35 0L25.2 8.534l6.25 6.25 3.067-3.117z"/></svg></span>`
.. |slideshow| replace:: :raw-html:`<span class="design-system-icon"><svg viewBox="0 0 24 24" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M22 16V4c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2zm-11-4l2.03 2.71L16 11l4 5H8l3-4zM2 6v14c0 1.1.9 2 2 2h14v-2H4V6H2z"/></svg></span>`
.. |socialSciencesResource| replace:: :raw-html:`<span class="design-system-icon"><svg viewBox="0 0 24 24" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M12 12.75c1.63 0 3.07.39 4.24.9 1.08.48 1.76 1.56 1.76 2.73V18H6v-1.61c0-1.18.68-2.26 1.76-2.73 1.17-.52 2.61-.91 4.24-.91zM4 13c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm1.13 1.1c-.37-.06-.74-.1-1.13-.1-.99 0-1.93.21-2.78.58A2.01 2.01 0 000 16.43V18h4.5v-1.61c0-.83.23-1.61.63-2.29zM20 13c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4 3.43c0-.81-.48-1.53-1.22-1.85A6.95 6.95 0 0020 14c-.39 0-.76.04-1.13.1.4.68.63 1.46.63 2.29V18H24v-1.57zM12 6c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3z"/></svg></span>`
.. |sortColumn| replace:: :raw-html:`<span class="design-system-icon"><svg viewBox="0 0 24 24" role="presentation" focusable="false" width="24" height="25" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.178 4.154l5.177 5.523H7l5.177-5.523zM12.177 20.654L7 15.13h10.354l-5.177 5.524z" fill="#000"/></svg></span>`
.. |sort| replace:: :raw-html:`<span class="design-system-icon"><svg viewBox="0 0 24 24" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M18 21l-4-4h3V7h-3l4-4 4 4h-3v10h3M2 19v-2h10v2M2 13v-2h7v2M2 7V5h4v2H2z"/></svg></span>`
.. |starBorder| replace:: :raw-html:`<span class="design-system-icon"><svg viewBox="0 0 24 24" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"/></svg></span>`
.. |star| replace:: :raw-html:`<span class="design-system-icon"><svg viewBox="0 0 24 24" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg></span>`
Expand Down
5 changes: 5 additions & 0 deletions docs/tableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ export default [
isCode: true,
keywords: ['button'],
}),
new Page({
path: '/ktable',
title: 'KTable',
isCode: true,
}),
new Page({
path: '/kgrid',
title: 'KGrid',
Expand Down
3 changes: 3 additions & 0 deletions lib/KIcon/iconDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const KolibriIcons = {
icon: require('./precompiled-icons/le/preview-unavailable.vue').default,
},
sort: { icon: require('./precompiled-icons/le/sort.vue').default },
sortColumn: {
icon: require('./precompiled-icons/le/sortColumn.vue').default,
},

// Features and links
learn: { icon: require('./precompiled-icons/material-icons/school/baseline.vue').default },
Expand Down
12 changes: 12 additions & 0 deletions lib/KIcon/precompiled-icons/le/sortColumn.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>

<svg viewBox="0 0 24 24" role="presentation" focusable="false" width="24" height="25" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.178 4.154l5.177 5.523H7l5.177-5.523zM12.177 20.654L7 15.13h10.354l-5.177 5.524z" fill="#000"/></svg>

</template>


<script>

export default {"name":"icon-804c4e229f501f72a23ba2f5a5cc42d5"}

</script>
85 changes: 85 additions & 0 deletions lib/KTable/KTableGridItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>

<td
:class="$computedClass(coreOutlineFocus)"
:style="{ textAlign: textAlign, minWidth: minWidth, width: width }"
tabindex="0"
data-focus="true"
role="gridcell"
BabyElias marked this conversation as resolved.
Show resolved Hide resolved
@keydown="onKeydown"
>
<slot :content="content">
{{ content }}
</slot>
</td>

</template>


<script>

export default {
name: 'KTableGridItem',
props: {
content: {
type: [String, Number, Boolean, Object, Array],
required: true,
},
rowIndex: {
type: Number,
required: true,
},
colIndex: {
type: Number,
required: true,
},
minWidth: {
type: String,
default: 'auto',
},
width: {
type: String,
default: 'auto',
},
textAlign: {
type: String,
required: true,
},
},
computed: {
coreOutlineFocus() {
return {
':focus': {
...this.$coreOutline,
outlineOffset: '-2px',
},
};
},
},
methods: {
onKeydown(event) {
BabyElias marked this conversation as resolved.
Show resolved Hide resolved
// Ensures that clickable elements within a table cell, such as buttons and links, can be clicked with ENTER key.
const focusedElement = event.target;
if (
event.key === 'Enter' &&
(focusedElement.tagName === 'BUTTON' || focusedElement.tagName === 'A')
) {
focusedElement.click();
} else {
this.$emit('keydown', event, this.rowIndex, this.colIndex);
}
},
},
};

</script>


<style scoped>
td {
word-wrap: break-word;
white-space: normal;
}


</style>
Loading