From 1914a801141ad55bd2363b2643cce915ed5ec255 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 8 Aug 2024 12:50:42 -0400 Subject: [PATCH] Add slider for allowed gappyness --- lib/src/components/dialogs/SettingsDialog.tsx | 19 +++++++++++++++ lib/src/model.ts | 23 ++++++++++++++++++- yarn.lock | 18 +++++++-------- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/lib/src/components/dialogs/SettingsDialog.tsx b/lib/src/components/dialogs/SettingsDialog.tsx index 758f1a48..a2b1fdb1 100644 --- a/lib/src/components/dialogs/SettingsDialog.tsx +++ b/lib/src/components/dialogs/SettingsDialog.tsx @@ -119,8 +119,10 @@ const MSASettings = observer(function MSASettings({ bgColor, contrastLettering, colWidth, + allowedGappyness, drawMsaLetters, colorSchemeName, + hideGaps, rowHeight, } = model @@ -142,6 +144,11 @@ const MSASettings = observer(function MSASettings({ onChange={() => model.setContrastLettering(!contrastLettering)} label="Use contrast lettering" /> + model.setHideGaps(!hideGaps)} + label={`Hide columns that are ${100 - allowedGappyness}% gaps`} + />
Column width ({colWidth}px) @@ -163,6 +170,18 @@ const MSASettings = observer(function MSASettings({ onChange={(_, val) => model.setRowHeight(val as number)} />
+ {hideGaps ? ( +
+ Allowed gappyness ({100 - allowedGappyness}%) + model.setAllowedGappyness(val as number)} + /> +
+ ) : null} , })) .actions(self => ({ + /** + * #action + */ + setHideGaps(arg: boolean) { + self.hideGaps = arg + }, + /** + * #action + */ + setAllowedGappyness(arg: number) { + self.allowedGappyness = arg + }, /** * #action */ @@ -669,6 +689,7 @@ function stateModelFactory() { * #getter */ get blanks() { + const { allowedGappyness } = self const blanks = [] const strs = this.leaves .map(leaf => this.MSA?.getRow(leaf.data.name)) @@ -681,7 +702,7 @@ function stateModelFactory() { counter++ } } - if (counter === strs.length) { + if (counter / strs.length >= allowedGappyness / 100) { blanks.push(i) } } diff --git a/yarn.lock b/yarn.lock index cb005be1..a0bc79f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1535,9 +1535,9 @@ callsites@^3.0.0: integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== caniuse-lite@^1.0.30001646: - version "1.0.30001650" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001650.tgz#dd1eba0938e39536d184c3c99b2569a13788bc16" - integrity sha512-fgEc7hP/LB7iicdXHUI9VsBsMZmUmlVJeQP2qqQW+3lkqVhbmjEU8zp+h5stWeilX+G7uXuIUIIlWlDw9jdt8g== + version "1.0.30001651" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz#52de59529e8b02b1aedcaaf5c05d9e23c0c28138" + integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg== canvas-sequencer@^3.1.0: version "3.1.0" @@ -2291,9 +2291,9 @@ for-each@^0.3.3: is-callable "^1.1.3" foreground-child@^3.1.0: - version "3.2.1" - resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.2.1.tgz#767004ccf3a5b30df39bed90718bab43fe0a59f7" - integrity sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA== + version "3.3.0" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.3.0.tgz#0ac8644c06e431439f8561db8ecf29a7b5519c77" + integrity sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg== dependencies: cross-spawn "^7.0.0" signal-exit "^4.0.1" @@ -3909,9 +3909,9 @@ synckit@^0.9.1: tslib "^2.6.2" terser@^5.17.4: - version "5.31.4" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.31.4.tgz#60274c4d3e20eb9a6468526a8878aba8e8428c5f" - integrity sha512-3OU03GgblDgu0g+sdnsVzhBPxnjV+WJuMmocN1qBBZDQ3ia7jZQSAkePeKbPlYAejGXUTYe1CmSaUeV51mvaIw== + version "5.31.5" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.31.5.tgz#e48b7c65f32d2808e7dad803e4586a0bc3829b87" + integrity sha512-YPmas0L0rE1UyLL/llTWA0SiDOqIcAQYLeUj7cJYzXHlRTAnMSg9pPe4VJ5PlKvTrPQsdVFuiRiwyeNlYgwh2Q== dependencies: "@jridgewell/source-map" "^0.3.3" acorn "^8.8.2"