1
1
import { DEFAULT_ASPECT_RATIOS } from '@codeimage/config' ;
2
- import { Box , HStack , Text } from '@codeimage/ui' ;
3
- import {
4
- As ,
5
- IconButton ,
6
- Popover ,
7
- PopoverContent ,
8
- PopoverTrigger ,
9
- } from '@codeui/kit' ;
10
- import { useModality } from '@core/hooks/isMobile' ;
11
- import {
12
- ExperimentalFeatureTooltip ,
13
- ExperimentalIcon ,
14
- } from '@ui/ExperimentalFeatureTooltip/ExperimentalFeatureTooltip' ;
2
+ import { Box , Text } from '@codeimage/ui' ;
3
+ import { As } from '@codeui/kit' ;
15
4
import { assignInlineVars } from '@vanilla-extract/dynamic' ;
16
5
import { createSignal , For , Show } from 'solid-js' ;
17
- import { CloseIcon } from '../../../Icons/CloseIcon' ;
6
+ import { SidebarPopover } from '../../SidebarPopover/SidebarPopover' ;
7
+ import { SidebarPopoverTitle } from '../../SidebarPopover/SidebarPopoverTitle' ;
18
8
import * as styles from './AspetRatioPicker.css' ;
19
9
20
10
interface AspectRatioPickerProps {
@@ -27,15 +17,11 @@ interface AspectRatioPickerProps {
27
17
*/
28
18
export function AspectRatioPicker ( props : AspectRatioPickerProps ) {
29
19
const [ open , setOpen ] = createSignal ( false ) ;
30
- const modality = useModality ( ) ;
31
20
32
21
return (
33
- < Popover
34
- placement = { modality === 'mobile' ? undefined : 'right-start' }
35
- open = { open ( ) }
36
- onOpenChange = { setOpen }
37
- >
38
- < PopoverTrigger asChild >
22
+ < SidebarPopover
23
+ contentClass = { styles . aspectRatioPopover }
24
+ input = {
39
25
< As component = { 'div' } class = { styles . input } >
40
26
< Show when = { props . value } >
41
27
{ aspectRatio => (
@@ -50,77 +36,58 @@ export function AspectRatioPicker(props: AspectRatioPickerProps) {
50
36
51
37
< Text weight = { 'semibold' } > { props . value ?? 'Auto' } </ Text >
52
38
</ As >
53
- </ PopoverTrigger >
54
- < PopoverContent variant = { 'bordered' } class = { styles . aspectRatioPopover } >
55
- < Box
56
- display = { 'flex' }
57
- justifyContent = { 'spaceBetween' }
58
- alignItems = { 'center' }
59
- marginBottom = { 4 }
60
- >
61
- < ExperimentalFeatureTooltip feature = { 'Aspect ratio' } >
62
- < HStack spacing = { '2' } alignItems = { 'flexEnd' } >
63
- < Text weight = { 'semibold' } > Aspect Ratio</ Text >
64
- < Text class = { styles . aspectRatioCardDetails } size = { 'xs' } >
65
- < Box as = { 'span' } display = { 'flex' } alignItems = { 'center' } >
66
- < ExperimentalIcon size = { 'xs' } />
67
- < Box marginLeft = { '1' } > Experimental</ Box >
68
- </ Box >
69
- </ Text >
70
- </ HStack >
71
- </ ExperimentalFeatureTooltip >
72
-
73
- < IconButton
74
- size = { 'xs' }
75
- aria-label = { 'Close' }
76
- theme = { 'secondary' }
77
- onClick = { ( ) => setOpen ( false ) }
78
- >
79
- < CloseIcon />
80
- </ IconButton >
81
- </ Box >
39
+ }
40
+ open = { open ( ) }
41
+ onOpenChange = { setOpen }
42
+ >
43
+ < SidebarPopoverTitle
44
+ experimental
45
+ featureName = { 'Aspect Ratio' }
46
+ onClose = { ( ) => setOpen ( false ) }
47
+ >
48
+ Aspect ratio
49
+ </ SidebarPopoverTitle >
82
50
83
- < div class = { styles . aspectRatioCardList } >
51
+ < div class = { styles . aspectRatioCardList } >
52
+ < div
53
+ data-selected = { ! props . value ? '' : null }
54
+ class = { styles . aspectRatioCardFull }
55
+ onClick = { ( ) => props . onChange ( null ) }
56
+ >
84
57
< div
85
- data-selected = { ! props . value ? '' : null }
86
- class = { styles . aspectRatioCardFull }
87
- onClick = { ( ) => props . onChange ( null ) }
58
+ style = { assignInlineVars ( {
59
+ [ styles . aspectRatio ] : 'auto' ,
60
+ } ) }
61
+ class = { styles . aspectRadioCardPreview }
88
62
>
89
- < div
90
- style = { assignInlineVars ( {
91
- [ styles . aspectRatio ] : 'auto' ,
92
- } ) }
93
- class = { styles . aspectRadioCardPreview }
94
- >
95
- < Box marginY = { 3 } > Auto</ Box >
96
- </ div >
63
+ < Box marginY = { 3 } > Auto</ Box >
97
64
</ div >
65
+ </ div >
98
66
99
- < For each = { DEFAULT_ASPECT_RATIOS } >
100
- { ratio => (
101
- < div
102
- data-selected = { props . value === ratio . ratio ? '' : null }
103
- class = { styles . aspectRatioCard }
104
- onClick = { ( ) => props . onChange ( ratio . ratio ) }
105
- >
106
- < div class = { styles . aspectRatioCardPreviewWrapper } >
107
- < div
108
- style = { assignInlineVars ( {
109
- [ styles . aspectRatio ] : ratio . ratio ,
110
- } ) }
111
- class = { styles . aspectRadioCardPreview }
112
- >
113
- { ratio . name }
114
- </ div >
67
+ < For each = { DEFAULT_ASPECT_RATIOS } >
68
+ { ratio => (
69
+ < div
70
+ data-selected = { props . value === ratio . ratio ? '' : null }
71
+ class = { styles . aspectRatioCard }
72
+ onClick = { ( ) => props . onChange ( ratio . ratio ) }
73
+ >
74
+ < div class = { styles . aspectRatioCardPreviewWrapper } >
75
+ < div
76
+ style = { assignInlineVars ( {
77
+ [ styles . aspectRatio ] : ratio . ratio ,
78
+ } ) }
79
+ class = { styles . aspectRadioCardPreview }
80
+ >
81
+ { ratio . name }
115
82
</ div >
116
- < span class = { styles . aspectRatioCardDetails } >
117
- { ratio . resolution . join ( 'x' ) }
118
- </ span >
119
83
</ div >
120
- ) }
121
- </ For >
122
- </ div >
123
- </ PopoverContent >
124
- </ Popover >
84
+ < span class = { styles . aspectRatioCardDetails } >
85
+ { ratio . resolution . join ( 'x' ) }
86
+ </ span >
87
+ </ div >
88
+ ) }
89
+ </ For >
90
+ </ div >
91
+ </ SidebarPopover >
125
92
) ;
126
93
}
0 commit comments