Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide resizable height prop controls #1641

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ const ComponentEditorRoot = styled('div')(({ theme }) => ({
},
}));

function shouldRenderControl<P extends object>(propTypeDef: ArgTypeDefinition<P>, props: P) {
function shouldRenderControl<P extends object>(
propTypeDef: ArgTypeDefinition<P>,
propName: keyof P,
props: P,
componentConfig: ComponentConfig<P>,
) {
if (propTypeDef.typeDef.type === 'element' || propTypeDef.typeDef.type === 'template') {
return (
propTypeDef.control?.type !== 'slot' &&
Expand All @@ -56,6 +61,10 @@ function shouldRenderControl<P extends object>(propTypeDef: ArgTypeDefinition<P>
return propTypeDef.visible(props);
}

if (componentConfig.resizableHeightProp && propName === componentConfig.resizableHeightProp) {
return false;
}

return true;
}

Expand Down Expand Up @@ -118,7 +127,7 @@ function ComponentPropsEditor<P extends object>({
{(
Object.entries(componentConfig.argTypes || {}) as ExactEntriesOf<ArgTypeDefinitions<P>>
).map(([propName, propTypeDef]) =>
propTypeDef && shouldRenderControl(propTypeDef, props) ? (
propTypeDef && shouldRenderControl(propTypeDef, propName, props, componentConfig) ? (
<div key={propName} className={classes.control}>
<NodeAttributeEditor
node={node}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { getDefaultControl } from '../../propertyControls';
import MarkdownTooltip from '../../../components/MarkdownTooltip';
import { isTemplateDescendant } from '../../../toolpadComponents/template';

const NON_BINDABLE_CONTROL_TYPES = ['GridColumns'];

export interface NodeAttributeEditorProps<P extends object> {
node: appDom.AppDomNode;
namespace?: string;
Expand Down Expand Up @@ -59,7 +61,10 @@ export default function NodeAttributeEditor<P extends object>({
// to make them bindable to other controlled props only
const isDisabled = !!argType.onChangeHandler;

const isBindable = !isDisabled && namespace !== 'layout';
const isBindable =
!isDisabled &&
namespace !== 'layout' &&
!NON_BINDABLE_CONTROL_TYPES.includes(argType.control?.type as string);

const jsBrowserRuntime = useBrowserJsRuntime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ export default function NodeHud({

const hintPosition = rect.y > HUD_HEIGHT ? HINT_POSITION_TOP : HINT_POSITION_BOTTOM;

const iconSx = { opacity: 0.7 };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but the opacity i had added here made the icons seem disabled.


return (
<React.Fragment>
<NodeHudWrapper
Expand Down Expand Up @@ -212,13 +210,13 @@ export default function NodeHud({
onMouseUp={stopPropagationHandler}
>
{component?.displayName || '<unknown>'}
<DragIndicatorIcon color="inherit" sx={iconSx} />
<IconButton aria-label="Duplicate" color="inherit" onMouseUp={onDuplicate} sx={iconSx}>
<DragIndicatorIcon color="inherit" />
<IconButton aria-label="Duplicate" color="inherit" onMouseUp={onDuplicate}>
<Tooltip title="Duplicate" enterDelay={400}>
<ContentCopy color="inherit" />
</Tooltip>
</IconButton>
<IconButton aria-label="Remove" color="inherit" onMouseUp={onDelete} sx={iconSx}>
<IconButton aria-label="Remove" color="inherit" onMouseUp={onDelete}>
<Tooltip title="Remove" enterDelay={400}>
<DeleteIcon color="inherit" />
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-components/src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ export default createComponent(DataGridComponent, {
typeDef: { type: 'string', enum: ['compact', 'standard', 'comfortable'], default: 'compact' },
},
height: {
typeDef: { type: 'number', default: 350 },
typeDef: { type: 'number', default: 350, minimum: 100 },
},
loading: {
helperText:
Expand Down