From cf7ae32b5c3cd4bc0965b9e07daac2268734d39d Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 22 Oct 2024 15:30:21 +0200 Subject: [PATCH 1/7] WIP root directory component --- .../lib/DirectoryPicker/DirectoryItem.svelte | 142 ++++++++++++++++ .../DirectoryPicker/DirectoryPicker.svelte | 49 ++++++ v2/pink-sb/src/lib/index.ts | 2 + v2/pink-sb/src/lib/selector/Radio.svelte | 11 +- .../stories/DirectoryPicker.stories.svelte | 151 ++++++++++++++++++ 5 files changed, 354 insertions(+), 1 deletion(-) create mode 100644 v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte create mode 100644 v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte create mode 100644 v2/pink-sb/src/stories/DirectoryPicker.stories.svelte diff --git a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte new file mode 100644 index 0000000000..0fa5103e54 --- /dev/null +++ b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte @@ -0,0 +1,142 @@ + + +
+ + {#if isExpanded} + {#each directory.subDirectories as subDirectory} + + {/each} + {/if} +
+ + diff --git a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte new file mode 100644 index 0000000000..5bb8e6d4a7 --- /dev/null +++ b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte @@ -0,0 +1,49 @@ + + +
+ {#if isLoading}
+ Loading directory data... +
{:else}{/if} +
+ + diff --git a/v2/pink-sb/src/lib/index.ts b/v2/pink-sb/src/lib/index.ts index 83c9dccff5..827b2a376c 100644 --- a/v2/pink-sb/src/lib/index.ts +++ b/v2/pink-sb/src/lib/index.ts @@ -18,6 +18,8 @@ export { default as ActionList } from './action-list/index.js'; export { default as Tooltip } from './Tooltip.svelte'; export { default as Dialog } from './Dialog.svelte'; export { default as Empty } from './Empty.svelte'; +export { default as DirectoryPicker } from './DirectoryPicker/DirectoryPicker.svelte'; +export { default as DirectoryItem } from './DirectoryPicker/DirectoryItem.svelte'; export { default as Keyboard } from './Keyboard.svelte'; export { default as Icon } from './Icon.svelte'; export { default as Pagination } from './Pagination.svelte'; diff --git a/v2/pink-sb/src/lib/selector/Radio.svelte b/v2/pink-sb/src/lib/selector/Radio.svelte index c6dcafe295..e73c83b414 100644 --- a/v2/pink-sb/src/lib/selector/Radio.svelte +++ b/v2/pink-sb/src/lib/selector/Radio.svelte @@ -15,10 +15,19 @@ export let size: $$Props['size'] = 'medium'; export let id: string | undefined = undefined; export let label: $$Props['label'] = undefined; + export let radioInput; - + From eef1a20b83fe5e17c3af4083113b77d7dc6fb733 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Wed, 23 Oct 2024 10:08:54 +0200 Subject: [PATCH 2/7] Typescript fixes --- .../src/lib/DirectoryPicker/DirectoryItem.svelte | 16 ++++++++++++---- .../lib/DirectoryPicker/DirectoryPicker.svelte | 15 ++++----------- v2/pink-sb/src/lib/DirectoryPicker/index.ts | 8 ++++++++ v2/pink-sb/src/lib/selector/Radio.svelte | 3 ++- 4 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 v2/pink-sb/src/lib/DirectoryPicker/index.ts diff --git a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte index 0fa5103e54..ff15aac1ec 100644 --- a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte +++ b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte @@ -1,16 +1,16 @@ From 355078282002486439c620cce63919b4a653c261 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Wed, 23 Oct 2024 13:26:28 +0200 Subject: [PATCH 3/7] Update to using melt --- pnpm-lock.yaml | 16 ++ v2/pink-sb/package.json | 9 +- .../lib/DirectoryPicker/DirectoryItem.svelte | 152 ++++++++++-------- .../DirectoryPicker/DirectoryPicker.svelte | 22 ++- v2/pink-sb/src/lib/DirectoryPicker/index.ts | 6 +- v2/pink-sb/svelte.config.js | 3 +- 6 files changed, 131 insertions(+), 77 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5a64134c09..f7b38be510 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: specifier: ^18.0.0 version: 18.3.1(react@18.3.1) devDependencies: + '@melt-ui/pp': + specifier: ^0.3.2 + version: 0.3.2(@melt-ui/svelte@0.83.0(svelte@4.2.18))(svelte@4.2.18) '@storybook/addon-a11y': specifier: ^8.2.9 version: 8.2.9(storybook@8.2.9(@babel/preset-env@7.25.3(@babel/core@7.25.2))) @@ -1366,6 +1369,12 @@ packages: '@types/react': '>=16' react: '>=16' + '@melt-ui/pp@0.3.2': + resolution: {integrity: sha512-xKkPvaIAFinklLXcQOpwZ8YSpqAFxykjWf8Y/fSJQwsixV/0rcFs07hJ49hJjPy5vItvw5Qa0uOjzFUbXzBypQ==} + peerDependencies: + '@melt-ui/svelte': '>= 0.29.0' + svelte: ^3.55.0 || ^4.0.0 || ^5.0.0-next.1 + '@melt-ui/svelte@0.83.0': resolution: {integrity: sha512-E7QT+8YSftz+Hdk1W0hNR3f+cnaF2COMWkStn+2u4vk0RO1I9mXRJl+bJD6uhYaH146oxEB+5elu/ABbv6rpsA==} peerDependencies: @@ -7174,6 +7183,13 @@ snapshots: '@types/react': 18.3.3 react: 18.3.1 + '@melt-ui/pp@0.3.2(@melt-ui/svelte@0.83.0(svelte@4.2.18))(svelte@4.2.18)': + dependencies: + '@melt-ui/svelte': 0.83.0(svelte@4.2.18) + estree-walker: 3.0.3 + magic-string: 0.30.11 + svelte: 4.2.18 + '@melt-ui/svelte@0.83.0(svelte@4.2.18)': dependencies: '@floating-ui/core': 1.6.7 diff --git a/v2/pink-sb/package.json b/v2/pink-sb/package.json index a96603c8d6..1dcb2da9cc 100644 --- a/v2/pink-sb/package.json +++ b/v2/pink-sb/package.json @@ -37,6 +37,7 @@ "svelte": "^4.0.0" }, "devDependencies": { + "@melt-ui/pp": "^0.3.2", "@storybook/addon-a11y": "^8.2.9", "@storybook/addon-essentials": "^8.2.9", "@storybook/addon-interactions": "^8.2.9", @@ -63,10 +64,13 @@ "eslint-plugin-svelte": "^2.43.0", "genauigkeit": "^0.0.36", "globals": "^15.9.0", + "node-gyp": "^10.2.0", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.6", "publint": "catalog:default", "sass": "^1.77.8", + "shiki": "^1.18.0", + "sourcemap-codec": "^1.4.8", "storybook": "^8.2.9", "svelte": "catalog:default", "svelte-check": "^3.8.5", @@ -74,10 +78,7 @@ "tslib": "^2.6.3", "typescript": "^5.5.4", "typescript-eslint": "^8.0.1", - "vite": "^5.4.0", - "node-gyp": "^10.2.0", - "shiki": "^1.18.0", - "sourcemap-codec": "^1.4.8" + "vite": "^5.4.0" }, "svelte": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte index ff15aac1ec..a10ac1a05a 100644 --- a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte +++ b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte @@ -1,80 +1,101 @@ -
- + + {#if children} +
+
-
-
- {#if thumbnailLoading} - - {/if} - - {#if thumbnailError} -
- {:else} - Directory thumbnail - {/if} -
- - {#if isExpanded} - {#each directory.subDirectories as subDirectory} - - {/each} - {/if} -
+ {/if} + +{/each} From 0ddbb7a486ee71c6a7f2575257418ddbbd6e17e8 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Wed, 23 Oct 2024 13:55:01 +0200 Subject: [PATCH 5/7] Better responsiveness --- .../lib/DirectoryPicker/DirectoryItem.svelte | 22 +++++++++++++++++-- .../DirectoryPicker/DirectoryPicker.svelte | 8 +++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte index a10ac1a05a..aedafe0dfe 100644 --- a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte +++ b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryItem.svelte @@ -8,6 +8,7 @@ export let directories: Directory[]; export let level = 0; + export let containerWidth: number | undefined; let radioInputs: HTMLInputElement[] = []; let thumbnailStates = directories.map(() => ({ @@ -65,7 +66,11 @@
- {title} + {title} ({fileCount} files)
@@ -91,7 +96,7 @@ {#if children}
- +
{/if} @@ -125,6 +130,7 @@ transition: transform ease-in-out 0.1s; margin-left: 8px; margin-right: 4px; + flex-shrink: 0; } .folder-open { transform: rotate(90deg); @@ -138,8 +144,20 @@ gap: var(--space-2, 4px); } + .title { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + flex-grow: 0; + } + .fileCount { color: var(--color-fgColor-neutral-tertiary, #97979b); + display: none; + + @media (min-width: 1024px) { + display: block; + } } .hidden { diff --git a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte index 78322f3379..04870e571e 100644 --- a/v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte +++ b/v2/pink-sb/src/lib/DirectoryPicker/DirectoryPicker.svelte @@ -17,12 +17,16 @@ export let directories: Directory[]; export let isLoading = true; + let rootContainer: HTMLDivElement; + let containerWidth: number | undefined; + + $: containerWidth = rootContainer ? rootContainer.getBoundingClientRect().width : undefined; -
+
{#if isLoading}
Loading directory data... -
{:else}{/if} +
{:else}{/if}