Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
cleanup unused imports and fix styling in panel layout (#10291)
Browse files Browse the repository at this point in the history
* replace inline style with tailwind

* remove unused imports in panel

---------

Co-authored-by: Andy Chen <[email protected]>
  • Loading branch information
aditya-mitra and achen5671 authored Jun 3, 2024
1 parent 7518068 commit 9cdea6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 76 deletions.
84 changes: 11 additions & 73 deletions packages/ui/src/components/editor/layout/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,8 @@ Ethereal Engine. All Rights Reserved.
import React, { ReactNode } from 'react'
import Text from '../../../primitives/tailwind/Text'

const panelIconStyles = {
color: 'var(--textColor)',
marginRight: '6px',
width: '18px'
}

const panelCheckboxStyles = {
color: 'var(--textColor)',
position: 'relative',
padding: '0px'
}

const panelContainerStyles = {
position: 'relative',
display: 'flex',
flex: 1,
flexDirection: 'column',
borderRadius: '4px',
backgroundColor: 'var(--dockBackground)',
overflow: 'hidden',
userSelect: 'none'
}

const panelToolbarStyles = {
display: 'flex',
padding: '4px',
height: '24px',
alignItems: 'center',
borderBottom: '1px solid rgba(0, 0, 0, 0.2)'
}

const panelContentStyles = {
display: 'flex',
flex: 1,
flexDirection: 'column',
position: 'relative',
overflow: 'hidden'
}

export const PanelIcon = ({ as: IconComponent, size = 12 }) => {
return <IconComponent style={panelIconStyles} size={size} />
const PanelIcon = ({ as: IconComponent, size = 12 }) => {
return <IconComponent className="mr-[6px] w-[18px] text-[var(--textColor)]" size={size} />
}

export const PanelTitle = ({ children }) => {
Expand All @@ -77,53 +38,30 @@ export const PanelTitle = ({ children }) => {
)
}

export const PanelCheckbox = ({ children }) => {
return <div style={panelCheckboxStyles as React.CSSProperties}>{children}</div>
}

export const PanelDragContainer = ({ children }) => {
// .dock-tab styled in Editor2Container.css
return <div className={`flex h-[30px] cursor-pointer rounded-t-md px-4 py-2`}>{children}</div>
}

export const PanelContainer = ({ children, ...rest }) => {
return (
<div style={panelContainerStyles as React.CSSProperties} {...rest}>
{children}
</div>
)
}

export const PanelToolbar = ({ children }) => {
return (
<div className="toolbar" style={panelToolbarStyles}>
{children}
</div>
)
}

export const PanelContent = ({ children }) => {
return <div style={panelContentStyles as React.CSSProperties}>{children}</div>
return <div className="flex h-[30px] cursor-pointer rounded-t-md px-4 py-2">{children}</div>
}

interface PanelProps {
icon?: React.ElementType
title: string
toolbarContent?: React.ReactNode
children?: ReactNode
// Add any other props you want to accept
}

const Panel: React.FC<PanelProps> = ({ icon, title, children, toolbarContent, ...rest }) => {
return (
<PanelContainer {...rest}>
<PanelToolbar>
<div
className="relative flex flex-1 select-none flex-col overflow-hidden rounded bg-[var(--dockBackground)]"
{...rest}
>
<div className="toolbar flex h-6 items-center border-b border-black border-opacity-20 p-1">
{icon && <PanelIcon as={icon} size={12} />}
<PanelTitle>{title}</PanelTitle>
{toolbarContent}
</PanelToolbar>
<PanelContent>{children}</PanelContent>
</PanelContainer>
</div>
<div className="relative flex flex-1 flex-col overflow-hidden">{children}</div>
</div>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/

import MaterialLibraryIcon from '@mui/icons-material/Yard'
import React, { useCallback, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { Texture, Uniform } from 'three'
Expand Down Expand Up @@ -58,7 +57,7 @@ import Button from '../../../../../primitives/tailwind/Button'
import InputGroup from '../../../input/Group'
import SelectInput from '../../../input/Select'
import StringInput from '../../../input/String'
import { PanelDragContainer, PanelIcon, PanelTitle } from '../../../layout/Panel'
import { PanelDragContainer, PanelTitle } from '../../../layout/Panel'
import { InfoTooltip } from '../../../layout/Tooltip'
import ParameterInput from '../../../properties/parameter'

Expand Down Expand Up @@ -304,7 +303,6 @@ export const MaterialPropertyTitle = () => {
return (
<div className={styles.dockableTab}>
<PanelDragContainer>
<PanelIcon as={MaterialLibraryIcon} size={12} />
<PanelTitle>
<InfoTooltip title={t('editor:properties.mesh.materialProperties.info')}>
<span>{t('editor:properties.mesh.materialProperties.title')}</span>
Expand Down

0 comments on commit 9cdea6a

Please sign in to comment.