From cc76ffb2d21c613ee2139081d42ba1a712b3c34e Mon Sep 17 00:00:00 2001
From: Julian Roeland
Date: Thu, 23 May 2024 14:48:05 +0200
Subject: [PATCH 1/6] :sparkles: #17 - feat: improved kanban
---
src/components/data/kanban/kanban.scss | 51 +-
src/components/data/kanban/kanban.tsx | 572 +++++-------------
src/style/tokens/base.scss | 1 +
src/templates/index.ts | 1 +
src/templates/kanban-template/index.ts | 1 +
.../kanban-template.stories.tsx} | 74 +--
.../kanban-template/kanban-template.tsx | 26 +
src/templates/kanban/index.ts | 1 -
src/templates/kanban/kanban.tsx | 47 --
9 files changed, 250 insertions(+), 524 deletions(-)
create mode 100644 src/templates/kanban-template/index.ts
rename src/templates/{kanban/kanban.stories.tsx => kanban-template/kanban-template.stories.tsx} (68%)
create mode 100644 src/templates/kanban-template/kanban-template.tsx
delete mode 100644 src/templates/kanban/index.ts
delete mode 100644 src/templates/kanban/kanban.tsx
diff --git a/src/components/data/kanban/kanban.scss b/src/components/data/kanban/kanban.scss
index f908c7e6..e566aaab 100644
--- a/src/components/data/kanban/kanban.scss
+++ b/src/components/data/kanban/kanban.scss
@@ -12,25 +12,29 @@
height: 100%;
}
- &__body .mykn-column {
+ &__count {
+ margin-left: var(--spacing-h);
+ border-radius: 10px;
border: 1px solid var(--typography-color-border);
- overflow-y: auto;
+ background-color: #fafafa;
+ padding: 0 6px;
+ color: var(--typography-color-muted);
}
- &__body .mykn-column:before {
- background-color: var(--typography-color-border);
- opacity: 0.1;
- content: "";
- height: 100%;
- position: absolute;
- width: 100%;
+ &__body .mykn-column {
+ border: 1px solid var(--typography-color-border);
+ border-radius: var(--border-radius-l);
+ background-color: var(--page-color-background-alt);
+ overflow-y: auto;
+ overflow-x: hidden;
+ padding: 18px 16px;
}
&__body &__drop-indicator {
background-color: var(--page-color-accent);
border: 1px dashed var(--page-color-primary);
box-sizing: content-box;
- height: calc(var(--typography-line-height-body-s) * 2);
+ height: calc(var(--typography-line-height-body-s) * 3);
padding-block: var(--spacing-v);
}
@@ -39,27 +43,24 @@
border-style: dashed;
}
- &__body .mykn-column > .mykn-h3 {
- position: sticky;
- top: 0;
- z-index: 10;
- }
-
&__body .mykn-column > .mykn-button {
+ border: 1px solid var(--typography-color-border);
+ border-radius: var(--border-radius-l);
white-space: normal;
+ background-color: var(--typography-color-background);
+ padding: 16px;
&:focus-within {
z-index: 100;
}
}
- &__body &__preview {
- display: flex;
- flex-shrink: 0;
- height: calc(var(--typography-line-height-body-s) * 2);
- justify-content: center;
- overflow: hidden;
- width: calc(var(--typography-line-height-body-s) * 2);
+ &__body .mykn-column > .mykn-button:hover,
+ &__body .mykn-column > .mykn-button:focus {
+ border: 1px solid var(--page-color-primary);
+ scale: 100%;
+ box-shadow: unset;
+ background-color: var(--typography-color-background-alt);
}
&__body .mykn-column > .mykn-button > .mykn-select {
@@ -80,4 +81,8 @@
visibility: visible;
}
}
+
+ &__item {
+ width: 100%;
+ }
}
diff --git a/src/components/data/kanban/kanban.tsx b/src/components/data/kanban/kanban.tsx
index 5fe5ddd4..928a2c7f 100644
--- a/src/components/data/kanban/kanban.tsx
+++ b/src/components/data/kanban/kanban.tsx
@@ -1,127 +1,72 @@
import React, { useEffect, useState } from "react";
-import {
- AttributeData,
- DEFAULT_URL_FIELDS,
- FieldSet,
- field2Title,
- formatMessage,
- useIntl,
-} from "../../../lib";
-import {
- GroupedAttributeDataProps,
- getContextData,
-} from "../../../lib/data/groupedattributedata";
-import { Button, ButtonLink, ButtonLinkProps, ButtonProps } from "../../button";
+import { Button, ButtonProps } from "../../button";
import { Select } from "../../form";
import { Column, Grid } from "../../layout";
-import { Body, H1, H2, H3, P } from "../../typography";
+import { Body, H2, H3 } from "../../typography";
import "./kanban.scss";
-export type KanbanProps = GroupedAttributeDataProps & {
- /** If set, items are `draggable` allowing the user to rearrange them (across) columns). */
+export type KanbanProps = {
+ /** If set, items are `draggable` allowing the user to rearrange them (across columns). */
draggable?: boolean;
- /** The kanban "change column" (accessible) label */
+ /** The kanban-template "change column" (accessible) label */
labelSelectColumn?: string;
- /** The kanban "move object position" (accessible) label. */
+ /** The kanban-template "move object position" (accessible) label. */
labelMoveObject?: string;
- /** Get called when the fieldsets change. */
- onFieldsetsChange?: (fieldsets: FieldSet[]) => void;
+ /** Get called when the componentList changes. */
+ onComponentListChange?: (componentList: KanbanColumn[]) => void;
- /** Get called when the objectLists change. */
- onObjectListsChange?: (objectLists: AttributeData[][]) => void;
+ /** The new componentList prop defining columns and their items */
+ componentList: KanbanColumn[];
- /** Get called when an object is dropped onto a column. */
- onObjectChange?: (
- object: AttributeData,
- sourceColumnIndex: number,
- targetColumnIndex: number,
- sourceObjectIndex: number,
- targetObjectIndex: number,
- ) => void;
+ /** The title of the kanban */
+ title?: string;
+};
+
+export type KanbanColumn = {
+ title: string;
+ items: React.ReactNode[];
};
export type KanbanDragData = {
sourceColumnIndex: number;
sourceObjectIndex: number;
- object: AttributeData;
};
-/**
- * Kanban component, shows item over various columns. Items can be made `draggable` allowing the user to rearrange them
- * (across columns).
- */
export const Kanban: React.FC = ({
- buttonProps,
- buttonLinkProps,
+ componentList,
draggable = false,
- fieldset,
- fieldsets,
- groupBy,
labelSelectColumn,
labelMoveObject,
- objectList,
- objectLists,
- renderPreview,
+ onComponentListChange,
title,
- urlFields = DEFAULT_URL_FIELDS,
- onClick,
- onFieldsetsChange,
- onObjectListsChange,
- onObjectChange,
...props
}) => {
const [dragIndexState, setDragIndexState] = useState<[number, number] | null>(
null,
);
- const [fieldsetsState, setFieldsetsState] = useState
-
- {fieldsetsState.map((fieldset, index) => (
-
- ))}
+
+ {componentListState.map((column, columnIndex) => {
+ const count = column.items.length;
+ return (
+
+
+
+ {column.title}
+
{count}
+
+
+
+
+ );
+ })}