Skip to content

Commit 36fae4f

Browse files
committed
feat(editor): simpler node numbers
1 parent 387990d commit 36fae4f

11 files changed

Lines changed: 143 additions & 24 deletions

packages/editor/src/__mock__/project/simple-project.ts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,47 @@ import type { Project } from '#model'
33
export const simpleProjectMock: Project = {
44
synthTree: {
55
nodes: {
6-
out: {
6+
output: {
77
type: 'output',
88
position: { x: 0, y: 0 },
99
params: {},
1010
color: 'zinc',
1111
number: 0,
1212
},
13-
gen: {
13+
generator: {
1414
type: 'generator',
15-
position: { x: -200, y: 0 },
15+
position: { x: -200, y: -50 },
1616
params: { waveShape: 'sawtooth', release: 1 },
1717
color: 'emerald',
1818
number: 1,
1919
},
20+
oscillator: {
21+
type: 'oscillator',
22+
position: { x: -400, y: 0 },
23+
params: {},
24+
color: 'yellow',
25+
number: 2,
26+
},
27+
reverb: {
28+
type: 'reverb',
29+
position: { x: -200, y: 50 },
30+
params: {},
31+
color: 'orange',
32+
number: 3,
33+
},
2034
},
2135
edges: {
2236
main: {
23-
source: { node: 'gen', socket: 0 },
24-
target: { node: 'out', socket: 0 },
37+
source: { node: 'generator', socket: 0 },
38+
target: { node: 'output', socket: 0 },
39+
},
40+
oscToReverb: {
41+
source: { node: 'oscillator', socket: 0 },
42+
target: { node: 'reverb', socket: 0 },
43+
},
44+
reverbToOutput: {
45+
source: { node: 'reverb', socket: 0 },
46+
target: { node: 'output', socket: 0 },
2547
},
2648
},
2749
},
@@ -30,10 +52,10 @@ export const simpleProjectMock: Project = {
3052
beatsPerMinute: 125,
3153
endingNote: 2,
3254
notes: {
33-
'note-1': { synth: 'gen', pitch: 'c4', time: 0, duration: 0.25 },
34-
'note-2': { synth: 'gen', pitch: 'e4', time: 0.25, duration: 0.25 },
35-
'note-3': { synth: 'gen', pitch: 'd4', time: 0.5, duration: 0.25 },
36-
'note-4': { synth: 'gen', pitch: 'f4', time: 0.75, duration: 0.25 },
55+
'note-1': { synth: 'generator', pitch: 'c4', time: 0, duration: 0.25 },
56+
'note-2': { synth: 'generator', pitch: 'e4', time: 0.25, duration: 0.25 },
57+
'note-3': { synth: 'generator', pitch: 'd4', time: 0.5, duration: 0.25 },
58+
'note-4': { synth: 'generator', pitch: 'f4', time: 0.75, duration: 0.25 },
3759
},
3860
},
3961
}

packages/editor/src/components/node-tile/node-tile.stories.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { Meta, StoryObj } from '@storybook/react'
22
import { allSettled, fork } from 'effector'
33
import type { ComponentProps } from 'react'
4-
import { mockRunningAudioContext } from '#__mock__/audio-context'
54
import { simpleProjectMock } from '#__mock__/project'
65
import { EditorScope } from '#components/editor'
76
import { editorModel } from '#model'
@@ -12,7 +11,6 @@ type StoryArgs = ComponentProps<typeof NodeTile>
1211
export default {
1312
title: 'tiles/Node',
1413
component: NodeTile,
15-
beforeEach: () => mockRunningAudioContext(),
1614
decorators: [
1715
(Story, { parameters: { scope } }) => (
1816
<EditorScope scope={scope}>
@@ -64,7 +62,7 @@ export const Selected: Story = {
6462
params: [
6563
{
6664
action: 'synth-node-select',
67-
id: 'gen',
65+
id: 'generator',
6866
selected: true,
6967
},
7068
],
@@ -91,7 +89,7 @@ export const Readonly: Story = {
9189
params: [
9290
{
9391
action: 'synth-node-select',
94-
id: 'gen',
92+
id: 'generator',
9593
selected: true,
9694
},
9795
],
23.8 KB
Loading
23.2 KB
Loading
24.1 KB
Loading
23.8 KB
Loading
24.6 KB
Loading
24.2 KB
Loading

packages/editor/src/components/synth-tree-tile/synth-tree-flow-nodes.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,15 @@ const SynthFlowNodeComponent: FC<NodeProps<SynthFlowNode>> = props => {
4949
<>
5050
<div
5151
className={cn(
52-
'-top-[1rlh] pointer-events-none absolute left-1 transition-all ease-out',
53-
selected && '-translate-y-1',
54-
)}
55-
>
56-
<Text color="muted" weight="bold">
57-
{number}
58-
</Text>
59-
</div>
60-
<div
61-
className={cn(
62-
'rounded-md border-2 border-accent bg-gradient-to-b p-1 px-2 text-white ring-offset-background transition-all ease-out',
52+
'flex flex-col justify-between rounded-md border-2 border-accent bg-gradient-to-b p-1 px-2 text-white ring-offset-background transition-all ease-out',
6353
selected && 'ring-2 ring-offset-2',
6454
NODE_COLOR_CLASSNAMES[color],
6555
isPlaying && !outgoingConnections && numberOfOutputs && 'opacity-65',
6656
)}
6757
style={{ width: `${width}px`, height: `${height}px` }}
6858
>
6959
<Text>{capitalize(type)}</Text>
60+
<Text variant="text-s">#{number}</Text>
7061
</div>
7162
{Array.from({ length: numberOfInputs }).map((_, i) => (
7263
<Handle key={String(i)} type="target" id={String(i)} position={Position.Left} className="!h-3 !w-3" />
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { testStoryMatrix } from '@repo/test-screen/test-story'
2+
3+
testStoryMatrix({
4+
meta: { title: 'tiles/SynthTree' },
5+
stories: ['Default', 'Selected', 'Readonly'],
6+
themes: ['light', 'dark'],
7+
})

0 commit comments

Comments
 (0)