Skip to content

Commit

Permalink
feat(demo-app): Add data grid example in the demo-app (#2487)
Browse files Browse the repository at this point in the history
<!-- Is your PR related to an issue? Then please link it via the
"Relates to #" below. Else, remove it. -->

Relates to #2293 

- Add example in the demo-app
  • Loading branch information
MajaZarkova authored Jan 14, 2025
1 parent 88c5b23 commit b01a711
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
49 changes: 45 additions & 4 deletions apps/demo-app/src/views/DataGridView.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<script setup lang="ts">
import { DataGridFeatures, OnyxDataGrid, OnyxHeadline, OnyxPageLayout, OnyxSwitch } from "sit-onyx";
import { computed, ref } from "vue";
import sort from "@sit-onyx/icons/sort.svg?raw";
import {
DataGridFeatures,
OnyxDataGrid,
OnyxHeadline,
OnyxMenuItem,
OnyxPageLayout,
OnyxSwitch,
OnyxSystemButton,
createFeature,
} from "sit-onyx";
import { computed, h, ref } from "vue";
const sortingEnabled = ref(false);
const moreActions = ref(false);
const data = [
{ id: 1, name: "John Doe", age: 30 },
Expand All @@ -12,11 +23,40 @@ const data = [
{ id: 5, name: "Asperiks Kafelon", age: 99 },
];
const features = computed(() => {
const dummyFeature = createFeature(() => ({
name: Symbol("More actions"),
watch: [],
header: {
actions: () => [
{
iconComponent: h(OnyxSystemButton, {
label: "Column options",
icon: sort,
color: "medium",
}),
menuItems: [h(OnyxMenuItem, () => "Pin column"), h(OnyxMenuItem, () => "Unpin column")],
},
{
iconComponent: h(OnyxSystemButton, {
label: "Column options",
icon: sort,
color: "medium",
}),
menuItems: [h(OnyxMenuItem, () => "Remove column")],
},
],
},
}));
const dataFeatures = computed(() => {
const enabled = [];
if (sortingEnabled.value) {
enabled.push(DataGridFeatures.useSorting());
}
if (moreActions.value) {
enabled.push(dummyFeature());
}
return enabled;
});
</script>
Expand All @@ -27,8 +67,9 @@ const features = computed(() => {
<OnyxHeadline is="h1">Data-Grid example</OnyxHeadline>
<section class="data-grid-settings">
<OnyxSwitch v-model="sortingEnabled" label="Enable sorting" />
<OnyxSwitch v-model="moreActions" label="Enable more actions" />
</section>
<OnyxDataGrid :features :data :columns="['name', 'age']" />
<OnyxDataGrid :features="dataFeatures" :data :columns="['name', 'age']" />
</div>
</OnyxPageLayout>
</template>
Expand Down
1 change: 1 addition & 0 deletions packages/sit-onyx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export { default as OnyxDataGrid } from "./components/OnyxDataGrid/OnyxDataGrid.
export * from "./components/OnyxDataGrid/types";

export * as DataGridFeatures from "./components/OnyxDataGrid/features/all";
export * from "./components/OnyxDataGrid/features/index.ts";

export { default as OnyxDatePicker } from "./components/OnyxDatePicker/OnyxDatePicker.vue";
export * from "./components/OnyxDatePicker/types";
Expand Down

0 comments on commit b01a711

Please sign in to comment.