forked from n8n-io/n8n
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add sticky notes support to the new canvas (no-changelog) (n8n-…
- Loading branch information
1 parent
9302e33
commit cd24c71
Showing
32 changed files
with
653 additions
and
147 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
packages/design-system/src/components/N8nResizeableSticky/ResizeableSticky.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { action } from '@storybook/addon-actions'; | ||
import type { StoryFn } from '@storybook/vue3'; | ||
import N8nResizeableSticky from './ResizeableSticky.vue'; | ||
|
||
export default { | ||
title: 'Atoms/ResizeableSticky', | ||
component: N8nResizeableSticky, | ||
argTypes: { | ||
content: { | ||
control: { | ||
control: 'text', | ||
}, | ||
}, | ||
height: { | ||
control: { | ||
control: 'number', | ||
}, | ||
}, | ||
minHeight: { | ||
control: { | ||
control: 'number', | ||
}, | ||
}, | ||
minWidth: { | ||
control: { | ||
control: 'number', | ||
}, | ||
}, | ||
readOnly: { | ||
control: { | ||
control: 'Boolean', | ||
}, | ||
}, | ||
width: { | ||
control: { | ||
control: 'number', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const methods = { | ||
onInput: action('update:modelValue'), | ||
onResize: action('resize'), | ||
onResizeEnd: action('resizeend'), | ||
onResizeStart: action('resizestart'), | ||
}; | ||
|
||
const Template: StoryFn = (args, { argTypes }) => ({ | ||
setup: () => ({ args }), | ||
props: Object.keys(argTypes), | ||
components: { | ||
N8nResizeableSticky, | ||
}, | ||
template: | ||
'<n8n-resizeable-sticky v-bind="args" @resize="onResize" @resizeend="onResizeEnd" @resizeStart="onResizeStart" @input="onInput"></n8n-resizeable-sticky>', | ||
methods, | ||
}); | ||
|
||
export const ResizeableSticky = Template.bind({}); | ||
ResizeableSticky.args = { | ||
height: 160, | ||
width: 150, | ||
modelValue: | ||
"## I'm a note \n**Double click** to edit me. [Guide](https://docs.n8n.io/workflows/sticky-notes/)", | ||
minHeight: 80, | ||
minWidth: 150, | ||
readOnly: false, | ||
}; |
61 changes: 61 additions & 0 deletions
61
packages/design-system/src/components/N8nResizeableSticky/ResizeableSticky.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<N8nResizeWrapper | ||
:is-resizing-enabled="!readOnly" | ||
:height="height" | ||
:width="width" | ||
:min-height="minHeight" | ||
:min-width="minWidth" | ||
:scale="scale" | ||
:grid-size="gridSize" | ||
@resizeend="onResizeEnd" | ||
@resize="onResize" | ||
@resizestart="onResizeStart" | ||
> | ||
<N8nSticky v-bind="stickyBindings" /> | ||
</N8nResizeWrapper> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, ref, useAttrs } from 'vue'; | ||
import N8nResizeWrapper, { type ResizeData } from '../N8nResizeWrapper/ResizeWrapper.vue'; | ||
import N8nSticky from '../N8nSticky/Sticky.vue'; | ||
import type { StickyProps } from '../N8nSticky/types'; | ||
import { defaultStickyProps } from '../N8nSticky/constants'; | ||
type ResizeableStickyProps = StickyProps & { | ||
scale?: number; | ||
gridSize?: number; | ||
}; | ||
const props = withDefaults(defineProps<ResizeableStickyProps>(), { | ||
...defaultStickyProps, | ||
scale: 1, | ||
gridSize: 20, | ||
}); | ||
const emit = defineEmits<{ | ||
resize: [values: ResizeData]; | ||
resizestart: []; | ||
resizeend: []; | ||
}>(); | ||
const attrs = useAttrs(); | ||
const stickyBindings = computed(() => ({ ...props, ...attrs })); | ||
const isResizing = ref(false); | ||
const onResize = (values: ResizeData) => { | ||
emit('resize', values); | ||
}; | ||
const onResizeStart = () => { | ||
isResizing.value = true; | ||
emit('resizestart'); | ||
}; | ||
const onResizeEnd = () => { | ||
isResizing.value = false; | ||
emit('resizeend'); | ||
}; | ||
</script> |
3 changes: 3 additions & 0 deletions
3
packages/design-system/src/components/N8nResizeableSticky/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ResizeableSticky from './ResizeableSticky.vue'; | ||
|
||
export default ResizeableSticky; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/design-system/src/components/N8nSticky/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const defaultStickyProps = { | ||
height: 180, | ||
width: 240, | ||
minHeight: 80, | ||
minWidth: 150, | ||
id: '0', | ||
editMode: false, | ||
readOnly: false, | ||
backgroundColor: 1, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export interface StickyProps { | ||
modelValue?: string; | ||
height?: number; | ||
width?: number; | ||
minHeight?: number; | ||
minWidth?: number; | ||
id?: string; | ||
defaultText?: string; | ||
editMode?: boolean; | ||
readOnly?: boolean; | ||
backgroundColor?: number | string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.