@moises.ai/design-system 3.11.0 → 3.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moises.ai/design-system",
3
- "version": "3.11.0",
3
+ "version": "3.11.2",
4
4
  "description": "Design System package based on @radix-ui/themes with custom defaults",
5
5
  "private": false,
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  width: 20px;
13
13
  height: 20px;
14
14
 
15
- &:focus-visible:not(.disabled){
15
+ &:focus-visible:not(.disabled) {
16
16
  outline: 2px solid var(--neutral-alpha-8);
17
17
  outline-offset: 2px;
18
18
  }
@@ -29,21 +29,16 @@
29
29
  }
30
30
 
31
31
  .selected.mute {
32
- background: #FFC53D;
32
+ background: #ffc53d;
33
33
  color: var(--neutral-1);
34
34
  }
35
35
 
36
36
  .selected.autoMute {
37
37
  background: var(--neutral-alpha-2);
38
- color: #FFC53D;
39
- }
40
-
41
- .selected.autoMute:hover {
42
- background: var(--neutral-alpha-3);
43
- cursor: pointer;
38
+ color: #ffc53d;
44
39
  }
45
40
 
46
41
  .selected.solo {
47
42
  background: var(--aqua-10);
48
43
  color: var(--neutral-1);
49
- }
44
+ }
@@ -0,0 +1,83 @@
1
+ import { Flex, Text } from '@radix-ui/themes'
2
+ import { Popover } from 'radix-ui'
3
+ import { useCallback, useState } from 'react'
4
+ import { Select } from '../Select/Select'
5
+ import { Slider } from '../Slider/Slider'
6
+ import styles from './RecordSettingsPopover.module.css'
7
+
8
+ export function RecordSettingsPopover({
9
+ isRecord,
10
+ device,
11
+ deviceOptions,
12
+ onDeviceChange,
13
+ channel,
14
+ channelOptions,
15
+ onChannelChange,
16
+ inputLevel,
17
+ children,
18
+ }) {
19
+ const [opened, setOpened] = useState(false)
20
+
21
+ const handleOpenChange = useCallback((open) => {
22
+ if (!open || !isRecord) {
23
+ setOpened(open)
24
+ }
25
+ }, [])
26
+
27
+ const handleContextMenu = useCallback(() => {
28
+ e.preventDefault()
29
+ setOpened(true)
30
+ }, [])
31
+
32
+ return (
33
+ <Popover.Root open={opened} onOpenChange={handleOpenChange}>
34
+ <Popover.Trigger asChild onContextMenu={handleContextMenu}>
35
+ {children}
36
+ </Popover.Trigger>
37
+
38
+ <Popover.Content width="360px">
39
+ <Flex className={styles.root} direction="column" gap="4">
40
+ <Flex direction="column" gap="1">
41
+ <Text size="1" weight="medium">
42
+ Source
43
+ </Text>
44
+
45
+ {deviceOptions?.length ? (
46
+ <Select
47
+ items={deviceOptions}
48
+ defaultValue={device}
49
+ onChange={onDeviceChange}
50
+ size="1"
51
+ />
52
+ ) : (
53
+ <Text size="1">No device options.</Text>
54
+ )}
55
+
56
+ {channelOptions?.length && (
57
+ <Select
58
+ items={channelOptions}
59
+ defaultValue={channel}
60
+ onChange={onChannelChange}
61
+ size="1"
62
+ />
63
+ )}
64
+ </Flex>
65
+
66
+ <Flex direction="column" gap="1">
67
+ <Text size="1" weight="medium">
68
+ Input Level
69
+ </Text>
70
+
71
+ {opened && (
72
+ <Slider
73
+ value={inputLevel}
74
+ max={30}
75
+ style={{ paddingTop: '8px', paddingBottom: '8px' }}
76
+ />
77
+ )}
78
+ </Flex>
79
+ </Flex>
80
+ </Popover.Content>
81
+ </Popover.Root>
82
+ )
83
+ }
@@ -0,0 +1,13 @@
1
+ .root {
2
+ width: 200px;
3
+ padding: var(--space-3);
4
+ border-radius: var(--radius-4, 8px);
5
+ border: 1px solid
6
+ var(--colors-neutral-neutral-alpha-3, rgba(221, 234, 248, 0.08));
7
+ background: var(--panel-solid, #18191b);
8
+
9
+ /* Shadows/shadow-5 */
10
+ box-shadow:
11
+ 0 12px 32px -16px var(--overlays-black-alpha-5, rgba(0, 0, 0, 0.3)),
12
+ 0 12px 60px 0 var(--overlays-black-alpha-3, rgba(0, 0, 0, 0.15));
13
+ }
@@ -6,6 +6,7 @@ import {
6
6
  More2Icon,
7
7
  } from '../../icons'
8
8
  import {
9
+ Box,
9
10
  DropdownMenu,
10
11
  Flex,
11
12
  HorizontalVolume,
@@ -15,22 +16,30 @@ import {
15
16
  Tooltip,
16
17
  TrackControlsToggle,
17
18
  } from '../../index'
19
+ import { RecordSettingsPopover } from './RecordSettingsPopover'
18
20
  import styles from './TrackHeader.module.css'
19
21
 
22
+ const DND_PROTECTION = {
23
+ onPointerDown: (e) => e.stopPropagation(),
24
+ onMouseDown: (e) => e.stopPropagation(),
25
+ onTouchStart: (e) => e.stopPropagation(),
26
+ }
27
+
20
28
  export const TrackHeader = memo(
21
29
  ({
22
30
  // Config
23
31
  title,
24
32
  menuOptions,
25
- instrumentOptions,
26
- onInstrumentChange,
27
- instrumentSelected,
28
33
  showPan = true,
29
34
  showVolumeControls = true,
30
35
  isGrouped = false,
31
36
  height = 81,
32
37
  compact = false,
33
38
  isActive = false,
39
+ instrumentOptions,
40
+ deviceOptions,
41
+ channelOptions,
42
+ inputLevel,
34
43
 
35
44
  // State
36
45
  volume,
@@ -40,6 +49,9 @@ export const TrackHeader = memo(
40
49
  isAutoMuted,
41
50
  isSolo,
42
51
  isOpen,
52
+ instrumentSelected,
53
+ device,
54
+ channel,
43
55
 
44
56
  // State change listeners
45
57
  onVolumeChange,
@@ -48,6 +60,9 @@ export const TrackHeader = memo(
48
60
  onRecordChange,
49
61
  onSoloChange,
50
62
  onOpenChange,
63
+ onInstrumentChange,
64
+ onDeviceChange,
65
+ onChannelChange,
51
66
 
52
67
  // Children (having content means group/takelanes)
53
68
  children,
@@ -93,9 +108,7 @@ export const TrackHeader = memo(
93
108
  style={{ minWidth: 0, overflow: 'hidden' }}
94
109
  >
95
110
  <IconButton
96
- onPointerDown={(e) => e.stopPropagation()}
97
- onMouseDown={(e) => e.stopPropagation()}
98
- onTouchStart={(e) => e.stopPropagation()}
111
+ {...DND_PROTECTION}
99
112
  variant="ghost"
100
113
  size="1"
101
114
  onClick={handleToggleOpen}
@@ -141,61 +154,63 @@ export const TrackHeader = memo(
141
154
  </Flex>
142
155
 
143
156
  <Flex
157
+ {...DND_PROTECTION}
144
158
  direction="row"
145
- gap="3"
159
+ gap="2px"
146
160
  align="center"
147
- onPointerDown={(e) => e.stopPropagation()}
148
- onMouseDown={(e) => e.stopPropagation()}
149
- onTouchStart={(e) => e.stopPropagation()}
150
161
  >
151
- <Flex gap="2px">
162
+ <RecordSettingsPopover
163
+ isRecord={isRecord}
164
+ deviceOptions={deviceOptions}
165
+ device={device}
166
+ onDeviceChange={onDeviceChange}
167
+ channelOptions={channelOptions}
168
+ channel={channel}
169
+ onChannelChange={onChannelChange}
170
+ inputLevel={inputLevel}
171
+ >
152
172
  <TrackControlsToggle
153
173
  type="record"
154
174
  selected={isRecord}
155
- onClick={onRecordChange}
156
- />
157
- <TrackControlsToggle
158
- type={
159
- isMuted ? 'mute' : isAutoMuted ? 'autoMute' : 'mute'
160
- }
161
- selected={isMuted}
162
- onClick={onMutedChange}
163
- />
164
- <TrackControlsToggle
165
- type="solo"
166
- selected={isSolo}
167
- onClick={onSoloChange}
175
+ onClick={() => onRecordChange?.()}
168
176
  />
169
- </Flex>
177
+ </RecordSettingsPopover>
178
+ <TrackControlsToggle
179
+ type={isMuted ? 'mute' : isAutoMuted ? 'autoMute' : 'mute'}
180
+ selected={isMuted || (!isSolo && isAutoMuted)}
181
+ onClick={onMutedChange}
182
+ />
183
+ <TrackControlsToggle
184
+ type="solo"
185
+ selected={isSolo}
186
+ onClick={onSoloChange}
187
+ />
170
188
  </Flex>
171
189
 
172
190
  {menuOptions && (
173
- <DropdownMenu
174
- trigger={
175
- <IconButton
176
- variant="ghost"
177
- size="1"
178
- className={styles.menuOptionsTrigger}
179
- >
180
- <More2Icon
181
- width={16}
182
- height={16}
183
- className={styles.menuOptionsIcon}
184
- />
185
- </IconButton>
186
- }
187
- options={menuOptions}
188
- />
191
+ <Box {...DND_PROTECTION}>
192
+ <DropdownMenu
193
+ trigger={
194
+ <IconButton
195
+ variant="ghost"
196
+ size="1"
197
+ className={styles.menuOptionsTrigger}
198
+ >
199
+ <More2Icon
200
+ width={16}
201
+ height={16}
202
+ className={styles.menuOptionsIcon}
203
+ />
204
+ </IconButton>
205
+ }
206
+ options={menuOptions}
207
+ />
208
+ </Box>
189
209
  )}
190
210
  </Flex>
191
211
  </div>
192
212
 
193
- <div
194
- className={styles.trackControls}
195
- onPointerDown={(e) => e.stopPropagation()}
196
- onMouseDown={(e) => e.stopPropagation()}
197
- onTouchStart={(e) => e.stopPropagation()}
198
- >
213
+ <div {...DND_PROTECTION} className={styles.trackControls}>
199
214
  {!compact && showVolumeControls && (
200
215
  <>
201
216
  <HorizontalVolume
@@ -1,6 +1,6 @@
1
- import { TrackHeader } from './TrackHeader'
2
1
  import { useState } from 'react'
3
- import { BassIcon, ElectricGuitarIcon, KeysIcon, DrumsIcon } from '../../icons'
2
+ import { BassIcon, DrumsIcon, ElectricGuitarIcon, KeysIcon } from '../../icons'
3
+ import { TrackHeader } from './TrackHeader'
4
4
  export default {
5
5
  title: 'Components/TrackHeader',
6
6
  component: TrackHeader,
@@ -89,15 +89,24 @@ import { TrackHeader } from '@moises.ai/design-system'
89
89
  }
90
90
 
91
91
  const menuOptions = [
92
- { type: 'item', key: 'delete', label: 'Delete', onClick: () => console.log('Delete clicked') },
92
+ {
93
+ type: 'item',
94
+ key: 'delete',
95
+ label: 'Delete',
96
+ onClick: () => console.log('Delete clicked'),
97
+ },
93
98
  ]
94
99
 
95
100
  const instrumentOptions = [
96
101
  { type: 'item', key: 'bass', label: 'Bass', icon: <BassIcon /> },
97
- { type: 'item', key: 'guitar', label: 'Guitar', icon: <ElectricGuitarIcon /> },
102
+ {
103
+ type: 'item',
104
+ key: 'guitar',
105
+ label: 'Guitar',
106
+ icon: <ElectricGuitarIcon />,
107
+ },
98
108
  { type: 'item', key: 'piano', label: 'Piano', icon: <KeysIcon /> },
99
109
  { type: 'item', key: 'drums', label: 'Drums', icon: <DrumsIcon /> },
100
-
101
110
  ]
102
111
  export const Default = {
103
112
  args: {
@@ -110,13 +119,14 @@ export const Default = {
110
119
  pan: 0,
111
120
  isMuted: false,
112
121
  isSolo: false,
122
+ isAutoMuted: false,
113
123
  compact: false,
114
124
  menuOptions,
115
- onVolumeChange: () => { },
116
- onPanChange: () => { },
117
- onMutedChange: () => { },
118
- onSoloChange: () => { },
119
- onInstrumentChange: () => { },
125
+ onVolumeChange: () => {},
126
+ onPanChange: () => {},
127
+ onMutedChange: () => {},
128
+ onSoloChange: () => {},
129
+ onInstrumentChange: () => {},
120
130
  instrumentOptions,
121
131
  instrumentSelected: instrumentOptions[0],
122
132
  },
@@ -133,12 +143,13 @@ export const Group = {
133
143
  pan: 0,
134
144
  isMuted: false,
135
145
  isSolo: false,
146
+ isAutoMuted: false,
136
147
  compact: false,
137
148
  menuOptions,
138
- onVolumeChange: () => { },
139
- onPanChange: () => { },
140
- onMutedChange: () => { },
141
- onSoloChange: () => { },
149
+ onVolumeChange: () => {},
150
+ onPanChange: () => {},
151
+ onMutedChange: () => {},
152
+ onSoloChange: () => {},
142
153
  },
143
154
  render: (args) => {
144
155
  const [isOpen, setIsOpen] = useState(true)
@@ -155,10 +166,10 @@ export const Group = {
155
166
  pan={pan}
156
167
  isMuted={false}
157
168
  isSolo={false}
158
- onVolumeChange={() => { }}
169
+ onVolumeChange={() => {}}
159
170
  onPanChange={setPan}
160
- onMutedChange={() => { }}
161
- onSoloChange={() => { }}
171
+ onMutedChange={() => {}}
172
+ onSoloChange={() => {}}
162
173
  menuOptions={menuOptions}
163
174
  />
164
175
  <TrackHeader
@@ -170,10 +181,10 @@ export const Group = {
170
181
  pan={pan2}
171
182
  isMuted={false}
172
183
  isSolo={false}
173
- onVolumeChange={() => { }}
184
+ onVolumeChange={() => {}}
174
185
  onPanChange={setPan2}
175
- onMutedChange={() => { }}
176
- onSoloChange={() => { }}
186
+ onMutedChange={() => {}}
187
+ onSoloChange={() => {}}
177
188
  menuOptions={menuOptions}
178
189
  />
179
190
  </TrackHeader>
@@ -194,11 +205,11 @@ export const Takelanes = {
194
205
  isSolo: false,
195
206
  compact: false,
196
207
  menuOptions,
197
- onVolumeChange: () => { },
198
- onPanChange: () => { },
199
- onMutedChange: () => { },
200
- onSoloChange: () => { },
201
- onOpenChange: () => { },
208
+ onVolumeChange: () => {},
209
+ onPanChange: () => {},
210
+ onMutedChange: () => {},
211
+ onSoloChange: () => {},
212
+ onOpenChange: () => {},
202
213
  },
203
214
  render: (args) => (
204
215
  <TrackHeader {...args}>