Skip to content

Commit 9b61c7d

Browse files
committed
refactor implementation
1 parent 3add3d6 commit 9b61c7d

File tree

2 files changed

+256
-179
lines changed

2 files changed

+256
-179
lines changed

packages/ui/src/components/devPrompts/KeylessPrompt/index.tsx

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function withLastActiveFallback(cb: () => string): string {
4343
const KeylessPromptInternal = (_props: KeylessPromptProps) => {
4444
const { isSignedIn } = useUser();
4545
const [isExpanded, setIsExpanded] = useState(false);
46-
const { corner, isDragging, style: positionStyle, containerRef, onPointerDown, preventClick } = useDragToCorner();
46+
const { isDragging, cornerStyle, containerRef, onPointerDown, preventClick } = useDragToCorner();
4747

4848
useEffect(() => {
4949
if (isSignedIn) {
@@ -118,25 +118,23 @@ const KeylessPromptInternal = (_props: KeylessPromptProps) => {
118118
<PromptContainer
119119
ref={containerRef}
120120
data-expanded={isForcedExpanded}
121-
data-dragging={isDragging}
122121
onPointerDown={onPointerDown}
123-
style={positionStyle}
124-
sx={t => ({
122+
style={{
123+
...cornerStyle,
125124
position: 'fixed',
125+
}}
126+
sx={t => ({
126127
height: `${t.sizes.$10}`,
127128
minWidth: '13.4rem',
128129
paddingLeft: `${t.space.$3}`,
129130
borderRadius: '1.25rem',
130131
touchAction: 'none', // Prevent scroll interference on mobile
131132
cursor: isDragging ? 'grabbing' : 'grab',
132-
133-
'&:hover [data-drag-handle]': {
134-
opacity: 0.4,
135-
},
136-
137-
'&[data-dragging="true"] [data-drag-handle]': {
138-
opacity: 0.6,
139-
},
133+
transition: isDragging
134+
? 'none'
135+
: isForcedExpanded
136+
? 'height 230ms cubic-bezier(0.28, 1, 0.32, 1), width 230ms cubic-bezier(0.28, 1, 0.32, 1), padding 230ms cubic-bezier(0.28, 1, 0.32, 1), border-radius 230ms cubic-bezier(0.28, 1, 0.32, 1)'
137+
: 'height 195ms cubic-bezier(0.2, 0.61, 0.1, 1), width 195ms cubic-bezier(0.2, 0.61, 0.1, 1), padding 195ms cubic-bezier(0.2, 0.61, 0.1, 1), border-radius 195ms cubic-bezier(0.2, 0.61, 0.1, 1)',
140138

141139
'&[data-expanded="false"]:hover': {
142140
background: 'linear-gradient(180deg, rgba(255, 255, 255, 0.20) 0%, rgba(255, 255, 255, 0) 100%), #1f1f1f',
@@ -180,34 +178,6 @@ const KeylessPromptInternal = (_props: KeylessPromptProps) => {
180178
position: relative;
181179
`}
182180
>
183-
{/* Drag handle indicator */}
184-
<div
185-
data-drag-handle
186-
css={css`
187-
position: absolute;
188-
left: 0.5rem;
189-
top: 50%;
190-
transform: translateY(-50%);
191-
display: flex;
192-
gap: 0.125rem;
193-
opacity: 0;
194-
transition: opacity 150ms ease-out;
195-
pointer-events: none;
196-
`}
197-
aria-hidden='true'
198-
>
199-
{[...Array(3)].map((_, i) => (
200-
<div
201-
key={i}
202-
css={css`
203-
width: 0.1875rem;
204-
height: 0.1875rem;
205-
background-color: #8c8c8c;
206-
border-radius: 50%;
207-
`}
208-
/>
209-
))}
210-
</div>
211181
<Flex
212182
sx={t => ({
213183
alignItems: 'center',

0 commit comments

Comments
 (0)