Skip to content

Commit

Permalink
feat: dashkit groups (#150)
Browse files Browse the repository at this point in the history
* feat: dashkit groups

* fix: types

* chore: clean up code

* feat: groups render props

* feat: preview fixes

* fix: empty groups render

* fix: dashkit height calculation for empty grid

* fix: review typo
  • Loading branch information
flops authored Jun 28, 2024
1 parent dceef5f commit 641f008
Show file tree
Hide file tree
Showing 16 changed files with 534 additions and 72 deletions.
57 changes: 41 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
"prepublishOnly": "npm run lint && npm run test && npm run build"
},
"dependencies": {
"@gravity-ui/icons": "^2.8.1",
"@bem-react/classname": "^1.6.0",
"@gravity-ui/icons": "^2.8.1",
"hashids": "^2.2.8",
"immutability-helper": "^3.1.1",
"prop-types": "^15.8.1",
"react-grid-layout": "^1.3.4",
"react-grid-layout": "^1.4.4",
"react-transition-group": "^4.4.5"
},
"peerDependencies": {
Expand All @@ -90,7 +90,7 @@
"@types/jest": "^26.0.20",
"@types/lodash": "^4.14.170",
"@types/react": "^18.0.27",
"@types/react-grid-layout": "^1.3.2",
"@types/react-grid-layout": "^1.3.5",
"babel-jest": "^26.6.3",
"copyfiles": "^2.4.1",
"enzyme": "^3.11.0",
Expand Down
17 changes: 8 additions & 9 deletions src/components/DashKit/DashKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
import {
AddConfigItem,
ContextProps,
DashKitGroup,
Plugin,
SetConfigItem,
SetNewItemOptions,
Expand All @@ -33,7 +34,11 @@ interface DashKitGeneralProps {

interface DashKitDefaultProps {
onItemEdit: (item: ConfigItem) => void;
onChange: (data: {config: Config; itemsStateAndParams: ItemsStateAndParams}) => void;
onChange: (data: {
config: Config;
itemsStateAndParams: ItemsStateAndParams;
groups?: DashKitGroup[];
}) => void;
onDrop: (dropProps: ItemDropProps) => void;
defaultGlobalParams: GlobalParams;
globalParams: GlobalParams;
Expand All @@ -42,6 +47,7 @@ interface DashKitDefaultProps {
context: ContextProps;
noOverlay: boolean;
focusable?: boolean;
groups?: DashKitGroup[];
}

export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {}
Expand Down Expand Up @@ -123,14 +129,7 @@ export class DashKit extends React.PureComponent<DashKitInnerProps> {
metaRef = React.createRef<GridLayout>();

render() {
return (
<DashKitView
// @ts-ignore
registerManager={registerManager}
ref={this.metaRef}
{...this.props}
/>
);
return <DashKitView registerManager={registerManager} ref={this.metaRef} {...this.props} />;
}

getItemsMeta() {
Expand Down
4 changes: 4 additions & 0 deletions src/components/DashKit/__stories__/DashKit.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {DashKit, DashKitProps} from '../DashKit';

import {CssApiShowcase} from './CssApiShowcase';
import {DashKitDnDShowcase} from './DashKitDnDShowcase';
import {DashKitGroupsShowcase} from './DashKitGroupsShowcase';
import {DashKitShowcase} from './DashKitShowcase';
import {getConfig} from './utils';

Expand Down Expand Up @@ -81,3 +82,6 @@ export const CSS_API = CssApiShowcaseTemplate.bind({});

const DndShowcaseTemplate: Story<DashKitProps> = () => <DashKitDnDShowcase />;
export const DragNDrop = DndShowcaseTemplate.bind({});

const GroupsShowcaseTemplate: Story<DashKitProps> = () => <DashKitGroupsShowcase />;
export const Groups = GroupsShowcaseTemplate.bind({});
Loading

0 comments on commit 641f008

Please sign in to comment.