-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: gridInfoではなくnumMeasuresをinjectするようにする #2605
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,42 @@ | |
</template> | ||
|
||
<script setup lang="ts"> | ||
import { inject } from "vue"; | ||
import { gridInfoInjectionKey } from "./ScoreSequencer.vue"; | ||
import { computed, inject } from "vue"; | ||
import { getKeyBaseHeight, getNumKeys, tickToBaseX } from "@/sing/viewHelper"; | ||
import { useStore } from "@/store"; | ||
import { measureNumberToTick } from "@/sing/domain"; | ||
import { numMeasuresInjectionKey } from "@/components/Sing/ScoreSequencer.vue"; | ||
const injectedValue = inject(gridInfoInjectionKey); | ||
const injectedValue = inject(numMeasuresInjectionKey); | ||
if (injectedValue == undefined) { | ||
throw new Error("injectedValue is undefined."); | ||
} | ||
const { numMeasures } = injectedValue; | ||
const { gridWidth, gridHeight } = injectedValue; | ||
const store = useStore(); | ||
const tpqn = computed(() => store.state.tpqn); | ||
const timeSignatures = computed(() => store.state.timeSignatures); | ||
const zoomX = computed(() => store.state.sequencerZoomX); | ||
const zoomY = computed(() => store.state.sequencerZoomY); | ||
const endMeasureNumber = computed(() => numMeasures.value + 1); | ||
const endTicks = computed(() => { | ||
return measureNumberToTick( | ||
endMeasureNumber.value, | ||
timeSignatures.value, | ||
tpqn.value, | ||
); | ||
}); | ||
const gridWidth = computed(() => { | ||
return tickToBaseX(endTicks.value, tpqn.value) * zoomX.value; | ||
}); | ||
const gridHeight = computed(() => { | ||
return getKeyBaseHeight() * getNumKeys() * zoomY.value; | ||
}); | ||
Comment on lines
+25
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. コードがコピペになっているのが気になりました! ちなみにgridWidthを以前共通化を提案したときのコメントはこんな感じでした。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (まず前提として:Storybookでプロパティの値を変更しても データの流れ(依存関係)は 整理すると:
|
||
</script> | ||
|
||
<style scoped lang="scss"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ただのコメントです)
このコンポーネント今思ったらなくせそうですね!!
widhtとheight指定してdiv作ってるだけなので、ScoreSequencer.vue側でこんな感じで書けば良さそう?
あるいはコンポーネント化するにしても、
GridSpacer
ではなくただのSpacer
とできそうだな~と。