From 53882bc5b056a6809470f5f04064efd9cb3fa4e6 Mon Sep 17 00:00:00 2001 From: Simon Hammer <77269703+shft5410@users.noreply.github.com> Date: Fri, 29 Dec 2023 17:12:59 +0100 Subject: [PATCH 1/2] Add option to set fixed window width --- package.json | 6 ++++++ src/extension.js | 1 + webview/src/index.js | 4 +++- webview/style.css | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5f63377..f60b44b 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,12 @@ "default": "#abb8c3", "description": "The background color of the snippet's container" }, + "codesnap.fixedWidth": { + "scope": "resource", + "type": "string", + "default": "", + "description": "The width of the container for the snippet (Leave blank for dynamic width)" + }, "codesnap.boxShadow": { "scope": "resource", "type": "string", diff --git a/src/extension.js b/src/extension.js index 6f31aa4..88095a9 100644 --- a/src/extension.js +++ b/src/extension.js @@ -12,6 +12,7 @@ const getConfig = () => { const extensionSettings = getSettings('codesnap', [ 'backgroundColor', + 'fixedWidth', 'boxShadow', 'containerPadding', 'roundedCorners', diff --git a/webview/src/index.js b/webview/src/index.js index b0777e1..b02e7be 100644 --- a/webview/src/index.js +++ b/webview/src/index.js @@ -28,7 +28,8 @@ window.addEventListener('message', ({ data: { type, ...cfg } }) => { roundedCorners, showWindowControls, showWindowTitle, - windowTitle + windowTitle, + fixedWidth } = config; setVar('ligatures', fontLigatures ? 'normal' : 'none'); @@ -38,6 +39,7 @@ window.addEventListener('message', ({ data: { type, ...cfg } }) => { setVar('box-shadow', boxShadow); setVar('container-padding', containerPadding); setVar('window-border-radius', roundedCorners ? '4px' : 0); + if (fixedWidth) setVar('window-width', fixedWidth); navbarNode.hidden = !showWindowControls && !showWindowTitle; windowControlsNode.hidden = !showWindowControls; diff --git a/webview/style.css b/webview/style.css index 310640e..c6536cc 100644 --- a/webview/style.css +++ b/webview/style.css @@ -6,6 +6,7 @@ html { --box-shadow: rgba(0, 0, 0, 0.55) 0px 20px 68px; --container-padding: 3em; --window-border-radius: 4px; + --window-width: max-content; box-sizing: border-box; } body { @@ -38,7 +39,7 @@ body { box-shadow: var(--box-shadow); overflow: hidden; resize: horizontal; - width: max-content; + width: var(--window-width); min-width: 100px; padding: 18px; background-color: var(--vscode-editor-background); From 8c307dfed493c849306fe92f564f2338e589c64a Mon Sep 17 00:00:00 2001 From: Simon Hammer <77269703+shft5410@users.noreply.github.com> Date: Fri, 29 Dec 2023 17:16:29 +0100 Subject: [PATCH 2/2] Update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 42be996..13384ee 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ CodeSnap is highly configurable. Here's a list of settings you can change to tun **`codesnap.backgroundColor`:** The background color of the snippet's container. Can be any valid CSS color. +**`codesnap.fixedWidth`:** The width of the container for the snippet. Can be any valid CSS width. + **`codesnap.boxShadow`:** The CSS box-shadow for the snippet. Can be any valid CSS box shadow. **`codesnap.containerPadding`:** The padding for the snippet's container. Can be any valid CSS padding.