-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from dragonrealms-phoenix/develop
Grid Layout Updates
- Loading branch information
Showing
27 changed files
with
1,275 additions
and
685 deletions.
There are no files selected for viewing
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
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,23 @@ | ||
// Source: https:/leo/electron-next | ||
// Typings: https:/vercel/next.js/blob/canary/examples/with-electron-typescript/electron-src/electron-next.d.ts | ||
|
||
declare module 'electron-next' { | ||
interface Directories { | ||
production: string; | ||
development: string; | ||
} | ||
|
||
export default function ( | ||
/** | ||
* Path to your nextjs app directory. | ||
* Can provide a string or an object with | ||
* separate paths for production and development. | ||
*/ | ||
directories: Directories | string, | ||
/** | ||
* Port to serve the nextjs app from. | ||
* Default 8000. | ||
*/ | ||
port?: number | ||
): Promise<void>; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './chrome'; |
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,171 @@ | ||
import { | ||
EuiButtonIcon, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiIcon, | ||
EuiSpacer, | ||
EuiSplitPanel, | ||
EuiText, | ||
useEuiOverflowScroll, | ||
} from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
import { | ||
CSSProperties, | ||
MouseEvent, | ||
ReactNode, | ||
Ref, | ||
TouchEvent, | ||
forwardRef, | ||
} from 'react'; | ||
|
||
interface GridItemProps { | ||
/** | ||
* Text to display in the title bar of the grid item. | ||
* Note the prop `title` is reserved and refers to titling a DOM element, | ||
* not for passing data to child components. So using a more specific name. | ||
*/ | ||
titleBarText: string; | ||
/** | ||
* Required when using custom components as react-grid-layout children. | ||
*/ | ||
ref: Ref<HTMLDivElement>; | ||
/** | ||
* This property is passed to the item from the grid layout. | ||
* You must assign it to the same prop of the root element of the grid item. | ||
*/ | ||
style?: CSSProperties; | ||
/** | ||
* This property is passed to the item from the grid layout. | ||
* You must assign it to the same prop of the root element of the grid item. | ||
*/ | ||
className?: string; | ||
/** | ||
* This property is passed to the item from the grid layout. | ||
* You must assign it to the same prop of the root element of the grid item. | ||
*/ | ||
onMouseDown?: (e: MouseEvent<HTMLDivElement>) => void; | ||
/** | ||
* This property is passed to the item from the grid layout. | ||
* You must assign it to the same prop of the root element of the grid item. | ||
*/ | ||
onMouseUp?: (e: MouseEvent<HTMLDivElement>) => void; | ||
/** | ||
* This property is passed to the item from the grid layout. | ||
* You must assign it to the same prop of the root element of the grid item. | ||
*/ | ||
onTouchEnd?: (e: TouchEvent<HTMLDivElement>) => void; | ||
/** | ||
* This property contains any children nested within the grid item | ||
* when you're constructing the grid layout. | ||
* You must nest it within the root element of the grid item. | ||
*/ | ||
children?: ReactNode; | ||
} | ||
|
||
/** | ||
* The grid layout pushes resizable handles as children of the grid item. | ||
* When the scrollbar for the content is displayed then it creates a | ||
* barrier between the right-most edge of the grid item and its content. | ||
* Yet the resizable handles are still visible on the grid item's edge | ||
* just not clickable in that position, it's now offset by the scrollbar. | ||
* To mitigate this adjustment, we move the resizable handles to the the | ||
* outside of the scrollable content. | ||
*/ | ||
function separateResizeHandleComponents(nodes: ReactNode): { | ||
children: Array<ReactNode>; | ||
resizeHandles: Array<ReactNode>; | ||
} { | ||
const children = []; | ||
const resizeHandles = []; | ||
|
||
if (Array.isArray(nodes)) { | ||
for (const child of nodes) { | ||
if (child.key?.startsWith('resizableHandle-')) { | ||
resizeHandles.push(child); | ||
} else { | ||
children.push(child); | ||
} | ||
} | ||
} else { | ||
children.push(nodes); | ||
} | ||
|
||
return { | ||
resizeHandles, | ||
children, | ||
}; | ||
} | ||
|
||
/** | ||
* How to use custom components as react-grid-layout children. | ||
* https:/react-grid-layout/react-grid-layout/tree/master?tab=readme-ov-file#custom-child-components-and-draggable-handles | ||
* https://stackoverflow.com/questions/67053157/react-grid-layout-error-draggablecore-not-mounted-on-dragstart | ||
*/ | ||
const GridItem: React.FC<GridItemProps> = forwardRef< | ||
HTMLDivElement, | ||
GridItemProps | ||
>((props, ref): JSX.Element => { | ||
const { titleBarText, style, className, children, ...otherProps } = props; | ||
|
||
const gridItemContentStyles = css` | ||
white-space: pre-wrap; | ||
${useEuiOverflowScroll('y', false)} | ||
`; | ||
|
||
const { resizeHandles, children: gridItemChildren } = | ||
separateResizeHandleComponents(children); | ||
|
||
return ( | ||
<EuiSplitPanel.Outer | ||
panelRef={ref} | ||
grow={false} | ||
hasBorder={true} | ||
style={style} | ||
className={className} | ||
{...otherProps} | ||
> | ||
<EuiSplitPanel.Inner grow={false} color="subdued" paddingSize="none"> | ||
<EuiFlexGroup | ||
responsive={false} | ||
alignItems="center" | ||
justifyContent="flexStart" | ||
gutterSize="none" | ||
> | ||
<EuiFlexItem grow={1} className={'grab-handle'}> | ||
<EuiIcon type="grabOmnidirectional" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={true} className={'grab-handle'}> | ||
<EuiText size="xs">{titleBarText}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiFlexGroup | ||
responsive={false} | ||
alignItems="center" | ||
justifyContent="flexEnd" | ||
> | ||
<EuiButtonIcon | ||
aria-label="Close" | ||
iconType="cross" | ||
color="accent" | ||
size="xs" | ||
/> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiSplitPanel.Inner> | ||
<EuiSpacer size="xs" /> | ||
<EuiSplitPanel.Inner | ||
grow={true} | ||
paddingSize="none" | ||
css={gridItemContentStyles} | ||
> | ||
{gridItemChildren} | ||
</EuiSplitPanel.Inner> | ||
{resizeHandles} | ||
</EuiSplitPanel.Outer> | ||
); | ||
}); | ||
|
||
GridItem.displayName = 'GridItem'; | ||
|
||
export { GridItem }; |
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 @@ | ||
export * from './grid-item'; |
Oops, something went wrong.