-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Embeddable Rebuild] [Controls] Add drag and drop to control group (#…
…188687) ## Summary > [!NOTE] > This PR has **no** user-facing changes - minus one small style change (which is a small selector simplification and doesn't actually change anything), all work is contained in the `examples` plugin. This PR adds drag and drop to the refactored control group in the `examples` plugin.  ### Checklist - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [x] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
10 changed files
with
195 additions
and
37 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
examples/controls_example/public/react_controls/components/control_clone.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
import { EuiFlexGroup, EuiFlexItem, EuiFormLabel, EuiIcon } from '@elastic/eui'; | ||
import { | ||
useBatchedOptionalPublishingSubjects, | ||
useStateFromPublishingSubject, | ||
} from '@kbn/presentation-publishing'; | ||
|
||
import { DefaultControlApi } from '../types'; | ||
|
||
/** | ||
* A simplified clone version of the control which is dragged. This version only shows | ||
* the title, because individual controls can be any size, and dragging a wide item | ||
* can be quite cumbersome. | ||
*/ | ||
export const ControlClone = ({ | ||
controlStyle, | ||
controlApi, | ||
}: { | ||
controlStyle: string; | ||
controlApi: DefaultControlApi; | ||
}) => { | ||
const width = useStateFromPublishingSubject(controlApi.width); | ||
const [panelTitle, defaultPanelTitle] = useBatchedOptionalPublishingSubjects( | ||
controlApi.panelTitle, | ||
controlApi.defaultPanelTitle | ||
); | ||
|
||
return ( | ||
<EuiFlexItem | ||
className={classNames('controlFrameCloneWrapper', { | ||
'controlFrameCloneWrapper--small': width === 'small', | ||
'controlFrameCloneWrapper--medium': width === 'medium', | ||
'controlFrameCloneWrapper--large': width === 'large', | ||
'controlFrameCloneWrapper--twoLine': controlStyle === 'twoLine', | ||
})} | ||
> | ||
{controlStyle === 'twoLine' ? ( | ||
<EuiFormLabel>{panelTitle ?? defaultPanelTitle}</EuiFormLabel> | ||
) : undefined} | ||
<EuiFlexGroup responsive={false} gutterSize="none" className={'controlFrame__draggable'}> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type="grabHorizontal" className="controlFrame__dragHandle" /> | ||
</EuiFlexItem> | ||
{controlStyle === 'oneLine' ? ( | ||
<EuiFlexItem> | ||
<label className="controlFrameCloneWrapper__label"> | ||
{panelTitle ?? defaultPanelTitle} | ||
</label> | ||
</EuiFlexItem> | ||
) : undefined} | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
); | ||
}; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.