Skip to content

Commit

Permalink
chore: migrate DragHandle component from jsx to tsx (#17326)
Browse files Browse the repository at this point in the history
* migrate DragHandle component from jsx to tsx

* Convert class based component to functional component
  • Loading branch information
Damans227 authored Nov 25, 2021
1 parent 7353a2b commit cf3f0e5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 58 deletions.
58 changes: 0 additions & 58 deletions superset-frontend/src/dashboard/components/dnd/DragHandle.jsx

This file was deleted.

49 changes: 49 additions & 0 deletions superset-frontend/src/dashboard/components/dnd/DragHandle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React, { LegacyRef } from 'react';
import cx from 'classnames';

interface DragHandleProps {
position: 'left' | 'top';
innerRef: LegacyRef<HTMLDivElement> | undefined;
dotCount: number;
}

export default function DragHandle({
position = 'left',
innerRef = null,
dotCount = 8,
}: DragHandleProps) {
return (
<div
ref={innerRef}
className={cx(
'drag-handle',
position === 'left' && 'drag-handle--left',
position === 'top' && 'drag-handle--top',
)}
>
{Array(dotCount)
.fill(null)
.map((_, i) => (
<div key={`handle-dot-${i}`} className="drag-handle-dot" />
))}
</div>
);
}

0 comments on commit cf3f0e5

Please sign in to comment.